Annotation of kernel/bsd/sys/syslog.h, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.