Initial revision
[rrdtool.git] / src / rrd_format.c
1 /*****************************************************************************
2  * RRDtool 1.0.33  Copyright Tobias Oetiker, 1999
3  *****************************************************************************
4  * rrd_format.c  RRD Database Format helper functions
5  *****************************************************************************
6  * $Id$
7  * $Log$
8  * Revision 1.1  2001/02/25 22:25:05  oetiker
9  * Initial revision
10  *
11  * Revision 1.3  1998/03/08 12:35:11  oetiker
12  * checkpointing things because the current setup seems to work
13  * according to the things said in the manpages
14  *
15  * Revision 1.2  1998/02/26 22:58:22  oetiker
16  * fixed define
17  *
18  * Revision 1.1  1998/02/21 16:14:41  oetiker
19  * Initial revision
20  *
21  *
22  *****************************************************************************/
23 #include "rrd_tool.h"
24
25 #define converter(VV,VVV) \
26    if (strcmp(#VV, string) == 0) return VVV;
27
28 /* conversion functions to allow symbolic entry of enumerations */
29 enum dst_en dst_conv(char *string)
30 {
31     converter(COUNTER,DST_COUNTER)
32     converter(ABSOLUTE,DST_ABSOLUTE)
33     converter(GAUGE,DST_GAUGE)
34     converter(DERIVE,DST_DERIVE)
35     rrd_set_error("unknown date aquisition function '%s'",string);
36     return(-1);
37 }
38
39
40 enum cf_en cf_conv(char *string)
41 {
42
43     converter(AVERAGE,CF_AVERAGE)
44     converter(MIN,CF_MINIMUM)
45     converter(MAX,CF_MAXIMUM)
46     converter(LAST,CF_LAST)
47     rrd_set_error("unknown consolidation function '%s'",string);
48     return(-1);
49 }
50
51 #undef converter        
52
53 long
54 ds_match(rrd_t *rrd,char *ds_nam){
55     long i;
56     for(i=0;i<rrd->stat_head->ds_cnt;i++)
57         if ((strcmp(ds_nam,rrd->ds_def[i].ds_nam))==0)
58             return i;
59     rrd_set_error("unknown data source name '%s'",ds_nam);
60     return -1;
61 }
62
63
64
65
66
67
68