rpmlog.h
Go to the documentation of this file.
#ifndef H_RPMLOG
#define H_RPMLOG 1
#include <stdarg.h>
/*@-typeuse@*/
typedef enum rpmlogLvl_e {
RPMLOG_EMERG = 0,
RPMLOG_ALERT = 1,
RPMLOG_CRIT = 2,
RPMLOG_ERR = 3,
RPMLOG_WARNING = 4,
RPMLOG_NOTICE = 5,
RPMLOG_INFO = 6,
RPMLOG_DEBUG = 7
} rpmlogLvl;
/*@=typeuse@*/
#define RPMLOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
/* extract priority */
#define RPMLOG_PRI(p) ((p) & RPMLOG_PRIMASK)
#define RPMLOG_MAKEPRI(fac, pri) ((((unsigned)(fac)) << 3) | (pri))
#ifdef RPMLOG_NAMES
#define _RPMLOG_NOPRI 0x10 /* the "no priority" priority */
/* mark "facility" */
#define _RPMLOG_MARK RPMLOG_MAKEPRI(RPMLOG_NFACILITIES, 0)
typedef struct _rpmcode {
const char *c_name;
int c_val;
} RPMCODE;
RPMCODE rpmprioritynames[] =
{
{ "alert", RPMLOG_ALERT },
{ "crit", RPMLOG_CRIT },
{ "debug", RPMLOG_DEBUG },
{ "emerg", RPMLOG_EMERG },
{ "err", RPMLOG_ERR },
{ "error", RPMLOG_ERR }, /* DEPRECATED */
{ "info", RPMLOG_INFO },
{ "none", _RPMLOG_NOPRI }, /* INTERNAL */
{ "notice", RPMLOG_NOTICE },
{ "panic", RPMLOG_EMERG }, /* DEPRECATED */
{ "warn", RPMLOG_WARNING }, /* DEPRECATED */
{ "warning",RPMLOG_WARNING },
{ NULL, -1 }
};
#endif
/*@-enummemuse -typeuse@*/
typedef enum rpmlogFac_e {
RPMLOG_KERN = (0<<3),
RPMLOG_USER = (1<<3),
RPMLOG_MAIL = (2<<3),
RPMLOG_DAEMON = (3<<3),
RPMLOG_AUTH = (4<<3),
RPMLOG_SYSLOG = (5<<3),
RPMLOG_LPR = (6<<3),
RPMLOG_NEWS = (7<<3),
RPMLOG_UUCP = (8<<3),
RPMLOG_CRON = (9<<3),
RPMLOG_AUTHPRIV = (10<<3),
RPMLOG_FTP = (11<<3),
/* other codes through 15 reserved for system use */
RPMLOG_LOCAL0 = (16<<3),
RPMLOG_LOCAL1 = (17<<3),
RPMLOG_LOCAL2 = (18<<3),
RPMLOG_LOCAL3 = (19<<3),
RPMLOG_LOCAL4 = (20<<3),
RPMLOG_LOCAL5 = (21<<3),
RPMLOG_LOCAL6 = (22<<3),
RPMLOG_LOCAL7 = (23<<3),
#define RPMLOG_NFACILITIES 24
RPMLOG_ERRMSG = (((unsigned)(RPMLOG_NFACILITIES+0))<<3)
} rpmlogFac;
/*@=enummemuse =typeuse@*/
#define RPMLOG_FACMASK 0x03f8
#define RPMLOG_FAC(p) (((p) & RPMLOG_FACMASK) >> 3)
#ifdef RPMLOG_NAMES
RPMCODE facilitynames[] =
{
{ "auth", RPMLOG_AUTH },
{ "authpriv",RPMLOG_AUTHPRIV },
{ "cron", RPMLOG_CRON },
{ "daemon", RPMLOG_DAEMON },
{ "ftp", RPMLOG_FTP },
{ "kern", RPMLOG_KERN },
{ "lpr", RPMLOG_LPR },
{ "mail", RPMLOG_MAIL },
{ "mark", _RPMLOG_MARK }, /* INTERNAL */
{ "news", RPMLOG_NEWS },
{ "security",RPMLOG_AUTH }, /* DEPRECATED */
{ "syslog", RPMLOG_SYSLOG },
{ "user", RPMLOG_USER },
{ "uucp", RPMLOG_UUCP },
{ "local0", RPMLOG_LOCAL0 },
{ "local1", RPMLOG_LOCAL1 },
{ "local2", RPMLOG_LOCAL2 },
{ "local3", RPMLOG_LOCAL3 },
{ "local4", RPMLOG_LOCAL4 },
{ "local5", RPMLOG_LOCAL5 },
{ "local6", RPMLOG_LOCAL6 },
{ "local7", RPMLOG_LOCAL7 },
{ NULL, -1 }
};
#endif
/*
* arguments to setlogmask.
*/
#define RPMLOG_MASK(pri) (1 << ((unsigned)(pri)))
#define RPMLOG_UPTO(pri) ((1 << (((unsigned)(pri))+1)) - 1)
/*
* Option flags for openlog.
*
* RPMLOG_ODELAY no longer does anything.
* RPMLOG_NDELAY is the inverse of what it used to be.
*/
#define RPMLOG_PID 0x01
#define RPMLOG_CONS 0x02
#define RPMLOG_ODELAY 0x04
#define RPMLOG_NDELAY 0x08
#define RPMLOG_NOWAIT 0x10
#define RPMLOG_PERROR 0x20
typedef /*@abstract@*/ struct rpmlogRec_s * rpmlogRec;
typedef /*@abstract@*/ void * rpmlogCallbackData;
typedef int (*rpmlogCallback) (rpmlogRec rec, rpmlogCallbackData data)
/*@*/;
#define RPMLOG_DEFAULT 0x01
#define RPMLOG_EXIT 0x02
#if defined(_RPMLOG_INTERNAL)
struct rpmlogRec_s {
int code;
rpmlogLvl pri; /* priority */
/*@owned@*/ /*@relnull@*/
const char * message;
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*@observer@*/
const char * rpmlogLevelPrefix(rpmlogLvl pri)
/*@*/;
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
/*@globals internalState@*/
/*@modifies internalState @*/;
void rpmlogGetCallback(rpmlogCallback *cb, rpmlogCallbackData *data)
/*@globals internalState @*/
/*@modifies *cb, *data, internalState @*/;
int rpmlogGetNrecs(void)
/*@*/;
/*@observer@*/ /*@retexpose@*/
const char * rpmlogRecMessage(rpmlogRec rec)
/*@*/;
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
/*@*/;
void rpmlogPrint(/*@null@*/ FILE *f)
/*@modifies *f @*/;
/*@unused@*/
void rpmlogClose (void)
/*@globals internalState@*/
/*@modifies internalState @*/;
/*@unused@*/
void rpmlogOpen (const char * ident, int option, int facility)
/*@globals internalState@*/
/*@modifies internalState @*/;
int rpmlogSetMask (int mask)
/*@globals internalState@*/
/*@modifies internalState @*/;
/*@mayexit@*/ /*@printflike@*/
void _rpmlog (int code, const char *fmt, ...)
#if defined(__GNUC__) && __GNUC__ >= 2
/* issue a warning if the format string doesn't match arguments */
__attribute__((format (printf, 2, 3)))
#endif
/*@*/;
void vrpmlog (unsigned code, const char * fmt, va_list ap)
/*@*/;
/*@mayexit@*/ /*@printflike@*/
static inline
void rpmlog (int code, const char *fmt, ...)
/*@*/
{
unsigned pri = RPMLOG_PRI(code);
unsigned mask = RPMLOG_MASK(pri);
if (mask & rpmlogSetMask(0)) {
va_list ap;
va_start(ap, fmt);
vrpmlog(code, fmt, ap);
va_end(ap);
}
}
/*@-exportlocal@*/
/*@-redecl@*/
/*@observer@*/ /*@null@*/ const char * rpmlogMessage(void)
/*@*/;
/*@=redecl@*/
int rpmlogCode(void)
/*@*/;
/*@null@*/
FILE * rpmlogSetFile(/*@null@*/ FILE * fp)
/*@globals internalState@*/
/*@modifies internalState @*/;
/*@=exportlocal@*/
#ifdef __cplusplus
}
#endif
#endif /* H_RPMLOG */