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 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    
00155 typedef void (*rpmlogCallback) (void);
00156 
00159 typedef /*@abstract@*/ struct rpmlogRec_s {
00160     int         code;
00161 /*@owned@*/ /*@null@*/
00162     const char * message;
00163 } * rpmlogRec;
00164 
00165 #ifdef __cplusplus
00166 extern "C" {
00167 #endif
00168 
00173 int rpmlogGetNrecs(void)        /*@*/;
00174 
00179 void rpmlogPrint(/*@null@*/ FILE *f)
00180         /*@modifies *f @*/;
00181 
00186 /*@unused@*/
00187 void rpmlogClose (void)
00188         /*@globals internalState@*/
00189         /*@modifies internalState @*/;
00190 
00195 /*@unused@*/
00196 void rpmlogOpen (const char * ident, int option, int facility)
00197         /*@globals internalState@*/
00198         /*@modifies internalState @*/;
00199 
00205 int rpmlogSetMask (int mask)
00206         /*@globals internalState@*/
00207         /*@modifies internalState @*/;
00208 
00212 /*@mayexit@*/ /*@printflike@*/ void rpmlog (int code, const char *fmt, ...)
00213         /*@*/;
00214 
00215 /*@-exportlocal@*/
00220 /*@-redecl@*/
00221 /*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)
00222         /*@*/;
00223 /*@=redecl@*/
00224 
00232 int rpmlogCode(void)
00233         /*@*/;
00234 
00240 rpmlogCallback rpmlogSetCallback(rpmlogCallback cb)
00241         /*@globals internalState@*/
00242         /*@modifies internalState @*/;
00243 
00249 /*@null@*/
00250 FILE * rpmlogSetFile(/*@null@*/ FILE * fp)
00251         /*@globals internalState@*/
00252         /*@modifies internalState @*/;
00253 /*@=exportlocal@*/
00254 
00259 extern rpmlogCallback rpmErrorSetCallback(rpmlogCallback cb)
00260         /*@globals internalState@*/
00261         /*@modifies internalState @*/;
00262 
00268 extern int rpmErrorCode(void)
00269         /*@*/;
00270 
00276 /*@-redecl@*/
00277 /*@observer@*/ /*@null@*/ extern const char * rpmErrorString(void)      /*@*/;
00278 /*@=redecl@*/
00279 
00280 #ifdef __cplusplus
00281 }
00282 #endif
00283 
00284 #endif /* H_RPMLOG */

Generated on Fri Oct 12 08:44:54 2007 for rpm by  doxygen 1.5.2