1 /* $Id$ */ 2 /* -/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/-/ 3 . Copyright (c) 2001 Michael Davis <mike@datanerds.net> 4 . 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 . 13 . 2. Redistributions in binary form must reproduce the above copyright 14 . notice, this list of conditions and the following disclaimer in the 15 . documentation and/or other materials provided with the distribution. 16 . 17 . 3. The name of author may not be used to endorse or promote products 18 . derived from this software without specific prior written permission. 19 . 20 . THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 . INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 22 . AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 . THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 24 . EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 25 . PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 26 . OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 27 . WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 . OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 29 . ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 . -\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\ */ 31 32 /* $OpenBSD: syslog.h,v 1.5 1998/02/10 18:41:57 deraadt Exp $ */ 33 /* $NetBSD: syslog.h,v 1.14 1996/04/03 20:46:44 christos Exp $ */ 34 35 /* 36 * Copyright (c) 1982, 1986, 1988, 1993 37 * The Regents of the University of California. All rights reserved. 38 * 39 * Redistribution and use in source and binary forms, with or without 40 * modification, are permitted provided that the following conditions 41 * are met: 42 * 1. Redistributions of source code must retain the above copyright 43 * notice, this list of conditions and the following disclaimer. 44 * 2. Redistributions in binary form must reproduce the above copyright 45 * notice, this list of conditions and the following disclaimer in the 46 * documentation and/or other materials provided with the distribution. 47 * 3. All advertising materials mentioning features or use of this software 48 * must display the following acknowledgement: 49 * This product includes software developed by the University of 50 * California, Berkeley and its contributors. 51 * 4. Neither the name of the University nor the names of its contributors 52 * may be used to endorse or promote products derived from this software 53 * without specific prior written permission. 54 * 55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 65 * SUCH DAMAGE. 66 * 67 * @(#)syslog.h 8.1 (Berkeley) 6/2/93 68 */ 69 70 #define _PATH_LOG "/dev/log" 71 72 /* 73 * priorities/facilities are encoded into a single 32-bit quantity, where the 74 * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility 75 * (0-big number). Both the priorities and the facilities map roughly 76 * one-to-one to strings in the syslogd(8) source code. This mapping is 77 * included in this file. 78 * 79 * priorities (these are ordered) 80 */ 81 #define LOG_EMERG 0 /* system is unusable */ 82 #define LOG_ALERT 1 /* action must be taken immediately */ 83 #define LOG_CRIT 2 /* critical conditions */ 84 #define LOG_ERR 3 /* error conditions */ 85 #define LOG_WARNING 4 /* warning conditions */ 86 #define LOG_NOTICE 5 /* normal but significant condition */ 87 #define LOG_INFO 6 /* informational */ 88 #define LOG_DEBUG 7 /* debug-level messages */ 89 90 #define LOG_PRIMASK 0x07 /* mask to extract priority part (internal) */ 91 /* extract priority */ 92 #define LOG_PRI(p) ((p) & LOG_PRIMASK) 93 #define LOG_MAKEPRI(fac, pri) (((fac) << 3) | (pri)) 94 95 #ifdef SYSLOG_NAMES 96 #define INTERNAL_NOPRI 0x10 /* the "no priority" priority */ 97 /* mark "facility" */ 98 #define INTERNAL_MARK LOG_MAKEPRI(LOG_NFACILITIES, 0) 99 typedef struct _code { 100 char *c_name; 101 int c_val; 102 } CODE; 103 104 CODE prioritynames[] = { 105 { "alert", LOG_ALERT }, 106 { "crit", LOG_CRIT }, 107 { "debug", LOG_DEBUG }, 108 { "emerg", LOG_EMERG }, 109 { "err", LOG_ERR }, 110 { "error", LOG_ERR }, /* DEPRECATED */ 111 { "info", LOG_INFO }, 112 { "none", INTERNAL_NOPRI }, /* INTERNAL */ 113 { "notice", LOG_NOTICE }, 114 { "panic", LOG_EMERG }, /* DEPRECATED */ 115 { "warn", LOG_WARNING }, /* DEPRECATED */ 116 { "warning", LOG_WARNING }, 117 { NULL, -1 }, 118 }; 119 #endif 120 121 /* facility codes */ 122 #define LOG_KERN (0<<3) /* kernel messages */ 123 #define LOG_USER (1<<3) /* random user-level messages */ 124 #define LOG_MAIL (2<<3) /* mail system */ 125 #define LOG_DAEMON (3<<3) /* system daemons */ 126 #define LOG_AUTH (4<<3) /* security/authorization messages */ 127 #define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */ 128 #define LOG_LPR (6<<3) /* line printer subsystem */ 129 #define LOG_NEWS (7<<3) /* network news subsystem */ 130 #define LOG_UUCP (8<<3) /* UUCP subsystem */ 131 #define LOG_CRON (9<<3) /* clock daemon */ 132 #define LOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */ 133 #define LOG_FTP (11<<3) /* ftp daemon */ 134 135 /* other codes through 15 reserved for system use */ 136 #define LOG_LOCAL0 (16<<3) /* reserved for local use */ 137 #define LOG_LOCAL1 (17<<3) /* reserved for local use */ 138 #define LOG_LOCAL2 (18<<3) /* reserved for local use */ 139 #define LOG_LOCAL3 (19<<3) /* reserved for local use */ 140 #define LOG_LOCAL4 (20<<3) /* reserved for local use */ 141 #define LOG_LOCAL5 (21<<3) /* reserved for local use */ 142 #define LOG_LOCAL6 (22<<3) /* reserved for local use */ 143 #define LOG_LOCAL7 (23<<3) /* reserved for local use */ 144 145 #define LOG_NFACILITIES 24 /* current number of facilities */ 146 #define LOG_FACMASK 0x03f8 /* mask to extract facility part */ 147 /* facility of pri */ 148 #define LOG_FAC(p) (((p) & LOG_FACMASK) >> 3) 149 150 #ifdef SYSLOG_NAMES 151 CODE facilitynames[] = { 152 { "auth", LOG_AUTH }, 153 { "authpriv", LOG_AUTHPRIV }, 154 { "cron", LOG_CRON }, 155 { "daemon", LOG_DAEMON }, 156 { "ftp", LOG_FTP }, 157 { "kern", LOG_KERN }, 158 { "lpr", LOG_LPR }, 159 { "mail", LOG_MAIL }, 160 { "mark", INTERNAL_MARK }, /* INTERNAL */ 161 { "news", LOG_NEWS }, 162 { "security", LOG_AUTH }, /* DEPRECATED */ 163 { "syslog", LOG_SYSLOG }, 164 { "user", LOG_USER }, 165 { "uucp", LOG_UUCP }, 166 { "local0", LOG_LOCAL0 }, 167 { "local1", LOG_LOCAL1 }, 168 { "local2", LOG_LOCAL2 }, 169 { "local3", LOG_LOCAL3 }, 170 { "local4", LOG_LOCAL4 }, 171 { "local5", LOG_LOCAL5 }, 172 { "local6", LOG_LOCAL6 }, 173 { "local7", LOG_LOCAL7 }, 174 { NULL, -1 }, 175 }; 176 #endif 177 178 #ifdef _KERNEL 179 #define LOG_PRINTF -1 /* pseudo-priority to indicate use of printf */ 180 #endif 181 182 /* 183 * arguments to setlogmask. 184 */ 185 #define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */ 186 #define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */ 187 188 /* 189 * Option flags for openlog. 190 * 191 * LOG_ODELAY no longer does anything. 192 * LOG_NDELAY is the inverse of what it used to be. 193 */ 194 #define LOG_PID 0x01 /* log the pid with each message */ 195 #define LOG_CONS 0x02 /* log on the console if errors in sending */ 196 #define LOG_ODELAY 0x04 /* delay open until first syslog() (default) */ 197 #define LOG_NDELAY 0x08 /* don't delay open */ 198 #define LOG_NOWAIT 0x10 /* don't wait for console forks: DEPRECATED */ 199 #define LOG_PERROR 0x20 /* log to stderr as well */ 200 201 #ifndef _KERNEL 202 203 /* 204 * Don't use va_list in the vsyslog() prototype. Va_list is typedef'd in two 205 * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one 206 * of them here we may collide with the utility's includes. It's unreasonable 207 * for utilities to have to include one of them to include syslog.h, so we get 208 * _BSD_VA_LIST_ from <machine/ansi.h> and use it. 209 */ 210 #include <stdarg.h> 211 212 #ifndef WIN32 213 #include <machine/ansi.h> 214 #include <sys/cdefs.h> 215 #endif 216 217 #ifdef WIN32 218 void AddEventSource(char *); 219 void syslog(int, char *, ...); 220 void vsyslog(int, char *, va_list); 221 void openlog(char *, int, int); 222 unsigned long resolve_host(char *); 223 #else 224 __BEGIN_DECLS 225 void closelog __P((void)); 226 void openlog __P((const char *, int, int)); 227 int setlogmask __P((int)); 228 void syslog __P((int, const char *, ...)) 229 __attribute__((__format__(__printf__,2,3))); 230 void vsyslog __P((int, const char *, _BSD_VA_LIST_)); 231 __END_DECLS 232 #endif 233 234 #else /* !_KERNEL */ 235 236 void logpri __P((int)); 237 void log __P((int, const char *, ...)) 238 __kprintf_attribute__((__format__(__kprintf__,2,3))); 239 int addlog __P((const char *, ...)) 240 __kprintf_attribute__((__format__(__kprintf__,1,2))); 241 void logwakeup __P((void)); 242 243 #endif /* !_KERNEL */ 244