summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 40b7e63)
raw | patch | inline | side by side (parent: 40b7e63)
author | Florian Forster <octo@collectd.org> | |
Wed, 20 Feb 2013 07:54:46 +0000 (08:54 +0100) | ||
committer | Florian Forster <octo@collectd.org> | |
Wed, 20 Feb 2013 07:54:46 +0000 (08:54 +0100) |
src/snort.c | patch | blob | history |
diff --git a/src/snort.c b/src/snort.c
index 6da5030296a83400d9c7181236d24d5eab075b7b..6e7e4a7f4ab8e63346c12a4427c4d6e5d88a431a 100644 (file)
--- a/src/snort.c
+++ b/src/snort.c
int i;
int fd;
- int metrics_num;
char **metrics;
- char **metrics_t;
+ int metrics_num;
struct stat sb;
- char *buf, *buf_t;
+ char *buf, *buf_ptr;
/* mmap, char pointers */
char *p_start;
}
/* Copy the line to the buffer */
- buf_t = buf = strdup(p_end);
+ buf = strdup(p_end);
/* Done with mmap and file pointer */
close(fd);
return (-1);
}
- for (metrics_t = metrics; (*metrics_t = strsep(&buf_t, ",")) != NULL;)
- if (**metrics_t != '\0')
- if (++metrics_t >= &metrics[metrics_num])
- break;
+ buf_ptr = buf;
+ i = 0;
+ while (buf_ptr != NULL) {
+ char *next = strchr (buf_ptr, ',');
+ if (next != NULL) {
+ *next = 0;
+ next++;
+ }
+ metrics[i] = buf_ptr;
+ buf_ptr = next;
+ i++;
+ }
+ assert (i == metrics_num);
/* Set last time */
id->last = TIME_T_TO_CDTIME_T(strtol(*metrics, NULL, 0));