]> git.ozlabs.org Git - petitboot/commitdiff
Add parser routine conf_replace_char()
authorGeoff Levand <geoff@infradead.org>
Sun, 18 Mar 2012 22:52:02 +0000 (15:52 -0700)
committerGeoff Levand <geoff@infradead.org>
Sun, 18 Mar 2012 22:52:02 +0000 (15:52 -0700)
Signed-off-by: Geoff Levand <geoff@infradead.org>
discover/parser-conf.c
discover/parser-conf.h

index 88e96b7bee9e149d8e0cc58f93a156b9779c7193..6926a92a3fc3b836f51353ec71d3f9b920c43812 100644 (file)
@@ -57,6 +57,22 @@ char *conf_strip_str(char *s)
        return strlen(s) ? s : NULL;
 }
 
        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.
 /**
  * conf_get_param_pair - Get the next 'name=value' parameter pair.
  * @str: The string to process.
index 3325faf4f3f8331731d2e3271c50fc863ce94885..66013f34b2b27ea9e3c447ace788effef87ab705 100644 (file)
@@ -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);
 
 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
 
 #endif