X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Ftypes_list.c;h=3be792d5ca11bbd741f9b599a517c9cfea7da9ac;hb=6acb19befc321c501e4d8b79f403ebda0c021acc;hp=6fce0190f3046405506b0ea83fc7ba6e8d5aa5ee;hpb=c493010e9f1a6537dca21be2290bc28051ad0efc;p=collectd.git diff --git a/src/types_list.c b/src/types_list.c index 6fce0190..3be792d5 100644 --- a/src/types_list.c +++ b/src/types_list.c @@ -85,13 +85,10 @@ static int parse_ds (data_source_t *dsrc, char *buf, size_t buf_len) else dsrc->max = atof (fields[3]); - DEBUG ("parse_ds: dsrc = {%s, %i, %lf, %lf};", - dsrc->name, dsrc->type, dsrc->min, dsrc->max); - return (0); } /* int parse_ds */ -static void parse_line (char *buf, size_t buf_len) +static void parse_line (char *buf) { char *fields[64]; size_t fields_num; @@ -125,12 +122,10 @@ static void parse_line (char *buf, size_t buf_len) return; } - DEBUG ("parse_line: ds = {%s, %i, %p};", - ds->type, ds->ds_num, (void *) ds->ds); - plugin_register_data_set (ds); - /* Do NOT free `ds' and `ds->ds', because it's NOT copied by - * `plugin_register_data_set'!. */ + + sfree (ds->ds); + sfree (ds); } /* void parse_line */ static void parse_file (FILE *fh) @@ -157,21 +152,23 @@ static void parse_file (FILE *fh) if ((buf_len == 0) || (buf[0] == '#')) continue; - parse_line (buf, buf_len); + while ((buf_len > 0) && ((buf[buf_len - 1] == '\n') + || (buf[buf_len - 1] == '\n'))) + buf[--buf_len] = '\0'; + + if (buf_len == 0) + continue; + + parse_line (buf); } /* while (fgets) */ } /* void parse_file */ -int read_types_list (void) +int read_types_list (const char *file) { - const char *file; FILE *fh; - file = global_option_get ("TypesDB"); if (file == NULL) - { - ERROR ("global_option_get (\"TypesDB\") returned NULL."); return (-1); - } fh = fopen (file, "r"); if (fh == NULL)