summaryrefslogtreecommitdiff
path: root/rpmio/rpmerr.c
blob: 8ddb3d8b3d2cd48109bb8039dd37077cdef902d1 (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
55
56
57
58
#include "system.h"

/** \ingroup rpmio
 * \file rpmio/rpmerr.c
 */

#include <stdarg.h>

#include <rpmerr.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);
    }
}