summaryrefslogtreecommitdiffstats
path: root/lib/utils_base.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-26 07:05:21 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-26 07:05:21 (GMT)
commitba132e9e521218efc5d35aa5f7a024cba93f5e29 (patch)
tree9328162d51cc85d99cf7c18b40e3b9684a17dedf /lib/utils_base.c
parent0a74b6fda08c484cba7216596d2ffa3931b900e5 (diff)
downloadmonitoring-plugins-ba132e9e521218efc5d35aa5f7a024cba93f5e29.tar.gz
Make extract_value more generic:
Add a separator argument passed using defines.
Diffstat (limited to 'lib/utils_base.c')
-rw-r--r--lib/utils_base.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c
index a34cc5c..77700f5 100644
--- a/lib/utils_base.c
+++ b/lib/utils_base.c
@@ -258,7 +258,7 @@ int np_warn_if_not_root(void) {
258 * This function can be used to parse NTP control packet data and performance 258 * This function can be used to parse NTP control packet data and performance
259 * data strings. 259 * data strings.
260 */ 260 */
261char *np_extract_value(const char *varlist, const char *name) { 261char *np_extract_value(const char *varlist, const char *name, char sep) {
262 char *tmp=NULL, *value=NULL; 262 char *tmp=NULL, *value=NULL;
263 int i; 263 int i;
264 264
@@ -277,7 +277,7 @@ char *np_extract_value(const char *varlist, const char *name) {
277 /* strip leading spaces */ 277 /* strip leading spaces */
278 for (varlist; isspace(varlist[0]); varlist++); 278 for (varlist; isspace(varlist[0]); varlist++);
279 279
280 if (tmp = index(varlist, ',')) { 280 if (tmp = index(varlist, sep)) {
281 /* Value is delimited by a comma */ 281 /* Value is delimited by a comma */
282 if (tmp-varlist == 0) continue; 282 if (tmp-varlist == 0) continue;
283 value = (char *)malloc(tmp-varlist+1); 283 value = (char *)malloc(tmp-varlist+1);
@@ -293,7 +293,7 @@ char *np_extract_value(const char *varlist, const char *name) {
293 break; 293 break;
294 } 294 }
295 } 295 }
296 if (tmp = index(varlist, ',')) { 296 if (tmp = index(varlist, sep)) {
297 /* More keys, keep going... */ 297 /* More keys, keep going... */
298 varlist = tmp + 1; 298 varlist = tmp + 1;
299 } else { 299 } else {