From 59c55e2b636c0f877d36dbd158ede80a6dbf7ae3 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Sun, 18 Mar 2012 15:52:02 -0700 Subject: [PATCH] Add parser routine conf_replace_char() Signed-off-by: Geoff Levand --- discover/parser-conf.c | 16 ++++++++++++++++ discover/parser-conf.h | 1 + 2 files changed, 17 insertions(+) diff --git a/discover/parser-conf.c b/discover/parser-conf.c index 88e96b7..6926a92 100644 --- a/discover/parser-conf.c +++ b/discover/parser-conf.c @@ -57,6 +57,22 @@ char *conf_strip_str(char *s) return strlen(s) ? s : NULL; } +/** + * conf_replace_char - replace one char with another. + */ + +char *conf_replace_char(char *s, char from, char to) +{ + if (!s) + return NULL; + + for ( ; *s; s++) + if (*s == from) + *s = to; + + return s; +} + /** * conf_get_param_pair - Get the next 'name=value' parameter pair. * @str: The string to process. diff --git a/discover/parser-conf.h b/discover/parser-conf.h index 3325faf..66013f3 100644 --- a/discover/parser-conf.h +++ b/discover/parser-conf.h @@ -51,5 +51,6 @@ int conf_set_global_option(struct conf_context *conf, const char *name, int conf_param_in_list(const char *const *list, const char *param); char *conf_strip_str(char *s); +char *conf_replace_char(char *s, char from, char to); #endif -- 2.39.2