shithub: riscv

ref: 1e9bb75854a336de2a63f9a4fb4d67dd75d682f1
dir: /sys/src/libbio/blethal.c/

View raw version
#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;
}