00001 /* $Id$ */ 00002 /* -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ 00003 . Copyright (c) 2001 Michael Davis <mike@datanerds.net> 00004 . All rights reserved. 00005 . 00006 . Redistribution and use in source and binary forms, with or without 00007 . modification, are permitted provided that the following conditions 00008 . are met: 00009 . 00010 . 1. Redistributions of source code must retain the above copyright 00011 . notice, this list of conditions and the following disclaimer. 00012 . 00013 . 2. Redistributions in binary form must reproduce the above copyright 00014 . notice, this list of conditions and the following disclaimer in the 00015 . documentation and/or other materials provided with the distribution. 00016 . 00017 . 3. The name of author may not be used to endorse or promote products 00018 . derived from this software without specific prior written permission. 00019 . 00020 . THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 00021 . INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00022 . AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 00023 . THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00024 . EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00025 . PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00026 . OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00027 . WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00028 . OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00029 . ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00030 . -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ */ 00031 00032 /* $OpenBSD: syslog.h,v 1.5 1998/02/10 18:41:57 deraadt Exp $ */ 00033 /* $NetBSD: syslog.h,v 1.14 1996/04/03 20:46:44 christos Exp $ */ 00034 00035 /* 00036 * Copyright (c) 1982, 1986, 1988, 1993 00037 * The Regents of the University of California. All rights reserved. 00038 * 00039 * Redistribution and use in source and binary forms, with or without 00040 * modification, are permitted provided that the following conditions 00041 * are met: 00042 * 1. Redistributions of source code must retain the above copyright 00043 * notice, this list of conditions and the following disclaimer. 00044 * 2. Redistributions in binary form must reproduce the above copyright 00045 * notice, this list of conditions and the following disclaimer in the 00046 * documentation and/or other materials provided with the distribution. 00047 * 3. All advertising materials mentioning features or use of this software 00048 * must display the following acknowledgement: 00049 * This product includes software developed by the University of 00050 * California, Berkeley and its contributors. 00051 * 4. Neither the name of the University nor the names of its contributors 00052 * may be used to endorse or promote products derived from this software 00053 * without specific prior written permission. 00054 * 00055 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 00056 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00057 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00058 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 00059 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00060 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00061 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00062 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00063 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00064 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00065 * SUCH DAMAGE. 00066 * 00067 * @(#)syslog.h 8.1 (Berkeley) 6/2/93 00068 */ 00069 00070 #define _PATH_LOG "/dev/log" 00071 00072 /* 00073 * priorities/facilities are encoded into a single 32-bit quantity, where the 00074 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 00075 * (0-big number). Both the priorities and the facilities map roughly 00076 * one-to-one to strings in the syslogd(8) source code. This mapping is 00077 * included in this file. 00078 * 00079 * priorities (these are ordered) 00080 */ 00081 #define LOG_EMERG 0 /* system is unusable */ 00082 #define LOG_ALERT 1 /* action must be taken immediately */ 00083 #define LOG_CRIT 2 /* critical conditions */ 00084 #define LOG_ERR 3 /* error conditions */ 00085 #define LOG_WARNING 4 /* warning conditions */ 00086 #define LOG_NOTICE 5 /* normal but significant condition */ 00087 #define LOG_INFO 6 /* informational */ 00088 #define LOG_DEBUG 7 /* debug-level messages */ 00089 00090 #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 00091 /* extract priority */ 00092 #define LOG_PRI(p) ((p) & LOG_PRIMASK) 00093 #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) 00094 00095 #ifdef SYSLOG_NAMES 00096 #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ 00097 /* mark "facility" */ 00098 #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) 00099 typedef struct _code { 00100 char *c_name; 00101 int c_val; 00102 } CODE; 00103 00104 CODE prioritynames[] = { 00105 { "alert", LOG_ALERT }, 00106 { "crit", LOG_CRIT }, 00107 { "debug", LOG_DEBUG }, 00108 { "emerg", LOG_EMERG }, 00109 { "err", LOG_ERR }, 00110 { "error", LOG_ERR }, /* DEPRECATED */ 00111 { "info", LOG_INFO }, 00112 { "none", INTERNAL_NOPRI }, /* INTERNAL */ 00113 { "notice", LOG_NOTICE }, 00114 { "panic", LOG_EMERG }, /* DEPRECATED */ 00115 { "warn", LOG_WARNING }, /* DEPRECATED */ 00116 { "warning", LOG_WARNING }, 00117 { NULL, -1 }, 00118 }; 00119 #endif 00120 00121 /* facility codes */ 00122 #define LOG_KERN (0<<3) /* kernel messages */ 00123 #define LOG_USER (1<<3) /* random user-level messages */ 00124 #define LOG_MAIL (2<<3) /* mail system */ 00125 #define LOG_DAEMON (3<<3) /* system daemons */ 00126 #define LOG_AUTH (4<<3) /* security/authorization messages */ 00127 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 00128 #define LOG_LPR (6<<3) /* line printer subsystem */ 00129 #define LOG_NEWS (7<<3) /* network news subsystem */ 00130 #define LOG_UUCP (8<<3) /* UUCP subsystem */ 00131 #define LOG_CRON (9<<3) /* clock daemon */ 00132 #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ 00133 #define LOG_FTP (11<<3) /* ftp daemon */ 00134 00135 /* other codes through 15 reserved for system use */ 00136 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 00137 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 00138 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 00139 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 00140 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 00141 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 00142 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 00143 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 00144 00145 #define LOG_NFACILITIES 24 /* current number of facilities */ 00146 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 00147 /* facility of pri */ 00148 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 00149 00150 #ifdef SYSLOG_NAMES 00151 CODE facilitynames[] = { 00152 { "auth", LOG_AUTH }, 00153 { "authpriv", LOG_AUTHPRIV }, 00154 { "cron", LOG_CRON }, 00155 { "daemon", LOG_DAEMON }, 00156 { "ftp", LOG_FTP }, 00157 { "kern", LOG_KERN }, 00158 { "lpr", LOG_LPR }, 00159 { "mail", LOG_MAIL }, 00160 { "mark", INTERNAL_MARK }, /* INTERNAL */ 00161 { "news", LOG_NEWS }, 00162 { "security", LOG_AUTH }, /* DEPRECATED */ 00163 { "syslog", LOG_SYSLOG }, 00164 { "user", LOG_USER }, 00165 { "uucp", LOG_UUCP }, 00166 { "local0", LOG_LOCAL0 }, 00167 { "local1", LOG_LOCAL1 }, 00168 { "local2", LOG_LOCAL2 }, 00169 { "local3", LOG_LOCAL3 }, 00170 { "local4", LOG_LOCAL4 }, 00171 { "local5", LOG_LOCAL5 }, 00172 { "local6", LOG_LOCAL6 }, 00173 { "local7", LOG_LOCAL7 }, 00174 { NULL, -1 }, 00175 }; 00176 #endif 00177 00178 #ifdef _KERNEL 00179 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 00180 #endif 00181 00182 /* 00183 * arguments to setlogmask. 00184 */ 00185 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 00186 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 00187 00188 /* 00189 * Option flags for openlog. 00190 * 00191 * LOG_ODELAY no longer does anything. 00192 * LOG_NDELAY is the inverse of what it used to be. 00193 */ 00194 #define LOG_PID 0x01 /* log the pid with each message */ 00195 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 00196 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 00197 #define LOG_NDELAY 0x08 /* don't delay open */ 00198 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 00199 #define LOG_PERROR 0x20 /* log to stderr as well */ 00200 00201 #ifndef _KERNEL 00202 00203 /* 00204 * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two 00205 * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one 00206 * of them here we may collide with the utility's includes. It's unreasonable 00207 * for utilities to have to include one of them to include syslog.h, so we get 00208 * _BSD_VA_LIST_ from <machine/ansi.h> and use it. 00209 */ 00210 #include <stdarg.h> 00211 00212 #ifndef WIN32 00213 #include <machine/ansi.h> 00214 #include <sys/cdefs.h> 00215 #endif 00216 00217 #ifdef WIN32 00218 void AddEventSource(char *); 00219 void syslog(int, char *, ...); 00220 void vsyslog(int, char *, va_list); 00221 void openlog(char *, int, int); 00222 unsigned long resolve_host(char *); 00223 #else 00224 __BEGIN_DECLS 00225 void closelog __P((void)); 00226 void openlog __P((const char *, int, int)); 00227 int setlogmask __P((int)); 00228 void syslog __P((int, const char *, ...)) 00229 __attribute__((__format__(__printf__,2,3))); 00230 void vsyslog __P((int, const char *, _BSD_VA_LIST_)); 00231 __END_DECLS 00232 #endif 00233 00234 #else /* !_KERNEL */ 00235 00236 void logpri __P((int)); 00237 void log __P((int, const char *, ...)) 00238 __kprintf_attribute__((__format__(__kprintf__,2,3))); 00239 int addlog __P((const char *, ...)) 00240 __kprintf_attribute__((__format__(__kprintf__,1,2))); 00241 void logwakeup __P((void)); 00242 00243 #endif /* !_KERNEL */