summaryrefslogtreecommitdiff
path: root/lib/rpmerr.c
blob: fc05e7e8767931d0bac85fbcb9188391a08444d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include "system.h"

#include <stdarg.h>

#include <rpmlib.h>

static struct err {
    int code;
    char string[1024];
} errorRec;

static rpmErrorCallBackType errorCallback = NULL;

int rpmErrorCode(void)
{
    return errorRec.code;
}

char *rpmErrorCodeString(void)
{
    return NULL;
}

char *rpmErrorString(void)
{
    return errorRec.string;
}

rpmErrorCallBackType rpmErrorSetCallback(rpmErrorCallBackType cb)
{
    rpmErrorCallBackType ocb;

    ocb = errorCallback;
    errorCallback = cb;
    
    return ocb;
}

void rpmError(int code, char *format, ...)
{
    va_list args;

    va_start(args, format);

    errorRec.code = code;
    vsprintf(errorRec.string, format, args);

    if (errorCallback) {
	errorCallback();
    } else {
	fputs(errorRec.string, stderr);
	fputs("\n", stderr);
    }
}