|
@@ -1,52 +1,71 @@
|
|
|
-#include "lub/log.h"
|
|
|
+/** @file log.c
|
|
|
+ * @brief Helpers for logging
|
|
|
+ */
|
|
|
+
|
|
|
+#ifdef HAVE_CONFIG_H
|
|
|
+#include "config.h"
|
|
|
+#endif /* HAVE_CONFIG_H */
|
|
|
+
|
|
|
#include <syslog.h>
|
|
|
-#include "lub/string.h"
|
|
|
|
|
|
-int lub_log_facility(const char *str, int *facility)
|
|
|
-{
|
|
|
- if (!lub_string_nocasecmp(str, "local0"))
|
|
|
+#include "faux/str.h"
|
|
|
+#include "faux/log.h"
|
|
|
+
|
|
|
+
|
|
|
+/** @brief Parses syslog facility string and returns the facility id.
|
|
|
+ *
|
|
|
+ * Gets syslog facility string, parse it and finds out the facility
|
|
|
+ * id in digital form. Usefull config or command line options parsing.
|
|
|
+ *
|
|
|
+ * @param [in] str Facility string.
|
|
|
+ * @param [out] facility Facility in digital form.
|
|
|
+ * @returns 0 - success, < 0 - parsing error
|
|
|
+ */
|
|
|
+int faux_log_facility(const char *str, int *facility) {
|
|
|
+
|
|
|
+ if (!faux_str_casecmp(str, "local0"))
|
|
|
*facility = LOG_LOCAL0;
|
|
|
- else if (!lub_string_nocasecmp(str, "local1"))
|
|
|
+ else if (!faux_str_casecmp(str, "local1"))
|
|
|
*facility = LOG_LOCAL1;
|
|
|
- else if (!lub_string_nocasecmp(str, "local2"))
|
|
|
+ else if (!faux_str_casecmp(str, "local2"))
|
|
|
*facility = LOG_LOCAL2;
|
|
|
- else if (!lub_string_nocasecmp(str, "local3"))
|
|
|
+ else if (!faux_str_casecmp(str, "local3"))
|
|
|
*facility = LOG_LOCAL3;
|
|
|
- else if (!lub_string_nocasecmp(str, "local4"))
|
|
|
+ else if (!faux_str_casecmp(str, "local4"))
|
|
|
*facility = LOG_LOCAL4;
|
|
|
- else if (!lub_string_nocasecmp(str, "local5"))
|
|
|
+ else if (!faux_str_casecmp(str, "local5"))
|
|
|
*facility = LOG_LOCAL5;
|
|
|
- else if (!lub_string_nocasecmp(str, "local6"))
|
|
|
+ else if (!faux_str_casecmp(str, "local6"))
|
|
|
*facility = LOG_LOCAL6;
|
|
|
- else if (!lub_string_nocasecmp(str, "local7"))
|
|
|
+ else if (!faux_str_casecmp(str, "local7"))
|
|
|
*facility = LOG_LOCAL7;
|
|
|
- else if (!lub_string_nocasecmp(str, "auth"))
|
|
|
+ else if (!faux_str_casecmp(str, "auth"))
|
|
|
*facility = LOG_AUTH;
|
|
|
#ifdef LOG_AUTHPRIV
|
|
|
- else if (!lub_string_nocasecmp(str, "authpriv"))
|
|
|
+ else if (!faux_str_casecmp(str, "authpriv"))
|
|
|
*facility = LOG_AUTHPRIV;
|
|
|
#endif
|
|
|
- else if (!lub_string_nocasecmp(str, "cron"))
|
|
|
+ else if (!faux_str_casecmp(str, "cron"))
|
|
|
*facility = LOG_CRON;
|
|
|
- else if (!lub_string_nocasecmp(str, "daemon"))
|
|
|
+ else if (!faux_str_casecmp(str, "daemon"))
|
|
|
*facility = LOG_DAEMON;
|
|
|
#ifdef LOG_FTP
|
|
|
- else if (!lub_string_nocasecmp(str, "ftp"))
|
|
|
+ else if (!faux_str_casecmp(str, "ftp"))
|
|
|
*facility = LOG_FTP;
|
|
|
#endif
|
|
|
- else if (!lub_string_nocasecmp(str, "kern"))
|
|
|
+ else if (!faux_str_casecmp(str, "kern"))
|
|
|
*facility = LOG_KERN;
|
|
|
- else if (!lub_string_nocasecmp(str, "lpr"))
|
|
|
+ else if (!faux_str_casecmp(str, "lpr"))
|
|
|
*facility = LOG_LPR;
|
|
|
- else if (!lub_string_nocasecmp(str, "mail"))
|
|
|
+ else if (!faux_str_casecmp(str, "mail"))
|
|
|
*facility = LOG_MAIL;
|
|
|
- else if (!lub_string_nocasecmp(str, "news"))
|
|
|
+ else if (!faux_str_casecmp(str, "news"))
|
|
|
*facility = LOG_NEWS;
|
|
|
- else if (!lub_string_nocasecmp(str, "syslog"))
|
|
|
+ else if (!faux_str_casecmp(str, "syslog"))
|
|
|
*facility = LOG_SYSLOG;
|
|
|
- else if (!lub_string_nocasecmp(str, "user"))
|
|
|
+ else if (!faux_str_casecmp(str, "user"))
|
|
|
*facility = LOG_USER;
|
|
|
- else if (!lub_string_nocasecmp(str, "uucp"))
|
|
|
+ else if (!faux_str_casecmp(str, "uucp"))
|
|
|
*facility = LOG_UUCP;
|
|
|
else
|
|
|
return -1;
|