From: Geoff Levand Date: Sun, 18 Mar 2012 22:52:02 +0000 (-0700) Subject: Add parser routine conf_replace_char() X-Git-Tag: v1.0.0~775 X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=59c55e2b636c0f877d36dbd158ede80a6dbf7ae3;hp=b53c175d61e9cac8e5a95abee9d6c05032d284b5;ds=sidebyside Add parser routine conf_replace_char() Signed-off-by: Geoff Levand --- 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