]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - string.c
Fix the --log_color option of para_server and para_audiod.
[paraslash.git] / string.c
index 3c80d27cc6b6ad73a95392c17cdb041837ec6ba5..e037ebb49c75f9a38c42e7699090253a55bef74d 100644 (file)
--- a/string.c
+++ b/string.c
@@ -292,9 +292,9 @@ __must_check __malloc char *para_homedir(void)
  *
  * \return The number of substrings found in \a args.
  */
-__must_check unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
+unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
 {
-       char *p = args;
+       char *p;
        char **argv;
        size_t n = 0, i, j;
 
@@ -587,21 +587,33 @@ int para_atoi32(const char *str, int32_t *value)
        return 1;
 }
 
+static inline int loglevel_equal(const char *arg, const char * const ll)
+{
+       return !strncasecmp(arg, ll, strlen(ll));
+}
+
+/**
+ * Compute the loglevel number from its name.
+ *
+ * \param txt The name of the loglevel (debug, info, ...).
+ *
+ * \return The numeric representation of the loglevel name.
+ */
 int get_loglevel_by_name(const char *txt)
 {
-       if (!strcasecmp(txt, "debug"))
+       if (loglevel_equal(txt, "debug"))
                return LL_DEBUG;
-       if (!strcasecmp(txt, "info"))
+       if (loglevel_equal(txt, "info"))
                return LL_INFO;
-       if (!strcasecmp(txt, "notice"))
+       if (loglevel_equal(txt, "notice"))
                return LL_NOTICE;
-       if (!strcasecmp(txt, "warning"))
+       if (loglevel_equal(txt, "warning"))
                return LL_WARNING;
-       if (!strcasecmp(txt, "error"))
+       if (loglevel_equal(txt, "error"))
                return LL_ERROR;
-       if (!strcasecmp(txt, "crit"))
+       if (loglevel_equal(txt, "crit"))
                return LL_CRIT;
-       if (!strcasecmp(txt, "emerg"))
+       if (loglevel_equal(txt, "emerg"))
                return LL_EMERG;
        return -1;
 }