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