1 diff a/src/rrd_fetch_libdbi.c b/src/rrd_fetch_libdbi.c
2 --- a/src/rrd_fetch_libdbi.c
3 +++ b/src/rrd_fetch_libdbi.c
4 @@ -17,20 +17,20 @@ struct sql_table_helper {
5 };
7 /* the prototypes */
8 -void _sql_close(struct sql_table_helper* th);
9 -int _sql_setparam(struct sql_table_helper* th,char* key, char* value);
10 -int _sql_fetchrow(struct sql_table_helper* th,time_t *timestamp, rrd_value_t *value,int ordered);
11 -char* _find_next_separator(char* start,char separator);
12 -char* _find_next_separator_twice(char*start,char separator);
13 -char _hexcharhelper(char c);
14 -int _inline_unescape (char* string);
15 -double rrd_fetch_dbi_double(dbi_result *result,int idx);
16 -long rrd_fetch_dbi_long(dbi_result *result,int idx);
17 +static void _sql_close(struct sql_table_helper* th);
18 +static int _sql_setparam(struct sql_table_helper* th,char* key, char* value);
19 +static int _sql_fetchrow(struct sql_table_helper* th,time_t *timestamp, rrd_value_t *value,int ordered);
20 +static char* _find_next_separator(char* start,char separator);
21 +static char* _find_next_separator_twice(char*start,char separator);
22 +static char _hexcharhelper(char c);
23 +static int _inline_unescape (char* string);
24 +static double rrd_fetch_dbi_double(dbi_result *result,int idx);
25 +static long rrd_fetch_dbi_long(dbi_result *result,int idx);
27 /* the real code */
29 /* helpers to get correctly converted values from DB*/
30 -long rrd_fetch_dbi_long(dbi_result *result,int idx) {
31 +static long rrd_fetch_dbi_long(dbi_result *result,int idx) {
32 char *ptmp="";
33 long value=DNAN;
34 /* get the attributes for this filed */
35 @@ -87,7 +87,7 @@ long rrd_fetch_dbi_long(dbi_result *result,int idx) {
36 return value;
37 }
39 -double rrd_fetch_dbi_double(dbi_result *result,int idx) {
40 +static double rrd_fetch_dbi_double(dbi_result *result,int idx) {
41 char *ptmp="";
42 double value=DNAN;
43 /* get the attributes for this filed */
44 @@ -144,7 +144,7 @@ double rrd_fetch_dbi_double(dbi_result *result,int idx) {
45 return value;
46 }
48 -void _sql_close(struct sql_table_helper* th) {
49 +static void _sql_close(struct sql_table_helper* th) {
50 /* close only if connected */
51 if (th->conn) {
52 if (getenv("RRDDEBUGSQL")) { fprintf(stderr,"RRDDEBUGSQL: %li: close connection\n",time(NULL) ); }
53 @@ -158,7 +158,7 @@ void _sql_close(struct sql_table_helper* th) {
54 }
55 }
57 -int _sql_setparam(struct sql_table_helper* th,char* key, char* value) {
58 +static int _sql_setparam(struct sql_table_helper* th,char* key, char* value) {
59 char* dbi_errstr=NULL;
60 dbi_driver driver;
61 /* if not connected */
62 @@ -200,7 +200,7 @@ int _sql_setparam(struct sql_table_helper* th,char* key, char* value) {
63 return 0;
64 }
66 -int _sql_fetchrow(struct sql_table_helper* th,time_t *timestamp, rrd_value_t *value,int ordered) {
67 +static int _sql_fetchrow(struct sql_table_helper* th,time_t *timestamp, rrd_value_t *value,int ordered) {
68 char* dbi_errstr=NULL;
69 char sql[10240];
70 time_t startt=0,endt=0;
71 @@ -269,7 +269,7 @@ int _sql_fetchrow(struct sql_table_helper* th,time_t *timestamp, rrd_value_t *va
72 return 1;
73 }
75 -char* _find_next_separator(char* start,char separator) {
76 +static char* _find_next_separator(char* start,char separator) {
77 char* found=strchr(start,separator);
78 /* have we found it */
79 if (found) {
80 @@ -282,7 +282,7 @@ char* _find_next_separator(char* start,char separator) {
81 return NULL;
82 }
84 -char* _find_next_separator_twice(char*start,char separator) {
85 +static char* _find_next_separator_twice(char*start,char separator) {
86 char *found=start;
87 /* find next separator in string*/
88 while (found) {
89 @@ -300,7 +300,7 @@ char* _find_next_separator_twice(char*start,char separator) {
90 return NULL;
91 }
93 -char _hexcharhelper(char c) {
94 +static char _hexcharhelper(char c) {
95 switch (c) {
96 case '0': return 0 ; break;
97 case '1': return 1 ; break;
98 @@ -328,7 +328,7 @@ char _hexcharhelper(char c) {
99 return -1;
100 }
102 -int _inline_unescape (char* string) {
103 +static int _inline_unescape (char* string) {
104 char *src=string;
105 char *dst=string;
106 char c,h1,h2;
107 @@ -341,9 +341,15 @@ int _inline_unescape (char* string) {
108 } else {
109 /* try to calculate hex value from the next 2 values*/
110 h1=_hexcharhelper(*src);
111 - if (h1<0) { rrd_set_error( "string escape error at: %s\n",string);return(1); }
112 + if (h1 == (char)-1) {
113 + rrd_set_error("string escape error at: %s\n",string);
114 + return(1);
115 + }
116 h2=_hexcharhelper(*(src+1));
117 - if (h2<0) { rrd_set_error( "string escape error at: %s\n",string);return(1); }
118 + if (h1 == (char)-1) {
119 + rrd_set_error("string escape error at: %s\n",string);
120 + return(1);
121 + }
122 c=h2+(h1<<4);
123 /* increase src pointer by 2 skiping 2 chars */
124 src+=2;
125 @@ -358,8 +364,8 @@ int _inline_unescape (char* string) {
127 int
128 rrd_fetch_fn_libdbi(
129 - char *filename, /* name of the rrd */
130 - enum cf_en cf_idx, /* which consolidation function ?*/
131 + const char *filename, /* name of the rrd */
132 + enum cf_en cf_idx __attribute__((unused)), /* consolidation function */
133 time_t *start,
134 time_t *end, /* which time frame do you want ?
135 * will be changed to represent reality */
136 diff a/src/rrd_tool.h b/src/rrd_tool.h
137 --- a/src/rrd_tool.h
138 +++ b/src/rrd_tool.h
139 @@ -94,7 +94,7 @@ extern "C" {
142 #ifdef HAVE_LIBDBI
143 -int rrd_fetch_fn_libdbi(char *filename, enum cf_en cf_idx,
144 +int rrd_fetch_fn_libdbi(const char *filename, enum cf_en cf_idx,
145 time_t *start,time_t *end,
146 unsigned long *step,
147 unsigned long *ds_cnt,