axsyslog.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef _SYS_AXSYSLOG_H
  2. #define _SYS_AXSYSLOG_H 1
  3. #include <features.h>
  4. #define __need___va_list
  5. #include <stdarg.h>
  6. /* This file defines _AXPATH_LOG. */
  7. #include <bits/axsyslog-path.h>
  8. /*
  9. * priorities/facilities are encoded into a single 32-bit quantity, where the
  10. * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
  11. * (0-big number). Both the priorities and the facilities map roughly
  12. * one-to-one to strings in the syslogd(8) source code. This mapping is
  13. * included in this file.
  14. *
  15. * priorities (these are ordered)
  16. */
  17. #define LOG_EMERG 0 /* system is unusable */
  18. #define LOG_ALERT 1 /* action must be taken immediately */
  19. #define LOG_CRIT 2 /* critical conditions */
  20. #define LOG_ERR 3 /* error conditions */
  21. #define LOG_WARNING 4 /* warning conditions */
  22. #define LOG_NOTICE 5 /* normal but significant condition */
  23. #define LOG_INFO 6 /* informational */
  24. #define LOG_DEBUG 7 /* debug-level messages */
  25. #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
  26. /* extract priority */
  27. #define LOG_PRI(p) ((p) & LOG_PRIMASK)
  28. #define LOG_MAKEPRI(fac, pri) ((fac) | (pri))
  29. #ifdef AXSYSLOG_NAMES
  30. #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */
  31. /* mark "facility" */
  32. #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES << 3, 0)
  33. typedef struct _code {
  34. char *c_name;
  35. int c_val;
  36. } CODE;
  37. CODE axprioritynames[] =
  38. {
  39. { "alert", LOG_ALERT },
  40. { "crit", LOG_CRIT },
  41. { "debug", LOG_DEBUG },
  42. { "emerg", LOG_EMERG },
  43. { "err", LOG_ERR },
  44. { "error", LOG_ERR }, /* DEPRECATED */
  45. { "info", LOG_INFO },
  46. { "none", INTERNAL_NOPRI }, /* INTERNAL */
  47. { "notice", LOG_NOTICE },
  48. { "panic", LOG_EMERG }, /* DEPRECATED */
  49. { "warn", LOG_WARNING }, /* DEPRECATED */
  50. { "warning", LOG_WARNING },
  51. { NULL, -1 }
  52. };
  53. #endif
  54. /* facility codes */
  55. #define LOG_KERN (0<<3) /* kernel messages */
  56. #define LOG_USER (1<<3) /* random user-level messages */
  57. #define LOG_MAIL (2<<3) /* mail system */
  58. #define LOG_DAEMON (3<<3) /* system daemons */
  59. #define LOG_AUTH (4<<3) /* security/authorization messages */
  60. #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
  61. #define LOG_LPR (6<<3) /* line printer subsystem */
  62. #define LOG_NEWS (7<<3) /* network news subsystem */
  63. #define LOG_UUCP (8<<3) /* UUCP subsystem */
  64. #define LOG_CRON (9<<3) /* clock daemon */
  65. #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
  66. #define LOG_FTP (11<<3) /* ftp daemon */
  67. /* other codes through 15 reserved for system use */
  68. #define LOG_LOCAL0 (16<<3) /* reserved for local use */
  69. #define LOG_LOCAL1 (17<<3) /* reserved for local use */
  70. #define LOG_LOCAL2 (18<<3) /* reserved for local use */
  71. #define LOG_LOCAL3 (19<<3) /* reserved for local use */
  72. #define LOG_LOCAL4 (20<<3) /* reserved for local use */
  73. #define LOG_LOCAL5 (21<<3) /* reserved for local use */
  74. #define LOG_LOCAL6 (22<<3) /* reserved for local use */
  75. #define LOG_LOCAL7 (23<<3) /* reserved for local use */
  76. #define LOG_NFACILITIES 24 /* current number of facilities */
  77. #define LOG_FACMASK 0x03f8 /* mask to extract facility part */
  78. /* facility of pri */
  79. #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
  80. #ifdef AXSYSLOG_NAMES
  81. CODE axfacilitynames[] =
  82. {
  83. { "auth", LOG_AUTH },
  84. { "authpriv", LOG_AUTHPRIV },
  85. { "cron", LOG_CRON },
  86. { "daemon", LOG_DAEMON },
  87. { "ftp", LOG_FTP },
  88. { "kern", LOG_KERN },
  89. { "lpr", LOG_LPR },
  90. { "mail", LOG_MAIL },
  91. { "mark", INTERNAL_MARK }, /* INTERNAL */
  92. { "news", LOG_NEWS },
  93. { "security", LOG_AUTH }, /* DEPRECATED */
  94. { "syslog", LOG_SYSLOG },
  95. { "user", LOG_USER },
  96. { "uucp", LOG_UUCP },
  97. { "local0", LOG_LOCAL0 },
  98. { "local1", LOG_LOCAL1 },
  99. { "local2", LOG_LOCAL2 },
  100. { "local3", LOG_LOCAL3 },
  101. { "local4", LOG_LOCAL4 },
  102. { "local5", LOG_LOCAL5 },
  103. { "local6", LOG_LOCAL6 },
  104. { "local7", LOG_LOCAL7 },
  105. { NULL, -1 }
  106. };
  107. #endif
  108. /*
  109. * arguments to setlogmask.
  110. */
  111. #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
  112. #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
  113. /*
  114. * Option flags for openlog.
  115. *
  116. * LOG_ODELAY no longer does anything.
  117. * LOG_NDELAY is the inverse of what it used to be.
  118. */
  119. #define LOG_PID 0x01 /* log the pid with each message */
  120. #define LOG_CONS 0x02 /* log on the console if errors in sending */
  121. #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
  122. #define LOG_NDELAY 0x08 /* don't delay open */
  123. #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
  124. #define LOG_PERROR 0x20 /* log to stderr as well */
  125. __BEGIN_DECLS
  126. /* Close descriptor used to write to system logger.
  127. This function is a possible cancellation point and therefore not
  128. marked with __THROW. */
  129. extern void axcloselog (void);
  130. /* Open connection to system logger.
  131. This function is a possible cancellation point and therefore not
  132. marked with __THROW. */
  133. extern void axopenlog (const char *__ident, int __option, int __facility);
  134. /* Set the log mask level. */
  135. extern int axsetlogmask (int __mask) __THROW;
  136. /* Generate a log message using FMT string and option arguments.
  137. This function is a possible cancellation point and therefore not
  138. marked with __THROW. */
  139. extern void axsyslog (int __pri, const char*__tag, int __id, const char *__fmt, ...)
  140. __attribute__ ((__format__ (__printf__, 4, 5)));
  141. /* Generate a log message using FMT and using arguments pointed to by AP.
  142. This function is not part of POSIX and therefore no official
  143. cancellation point. But due to similarity with an POSIX interface
  144. or due to the implementation it is a cancellation point and
  145. therefore not marked with __THROW. */
  146. extern void axvsyslog (int __pri, const char* __tag, int __id, const char *__fmt, __gnuc_va_list __ap)
  147. __attribute__ ((__format__ (__printf__, 4, 0)));
  148. /* Define some macros helping to catch buffer overflows. */
  149. # include <bits/axsyslog.h>
  150. # include <bits/axsyslog-ldbl.h>
  151. __END_DECLS
  152. #endif /* sys/axsyslog.h */