1 /*****************************************************************************
2 * RRDtool 1.1.x Copyright Tobias Oetiker, 1999
3 *****************************************************************************
4 * rrd_format.c RRD Database Format helper functions
5 *****************************************************************************
6 * $Id$
7 * $Log$
8 * Revision 1.3 2002/02/01 20:34:49 oetiker
9 * fixed version number and date/time
10 *
11 * Revision 1.2 2001/03/10 23:54:39 oetiker
12 * Support for COMPUTE data sources (CDEF data sources). Removes the RPN
13 * parser and calculator from rrd_graph and puts then in a new file,
14 * rrd_rpncalc.c. Changes to core files rrd_create and rrd_update. Some
15 * clean-up of aberrant behavior stuff, including a bug fix.
16 * Documentation update (rrdcreate.pod, rrdupdate.pod). Change xml format.
17 * -- Jake Brutlag <jakeb@corp.webtv.net>
18 *
19 * Revision 1.1.1.1 2001/02/25 22:25:05 oetiker
20 * checkin
21 *
22 * Revision 1.3 1998/03/08 12:35:11 oetiker
23 * checkpointing things because the current setup seems to work
24 * according to the things said in the manpages
25 *
26 * Revision 1.2 1998/02/26 22:58:22 oetiker
27 * fixed define
28 *
29 * Revision 1.1 1998/02/21 16:14:41 oetiker
30 * Initial revision
31 *
32 *
33 *****************************************************************************/
34 #include "rrd_tool.h"
36 #define converter(VV,VVV) \
37 if (strcmp(#VV, string) == 0) return VVV;
39 /* conversion functions to allow symbolic entry of enumerations */
40 enum dst_en dst_conv(char *string)
41 {
42 converter(COUNTER,DST_COUNTER)
43 converter(ABSOLUTE,DST_ABSOLUTE)
44 converter(GAUGE,DST_GAUGE)
45 converter(DERIVE,DST_DERIVE)
46 converter(COMPUTE,DST_CDEF)
47 rrd_set_error("unknown data aquisition function '%s'",string);
48 return(-1);
49 }
52 enum cf_en cf_conv(char *string)
53 {
55 converter(AVERAGE,CF_AVERAGE)
56 converter(MIN,CF_MINIMUM)
57 converter(MAX,CF_MAXIMUM)
58 converter(LAST,CF_LAST)
59 converter(HWPREDICT,CF_HWPREDICT)
60 converter(DEVPREDICT,CF_DEVPREDICT)
61 converter(SEASONAL,CF_SEASONAL)
62 converter(DEVSEASONAL,CF_DEVSEASONAL)
63 converter(FAILURES,CF_FAILURES)
64 rrd_set_error("unknown consolidation function '%s'",string);
65 return(-1);
66 }
68 #undef converter
70 long
71 ds_match(rrd_t *rrd,char *ds_nam){
72 long i;
73 for(i=0;i<rrd->stat_head->ds_cnt;i++)
74 if ((strcmp(ds_nam,rrd->ds_def[i].ds_nam))==0)
75 return i;
76 rrd_set_error("unknown data source name '%s'",ds_nam);
77 return -1;
78 }