summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rpmerr.c40
-rw-r--r--rpmio/rpmerr.c40
2 files changed, 76 insertions, 4 deletions
diff --git a/lib/rpmerr.c b/lib/rpmerr.c
index 17c22228c..e20bdc6f5 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 17c22228c..e20bdc6f5 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();
+ }
}