bglibs: msg.h Source File

bglibs

msg.h
1 #ifndef MSG__H__
2 #define MSG__H__
3
4 #include "sysdeps.h"
5 #include <stdarg.h>
6 #include "debug.h"
7
8 extern const char program[] __attribute__((__weak__));
9 extern const int msg_show_pid __attribute__((__weak__));
10
11 void msg_common(const char* type, const char*, const char*, const char*, const char*, const char*, const char*, int);
12 void msg_commonf(const char* type, int showsys, const char* format, ...);
13 void msg_commonfv(const char* type, int showsys, const char* format, va_list ap);
14 #define msg(a,b,c,d,e,f) msg_common(0,a,b,c,d,e,f,0)
15 void msg_warn(const char*, const char*, const char*, const char*, const char*, const char*, int);
16 void msg_warnf(int showsys, const char* format, ...);
17 void msg_error(const char*, const char*, const char*, const char*, const char*, const char*, int);
18 void msg_errorf(int showsys, const char* format, ...);
19 void msg_die(int code, const char* a, const char* b, const char* c, const char* d, const char* e, const char* f, int showsys) __NORETURN__;
20 void msg_dief(int code, int showsys, const char* format, ...) __NORETURN__;
21
22 #define msg1(a) msg(a,0,0,0,0,0)
23 #define msg2(a,b) msg(a,b,0,0,0,0)
24 #define msg3(a,b,c) msg(a,b,c,0,0,0)
25 #define msg4(a,b,c,d) msg(a,b,c,d,0,0)
26 #define msg5(a,b,c,d,e) msg(a,b,c,d,e,0)
27 #define msg6(a,b,c,d,e,f) msg(a,b,c,d,e,f)
28 #define msgf(f,...) msg_commonf(0,0,f,__VA_ARGS__)
29
30 #define warn1(a) msg_warn(a,0,0,0,0,0,0)
31 #define warn2(a,b) msg_warn(a,b,0,0,0,0,0)
32 #define warn3(a,b,c) msg_warn(a,b,c,0,0,0,0)
33 #define warn4(a,b,c,d) msg_warn(a,b,c,d,0,0,0)
34 #define warn5(a,b,c,d,e) msg_warn(a,b,c,d,e,0,0)
35 #define warn6(a,b,c,d,e,f) msg_warn(a,b,c,d,e,f,0)
36 #define warnf(f,...) msg_warnf(0,f,__VA_ARGS__)
37
38 #define error1(a) msg_error(a,0,0,0,0,0,0)
39 #define error2(a,b) msg_error(a,b,0,0,0,0,0)
40 #define error3(a,b,c) msg_error(a,b,c,0,0,0,0)
41 #define error4(a,b,c,d) msg_error(a,b,c,d,0,0,0)
42 #define error5(a,b,c,d,e) msg_error(a,b,c,d,e,0,0)
43 #define error6(a,b,c,d,e,f) msg_error(a,b,c,d,e,f,0)
44 #define errorf(f,...) msg_errorf(0,f,__VA_ARGS__)
45
46 #define die1(x,a) msg_die(x,a,0,0,0,0,0,0)
47 #define die2(x,a,b) msg_die(x,a,b,0,0,0,0,0)
48 #define die3(x,a,b,c) msg_die(x,a,b,c,0,0,0,0)
49 #define die4(x,a,b,c,d) msg_die(x,a,b,c,d,0,0,0)
50 #define die5(x,a,b,c,d,e) msg_die(x,a,b,c,d,e,0,0)
51 #define die6(x,a,b,c,d,e,f) msg_die(x,a,b,c,d,e,f,0)
52 #define dief(x,f,...) msg_dief(x,0,f,__VA_ARGS__)
53
54 #define warn1sys(a) msg_warn(a,0,0,0,0,0,1)
55 #define warn2sys(a,b) msg_warn(a,b,0,0,0,0,1)
56 #define warn3sys(a,b,c) msg_warn(a,b,c,0,0,0,1)
57 #define warn4sys(a,b,c,d) msg_warn(a,b,c,d,0,0,1)
58 #define warn5sys(a,b,c,d,e) msg_warn(a,b,c,d,e,0,1)
59 #define warn6sys(a,b,c,d,e,f) msg_warn(a,b,c,d,e,f,1)
60 #define warnfsys(f,...) msg_warnf(1,f,__VA_ARGS__)
61
62 #define error1sys(a) msg_error(a,0,0,0,0,0,1)
63 #define error2sys(a,b) msg_error(a,b,0,0,0,0,1)
64 #define error3sys(a,b,c) msg_error(a,b,c,0,0,0,1)
65 #define error4sys(a,b,c,d) msg_error(a,b,c,d,0,0,1)
66 #define error5sys(a,b,c,d,e) msg_error(a,b,c,d,e,0,1)
67 #define error6sys(a,b,c,d,e,f) msg_error(a,b,c,d,e,f,1)
68 #define errorfsys(f,...) msg_errorf(1,f,__VA_ARGS__)
69
70 #define die1sys(x,a) msg_die(x,a,0,0,0,0,0,1)
71 #define die2sys(x,a,b) msg_die(x,a,b,0,0,0,0,1)
72 #define die3sys(x,a,b,c) msg_die(x,a,b,c,0,0,0,1)
73 #define die4sys(x,a,b,c,d) msg_die(x,a,b,c,d,0,0,1)
74 #define die5sys(x,a,b,c,d,e) msg_die(x,a,b,c,d,e,0,1)
75 #define die6sys(x,a,b,c,d,e,f) msg_die(x,a,b,c,d,e,f,1)
76 #define diefsys(x,f,...) msg_dief(x,1,f,__VA_ARGS__)
77
78 extern void die_oom(int);
79
80 #endif