diff options
author | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-26 02:05:21 -0500 |
---|---|---|
committer | Thomas Guyot-Sionnest <dermoth@aei.ca> | 2009-01-26 02:05:21 -0500 |
commit | ba132e9e521218efc5d35aa5f7a024cba93f5e29 (patch) | |
tree | 9328162d51cc85d99cf7c18b40e3b9684a17dedf /lib/utils_base.c | |
parent | 0a74b6fda08c484cba7216596d2ffa3931b900e5 (diff) | |
download | monitoring-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.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/utils_base.c b/lib/utils_base.c index a34cc5cc..77700f5b 100644 --- a/lib/utils_base.c +++ b/lib/utils_base.c @@ -258,7 +258,7 @@ int np_warn_if_not_root(void) { * This function can be used to parse NTP control packet data and performance * data strings. */ -char *np_extract_value(const char *varlist, const char *name) { +char *np_extract_value(const char *varlist, const char *name, char sep) { char *tmp=NULL, *value=NULL; int i; @@ -277,7 +277,7 @@ char *np_extract_value(const char *varlist, const char *name) { /* strip leading spaces */ for (varlist; isspace(varlist[0]); varlist++); - if (tmp = index(varlist, ',')) { + if (tmp = index(varlist, sep)) { /* Value is delimited by a comma */ if (tmp-varlist == 0) continue; value = (char *)malloc(tmp-varlist+1); @@ -293,7 +293,7 @@ char *np_extract_value(const char *varlist, const char *name) { break; } } - if (tmp = index(varlist, ',')) { + if (tmp = index(varlist, sep)) { /* More keys, keep going... */ varlist = tmp + 1; } else { |