fecdec: Minor cleanups.
[paraslash.git] / string.c
index bdc113d3586c63059311968275f6134f5a9037b9..3c80d27cc6b6ad73a95392c17cdb041837ec6ba5 100644 (file)
--- a/string.c
+++ b/string.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2004-2008 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2004-2009 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -586,3 +586,22 @@ int para_atoi32(const char *str, int32_t *value)
        *value = tmp;
        return 1;
 }
+
+int get_loglevel_by_name(const char *txt)
+{
+       if (!strcasecmp(txt, "debug"))
+               return LL_DEBUG;
+       if (!strcasecmp(txt, "info"))
+               return LL_INFO;
+       if (!strcasecmp(txt, "notice"))
+               return LL_NOTICE;
+       if (!strcasecmp(txt, "warning"))
+               return LL_WARNING;
+       if (!strcasecmp(txt, "error"))
+               return LL_ERROR;
+       if (!strcasecmp(txt, "crit"))
+               return LL_CRIT;
+       if (!strcasecmp(txt, "emerg"))
+               return LL_EMERG;
+       return -1;
+}