8 #define _RPMLOG_INTERNAL
30 if (recs !=
NULL && nrecs > 0)
31 return recs[nrecs-1].code;
37 if (recs !=
NULL && nrecs > 0)
38 return recs[nrecs-1].message;
39 return _(
"(no error)");
44 return (rec ? rec->message :
NULL);
61 for (i = 0; i <
nrecs; i++) {
63 if (rec->message && *rec->message)
64 fprintf(f,
" %s", rec->message);
76 for (i = 0; i <
nrecs; i++) {
78 rec->message =
_free(rec->message);
119 _rpmlogCallback = cb;
120 _rpmlogCallbackData = data;
139 FILE *msgout = (_stdlog ? _stdlog : stderr);
144 msgout = (_stdlog ? _stdlog : stdout);
159 (
void) fputs(rec->message, msgout);
160 (
void) fflush(msgout);
190 return rpmlogMsgPrefix[pri&0x7];
193 #if !defined(HAVE_VSNPRINTF)
195 const char * fmt, va_list ap)
197 return vsprintf(buf, fmt, ap);
204 void vrpmlog (
unsigned code,
const char *fmt, va_list ap)
214 size_t msgnb = BUFSIZ;
218 struct rpmlogRec_s rec;
220 if ((mask & rpmlogMask) == 0)
223 msgbuf = (
char *)
xmalloc(msgnb);
231 if (nb > -1 && (
size_t)nb < msgnb)
237 msgbuf = (
char *)
xrealloc(msgbuf, msgnb);
242 msgbuf[msgnb - 1] =
'\0';
255 recs[
nrecs].code = rec.code;
256 recs[
nrecs].pri = rec.pri;
259 recs[
nrecs].code = 0;
264 if (_rpmlogCallback) {
277 msgbuf =
_free(msgbuf);
enum rpmlogLvl_e rpmlogLvl
RPM Log levels.
rpmlogCallback rpmlogSetCallback(rpmlogCallback cb, rpmlogCallbackData data)
Set rpmlog callback function.
char * xstrdup(const char *str)
static char *size_t nb
fgets(3) analogue that reads \ continuations.
void * rpmlogCallbackData
void rpmlogClose(void)
Close desriptor used to write to system logger.
static rpmlogCallback _rpmlogCallback
rpmlogLvl rpmlogRecPriority(rpmlogRec rec)
Retrieve log priority from rpmlog record.
void rpmlogGetCallback(rpmlogCallback *cb, rpmlogCallbackData *data)
Get rpmlog callback function and data.
void _rpmlog(int code, const char *fmt,...)
Generate a log message using FMT string and option arguments.
FILE * rpmlogSetFile(FILE *fp)
Set rpmlog file handle.
const char * rpmlogMessage(void)
Return text of last rpmError() message.
Yet Another syslog(3) API clone.
void vrpmlog(unsigned code, const char *fmt, va_list ap)
Same as _rpmlog with stdarg argument list.
struct rpmlogRec_s * rpmlogRec
static unsigned rpmlogMask
static int rpmlogDefault(rpmlogRec rec)
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
int rpmlogGetNrecs(void)
Return number of messages.
int(* rpmlogCallback)(rpmlogRec rec, rpmlogCallbackData data)
static rpmlogCallbackData _rpmlogCallbackData
#define RPMLOG_DEFAULT
Option flags for callback return value.
void rpmlogOpen(const char *ident, int option, int facility)
Open connection to system logger.
static int vsnprintf(char *buf, int nb, const char *fmt, va_list ap)
int rpmlogCode(void)
Return error code from last rpmError() message.
const char * rpmlogLevelPrefix(rpmlogLvl pri)
Return translated prefix string (if any) given log level.
static const char * rpmlogMsgPrefix[]
void rpmlogPrint(FILE *f)
Print all rpmError() messages.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
char * buf
Parse (and execute) macro undefinition.
int rpmlogSetMask(int mask)
Set the log mask level.
const char * rpmlogRecMessage(rpmlogRec rec)
Retrieve log message string from rpmlog record.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.