syslogd_and_logger.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * prioritynames[] and facilitynames[]
  4. *
  5. * Copyright (C) 2008 by Denys Vlasenko <vda.linux@gmail.com>
  6. *
  7. * Licensed under GPLv2, see file LICENSE in this source tree.
  8. */
  9. #include "libbb.h"
  10. #define SYSLOG_NAMES
  11. #define SYSLOG_NAMES_CONST
  12. #include <syslog.h>
  13. #if 0
  14. /* For the record: with SYSLOG_NAMES <syslog.h> defines
  15. * (not declares) the following:
  16. */
  17. typedef struct _code {
  18. /*const*/ char *c_name;
  19. int c_val;
  20. } CODE;
  21. /*const*/ CODE prioritynames[] = {
  22. { "alert", LOG_ALERT },
  23. ...
  24. { NULL, -1 }
  25. };
  26. /* same for facilitynames[] */
  27. /* This MUST occur only once per entire executable,
  28. * therefore we can't just do it in syslogd.c and logger.c -
  29. * there will be two copies of it.
  30. *
  31. * We cannot even do it in separate file and then just reference
  32. * prioritynames[] from syslogd.c and logger.c - bare <syslog.h>
  33. * will not emit extern decls for prioritynames[]! Attempts to
  34. * emit "matching" struct _code declaration defeat the whole purpose
  35. * of <syslog.h>.
  36. *
  37. * For now, syslogd.c and logger.c are simply compiled into
  38. * one object file.
  39. */
  40. #endif
  41. #if ENABLE_SYSLOGD
  42. #include "syslogd.c"
  43. #endif
  44. #if ENABLE_LOGGER
  45. #include "logger.c"
  46. #endif