ref: ebe8f9460b6a3012c9c75d8479a3e427d5c04977
parent: 34f333404f958f8d93e8f1f582c0a347d2bfd64a
author: aiju <[email protected]>
date: Wed Jul 13 05:30:08 EDT 2011
forgot important file...
--- /dev/null
+++ b/sys/src/libbio/blethal.c
@@ -1,0 +1,33 @@
+#include <u.h>
+#include <libc.h>
+#include <bio.h>
+
+void
+Berror(Biobufhdr *bp, char *fmt, ...)
+{
+ va_list va;
+ char buf[ERRMAX];
+
+ if(bp->errorf == nil)
+ return;
+
+ va_start(va, fmt);
+ vsnprint(buf, ERRMAX, fmt, va);
+ va_end(va);
+ bp->errorf(buf);
+}
+
+static void
+Bpanic(char *s)
+{
+ sysfatal("%s", s);
+}
+
+void
+Blethal(Biobufhdr *bp, void (*errorf)(char *))
+{
+ if(errorf == nil)
+ errorf = Bpanic;
+
+ bp->errorf = errorf;
+}