syslog.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #ifndef _SYSLOG_H
  2. #define _SYSLOG_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <features.h>
  7. #define LOG_EMERG 0
  8. #define LOG_ALERT 1
  9. #define LOG_CRIT 2
  10. #define LOG_ERR 3
  11. #define LOG_WARNING 4
  12. #define LOG_NOTICE 5
  13. #define LOG_INFO 6
  14. #define LOG_DEBUG 7
  15. #define LOG_PRIMASK 7
  16. #define LOG_PRI(p) ((p)&LOG_PRIMASK)
  17. #define LOG_MAKEPRI(f, p) (((f)<<3)|(p))
  18. #define LOG_MASK(p) (1<<(p))
  19. #define LOG_UPTO(p) ((1<<((p)+1))-1)
  20. #define LOG_KERN (0<<3)
  21. #define LOG_USER (1<<3)
  22. #define LOG_MAIL (2<<3)
  23. #define LOG_DAEMON (3<<3)
  24. #define LOG_AUTH (4<<3)
  25. #define LOG_SYSLOG (5<<3)
  26. #define LOG_LPR (6<<3)
  27. #define LOG_NEWS (7<<3)
  28. #define LOG_UUCP (8<<3)
  29. #define LOG_CRON (9<<3)
  30. #define LOG_AUTHPRIV (10<<3)
  31. #define LOG_FTP (11<<3)
  32. #define LOG_LOCAL0 (16<<3)
  33. #define LOG_LOCAL1 (17<<3)
  34. #define LOG_LOCAL2 (18<<3)
  35. #define LOG_LOCAL3 (19<<3)
  36. #define LOG_LOCAL4 (20<<3)
  37. #define LOG_LOCAL5 (21<<3)
  38. #define LOG_LOCAL6 (22<<3)
  39. #define LOG_LOCAL7 (23<<3)
  40. #define LOG_NFACILITIES 24
  41. #define LOG_FACMASK 0x3f8
  42. #define LOG_FAC(p) (((p)&LOG_FACMASK)>>3)
  43. #define LOG_PID 0x01
  44. #define LOG_CONS 0x02
  45. #define LOG_ODELAY 0x04
  46. #define LOG_NDELAY 0x08
  47. #define LOG_NOWAIT 0x10
  48. #define LOG_PERROR 0x20
  49. #if __GNUC__ >= 3
  50. #define __fp(x, y) __attribute__ ((__format__ (__printf__, x, y)))
  51. #else
  52. #define __fp(x, y)
  53. #endif
  54. void closelog (void);
  55. void openlog (const char *, int, int);
  56. int setlogmask (int);
  57. void syslog (int, const char *, ...) __fp(2, 3);
  58. #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
  59. #define _PATH_LOG "/dev/log"
  60. #define __NEED_va_list
  61. #include <bits/alltypes.h>
  62. void vsyslog (int, const char *, va_list) __fp(2, 0);
  63. #if defined(SYSLOG_NAMES)
  64. #define INTERNAL_NOPRI 0x10
  65. #define INTERNAL_MARK (LOG_NFACILITIES<<3)
  66. typedef struct {
  67. char *c_name;
  68. int c_val;
  69. } CODE;
  70. #define prioritynames ((CODE *)(const CODE []){ \
  71. { "alert", LOG_ALERT }, { "crit", LOG_CRIT }, { "debug", LOG_DEBUG }, \
  72. { "emerg", LOG_EMERG }, { "err", LOG_ERR }, { "error", LOG_ERR }, \
  73. { "info", LOG_INFO }, { "none", INTERNAL_NOPRI }, \
  74. { "notice", LOG_NOTICE }, { "panic", LOG_EMERG }, \
  75. { "warn", LOG_WARNING }, { "warning", LOG_WARNING }, { 0, -1 } })
  76. #define facilitynames ((CODE *)(const CODE []){ \
  77. { "auth", LOG_AUTH }, { "authpriv", LOG_AUTHPRIV }, \
  78. { "cron", LOG_CRON }, { "daemon", LOG_DAEMON }, { "ftp", LOG_FTP }, \
  79. { "kern", LOG_KERN }, { "lpr", LOG_LPR }, { "mail", LOG_MAIL }, \
  80. { "mark", INTERNAL_MARK }, { "news", LOG_NEWS }, \
  81. { "security", LOG_AUTH }, { "syslog", LOG_SYSLOG }, \
  82. { "user", LOG_USER }, { "uucp", LOG_UUCP }, \
  83. { "local0", LOG_LOCAL0 }, { "local1", LOG_LOCAL1 }, \
  84. { "local2", LOG_LOCAL2 }, { "local3", LOG_LOCAL3 }, \
  85. { "local4", LOG_LOCAL4 }, { "local5", LOG_LOCAL5 }, \
  86. { "local6", LOG_LOCAL6 }, { "local7", LOG_LOCAL7 }, { 0, -1 } })
  87. #endif
  88. #endif
  89. #undef __fp
  90. #ifdef __cplusplus
  91. }
  92. #endif
  93. #endif