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