From 8a0ef9fe18d69eb784f2c4c75f2347f0fd1d4229 Mon Sep 17 00:00:00 2001 From: marc Date: Mon, 18 Dec 1995 14:48:03 +0000 Subject: [PATCH] made global error structure, and functions to read/write it ,. CVS patchset: 47 CVS date: 1995/12/18 14:48:03 --- lib/rpmerr.c | 40 ++++++++++++++++++++++++++++++++++++++-- rpmio/rpmerr.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 76 insertions(+), 4 deletions(-) diff --git a/lib/rpmerr.c b/lib/rpmerr.c index 17c2222..e20bdc6 100644 --- a/lib/rpmerr.c +++ b/lib/rpmerr.c @@ -3,12 +3,48 @@ #include "rpmerr.h" +static struct err { + int code; + char string[1024]; +} errorRec; + +static CallBackType errorCallback = NULL; + +int errCode(void) +{ + return errorRec.code; +} + +char *errCodeString(void) +{ + return NULL; +} + +char *errString(void) +{ + return errorRec.string; +} + +CallBackType errSetCallback(CallBackType cb) +{ + CallBackType ocb; + + ocb = errorCallback; + errorCallback = cb; + + return ocb; +} + void error(int code, char *format, ...) { va_list args; va_start(args, format); - fprintf(stderr, "ERROR(%d): ", code); - vfprintf(stdout, format, args); + errorRec.code = code; + vsprintf(errorRec.string, format, args); + + if (errorCallback) { + errorCallback(); + } } diff --git a/rpmio/rpmerr.c b/rpmio/rpmerr.c index 17c2222..e20bdc6 100644 --- a/rpmio/rpmerr.c +++ b/rpmio/rpmerr.c @@ -3,12 +3,48 @@ #include "rpmerr.h" +static struct err { + int code; + char string[1024]; +} errorRec; + +static CallBackType errorCallback = NULL; + +int errCode(void) +{ + return errorRec.code; +} + +char *errCodeString(void) +{ + return NULL; +} + +char *errString(void) +{ + return errorRec.string; +} + +CallBackType errSetCallback(CallBackType cb) +{ + CallBackType ocb; + + ocb = errorCallback; + errorCallback = cb; + + return ocb; +} + void error(int code, char *format, ...) { va_list args; va_start(args, format); - fprintf(stderr, "ERROR(%d): ", code); - vfprintf(stdout, format, args); + errorRec.code = code; + vsprintf(errorRec.string, format, args); + + if (errorCallback) { + errorCallback(); + } } -- 2.7.4