Line data Source code
1 : #include <stdarg.h>
2 : #include <stdlib.h>
3 : #include <stdio.h>
4 :
5 : #include "error.h"
6 :
7 0 : void (error)(char* file, int line, const char* func, char* msg, ...)
8 : {
9 : va_list ap;
10 : static char colon[] = ": ";
11 :
12 0 : if (progname == NULL) {
13 0 : progname = "";
14 0 : colon[0] = 0;
15 0 : }
16 :
17 0 : va_start(ap, msg);
18 :
19 0 : fprintf(stderr, "%s%serror: detected in file \"%s\", line %u"
20 0 : " in function \"%s\": ", progname, colon, file, line, func);
21 :
22 0 : vfprintf(stderr, msg, ap);
23 :
24 0 : va_end(ap);
25 :
26 0 : fputc('\n', stderr);
27 :
28 0 : exit(EXIT_FAILURE);
29 : }
|