Main Page Modules Data Structures File List Data Fields Globals Related Pages

# rpmio/rpmlog.h

Go to the documentation of this file.

    00001 #ifndef H_RPMLOG
    00002 #define H_RPMLOG 1
    00003
    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 CODE 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
    00155 typedef void (*rpmlogCallback) (void);
    00156
    00159 typedef /*@abstract@*/ struct rpmlogRec_s {
    00160     int         code;
    00161 /*@owned@*/ /*@null@*/ const char * message;
    00162 } * rpmlogRec;
    00163
    00164 #ifdef __cplusplus
    00165 extern "C" {
    00166 #endif
    00167
    00172 int rpmlogGetNrecs(void)        /*@*/;
    00173
    00178 void rpmlogPrint(FILE *f)
    00179         /*@modifies *f @*/;
    00180
    00185 /*@unused@*/
    00186 void rpmlogClose (void)
    00187         /*@globals internalState@*/
    00188         /*@modifies internalState @*/;
    00189
    00194 /*@unused@*/
    00195 void rpmlogOpen (const char * ident, int option, int facility)
    00196         /*@globals internalState@*/
    00197         /*@modifies internalState @*/;
    00198
    00202 int rpmlogSetMask (int mask)
    00203         /*@globals internalState@*/
    00204         /*@modifies internalState @*/;
    00205
    00209 /*@mayexit@*/ /*@printflike@*/ void rpmlog (int code, const char *fmt, ...)
    00210         /*@*/;
    00211
    00212 /*@-exportlocal@*/
    00217 /*@-redecl@*/
    00218 /*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)      /*@*/;
    00219 /*@=redecl@*/
    00220
    00228 int rpmlogCode(void)    /*@*/;
    00229
    00233 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
    00234         /*@globals internalState@*/
    00235         /*@modifies internalState @*/;
    00236 /*@=exportlocal@*/
    00237
    00242 extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
    00243         /*@globals internalState@*/
    00244         /*@modifies internalState @*/;
    00245
    00251 extern int rpmErrorCode(void)   /*@*/;
    00252
    00258 /*@-redecl@*/
    00259 /*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void)      /*@*/;
    00260 /*@=redecl@*/
    00261
    00262 #ifdef __cplusplus
    00263 }
    00264 #endif
    00265
    00266 #endif /* H_RPMLOG */