Initial revision
[rrdtool.git] / src / rrd_error.c
1 /*****************************************************************************
2  * RRDtool 1.0.33  Copyright Tobias Oetiker, 1997 - 2000
3  *****************************************************************************
4  * rrd_error.c   Common Header File
5  *****************************************************************************
6  * $Id$
7  * $Log$
8  * Revision 1.1  2001/02/25 22:25:05  oetiker
9  * Initial revision
10  *
11  *************************************************************************** */
12
13 #include "rrd_tool.h"
14 #define MAXLEN 4096
15 static char rrd_error[MAXLEN] = "\0";
16 #include <stdarg.h>
17
18
19
20 void
21 rrd_set_error(char *fmt, ...)
22 {
23     va_list argp;
24     rrd_clear_error();
25     va_start(argp, fmt);
26 #ifdef HAVE_VSNPRINTF
27     vsnprintf((char *)rrd_error, MAXLEN-1, fmt, argp);
28 #else
29     vsprintf((char *)rrd_error, fmt, argp);
30 #endif
31     va_end(argp);
32 }
33
34 int
35 rrd_test_error(void) {
36     return rrd_error[0] != '\0';
37 }
38
39 void
40 rrd_clear_error(void){
41     rrd_error[0] = '\0';
42 }
43
44 char *
45 rrd_get_error(void){
46     return (char *)rrd_error;
47 }
48
49
50
51
52
53
54
55
56
57
58