xref: /minix3/crypto/external/bsd/heimdal/dist/lib/roken/syslog.hin (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc/*
2*ebfedea0SLionel Sambuc * Copyright (c) 1982, 1986, 1988, 1993
3*ebfedea0SLionel Sambuc *	The Regents of the University of California.  All rights reserved.
4*ebfedea0SLionel Sambuc *
5*ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
6*ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
7*ebfedea0SLionel Sambuc * are met:
8*ebfedea0SLionel Sambuc * 1. Redistributions of source code must retain the above copyright
9*ebfedea0SLionel Sambuc *    notice, this list of conditions and the following disclaimer.
10*ebfedea0SLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright
11*ebfedea0SLionel Sambuc *    notice, this list of conditions and the following disclaimer in the
12*ebfedea0SLionel Sambuc *    documentation and/or other materials provided with the distribution.
13*ebfedea0SLionel Sambuc * 4. Neither the name of the University nor the names of its contributors
14*ebfedea0SLionel Sambuc *    may be used to endorse or promote products derived from this software
15*ebfedea0SLionel Sambuc *    without specific prior written permission.
16*ebfedea0SLionel Sambuc *
17*ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18*ebfedea0SLionel Sambuc * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*ebfedea0SLionel Sambuc * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*ebfedea0SLionel Sambuc * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21*ebfedea0SLionel Sambuc * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*ebfedea0SLionel Sambuc * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*ebfedea0SLionel Sambuc * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*ebfedea0SLionel Sambuc * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*ebfedea0SLionel Sambuc * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*ebfedea0SLionel Sambuc * SUCH DAMAGE.
28*ebfedea0SLionel Sambuc *
29*ebfedea0SLionel Sambuc *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
30*ebfedea0SLionel Sambuc */
31*ebfedea0SLionel Sambuc
32*ebfedea0SLionel Sambuc/***********************************************************************
33*ebfedea0SLionel Sambuc * Copyright (c) 2009, Secure Endpoints Inc.
34*ebfedea0SLionel Sambuc * All rights reserved.
35*ebfedea0SLionel Sambuc *
36*ebfedea0SLionel Sambuc * Redistribution and use in source and binary forms, with or without
37*ebfedea0SLionel Sambuc * modification, are permitted provided that the following conditions
38*ebfedea0SLionel Sambuc * are met:
39*ebfedea0SLionel Sambuc *
40*ebfedea0SLionel Sambuc * - Redistributions of source code must retain the above copyright
41*ebfedea0SLionel Sambuc *   notice, this list of conditions and the following disclaimer.
42*ebfedea0SLionel Sambuc *
43*ebfedea0SLionel Sambuc * - Redistributions in binary form must reproduce the above copyright
44*ebfedea0SLionel Sambuc *   notice, this list of conditions and the following disclaimer in
45*ebfedea0SLionel Sambuc *   the documentation and/or other materials provided with the
46*ebfedea0SLionel Sambuc *   distribution.
47*ebfedea0SLionel Sambuc *
48*ebfedea0SLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49*ebfedea0SLionel Sambuc * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50*ebfedea0SLionel Sambuc * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
51*ebfedea0SLionel Sambuc * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
52*ebfedea0SLionel Sambuc * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
53*ebfedea0SLionel Sambuc * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
54*ebfedea0SLionel Sambuc * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
55*ebfedea0SLionel Sambuc * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
56*ebfedea0SLionel Sambuc * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
57*ebfedea0SLionel Sambuc * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
58*ebfedea0SLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
59*ebfedea0SLionel Sambuc * OF THE POSSIBILITY OF SUCH DAMAGE.
60*ebfedea0SLionel Sambuc *
61*ebfedea0SLionel Sambuc **********************************************************************/
62*ebfedea0SLionel Sambuc
63*ebfedea0SLionel Sambuc#ifndef _SYS_SYSLOG_H
64*ebfedea0SLionel Sambuc#define _SYS_SYSLOG_H 1
65*ebfedea0SLionel Sambuc
66*ebfedea0SLionel Sambuc#include <stdarg.h>
67*ebfedea0SLionel Sambuc
68*ebfedea0SLionel Sambuc/*
69*ebfedea0SLionel Sambuc * priorities/facilities are encoded into a single 32-bit quantity, where the
70*ebfedea0SLionel Sambuc * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
71*ebfedea0SLionel Sambuc * (0-big number).  Both the priorities and the facilities map roughly
72*ebfedea0SLionel Sambuc * one-to-one to strings in the syslogd(8) source code.  This mapping is
73*ebfedea0SLionel Sambuc * included in this file.
74*ebfedea0SLionel Sambuc *
75*ebfedea0SLionel Sambuc * priorities (these are ordered)
76*ebfedea0SLionel Sambuc */
77*ebfedea0SLionel Sambuc#define	LOG_EMERG	0	/* system is unusable */
78*ebfedea0SLionel Sambuc#define	LOG_ALERT	1	/* action must be taken immediately */
79*ebfedea0SLionel Sambuc#define	LOG_CRIT	2	/* critical conditions */
80*ebfedea0SLionel Sambuc#define	LOG_ERR		3	/* error conditions */
81*ebfedea0SLionel Sambuc#define	LOG_WARNING	4	/* warning conditions */
82*ebfedea0SLionel Sambuc#define	LOG_NOTICE	5	/* normal but significant condition */
83*ebfedea0SLionel Sambuc#define	LOG_INFO	6	/* informational */
84*ebfedea0SLionel Sambuc#define	LOG_DEBUG	7	/* debug-level messages */
85*ebfedea0SLionel Sambuc
86*ebfedea0SLionel Sambuc#define	LOG_PRIMASK	0x07	/* mask to extract priority part (internal) */
87*ebfedea0SLionel Sambuc				/* extract priority */
88*ebfedea0SLionel Sambuc#define	LOG_PRI(p)	((p) & LOG_PRIMASK)
89*ebfedea0SLionel Sambuc#define	LOG_MAKEPRI(fac, pri)	(((fac) << 3) | (pri))
90*ebfedea0SLionel Sambuc
91*ebfedea0SLionel Sambuc#ifdef SYSLOG_NAMES
92*ebfedea0SLionel Sambuc#define	INTERNAL_NOPRI	0x10	/* the "no priority" priority */
93*ebfedea0SLionel Sambuc				/* mark "facility" */
94*ebfedea0SLionel Sambuc#define	INTERNAL_MARK	LOG_MAKEPRI(LOG_NFACILITIES, 0)
95*ebfedea0SLionel Sambuctypedef struct _code {
96*ebfedea0SLionel Sambuc	char	*c_name;
97*ebfedea0SLionel Sambuc	int	c_val;
98*ebfedea0SLionel Sambuc} CODE;
99*ebfedea0SLionel Sambuc
100*ebfedea0SLionel SambucCODE prioritynames[] =
101*ebfedea0SLionel Sambuc  {
102*ebfedea0SLionel Sambuc    { "alert", LOG_ALERT },
103*ebfedea0SLionel Sambuc    { "crit", LOG_CRIT },
104*ebfedea0SLionel Sambuc    { "debug", LOG_DEBUG },
105*ebfedea0SLionel Sambuc    { "emerg", LOG_EMERG },
106*ebfedea0SLionel Sambuc    { "err", LOG_ERR },
107*ebfedea0SLionel Sambuc    { "error", LOG_ERR },		/* DEPRECATED */
108*ebfedea0SLionel Sambuc    { "info", LOG_INFO },
109*ebfedea0SLionel Sambuc    { "none", INTERNAL_NOPRI },		/* INTERNAL */
110*ebfedea0SLionel Sambuc    { "notice", LOG_NOTICE },
111*ebfedea0SLionel Sambuc    { "panic", LOG_EMERG },		/* DEPRECATED */
112*ebfedea0SLionel Sambuc    { "warn", LOG_WARNING },		/* DEPRECATED */
113*ebfedea0SLionel Sambuc    { "warning", LOG_WARNING },
114*ebfedea0SLionel Sambuc    { NULL, -1 }
115*ebfedea0SLionel Sambuc  };
116*ebfedea0SLionel Sambuc#endif
117*ebfedea0SLionel Sambuc
118*ebfedea0SLionel Sambuc/* facility codes */
119*ebfedea0SLionel Sambuc#define	LOG_KERN	(0<<3)	/* kernel messages */
120*ebfedea0SLionel Sambuc#define	LOG_USER	(1<<3)	/* random user-level messages */
121*ebfedea0SLionel Sambuc#define	LOG_MAIL	(2<<3)	/* mail system */
122*ebfedea0SLionel Sambuc#define	LOG_DAEMON	(3<<3)	/* system daemons */
123*ebfedea0SLionel Sambuc#define	LOG_AUTH	(4<<3)	/* security/authorization messages */
124*ebfedea0SLionel Sambuc#define	LOG_SYSLOG	(5<<3)	/* messages generated internally by syslogd */
125*ebfedea0SLionel Sambuc#define	LOG_LPR		(6<<3)	/* line printer subsystem */
126*ebfedea0SLionel Sambuc#define	LOG_NEWS	(7<<3)	/* network news subsystem */
127*ebfedea0SLionel Sambuc#define	LOG_UUCP	(8<<3)	/* UUCP subsystem */
128*ebfedea0SLionel Sambuc#define	LOG_CRON	(9<<3)	/* clock daemon */
129*ebfedea0SLionel Sambuc#define	LOG_AUTHPRIV	(10<<3)	/* security/authorization messages (private) */
130*ebfedea0SLionel Sambuc#define	LOG_FTP		(11<<3)	/* ftp daemon */
131*ebfedea0SLionel Sambuc
132*ebfedea0SLionel Sambuc	/* other codes through 15 reserved for system use */
133*ebfedea0SLionel Sambuc#define	LOG_LOCAL0	(16<<3)	/* reserved for local use */
134*ebfedea0SLionel Sambuc#define	LOG_LOCAL1	(17<<3)	/* reserved for local use */
135*ebfedea0SLionel Sambuc#define	LOG_LOCAL2	(18<<3)	/* reserved for local use */
136*ebfedea0SLionel Sambuc#define	LOG_LOCAL3	(19<<3)	/* reserved for local use */
137*ebfedea0SLionel Sambuc#define	LOG_LOCAL4	(20<<3)	/* reserved for local use */
138*ebfedea0SLionel Sambuc#define	LOG_LOCAL5	(21<<3)	/* reserved for local use */
139*ebfedea0SLionel Sambuc#define	LOG_LOCAL6	(22<<3)	/* reserved for local use */
140*ebfedea0SLionel Sambuc#define	LOG_LOCAL7	(23<<3)	/* reserved for local use */
141*ebfedea0SLionel Sambuc
142*ebfedea0SLionel Sambuc#define	LOG_NFACILITIES	24	/* current number of facilities */
143*ebfedea0SLionel Sambuc#define	LOG_FACMASK	0x03f8	/* mask to extract facility part */
144*ebfedea0SLionel Sambuc				/* facility of pri */
145*ebfedea0SLionel Sambuc#define	LOG_FAC(p)	(((p) & LOG_FACMASK) >> 3)
146*ebfedea0SLionel Sambuc
147*ebfedea0SLionel Sambuc#ifdef SYSLOG_NAMES
148*ebfedea0SLionel SambucCODE facilitynames[] =
149*ebfedea0SLionel Sambuc  {
150*ebfedea0SLionel Sambuc    { "auth", LOG_AUTH },
151*ebfedea0SLionel Sambuc    { "authpriv", LOG_AUTHPRIV },
152*ebfedea0SLionel Sambuc    { "cron", LOG_CRON },
153*ebfedea0SLionel Sambuc    { "daemon", LOG_DAEMON },
154*ebfedea0SLionel Sambuc    { "ftp", LOG_FTP },
155*ebfedea0SLionel Sambuc    { "kern", LOG_KERN },
156*ebfedea0SLionel Sambuc    { "lpr", LOG_LPR },
157*ebfedea0SLionel Sambuc    { "mail", LOG_MAIL },
158*ebfedea0SLionel Sambuc    { "mark", INTERNAL_MARK },		/* INTERNAL */
159*ebfedea0SLionel Sambuc    { "news", LOG_NEWS },
160*ebfedea0SLionel Sambuc    { "security", LOG_AUTH },		/* DEPRECATED */
161*ebfedea0SLionel Sambuc    { "syslog", LOG_SYSLOG },
162*ebfedea0SLionel Sambuc    { "user", LOG_USER },
163*ebfedea0SLionel Sambuc    { "uucp", LOG_UUCP },
164*ebfedea0SLionel Sambuc    { "local0", LOG_LOCAL0 },
165*ebfedea0SLionel Sambuc    { "local1", LOG_LOCAL1 },
166*ebfedea0SLionel Sambuc    { "local2", LOG_LOCAL2 },
167*ebfedea0SLionel Sambuc    { "local3", LOG_LOCAL3 },
168*ebfedea0SLionel Sambuc    { "local4", LOG_LOCAL4 },
169*ebfedea0SLionel Sambuc    { "local5", LOG_LOCAL5 },
170*ebfedea0SLionel Sambuc    { "local6", LOG_LOCAL6 },
171*ebfedea0SLionel Sambuc    { "local7", LOG_LOCAL7 },
172*ebfedea0SLionel Sambuc    { NULL, -1 }
173*ebfedea0SLionel Sambuc  };
174*ebfedea0SLionel Sambuc#endif
175*ebfedea0SLionel Sambuc
176*ebfedea0SLionel Sambuc/*
177*ebfedea0SLionel Sambuc * arguments to setlogmask.
178*ebfedea0SLionel Sambuc */
179*ebfedea0SLionel Sambuc#define	LOG_MASK(pri)	(1 << (pri))		/* mask for one priority */
180*ebfedea0SLionel Sambuc#define	LOG_UPTO(pri)	((1 << ((pri)+1)) - 1)	/* all priorities through pri */
181*ebfedea0SLionel Sambuc
182*ebfedea0SLionel Sambuc/*
183*ebfedea0SLionel Sambuc * Option flags for openlog.
184*ebfedea0SLionel Sambuc *
185*ebfedea0SLionel Sambuc * LOG_ODELAY no longer does anything.
186*ebfedea0SLionel Sambuc * LOG_NDELAY is the inverse of what it used to be.
187*ebfedea0SLionel Sambuc */
188*ebfedea0SLionel Sambuc#define	LOG_PID		0x01	/* log the pid with each message */
189*ebfedea0SLionel Sambuc#define	LOG_CONS	0x02	/* log on the console if errors in sending */
190*ebfedea0SLionel Sambuc#define	LOG_ODELAY	0x04	/* delay open until first syslog() (default) */
191*ebfedea0SLionel Sambuc#define	LOG_NDELAY	0x08	/* don't delay open */
192*ebfedea0SLionel Sambuc#define	LOG_NOWAIT	0x10	/* don't wait for console forks: DEPRECATED */
193*ebfedea0SLionel Sambuc#define	LOG_PERROR	0x20	/* log to stderr as well */
194*ebfedea0SLionel Sambuc
195*ebfedea0SLionel Sambuc#define SYSLOG_PORT     514
196*ebfedea0SLionel Sambuc
197*ebfedea0SLionel Sambuc#ifdef __cplusplus
198*ebfedea0SLionel Sambucextern "C" {
199*ebfedea0SLionel Sambuc#endif
200*ebfedea0SLionel Sambuc
201*ebfedea0SLionel Sambuc/* Close desriptor used to write to system logger.  */
202*ebfedea0SLionel Sambucextern void closelog (void);
203*ebfedea0SLionel Sambuc
204*ebfedea0SLionel Sambuc/* Open connection to system logger.  */
205*ebfedea0SLionel Sambucextern void openlog (char *__ident, int __option, int __facility);
206*ebfedea0SLionel Sambuc
207*ebfedea0SLionel Sambuc/* Set the log mask level.  */
208*ebfedea0SLionel Sambucextern int setlogmask (int __mask);
209*ebfedea0SLionel Sambuc
210*ebfedea0SLionel Sambuc/* Generate a log message using FMT string and option arguments.  */
211*ebfedea0SLionel Sambucextern void syslog (int __pri, char *__fmt, ...);
212*ebfedea0SLionel Sambuc
213*ebfedea0SLionel Sambuc/* Generate a log message using FMT and using arguments pointed to by AP.  */
214*ebfedea0SLionel Sambucextern void vsyslog (int __pri, char *__fmt, va_list __ap);
215*ebfedea0SLionel Sambuc
216*ebfedea0SLionel Sambuc#ifdef _WIN32
217*ebfedea0SLionel Sambuc    /* Windows specific.
218*ebfedea0SLionel Sambuc
219*ebfedea0SLionel Sambuc       init_syslog() *must* be called before calling any of the above
220*ebfedea0SLionel Sambuc       functions.  exit_syslog() will be scheduled using atexit().
221*ebfedea0SLionel Sambuc       However, it is not an error and encouraged to call
222*ebfedea0SLionel Sambuc       exit_syslog() before the application exits.
223*ebfedea0SLionel Sambuc
224*ebfedea0SLionel Sambuc       During operation, the application is free to call exit_syslog()
225*ebfedea0SLionel Sambuc       followed by init_syslog() to re-initialize the library. i.e. if
226*ebfedea0SLionel Sambuc       a different syslog host is to be used.
227*ebfedea0SLionel Sambuc
228*ebfedea0SLionel Sambuc     */
229*ebfedea0SLionel Sambuc
230*ebfedea0SLionel Sambuc    /* Initializes the syslog library and sets the syslog host.  The
231*ebfedea0SLionel Sambuc       hostname parameter is of the form "<hostname>[:<port>]".  The
232*ebfedea0SLionel Sambuc       <port> may be a numeric port or it may be a name of a service.
233*ebfedea0SLionel Sambuc       If the <port> is specified using a service name, it will be
234*ebfedea0SLionel Sambuc       looked up using getservbyname().
235*ebfedea0SLionel Sambuc
236*ebfedea0SLionel Sambuc       On failure, the hostname and port will be set to "localhost"
237*ebfedea0SLionel Sambuc       and SYSLOG_PORT respectively.
238*ebfedea0SLionel Sambuc    */
239*ebfedea0SLionel Sambuc    extern void init_syslog(const char * hostname);
240*ebfedea0SLionel Sambuc
241*ebfedea0SLionel Sambuc    extern void exit_syslog(void);
242*ebfedea0SLionel Sambuc#endif
243*ebfedea0SLionel Sambuc
244*ebfedea0SLionel Sambuc#ifdef __cplusplus
245*ebfedea0SLionel Sambuc}
246*ebfedea0SLionel Sambuc#endif
247*ebfedea0SLionel Sambuc
248*ebfedea0SLionel Sambuc#endif /* syslog.h */
249