syslog.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef _SYS_SYSLOG_H_
  2. #define _SYS_SYSLOG_H_
  3. /*
  4. * Copyright (C) 2001-2004 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Portions Copyright (c) 1982, 1986, 1988, 1993
  36. * The Regents of the University of California. All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. *
  62. */
  63. /*
  64. * $Log: syslog.h,v $
  65. * Revision 1.5 2004/11/24 16:41:18 haraldkipp
  66. * Wrong prototypes for _P routines fixed
  67. *
  68. * Revision 1.4 2004/10/03 18:41:43 haraldkipp
  69. * RAM saving calls added
  70. *
  71. * Revision 1.3 2004/09/19 11:18:44 haraldkipp
  72. * Syslog client added
  73. *
  74. */
  75. /*
  76. * priorities/facilities are encoded into a single 32-bit quantity, where the
  77. * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
  78. * (0-big number). Both the priorities and the facilities map roughly
  79. * one-to-one to strings in the syslogd(8) source code. This mapping is
  80. * included in this file.
  81. *
  82. * priorities (these are ordered)
  83. */
  84. #include <sys/types.h>
  85. #include <stdarg.h>
  86. #define LOG_EMERG 0 /* system is unusable */
  87. #define LOG_ALERT 1 /* action must be taken immediately */
  88. #define LOG_CRIT 2 /* critical conditions */
  89. #define LOG_ERR 3 /* error conditions */
  90. #define LOG_WARNING 4 /* warning conditions */
  91. #define LOG_NOTICE 5 /* normal but significant condition */
  92. #define LOG_INFO 6 /* informational */
  93. #define LOG_DEBUG 7 /* debug-level messages */
  94. #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */
  95. /* extract priority */
  96. #define LOG_PRI(p) ((p) & LOG_PRIMASK)
  97. #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri))
  98. /* facility codes */
  99. #define LOG_KERN (0<<3) /* kernel messages */
  100. #define LOG_USER (1<<3) /* random user-level messages */
  101. #define LOG_MAIL (2<<3) /* mail system */
  102. #define LOG_DAEMON (3<<3) /* system daemons */
  103. #define LOG_AUTH (4<<3) /* security/authorization messages */
  104. #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
  105. #define LOG_LPR (6<<3) /* line printer subsystem */
  106. #define LOG_NEWS (7<<3) /* network news subsystem */
  107. #define LOG_UUCP (8<<3) /* UUCP subsystem */
  108. #define LOG_CRON (9<<3) /* clock daemon */
  109. #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
  110. #define LOG_FTP (11<<3) /* ftp daemon */
  111. /* other codes through 15 reserved for system use */
  112. #define LOG_LOCAL0 (16<<3) /* reserved for local use */
  113. #define LOG_LOCAL1 (17<<3) /* reserved for local use */
  114. #define LOG_LOCAL2 (18<<3) /* reserved for local use */
  115. #define LOG_LOCAL3 (19<<3) /* reserved for local use */
  116. #define LOG_LOCAL4 (20<<3) /* reserved for local use */
  117. #define LOG_LOCAL5 (21<<3) /* reserved for local use */
  118. #define LOG_LOCAL6 (22<<3) /* reserved for local use */
  119. #define LOG_LOCAL7 (23<<3) /* reserved for local use */
  120. #define LOG_NFACILITIES 24 /* current number of facilities */
  121. #define LOG_FACMASK 0x03f8 /* mask to extract facility part */
  122. /* facility of pri */
  123. #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3)
  124. #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */
  125. /*
  126. * arguments to setlogmask.
  127. */
  128. #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
  129. #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
  130. /*
  131. * Option flags for openlog.
  132. *
  133. * LOG_ODELAY no longer does anything.
  134. * LOG_NDELAY is the inverse of what it used to be.
  135. */
  136. #define LOG_PID 0x01 /* log the pid with each message */
  137. #define LOG_CONS 0x02 /* log on the console if errors in sending */
  138. #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */
  139. #define LOG_NDELAY 0x08 /* don't delay open */
  140. #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */
  141. #define LOG_PERROR 0x20 /* log to stderr as well */
  142. __BEGIN_DECLS /* */
  143. extern void closelog(void);
  144. extern void openlog(CONST char *, int, int);
  145. extern int setlogmask(int);
  146. extern u_long setlogserver(u_long ip, u_short port);
  147. extern void syslog(int, CONST char *, ...);
  148. extern void vsyslog(int, CONST char *, va_list);
  149. #ifdef __HARVARD_ARCH__
  150. extern void syslog_P(int pri, PGM_P fmt, ...);
  151. extern void vsyslog_P(int pri, PGM_P fmt, va_list ap);
  152. #endif
  153. __END_DECLS /* */
  154. #endif