xref: /xnu-10063.101.15/bsd/sys/syslog.h (revision 94d3b452840153a99b38a3a9659680b2a006908e)
1*94d3b452SApple OSS Distributions /*
2*94d3b452SApple OSS Distributions  * Copyright (c) 2000-2005 Apple Computer, Inc. All rights reserved.
3*94d3b452SApple OSS Distributions  *
4*94d3b452SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5*94d3b452SApple OSS Distributions  *
6*94d3b452SApple OSS Distributions  * This file contains Original Code and/or Modifications of Original Code
7*94d3b452SApple OSS Distributions  * as defined in and that are subject to the Apple Public Source License
8*94d3b452SApple OSS Distributions  * Version 2.0 (the 'License'). You may not use this file except in
9*94d3b452SApple OSS Distributions  * compliance with the License. The rights granted to you under the License
10*94d3b452SApple OSS Distributions  * may not be used to create, or enable the creation or redistribution of,
11*94d3b452SApple OSS Distributions  * unlawful or unlicensed copies of an Apple operating system, or to
12*94d3b452SApple OSS Distributions  * circumvent, violate, or enable the circumvention or violation of, any
13*94d3b452SApple OSS Distributions  * terms of an Apple operating system software license agreement.
14*94d3b452SApple OSS Distributions  *
15*94d3b452SApple OSS Distributions  * Please obtain a copy of the License at
16*94d3b452SApple OSS Distributions  * http://www.opensource.apple.com/apsl/ and read it before using this file.
17*94d3b452SApple OSS Distributions  *
18*94d3b452SApple OSS Distributions  * The Original Code and all software distributed under the License are
19*94d3b452SApple OSS Distributions  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20*94d3b452SApple OSS Distributions  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21*94d3b452SApple OSS Distributions  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22*94d3b452SApple OSS Distributions  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23*94d3b452SApple OSS Distributions  * Please see the License for the specific language governing rights and
24*94d3b452SApple OSS Distributions  * limitations under the License.
25*94d3b452SApple OSS Distributions  *
26*94d3b452SApple OSS Distributions  * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27*94d3b452SApple OSS Distributions  */
28*94d3b452SApple OSS Distributions /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
29*94d3b452SApple OSS Distributions /*-
30*94d3b452SApple OSS Distributions  * Copyright (c) 1982, 1986, 1988, 1993
31*94d3b452SApple OSS Distributions  *	The Regents of the University of California.  All rights reserved.
32*94d3b452SApple OSS Distributions  *
33*94d3b452SApple OSS Distributions  * Redistribution and use in source and binary forms, with or without
34*94d3b452SApple OSS Distributions  * modification, are permitted provided that the following conditions
35*94d3b452SApple OSS Distributions  * are met:
36*94d3b452SApple OSS Distributions  * 1. Redistributions of source code must retain the above copyright
37*94d3b452SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer.
38*94d3b452SApple OSS Distributions  * 2. Redistributions in binary form must reproduce the above copyright
39*94d3b452SApple OSS Distributions  *    notice, this list of conditions and the following disclaimer in the
40*94d3b452SApple OSS Distributions  *    documentation and/or other materials provided with the distribution.
41*94d3b452SApple OSS Distributions  * 4. Neither the name of the University nor the names of its contributors
42*94d3b452SApple OSS Distributions  *    may be used to endorse or promote products derived from this software
43*94d3b452SApple OSS Distributions  *    without specific prior written permission.
44*94d3b452SApple OSS Distributions  *
45*94d3b452SApple OSS Distributions  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46*94d3b452SApple OSS Distributions  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47*94d3b452SApple OSS Distributions  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48*94d3b452SApple OSS Distributions  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49*94d3b452SApple OSS Distributions  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50*94d3b452SApple OSS Distributions  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51*94d3b452SApple OSS Distributions  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52*94d3b452SApple OSS Distributions  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53*94d3b452SApple OSS Distributions  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54*94d3b452SApple OSS Distributions  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55*94d3b452SApple OSS Distributions  * SUCH DAMAGE.
56*94d3b452SApple OSS Distributions  *
57*94d3b452SApple OSS Distributions  *	@(#)syslog.h	8.1 (Berkeley) 6/2/93
58*94d3b452SApple OSS Distributions  * $FreeBSD: src/sys/sys/syslog.h,v 1.27.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $
59*94d3b452SApple OSS Distributions  */
60*94d3b452SApple OSS Distributions 
61*94d3b452SApple OSS Distributions #ifndef _SYS_SYSLOG_H_
62*94d3b452SApple OSS Distributions #define _SYS_SYSLOG_H_
63*94d3b452SApple OSS Distributions 
64*94d3b452SApple OSS Distributions #include <sys/appleapiopts.h>
65*94d3b452SApple OSS Distributions #include <sys/cdefs.h>
66*94d3b452SApple OSS Distributions 
67*94d3b452SApple OSS Distributions #define _PATH_LOG       "/var/run/syslog"
68*94d3b452SApple OSS Distributions 
69*94d3b452SApple OSS Distributions /*
70*94d3b452SApple OSS Distributions  * priorities/facilities are encoded into a single 32-bit quantity, where the
71*94d3b452SApple OSS Distributions  * bottom 3 bits are the priority (0-7) and the top 28 bits are the facility
72*94d3b452SApple OSS Distributions  * (0-big number).  Both the priorities and the facilities map roughly
73*94d3b452SApple OSS Distributions  * one-to-one to strings in the syslogd(8) source code.  This mapping is
74*94d3b452SApple OSS Distributions  * included in this file.
75*94d3b452SApple OSS Distributions  *
76*94d3b452SApple OSS Distributions  * priorities (these are ordered)
77*94d3b452SApple OSS Distributions  */
78*94d3b452SApple OSS Distributions #define LOG_EMERG       0       /* system is unusable */
79*94d3b452SApple OSS Distributions #define LOG_ALERT       1       /* action must be taken immediately */
80*94d3b452SApple OSS Distributions #define LOG_CRIT        2       /* critical conditions */
81*94d3b452SApple OSS Distributions #define LOG_ERR         3       /* error conditions */
82*94d3b452SApple OSS Distributions #define LOG_WARNING     4       /* warning conditions */
83*94d3b452SApple OSS Distributions #define LOG_NOTICE      5       /* normal but significant condition */
84*94d3b452SApple OSS Distributions #define LOG_INFO        6       /* informational */
85*94d3b452SApple OSS Distributions #define LOG_DEBUG       7       /* debug-level messages */
86*94d3b452SApple OSS Distributions 
87*94d3b452SApple OSS Distributions #define LOG_PRIMASK     0x07    /* mask to extract priority part (internal) */
88*94d3b452SApple OSS Distributions /* extract priority */
89*94d3b452SApple OSS Distributions #define LOG_PRI(p)      ((p) & LOG_PRIMASK)
90*94d3b452SApple OSS Distributions #define LOG_MAKEPRI(fac, pri)   ((fac) | (pri))
91*94d3b452SApple OSS Distributions 
92*94d3b452SApple OSS Distributions #ifdef SYSLOG_NAMES
93*94d3b452SApple OSS Distributions #define INTERNAL_NOPRI  0x10    /* the "no priority" priority */
94*94d3b452SApple OSS Distributions /* mark "facility" */
95*94d3b452SApple OSS Distributions #define INTERNAL_MARK   LOG_MAKEPRI((LOG_NFACILITIES<<3), 0)
96*94d3b452SApple OSS Distributions typedef struct _code {
97*94d3b452SApple OSS Distributions 	const char      *c_name;
98*94d3b452SApple OSS Distributions 	int             c_val;
99*94d3b452SApple OSS Distributions } CODE;
100*94d3b452SApple OSS Distributions 
101*94d3b452SApple OSS Distributions CODE prioritynames[] = {
102*94d3b452SApple OSS Distributions 	{ "alert", LOG_ALERT, },
103*94d3b452SApple OSS Distributions 	{ "crit", LOG_CRIT, },
104*94d3b452SApple OSS Distributions 	{ "debug", LOG_DEBUG, },
105*94d3b452SApple OSS Distributions 	{ "emerg", LOG_EMERG, },
106*94d3b452SApple OSS Distributions 	{ "err", LOG_ERR, },
107*94d3b452SApple OSS Distributions 	{ "error", LOG_ERR, },                  /* DEPRECATED */
108*94d3b452SApple OSS Distributions 	{ "info", LOG_INFO, },
109*94d3b452SApple OSS Distributions 	{ "none", INTERNAL_NOPRI, },            /* INTERNAL */
110*94d3b452SApple OSS Distributions 	{ "notice", LOG_NOTICE, },
111*94d3b452SApple OSS Distributions 	{ "panic", LOG_EMERG, },                /* DEPRECATED */
112*94d3b452SApple OSS Distributions 	{ "warn", LOG_WARNING, },               /* DEPRECATED */
113*94d3b452SApple OSS Distributions 	{ "warning", LOG_WARNING, },
114*94d3b452SApple OSS Distributions 	{ NULL, -1, }
115*94d3b452SApple OSS Distributions };
116*94d3b452SApple OSS Distributions #endif
117*94d3b452SApple OSS Distributions 
118*94d3b452SApple OSS Distributions /* facility codes */
119*94d3b452SApple OSS Distributions #define LOG_KERN        (0<<3)  /* kernel messages */
120*94d3b452SApple OSS Distributions #define LOG_USER        (1<<3)  /* random user-level messages */
121*94d3b452SApple OSS Distributions #define LOG_MAIL        (2<<3)  /* mail system */
122*94d3b452SApple OSS Distributions #define LOG_DAEMON      (3<<3)  /* system daemons */
123*94d3b452SApple OSS Distributions #define LOG_AUTH        (4<<3)  /* authorization messages */
124*94d3b452SApple OSS Distributions #define LOG_SYSLOG      (5<<3)  /* messages generated internally by syslogd */
125*94d3b452SApple OSS Distributions #define LOG_LPR         (6<<3)  /* line printer subsystem */
126*94d3b452SApple OSS Distributions #define LOG_NEWS        (7<<3)  /* network news subsystem */
127*94d3b452SApple OSS Distributions #define LOG_UUCP        (8<<3)  /* UUCP subsystem */
128*94d3b452SApple OSS Distributions #define LOG_CRON        (9<<3)  /* clock daemon */
129*94d3b452SApple OSS Distributions #define LOG_AUTHPRIV    (10<<3) /* authorization messages (private) */
130*94d3b452SApple OSS Distributions /* Facility #10 clashes in DEC UNIX, where */
131*94d3b452SApple OSS Distributions /* it's defined as LOG_MEGASAFE for AdvFS  */
132*94d3b452SApple OSS Distributions /* event logging.                          */
133*94d3b452SApple OSS Distributions #define LOG_FTP         (11<<3) /* ftp daemon */
134*94d3b452SApple OSS Distributions //#define	LOG_NTP		(12<<3)	/* NTP subsystem */
135*94d3b452SApple OSS Distributions //#define	LOG_SECURITY	(13<<3) /* security subsystems (firewalling, etc.) */
136*94d3b452SApple OSS Distributions //#define	LOG_CONSOLE	(14<<3) /* /dev/console output */
137*94d3b452SApple OSS Distributions #define LOG_NETINFO     (12<<3) /* NetInfo */
138*94d3b452SApple OSS Distributions #define LOG_REMOTEAUTH  (13<<3) /* remote authentication/authorization */
139*94d3b452SApple OSS Distributions #define LOG_INSTALL     (14<<3) /* installer subsystem */
140*94d3b452SApple OSS Distributions #define LOG_RAS         (15<<3) /* Remote Access Service (VPN / PPP) */
141*94d3b452SApple OSS Distributions 
142*94d3b452SApple OSS Distributions /* other codes through 15 reserved for system use */
143*94d3b452SApple OSS Distributions #define LOG_LOCAL0      (16<<3) /* reserved for local use */
144*94d3b452SApple OSS Distributions #define LOG_LOCAL1      (17<<3) /* reserved for local use */
145*94d3b452SApple OSS Distributions #define LOG_LOCAL2      (18<<3) /* reserved for local use */
146*94d3b452SApple OSS Distributions #define LOG_LOCAL3      (19<<3) /* reserved for local use */
147*94d3b452SApple OSS Distributions #define LOG_LOCAL4      (20<<3) /* reserved for local use */
148*94d3b452SApple OSS Distributions #define LOG_LOCAL5      (21<<3) /* reserved for local use */
149*94d3b452SApple OSS Distributions #define LOG_LOCAL6      (22<<3) /* reserved for local use */
150*94d3b452SApple OSS Distributions #define LOG_LOCAL7      (23<<3) /* reserved for local use */
151*94d3b452SApple OSS Distributions 
152*94d3b452SApple OSS Distributions #define LOG_LAUNCHD     (24<<3) /* launchd - general bootstrap daemon */
153*94d3b452SApple OSS Distributions 
154*94d3b452SApple OSS Distributions #define LOG_NFACILITIES 25      /* current number of facilities */
155*94d3b452SApple OSS Distributions #define LOG_FACMASK     0x03f8  /* mask to extract facility part */
156*94d3b452SApple OSS Distributions /* facility of pri */
157*94d3b452SApple OSS Distributions #define LOG_FAC(p)      (((p) & LOG_FACMASK) >> 3)
158*94d3b452SApple OSS Distributions 
159*94d3b452SApple OSS Distributions #ifdef SYSLOG_NAMES
160*94d3b452SApple OSS Distributions CODE facilitynames[] = {
161*94d3b452SApple OSS Distributions 	{ "auth", LOG_AUTH, },
162*94d3b452SApple OSS Distributions 	{ "authpriv", LOG_AUTHPRIV, },
163*94d3b452SApple OSS Distributions 	{ "cron", LOG_CRON, },
164*94d3b452SApple OSS Distributions 	{ "daemon", LOG_DAEMON, },
165*94d3b452SApple OSS Distributions 	{ "ftp", LOG_FTP, },
166*94d3b452SApple OSS Distributions 	{ "install", LOG_INSTALL     },
167*94d3b452SApple OSS Distributions 	{ "kern", LOG_KERN, },
168*94d3b452SApple OSS Distributions 	{ "lpr", LOG_LPR, },
169*94d3b452SApple OSS Distributions 	{ "mail", LOG_MAIL, },
170*94d3b452SApple OSS Distributions 	{ "mark", INTERNAL_MARK, },             /* INTERNAL */
171*94d3b452SApple OSS Distributions 	{ "netinfo", LOG_NETINFO, },
172*94d3b452SApple OSS Distributions 	{ "ras", LOG_RAS         },
173*94d3b452SApple OSS Distributions 	{ "remoteauth", LOG_REMOTEAUTH  },
174*94d3b452SApple OSS Distributions 	{ "news", LOG_NEWS, },
175*94d3b452SApple OSS Distributions 	{ "security", LOG_AUTH        },        /* DEPRECATED */
176*94d3b452SApple OSS Distributions 	{ "syslog", LOG_SYSLOG, },
177*94d3b452SApple OSS Distributions 	{ "user", LOG_USER, },
178*94d3b452SApple OSS Distributions 	{ "uucp", LOG_UUCP, },
179*94d3b452SApple OSS Distributions 	{ "local0", LOG_LOCAL0, },
180*94d3b452SApple OSS Distributions 	{ "local1", LOG_LOCAL1, },
181*94d3b452SApple OSS Distributions 	{ "local2", LOG_LOCAL2, },
182*94d3b452SApple OSS Distributions 	{ "local3", LOG_LOCAL3, },
183*94d3b452SApple OSS Distributions 	{ "local4", LOG_LOCAL4, },
184*94d3b452SApple OSS Distributions 	{ "local5", LOG_LOCAL5, },
185*94d3b452SApple OSS Distributions 	{ "local6", LOG_LOCAL6, },
186*94d3b452SApple OSS Distributions 	{ "local7", LOG_LOCAL7, },
187*94d3b452SApple OSS Distributions 	{ "launchd", LOG_LAUNCHD     },
188*94d3b452SApple OSS Distributions 	{ NULL, -1, }
189*94d3b452SApple OSS Distributions };
190*94d3b452SApple OSS Distributions #endif
191*94d3b452SApple OSS Distributions 
192*94d3b452SApple OSS Distributions #ifdef KERNEL
193*94d3b452SApple OSS Distributions #ifdef __APPLE_API_PRIVATE
194*94d3b452SApple OSS Distributions #define LOG_PRINTF      -1      /* pseudo-priority to indicate use of printf */
195*94d3b452SApple OSS Distributions #endif /* __APPLE_API_PRIVATE */
196*94d3b452SApple OSS Distributions #endif
197*94d3b452SApple OSS Distributions 
198*94d3b452SApple OSS Distributions /*
199*94d3b452SApple OSS Distributions  * arguments to setlogmask.
200*94d3b452SApple OSS Distributions  */
201*94d3b452SApple OSS Distributions #define LOG_MASK(pri)   (1 << (pri))            /* mask for one priority */
202*94d3b452SApple OSS Distributions #define LOG_UPTO(pri)   ((1 << ((pri)+1)) - 1)  /* all priorities through pri */
203*94d3b452SApple OSS Distributions 
204*94d3b452SApple OSS Distributions /*
205*94d3b452SApple OSS Distributions  * Option flags for openlog.
206*94d3b452SApple OSS Distributions  *
207*94d3b452SApple OSS Distributions  * LOG_ODELAY no longer does anything.
208*94d3b452SApple OSS Distributions  * LOG_NDELAY is the inverse of what it used to be.
209*94d3b452SApple OSS Distributions  */
210*94d3b452SApple OSS Distributions #define LOG_PID         0x01    /* log the pid with each message */
211*94d3b452SApple OSS Distributions #define LOG_CONS        0x02    /* log on the console if errors in sending */
212*94d3b452SApple OSS Distributions #define LOG_ODELAY      0x04    /* delay open until first syslog() (default) */
213*94d3b452SApple OSS Distributions #define LOG_NDELAY      0x08    /* don't delay open */
214*94d3b452SApple OSS Distributions #define LOG_NOWAIT      0x10    /* don't wait for console forks: DEPRECATED */
215*94d3b452SApple OSS Distributions #define LOG_PERROR      0x20    /* log to stderr as well */
216*94d3b452SApple OSS Distributions 
217*94d3b452SApple OSS Distributions #ifndef KERNEL
218*94d3b452SApple OSS Distributions 
219*94d3b452SApple OSS Distributions /*
220*94d3b452SApple OSS Distributions  * Don't use va_list in the vsyslog() prototype.   Va_list is typedef'd in two
221*94d3b452SApple OSS Distributions  * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one
222*94d3b452SApple OSS Distributions  * of them here we may collide with the utility's includes.  It's unreasonable
223*94d3b452SApple OSS Distributions  * for utilities to have to include one of them to include syslog.h, so we get
224*94d3b452SApple OSS Distributions  * __va_list from <sys/_types.h> and use it.
225*94d3b452SApple OSS Distributions  */
226*94d3b452SApple OSS Distributions #include <sys/_types.h>
227*94d3b452SApple OSS Distributions 
228*94d3b452SApple OSS Distributions __BEGIN_DECLS
229*94d3b452SApple OSS Distributions void    closelog(void);
230*94d3b452SApple OSS Distributions void    openlog(const char *, int, int);
231*94d3b452SApple OSS Distributions int     setlogmask(int);
232*94d3b452SApple OSS Distributions #if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && __DARWIN_C_LEVEL >= __DARWIN_C_FULL
233*94d3b452SApple OSS Distributions void    syslog(int, const char *, ...) __DARWIN_ALIAS_STARTING(__MAC_10_13, __IPHONE_NA, __DARWIN_EXTSN(syslog)) __printflike(2, 3) __not_tail_called;
234*94d3b452SApple OSS Distributions #else
235*94d3b452SApple OSS Distributions void    syslog(int, const char *, ...) __printflike(2, 3) __not_tail_called;
236*94d3b452SApple OSS Distributions #endif
237*94d3b452SApple OSS Distributions #if __DARWIN_C_LEVEL >= __DARWIN_C_FULL
238*94d3b452SApple OSS Distributions void    vsyslog(int, const char *, __darwin_va_list) __printflike(2, 0) __not_tail_called;
239*94d3b452SApple OSS Distributions #endif
240*94d3b452SApple OSS Distributions __END_DECLS
241*94d3b452SApple OSS Distributions 
242*94d3b452SApple OSS Distributions #else /* !KERNEL */
243*94d3b452SApple OSS Distributions #ifdef __APPLE_API_OBSOLETE
244*94d3b452SApple OSS Distributions /*
245*94d3b452SApple OSS Distributions  * bit field descriptions for printf %r and %R formats
246*94d3b452SApple OSS Distributions  */
247*94d3b452SApple OSS Distributions 
248*94d3b452SApple OSS Distributions /*
249*94d3b452SApple OSS Distributions  * printf("%r %R", val, reg_descp);
250*94d3b452SApple OSS Distributions  * struct reg_desc *reg_descp;
251*94d3b452SApple OSS Distributions  *
252*94d3b452SApple OSS Distributions  * the %r and %R formats allow formatted output of bit fields.
253*94d3b452SApple OSS Distributions  * reg_descp points to an array of reg_desc structures, each element of the
254*94d3b452SApple OSS Distributions  * array describes a range of bits within val.  the array should have a
255*94d3b452SApple OSS Distributions  * final element with all structure elements 0.
256*94d3b452SApple OSS Distributions  * %r outputs a string of the format "<bit field descriptions>"
257*94d3b452SApple OSS Distributions  * %R outputs a string of the format "0x%x<bit field descriptions>"
258*94d3b452SApple OSS Distributions  *
259*94d3b452SApple OSS Distributions  * The fields in a reg_desc are:
260*94d3b452SApple OSS Distributions  *	unsigned rd_mask;	An appropriate mask to isolate the bit field
261*94d3b452SApple OSS Distributions  *				within a word, and'ed with val
262*94d3b452SApple OSS Distributions  *
263*94d3b452SApple OSS Distributions  *	int rd_shift;		A shift amount to be done to the isolated
264*94d3b452SApple OSS Distributions  *				bit field.  done before printing the isolate
265*94d3b452SApple OSS Distributions  *				bit field with rd_format and before searching
266*94d3b452SApple OSS Distributions  *				for symbolic value names in rd_values
267*94d3b452SApple OSS Distributions  *
268*94d3b452SApple OSS Distributions  *	char *rd_name;		If non-null, a bit field name to label any
269*94d3b452SApple OSS Distributions  *				out from rd_format or searching rd_values.
270*94d3b452SApple OSS Distributions  *				if neither rd_format or rd_values is non-null
271*94d3b452SApple OSS Distributions  *				rd_name is printed only if the isolated
272*94d3b452SApple OSS Distributions  *				bit field is non-null.
273*94d3b452SApple OSS Distributions  *
274*94d3b452SApple OSS Distributions  *	char *rd_format;	If non-null, the shifted bit field value
275*94d3b452SApple OSS Distributions  *				is printed using this format.
276*94d3b452SApple OSS Distributions  *
277*94d3b452SApple OSS Distributions  *	struct reg_values *rd_values;	If non-null, a pointer to a table
278*94d3b452SApple OSS Distributions  *				matching numeric values with symbolic names.
279*94d3b452SApple OSS Distributions  *				rd_values are searched and the symbolic
280*94d3b452SApple OSS Distributions  *				value is printed if a match is found, if no
281*94d3b452SApple OSS Distributions  *				match is found "???" is printed.
282*94d3b452SApple OSS Distributions  *
283*94d3b452SApple OSS Distributions  * printf("%n %N", val, reg_valuesp);
284*94d3b452SApple OSS Distributions  * struct reg_values *reg_valuesp;
285*94d3b452SApple OSS Distributions  *
286*94d3b452SApple OSS Distributions  * the %n and %N formats allow formatted output of symbolic constants
287*94d3b452SApple OSS Distributions  * Reg_valuesp is a pointer to an array of struct reg_values which pairs
288*94d3b452SApple OSS Distributions  * numeric values (rv_value) with symbolic names (rv_name).  The array is
289*94d3b452SApple OSS Distributions  * terminated with a reg_values entry that has a null pointer for the
290*94d3b452SApple OSS Distributions  * rv_name field.  When %n or %N is used rd_values are searched and the
291*94d3b452SApple OSS Distributions  * symbolic value is printed if a match is found, if no match is found
292*94d3b452SApple OSS Distributions  * "???" is printed.
293*94d3b452SApple OSS Distributions  *
294*94d3b452SApple OSS Distributions  * printf("%C", val);
295*94d3b452SApple OSS Distributions  * int val;
296*94d3b452SApple OSS Distributions  *
297*94d3b452SApple OSS Distributions  * the %C format prints an int as a 4 character string.
298*94d3b452SApple OSS Distributions  * The most significant byte of the int is printed first, the least
299*94d3b452SApple OSS Distributions  * significant byte is printed last.
300*94d3b452SApple OSS Distributions  */
301*94d3b452SApple OSS Distributions 
302*94d3b452SApple OSS Distributions /*
303*94d3b452SApple OSS Distributions  * register values
304*94d3b452SApple OSS Distributions  * map between numeric values and symbolic values
305*94d3b452SApple OSS Distributions  */
306*94d3b452SApple OSS Distributions struct reg_values {
307*94d3b452SApple OSS Distributions 	unsigned rv_value;
308*94d3b452SApple OSS Distributions 	char *rv_name;
309*94d3b452SApple OSS Distributions };
310*94d3b452SApple OSS Distributions 
311*94d3b452SApple OSS Distributions /*
312*94d3b452SApple OSS Distributions  * register descriptors are used for formatted prints of register values
313*94d3b452SApple OSS Distributions  * rd_mask and rd_shift must be defined, other entries may be null
314*94d3b452SApple OSS Distributions  */
315*94d3b452SApple OSS Distributions struct reg_desc {
316*94d3b452SApple OSS Distributions 	unsigned rd_mask;       /* mask to extract field */
317*94d3b452SApple OSS Distributions 	int rd_shift;           /* shift for extracted value, - >>, + << */
318*94d3b452SApple OSS Distributions 	char *rd_name;          /* field name */
319*94d3b452SApple OSS Distributions 	char *rd_format;        /* format to print field */
320*94d3b452SApple OSS Distributions 	struct reg_values *rd_values;   /* symbolic names of values */
321*94d3b452SApple OSS Distributions };
322*94d3b452SApple OSS Distributions 
323*94d3b452SApple OSS Distributions #endif /* __APPLE_API_OBSOLETE */
324*94d3b452SApple OSS Distributions 
325*94d3b452SApple OSS Distributions #include <stdarg.h>
326*94d3b452SApple OSS Distributions __BEGIN_DECLS
327*94d3b452SApple OSS Distributions void    log(int, const char *, ...) __printflike(2, 3);
328*94d3b452SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE
329*94d3b452SApple OSS Distributions void    logtime(time_t);
330*94d3b452SApple OSS Distributions #endif /* XNU_KERNEL_PRIVATE */
331*94d3b452SApple OSS Distributions 
332*94d3b452SApple OSS Distributions __END_DECLS
333*94d3b452SApple OSS Distributions 
334*94d3b452SApple OSS Distributions #endif /* !KERNEL */
335*94d3b452SApple OSS Distributions #endif /* !_SYS_SYSLOG_H_ */
336