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