equal
deleted
inserted
replaced
1 #include <stdlib.h> |
1 #include <stdlib.h> |
2 #include <stdio.h> |
2 #include <stdio.h> |
3 #include <stdarg.h> |
3 #include <stdarg.h> |
4 #include <string.h> |
4 #include <string.h> |
5 #include <errno.h> |
5 #include <errno.h> |
|
6 #include <assert.h> |
6 |
7 |
7 #include "log.h" |
8 #include "log.h" |
8 |
9 |
9 static void _generic_err_vargs (int flags, const char *func, int err, const char *fmt, va_list va) { |
10 static void _generic_err_vargs (int flags, const char *func, int err, const char *fmt, va_list va) { |
10 FILE *stream = flags & LOG_DISPLAY_STDERR ? stderr : stdout; |
11 FILE *stream = flags & LOG_DISPLAY_STDERR ? stderr : stdout; |
|
12 |
|
13 if (!fmt) |
|
14 return; |
11 |
15 |
12 if (flags & LOG_DISPLAY_FATAL) |
16 if (flags & LOG_DISPLAY_FATAL) |
13 fprintf(stream, "FATAL: "); |
17 fprintf(stream, "FATAL: "); |
14 |
18 |
15 if (func) |
19 if (func) |
33 } |
37 } |
34 |
38 |
35 void _generic_err_exit (int flags, const char *func, int err, const char *fmt, ...) { |
39 void _generic_err_exit (int flags, const char *func, int err, const char *fmt, ...) { |
36 va_list va; |
40 va_list va; |
37 |
41 |
|
42 assert(fmt); |
|
43 |
38 va_start(va, fmt); |
44 va_start(va, fmt); |
39 _generic_err_vargs(flags | LOG_DISPLAY_FATAL, func, err, fmt, va); |
45 _generic_err_vargs(flags | LOG_DISPLAY_FATAL, func, err, fmt, va); |
40 va_end(va); |
46 va_end(va); |
41 |
47 |
42 exit(EXIT_FAILURE); |
48 exit(EXIT_FAILURE); |