rpm 5.3.7
|
00001 #ifndef H_RPMLOG 00002 #define H_RPMLOG 1 00003 00009 #include <stdio.h> 00010 #include <stdarg.h> 00011 00022 /*@-typeuse@*/ 00023 typedef enum rpmlogLvl_e { 00024 RPMLOG_EMERG = 0, 00025 RPMLOG_ALERT = 1, 00026 RPMLOG_CRIT = 2, 00027 RPMLOG_ERR = 3, 00028 RPMLOG_WARNING = 4, 00029 RPMLOG_NOTICE = 5, 00030 RPMLOG_INFO = 6, 00031 RPMLOG_DEBUG = 7 00032 } rpmlogLvl; 00033 /*@=typeuse@*/ 00034 00035 #define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 00036 /* extract priority */ 00037 #define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK) 00038 #define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri)) 00039 00040 #ifdef RPMLOG_NAMES 00041 #define _RPMLOG_NOPRI 0x10 /* the "no priority" priority */ 00042 /* mark "facility" */ 00043 #define _RPMLOG_MARK RPMLOG_MAKEPRI(RPMLOG_NFACILITIES, 0) 00044 typedef struct _rpmcode { 00045 const char *c_name; 00046 int c_val; 00047 } RPMCODE; 00048 00049 RPMCODE rpmprioritynames[] = 00050 { 00051 { "alert", RPMLOG_ALERT }, 00052 { "crit", RPMLOG_CRIT }, 00053 { "debug", RPMLOG_DEBUG }, 00054 { "emerg", RPMLOG_EMERG }, 00055 { "err", RPMLOG_ERR }, 00056 { "error", RPMLOG_ERR }, /* DEPRECATED */ 00057 { "info", RPMLOG_INFO }, 00058 { "none", _RPMLOG_NOPRI }, /* INTERNAL */ 00059 { "notice", RPMLOG_NOTICE }, 00060 { "panic", RPMLOG_EMERG }, /* DEPRECATED */ 00061 { "warn", RPMLOG_WARNING }, /* DEPRECATED */ 00062 { "warning",RPMLOG_WARNING }, 00063 { NULL, -1 } 00064 }; 00065 #endif 00066 00070 /*@-enummemuse -typeuse@*/ 00071 typedef enum rpmlogFac_e { 00072 RPMLOG_KERN = (0<<3), 00073 RPMLOG_USER = (1<<3), 00074 RPMLOG_MAIL = (2<<3), 00075 RPMLOG_DAEMON = (3<<3), 00076 RPMLOG_AUTH = (4<<3), 00077 RPMLOG_SYSLOG = (5<<3), 00078 RPMLOG_LPR = (6<<3), 00079 RPMLOG_NEWS = (7<<3), 00080 RPMLOG_UUCP = (8<<3), 00081 RPMLOG_CRON = (9<<3), 00082 RPMLOG_AUTHPRIV = (10<<3), 00083 RPMLOG_FTP = (11<<3), 00085 /* other codes through 15 reserved for system use */ 00086 RPMLOG_LOCAL0 = (16<<3), 00087 RPMLOG_LOCAL1 = (17<<3), 00088 RPMLOG_LOCAL2 = (18<<3), 00089 RPMLOG_LOCAL3 = (19<<3), 00090 RPMLOG_LOCAL4 = (20<<3), 00091 RPMLOG_LOCAL5 = (21<<3), 00092 RPMLOG_LOCAL6 = (22<<3), 00093 RPMLOG_LOCAL7 = (23<<3), 00095 #define RPMLOG_NFACILITIES 24 00096 RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3) 00097 } rpmlogFac; 00098 /*@=enummemuse =typeuse@*/ 00099 00100 #define RPMLOG_FACMASK 0x03f8 00101 #define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3) 00102 00103 00104 #ifdef RPMLOG_NAMES 00105 RPMCODE facilitynames[] = 00106 { 00107 { "auth", RPMLOG_AUTH }, 00108 { "authpriv",RPMLOG_AUTHPRIV }, 00109 { "cron", RPMLOG_CRON }, 00110 { "daemon", RPMLOG_DAEMON }, 00111 { "ftp", RPMLOG_FTP }, 00112 { "kern", RPMLOG_KERN }, 00113 { "lpr", RPMLOG_LPR }, 00114 { "mail", RPMLOG_MAIL }, 00115 { "mark", _RPMLOG_MARK }, /* INTERNAL */ 00116 { "news", RPMLOG_NEWS }, 00117 { "security",RPMLOG_AUTH }, /* DEPRECATED */ 00118 { "syslog", RPMLOG_SYSLOG }, 00119 { "user", RPMLOG_USER }, 00120 { "uucp", RPMLOG_UUCP }, 00121 { "local0", RPMLOG_LOCAL0 }, 00122 { "local1", RPMLOG_LOCAL1 }, 00123 { "local2", RPMLOG_LOCAL2 }, 00124 { "local3", RPMLOG_LOCAL3 }, 00125 { "local4", RPMLOG_LOCAL4 }, 00126 { "local5", RPMLOG_LOCAL5 }, 00127 { "local6", RPMLOG_LOCAL6 }, 00128 { "local7", RPMLOG_LOCAL7 }, 00129 { NULL, -1 } 00130 }; 00131 #endif 00132 00133 /* 00134 * arguments to setlogmask. 00135 */ 00136 #define RPMLOG_MASK(pri) (1 << ((unsigned)(pri))) 00137 #define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1) 00139 /* 00140 * Option flags for openlog. 00141 * 00142 * RPMLOG_ODELAY no longer does anything. 00143 * RPMLOG_NDELAY is the inverse of what it used to be. 00144 */ 00145 #define RPMLOG_PID 0x01 00146 #define RPMLOG_CONS 0x02 00147 #define RPMLOG_ODELAY 0x04 00148 #define RPMLOG_NDELAY 0x08 00149 #define RPMLOG_NOWAIT 0x10 00150 #define RPMLOG_PERROR 0x20 00154 typedef /*@abstract@*/ struct rpmlogRec_s * rpmlogRec; 00155 00158 typedef /*@abstract@*/ void * rpmlogCallbackData; 00159 00168 typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data) 00169 /*@*/; 00170 00174 #define RPMLOG_DEFAULT 0x01 00175 #define RPMLOG_EXIT 0x02 00177 #if defined(_RPMLOG_INTERNAL) 00178 00180 struct rpmlogRec_s { 00181 int code; 00182 rpmlogLvl pri; /* priority */ 00183 /*@owned@*/ /*@relnull@*/ 00184 const char * message; 00185 }; 00186 #endif 00187 00188 #ifdef __cplusplus 00189 extern "C" { 00190 #endif 00191 00197 /*@observer@*/ 00198 const char * rpmlogLevelPrefix(rpmlogLvl pri) 00199 /*@*/; 00200 00207 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data) 00208 /*@globals internalState@*/ 00209 /*@modifies internalState @*/; 00210 00217 void rpmlogGetCallback(rpmlogCallback *cb, rpmlogCallbackData *data) 00218 /*@globals internalState @*/ 00219 /*@modifies *cb, *data, internalState @*/; 00220 00225 int rpmlogGetNrecs(void) 00226 /*@*/; 00227 00233 /*@observer@*/ /*@retexpose@*/ 00234 const char * rpmlogRecMessage(rpmlogRec rec) 00235 /*@*/; 00236 00242 rpmlogLvl rpmlogRecPriority(rpmlogRec rec) 00243 /*@*/; 00244 00249 void rpmlogPrint(/*@null@*/ FILE *f) 00250 /*@modifies *f @*/; 00251 00256 /*@unused@*/ 00257 void rpmlogClose (void) 00258 /*@globals internalState@*/ 00259 /*@modifies internalState @*/; 00260 00265 /*@unused@*/ 00266 void rpmlogOpen (const char * ident, int option, int facility) 00267 /*@globals internalState@*/ 00268 /*@modifies internalState @*/; 00269 00275 int rpmlogSetMask (int mask) 00276 /*@globals internalState@*/ 00277 /*@modifies internalState @*/; 00278 00283 /*@mayexit@*/ /*@printflike@*/ 00284 void _rpmlog (int code, const char *fmt, ...) 00285 #if defined(__GNUC__) && __GNUC__ >= 2 00286 /* issue a warning if the format string doesn't match arguments */ 00287 __attribute__((format (printf, 2, 3))) 00288 #endif 00289 /*@*/; 00290 00294 void vrpmlog (unsigned code, const char * fmt, va_list ap) 00295 /*@*/; 00296 00297 /*@mayexit@*/ /*@printflike@*/ 00298 static inline 00299 void rpmlog (int code, const char *fmt, ...) 00300 /*@*/ 00301 { 00302 unsigned pri = RPMLOG_PRI(code); 00303 unsigned mask = RPMLOG_MASK(pri); 00304 00305 if (mask & rpmlogSetMask(0)) { 00306 va_list ap; 00307 va_start(ap, fmt); 00308 vrpmlog(code, fmt, ap); 00309 va_end(ap); 00310 } 00311 } 00312 00313 /*@-exportlocal@*/ 00318 /*@-redecl@*/ 00319 /*@observer@*/ /*@null@*/ const char * rpmlogMessage(void) 00320 /*@*/; 00321 /*@=redecl@*/ 00322 00330 int rpmlogCode(void) 00331 /*@*/; 00332 00338 /*@null@*/ 00339 FILE * rpmlogSetFile(/*@null@*/ FILE * fp) 00340 /*@globals internalState@*/ 00341 /*@modifies internalState @*/; 00342 /*@=exportlocal@*/ 00343 00344 #ifdef __cplusplus 00345 } 00346 #endif 00347 00348 #endif /* H_RPMLOG */