1995-12-14 05:40:59 +08:00
|
|
|
#include <stdarg.h>
|
1995-11-28 06:31:21 +08:00
|
|
|
#include <stdio.h>
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
#include "rpmlib.h"
|
1995-11-28 06:31:21 +08:00
|
|
|
|
1995-12-18 22:48:03 +08:00
|
|
|
static struct err {
|
|
|
|
int code;
|
|
|
|
char string[1024];
|
|
|
|
} errorRec;
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
static rpmErrorCallBackType errorCallback = NULL;
|
1995-12-18 22:48:03 +08:00
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
int rpmErrorCode(void)
|
1995-12-18 22:48:03 +08:00
|
|
|
{
|
|
|
|
return errorRec.code;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
char *rpmErrorCodeString(void)
|
1995-12-18 22:48:03 +08:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
char *rpmErrorString(void)
|
1995-12-18 22:48:03 +08:00
|
|
|
{
|
|
|
|
return errorRec.string;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType cb)
|
1995-12-18 22:48:03 +08:00
|
|
|
{
|
1996-11-19 02:02:36 +08:00
|
|
|
rpmErrorCallBackType ocb;
|
1995-12-18 22:48:03 +08:00
|
|
|
|
|
|
|
ocb = errorCallback;
|
|
|
|
errorCallback = cb;
|
|
|
|
|
|
|
|
return ocb;
|
|
|
|
}
|
|
|
|
|
1996-11-19 02:02:36 +08:00
|
|
|
void rpmError(int code, char *format, ...)
|
1995-11-28 06:31:21 +08:00
|
|
|
{
|
1995-12-14 05:40:59 +08:00
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
1995-12-18 22:48:03 +08:00
|
|
|
errorRec.code = code;
|
|
|
|
vsprintf(errorRec.string, format, args);
|
|
|
|
|
|
|
|
if (errorCallback) {
|
|
|
|
errorCallback();
|
1996-01-09 03:15:22 +08:00
|
|
|
} else {
|
|
|
|
fputs(errorRec.string, stderr);
|
|
|
|
fputs("\n", stderr);
|
1995-12-18 22:48:03 +08:00
|
|
|
}
|
1995-11-28 06:31:21 +08:00
|
|
|
}
|