comparison lwlib/lw_error.c @ 331:ed3553296580

Port manual forward with corrections from Jason Law
author lost
date Sun, 28 Feb 2010 05:55:07 +0000
parents c15cca3ae6a2
children
comparison
equal deleted inserted replaced
330:81c005b82775 331:ed3553296580
26 26
27 #include <stdio.h> 27 #include <stdio.h>
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <stdarg.h> 29 #include <stdarg.h>
30 30
31 static void (*lw_error_func)(const char *fmt, ...) = NULL;
32
31 void lw_error(const char *fmt, ...) 33 void lw_error(const char *fmt, ...)
32 { 34 {
33 va_list args; 35 va_list args;
34 va_start(args, fmt); 36 va_start(args, fmt);
35 vfprintf(stderr, fmt, args); 37 if (lw_error_func)
38 (*lw_error_func)(fmt, args);
39 else
40 vfprintf(stderr, fmt, args);
36 va_end(args); 41 va_end(args);
37 exit(1); 42 exit(1);
38 } 43 }
44
45 void lw_error_setfunc(void (*f)(const char *fmt, ...))
46 {
47 lw_error_func = f;
48 }