From d953213bf75892f5dfaedbb9627e39458fc7c89b Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 17 May 2010 12:06:02 -0400 Subject: [PATCH] Add forgotten cmd/wmii/error.c --- cmd/wmii/error.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 cmd/wmii/error.c diff --git a/cmd/wmii/error.c b/cmd/wmii/error.c new file mode 100644 index 00000000..027bd07f --- /dev/null +++ b/cmd/wmii/error.c @@ -0,0 +1,41 @@ +/* Copyright ©2007-2009 Kris Maglione + * See LICENSE file for license details. + */ + +#include "dat.h" +#include "fns.h" + +static jmp_buf errjmp[16]; +static long nerror; + +void +error(char *fmt, ...) { + char errbuf[IXP_ERRMAX]; + va_list ap; + + va_start(ap, fmt); + vsnprint(errbuf, IXP_ERRMAX, fmt, ap); + va_end(ap); + ixp_errstr(errbuf, IXP_ERRMAX); + + nexterror(); +} + +void +nexterror(void) { + assert(nerror > 0); + longjmp(errjmp[--nerror], 1); +} + +void +poperror(void) { + assert(nerror > 0); + --nerror; +} + +jmp_buf* +pusherror(void) { + assert(nerror < nelem(errjmp)); + return &errjmp[nerror++]; +} +