rpm  4.5
rpmlog.h
Go to the documentation of this file.
1 #ifndef H_RPMLOG
2 #define H_RPMLOG 1
3 
10 #include <stdarg.h>
11 
22 /*@-typeuse@*/
23 typedef enum rpmlogLvl_e {
27  RPMLOG_ERR = 3,
32 } rpmlogLvl;
33 /*@=typeuse@*/
34 
35 #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
36  /* extract priority */
37 #define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK)
38 #define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri))
39 
40 #ifdef RPMLOG_NAMES
41 #define _RPMLOG_NOPRI 0x10 /* the "no priority" priority */
42  /* mark "facility" */
43 #define _RPMLOG_MARK RPMLOG_MAKEPRI(RPMLOG_NFACILITIES, 0)
44 typedef struct _rpmcode {
45  const char *c_name;
46  int c_val;
47 } RPMCODE;
48 
49 RPMCODE rpmprioritynames[] =
50  {
51  { "alert", RPMLOG_ALERT },
52  { "crit", RPMLOG_CRIT },
53  { "debug", RPMLOG_DEBUG },
54  { "emerg", RPMLOG_EMERG },
55  { "err", RPMLOG_ERR },
56  { "error", RPMLOG_ERR }, /* DEPRECATED */
57  { "info", RPMLOG_INFO },
58  { "none", _RPMLOG_NOPRI }, /* INTERNAL */
59  { "notice", RPMLOG_NOTICE },
60  { "panic", RPMLOG_EMERG }, /* DEPRECATED */
61  { "warn", RPMLOG_WARNING }, /* DEPRECATED */
62  { "warning",RPMLOG_WARNING },
63  { NULL, -1 }
64  };
65 #endif
66 
70 /*@-enummemuse -typeuse@*/
71 typedef enum rpmlogFac_e {
72  RPMLOG_KERN = (0<<3),
73  RPMLOG_USER = (1<<3),
74  RPMLOG_MAIL = (2<<3),
75  RPMLOG_DAEMON = (3<<3),
76  RPMLOG_AUTH = (4<<3),
77  RPMLOG_SYSLOG = (5<<3),
78  RPMLOG_LPR = (6<<3),
79  RPMLOG_NEWS = (7<<3),
80  RPMLOG_UUCP = (8<<3),
81  RPMLOG_CRON = (9<<3),
82  RPMLOG_AUTHPRIV = (10<<3),
83  RPMLOG_FTP = (11<<3),
85  /* other codes through 15 reserved for system use */
86  RPMLOG_LOCAL0 = (16<<3),
87  RPMLOG_LOCAL1 = (17<<3),
88  RPMLOG_LOCAL2 = (18<<3),
89  RPMLOG_LOCAL3 = (19<<3),
90  RPMLOG_LOCAL4 = (20<<3),
91  RPMLOG_LOCAL5 = (21<<3),
92  RPMLOG_LOCAL6 = (22<<3),
93  RPMLOG_LOCAL7 = (23<<3),
95 #define RPMLOG_NFACILITIES 24
96  RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
97 } rpmlogFac;
98 /*@=enummemuse =typeuse@*/
99 
100 #define RPMLOG_FACMASK 0x03f8
101 #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
102 
103 
104 #ifdef RPMLOG_NAMES
105 RPMCODE facilitynames[] =
106  {
107  { "auth", RPMLOG_AUTH },
108  { "authpriv",RPMLOG_AUTHPRIV },
109  { "cron", RPMLOG_CRON },
110  { "daemon", RPMLOG_DAEMON },
111  { "ftp", RPMLOG_FTP },
112  { "kern", RPMLOG_KERN },
113  { "lpr", RPMLOG_LPR },
114  { "mail", RPMLOG_MAIL },
115  { "mark", _RPMLOG_MARK }, /* INTERNAL */
116  { "news", RPMLOG_NEWS },
117  { "security",RPMLOG_AUTH }, /* DEPRECATED */
118  { "syslog", RPMLOG_SYSLOG },
119  { "user", RPMLOG_USER },
120  { "uucp", RPMLOG_UUCP },
121  { "local0", RPMLOG_LOCAL0 },
122  { "local1", RPMLOG_LOCAL1 },
123  { "local2", RPMLOG_LOCAL2 },
124  { "local3", RPMLOG_LOCAL3 },
125  { "local4", RPMLOG_LOCAL4 },
126  { "local5", RPMLOG_LOCAL5 },
127  { "local6", RPMLOG_LOCAL6 },
128  { "local7", RPMLOG_LOCAL7 },
129  { NULL, -1 }
130  };
131 #endif
132 
133 /*
134  * arguments to setlogmask.
135  */
136 #define RPMLOG_MASK(pri) (1 << ((unsigned)(pri)))
137 #define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1)
139 /*
140  * Option flags for openlog.
141  *
142  * RPMLOG_ODELAY no longer does anything.
143  * RPMLOG_NDELAY is the inverse of what it used to be.
144  */
145 #define RPMLOG_PID 0x01
146 #define RPMLOG_CONS 0x02
147 #define RPMLOG_ODELAY 0x04
148 #define RPMLOG_NDELAY 0x08
149 #define RPMLOG_NOWAIT 0x10
150 #define RPMLOG_PERROR 0x20
155 typedef void (*rpmlogCallback) (void);
156 
159 typedef /*@abstract@*/ struct rpmlogRec_s {
160  int code;
161 /*@owned@*/ /*@null@*/
162  const char * message;
163 } * rpmlogRec;
164 
165 #ifdef __cplusplus
166 extern "C" {
167 #endif
168 
173 int rpmlogGetNrecs(void) /*@*/;
174 
179 void rpmlogPrint(/*@null@*/ FILE *f)
180  /*@modifies *f @*/;
181 
186 /*@unused@*/
187 void rpmlogClose (void)
188  /*@globals internalState@*/
189  /*@modifies internalState @*/;
190 
195 /*@unused@*/
196 void rpmlogOpen (const char * ident, int option, int facility)
197  /*@globals internalState@*/
198  /*@modifies internalState @*/;
199 
205 int rpmlogSetMask (int mask)
206  /*@globals internalState@*/
207  /*@modifies internalState @*/;
208 
212 /*@mayexit@*/ /*@printflike@*/ void rpmlog (int code, const char *fmt, ...)
213  /*@*/;
214 
215 /*@-exportlocal@*/
220 /*@-redecl@*/
221 /*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)
222  /*@*/;
223 /*@=redecl@*/
224 
232 int rpmlogCode(void)
233  /*@*/;
234 
241  /*@globals internalState@*/
242  /*@modifies internalState @*/;
243 
249 /*@null@*/
250 FILE * rpmlogSetFile(/*@null@*/ FILE * fp)
251  /*@globals internalState@*/
252  /*@modifies internalState @*/;
253 /*@=exportlocal@*/
254 
260  /*@globals internalState@*/
261  /*@modifies internalState @*/;
262 
268 extern int rpmErrorCode(void)
269  /*@*/;
270 
276 /*@-redecl@*/
277 /*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void) /*@*/;
278 /*@=redecl@*/
279 
280 #ifdef __cplusplus
281 }
282 #endif
283 
284 #endif /* H_RPMLOG */