- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

# rpmio/rpmlog.h

Go to the documentation of this file.

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