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