made global error structure, and functions to read/write it
authormarc <devnull@localhost>
Mon, 18 Dec 1995 14:48:03 +0000 (14:48 +0000)
committermarc <devnull@localhost>
Mon, 18 Dec 1995 14:48:03 +0000 (14:48 +0000)
,.

CVS patchset: 47
CVS date: 1995/12/18 14:48:03

lib/rpmerr.c
rpmio/rpmerr.c

index 17c2222..e20bdc6 100644 (file)
@@ -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();
+    }
 }
index 17c2222..e20bdc6 100644 (file)
@@ -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();
+    }
 }