log.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "log.h"
  2. #include <syslog.h>
  3. #include <strings.h>
  4. int parse_log_facility(const char *str, int *facility)
  5. {
  6. if (!strcasecmp(str, "local0"))
  7. *facility = LOG_LOCAL0;
  8. else if (!strcasecmp(str, "local1"))
  9. *facility = LOG_LOCAL1;
  10. else if (!strcasecmp(str, "local2"))
  11. *facility = LOG_LOCAL2;
  12. else if (!strcasecmp(str, "local3"))
  13. *facility = LOG_LOCAL3;
  14. else if (!strcasecmp(str, "local4"))
  15. *facility = LOG_LOCAL4;
  16. else if (!strcasecmp(str, "local5"))
  17. *facility = LOG_LOCAL5;
  18. else if (!strcasecmp(str, "local6"))
  19. *facility = LOG_LOCAL6;
  20. else if (!strcasecmp(str, "local7"))
  21. *facility = LOG_LOCAL7;
  22. else if (!strcasecmp(str, "auth"))
  23. *facility = LOG_AUTH;
  24. else if (!strcasecmp(str, "authpriv"))
  25. *facility = LOG_AUTHPRIV;
  26. else if (!strcasecmp(str, "cron"))
  27. *facility = LOG_CRON;
  28. else if (!strcasecmp(str, "daemon"))
  29. *facility = LOG_DAEMON;
  30. else if (!strcasecmp(str, "ftp"))
  31. *facility = LOG_FTP;
  32. else if (!strcasecmp(str, "kern"))
  33. *facility = LOG_KERN;
  34. else if (!strcasecmp(str, "lpr"))
  35. *facility = LOG_LPR;
  36. else if (!strcasecmp(str, "mail"))
  37. *facility = LOG_MAIL;
  38. else if (!strcasecmp(str, "news"))
  39. *facility = LOG_NEWS;
  40. else if (!strcasecmp(str, "syslog"))
  41. *facility = LOG_SYSLOG;
  42. else if (!strcasecmp(str, "user"))
  43. *facility = LOG_USER;
  44. else if (!strcasecmp(str, "uucp"))
  45. *facility = LOG_UUCP;
  46. else
  47. return -1;
  48. return 0;
  49. }