00001 #ifndef H_RPMLOG
00002 #define H_RPMLOG 1
00003
00010 #include <stdarg.h>
00011
00022
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
00034
00035 #define RPMLOG_PRIMASK 0x07
00036
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
00042
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 },
00057 { "info", RPMLOG_INFO },
00058 { "none", _RPMLOG_NOPRI },
00059 { "notice", RPMLOG_NOTICE },
00060 { "panic", RPMLOG_EMERG },
00061 { "warn", RPMLOG_WARNING },
00062 { "warning",RPMLOG_WARNING },
00063 { NULL, -1 }
00064 };
00065 #endif
00066
00070
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
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
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 },
00116 { "news", RPMLOG_NEWS },
00117 { "security",RPMLOG_AUTH },
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
00135
00136 #define RPMLOG_MASK(pri) (1 << ((unsigned)(pri)))
00137 #define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1)
00139
00140
00141
00142
00143
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
00155 typedef void (*rpmlogCallback) (void);
00156
00159 typedef struct rpmlogRec_s {
00160 int code;
00161
00162 const char * message;
00163 } * rpmlogRec;
00164
00165 #ifdef __cplusplus
00166 extern "C" {
00167 #endif
00168
00173 int rpmlogGetNrecs(void) ;
00174
00179 void rpmlogPrint( FILE *f)
00180 ;
00181
00186
00187 void rpmlogClose (void)
00188
00189 ;
00190
00195
00196 void rpmlogOpen (const char * ident, int option, int facility)
00197
00198 ;
00199
00205 int rpmlogSetMask (int mask)
00206
00207 ;
00208
00212 void rpmlog (int code, const char *fmt, ...)
00213 ;
00214
00215
00220
00221 const char * rpmlogMessage(void)
00222 ;
00223
00224
00232 int rpmlogCode(void)
00233 ;
00234
00240 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
00241
00242 ;
00243
00249
00250 FILE * rpmlogSetFile( FILE * fp)
00251
00252 ;
00253
00254
00259 extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
00260
00261 ;
00262
00268 extern int rpmErrorCode(void)
00269 ;
00270
00276
00277 extern const char * rpmErrorString(void) ;
00278
00279
00280 #ifdef __cplusplus
00281 }
00282 #endif
00283
00284 #endif