fixed version checks to only complain if xml version is > than current RRD version
[rrdtool.git] / src / rrd_format.c
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.4  2003/02/13 07:05:27  oetiker
9  * Find attached the patch I promised to send to you. Please note that there
10  * are three new source files (src/rrd_is_thread_safe.h, src/rrd_thread_safe.c
11  * and src/rrd_not_thread_safe.c) and the introduction of librrd_th. This
12  * library is identical to librrd, but it contains support code for per-thread
13  * global variables currently used for error information only. This is similar
14  * to how errno per-thread variables are implemented.  librrd_th must be linked
15  * alongside of libpthred
16  *
17  * There is also a new file "THREADS", holding some documentation.
18  *
19  * -- Peter Stamfest <peter@stamfest.at>
20  *
21  * Revision 1.3  2002/02/01 20:34:49  oetiker
22  * fixed version number and date/time
23  *
24  * Revision 1.2  2001/03/10 23:54:39  oetiker
25  * Support for COMPUTE data sources (CDEF data sources). Removes the RPN
26  * parser and calculator from rrd_graph and puts then in a new file,
27  * rrd_rpncalc.c. Changes to core files rrd_create and rrd_update. Some
28  * clean-up of aberrant behavior stuff, including a bug fix.
29  * Documentation update (rrdcreate.pod, rrdupdate.pod). Change xml format.
30  * -- Jake Brutlag <jakeb@corp.webtv.net>
31  *
32  * Revision 1.1.1.1  2001/02/25 22:25:05  oetiker
33  * checkin
34  *
35  * Revision 1.3  1998/03/08 12:35:11  oetiker
36  * checkpointing things because the current setup seems to work
37  * according to the things said in the manpages
38  *
39  * Revision 1.2  1998/02/26 22:58:22  oetiker
40  * fixed define
41  *
42  * Revision 1.1  1998/02/21 16:14:41  oetiker
43  * Initial revision
44  *
45  *
46  *****************************************************************************/
47 #include "rrd_tool.h"
48
49 #define converter(VV,VVV) \
50    if (strcmp(#VV, string) == 0) return VVV;
51
52 /* conversion functions to allow symbolic entry of enumerations */
53 enum dst_en dst_conv(char *string)
54 {
55     converter(COUNTER,DST_COUNTER)
56     converter(ABSOLUTE,DST_ABSOLUTE)
57     converter(GAUGE,DST_GAUGE)
58     converter(DERIVE,DST_DERIVE)
59     converter(COMPUTE,DST_CDEF)
60     rrd_set_error("unknown data aquisition function '%s'",string);
61     return(-1);
62 }
63
64
65 enum cf_en cf_conv(char *string)
66 {
67
68     converter(AVERAGE,CF_AVERAGE)
69     converter(MIN,CF_MINIMUM)
70     converter(MAX,CF_MAXIMUM)
71     converter(LAST,CF_LAST)
72     converter(HWPREDICT,CF_HWPREDICT)
73     converter(DEVPREDICT,CF_DEVPREDICT)
74     converter(SEASONAL,CF_SEASONAL)
75     converter(DEVSEASONAL,CF_DEVSEASONAL)
76     converter(FAILURES,CF_FAILURES)
77     rrd_set_error("unknown consolidation function '%s'",string);
78     return(-1);
79 }
80
81 #undef converter        
82
83 long
84 ds_match(rrd_t *rrd,char *ds_nam){
85     unsigned long i;
86     for(i=0;i<rrd->stat_head->ds_cnt;i++)
87         if ((strcmp(ds_nam,rrd->ds_def[i].ds_nam))==0)
88             return i;
89     rrd_set_error("unknown data source name '%s'",ds_nam);
90     return -1;
91 }