1*b30d1939SAndy Fiddaman /***********************************************************************
2*b30d1939SAndy Fiddaman *                                                                      *
3*b30d1939SAndy Fiddaman *               This software is part of the ast package               *
4*b30d1939SAndy Fiddaman *          Copyright (c) 1985-2011 AT&T Intellectual Property          *
5*b30d1939SAndy Fiddaman *                      and is licensed under the                       *
6*b30d1939SAndy Fiddaman *                 Eclipse Public License, Version 1.0                  *
7*b30d1939SAndy Fiddaman *                    by AT&T Intellectual Property                     *
8*b30d1939SAndy Fiddaman *                                                                      *
9*b30d1939SAndy Fiddaman *                A copy of the License is available at                 *
10*b30d1939SAndy Fiddaman *          http://www.eclipse.org/org/documents/epl-v10.html           *
11*b30d1939SAndy Fiddaman *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         *
12*b30d1939SAndy Fiddaman *                                                                      *
13*b30d1939SAndy Fiddaman *              Information and Software Systems Research               *
14*b30d1939SAndy Fiddaman *                            AT&T Research                             *
15*b30d1939SAndy Fiddaman *                           Florham Park NJ                            *
16*b30d1939SAndy Fiddaman *                                                                      *
17*b30d1939SAndy Fiddaman *                 Glenn Fowler <gsf@research.att.com>                  *
18*b30d1939SAndy Fiddaman *                  David Korn <dgk@research.att.com>                   *
19*b30d1939SAndy Fiddaman *                   Phong Vo <kpv@research.att.com>                    *
20*b30d1939SAndy Fiddaman *                                                                      *
21*b30d1939SAndy Fiddaman ***********************************************************************/
22*b30d1939SAndy Fiddaman #pragma prototyped
23*b30d1939SAndy Fiddaman /*
24*b30d1939SAndy Fiddaman  * posix syslog interface definitions
25*b30d1939SAndy Fiddaman  */
26*b30d1939SAndy Fiddaman 
27*b30d1939SAndy Fiddaman #ifndef _SYSLOG_H
28*b30d1939SAndy Fiddaman #define _SYSLOG_H
29*b30d1939SAndy Fiddaman 
30*b30d1939SAndy Fiddaman #include <stdarg.h>
31*b30d1939SAndy Fiddaman 
32*b30d1939SAndy Fiddaman #define LOG_PRIBITS	3	/* priority bits			*/
33*b30d1939SAndy Fiddaman #define LOG_FACBITS	7	/* facility bits			*/
34*b30d1939SAndy Fiddaman 
35*b30d1939SAndy Fiddaman #define LOG_PRIMASK	((1<<LOG_PRIBITS)-1)
36*b30d1939SAndy Fiddaman #define LOG_FACMASK	(((1<<LOG_FACBITS)-1)<<LOG_PRIBITS)
37*b30d1939SAndy Fiddaman 
38*b30d1939SAndy Fiddaman #define LOG_PRI(p)	((p)&((1<<LOG_PRIBITS)-1))
39*b30d1939SAndy Fiddaman #define LOG_FAC(p)	(((p)>>LOG_PRIBITS)&((1<<LOG_FACBITS)-1))
40*b30d1939SAndy Fiddaman 
41*b30d1939SAndy Fiddaman #define LOG_MAKEPRI(f,p) (((f)<<LOG_PRIBITS)|(p))
42*b30d1939SAndy Fiddaman 
43*b30d1939SAndy Fiddaman /* syslog priority severity levels */
44*b30d1939SAndy Fiddaman 
45*b30d1939SAndy Fiddaman #define LOG_EMERG	0	/* panic condition			*/
46*b30d1939SAndy Fiddaman #define LOG_ALERT	1	/* should be corrected immediately	*/
47*b30d1939SAndy Fiddaman #define LOG_CRIT	2	/* critical condition			*/
48*b30d1939SAndy Fiddaman #define LOG_ERR		3	/* error condition			*/
49*b30d1939SAndy Fiddaman #define LOG_WARNING	4	/* warning condition			*/
50*b30d1939SAndy Fiddaman #define LOG_NOTICE	5	/* no error but may need intervention	*/
51*b30d1939SAndy Fiddaman #define LOG_INFO	6	/* informational message		*/
52*b30d1939SAndy Fiddaman #define LOG_DEBUG	7	/* debug message			*/
53*b30d1939SAndy Fiddaman 
54*b30d1939SAndy Fiddaman /* setlogmask masks */
55*b30d1939SAndy Fiddaman 
56*b30d1939SAndy Fiddaman #define	LOG_MASK(s)	(1<<(s))	/* individual severity s	*/
57*b30d1939SAndy Fiddaman #define	LOG_UPTO(s)	((1<<((s)+1))-1)/* up to and including s	*/
58*b30d1939SAndy Fiddaman 
59*b30d1939SAndy Fiddaman /* syslog facilities */
60*b30d1939SAndy Fiddaman 
61*b30d1939SAndy Fiddaman #define LOG_KERN	(0<<LOG_PRIBITS) /* kernel			*/
62*b30d1939SAndy Fiddaman #define LOG_USER	(1<<LOG_PRIBITS) /* user process -- default	*/
63*b30d1939SAndy Fiddaman #define LOG_MAIL	(2<<LOG_PRIBITS) /* mail			*/
64*b30d1939SAndy Fiddaman #define LOG_DAEMON	(3<<LOG_PRIBITS) /* daemon			*/
65*b30d1939SAndy Fiddaman #define LOG_AUTH	(4<<LOG_PRIBITS) /* security/authorization	*/
66*b30d1939SAndy Fiddaman #define LOG_SYSLOG	(5<<LOG_PRIBITS) /* syslog internal		*/
67*b30d1939SAndy Fiddaman #define LOG_LPR		(6<<LOG_PRIBITS) /* line printer		*/
68*b30d1939SAndy Fiddaman #define LOG_NEWS	(7<<LOG_PRIBITS) /* network news		*/
69*b30d1939SAndy Fiddaman #define LOG_UUCP	(8<<LOG_PRIBITS) /* uucp			*/
70*b30d1939SAndy Fiddaman #define LOG_CRON	(9<<LOG_PRIBITS) /* cron			*/
71*b30d1939SAndy Fiddaman #define LOG_AUDIT	(13<<LOG_PRIBITS) /* audit daemon		*/
72*b30d1939SAndy Fiddaman #define LOG_LFMT	(14<<LOG_PRIBITS) /* logalert			*/
73*b30d1939SAndy Fiddaman #define LOG_LOCAL0	(16<<LOG_PRIBITS) /* reserved for local use	*/
74*b30d1939SAndy Fiddaman #define LOG_LOCAL1	(17<<LOG_PRIBITS) /* reserved for local use	*/
75*b30d1939SAndy Fiddaman #define LOG_LOCAL2	(18<<LOG_PRIBITS) /* reserved for local use	*/
76*b30d1939SAndy Fiddaman #define LOG_LOCAL3	(19<<LOG_PRIBITS) /* reserved for local use	*/
77*b30d1939SAndy Fiddaman #define LOG_LOCAL4	(20<<LOG_PRIBITS) /* reserved for local use	*/
78*b30d1939SAndy Fiddaman #define LOG_LOCAL5	(21<<LOG_PRIBITS) /* reserved for local use	*/
79*b30d1939SAndy Fiddaman #define LOG_LOCAL6	(22<<LOG_PRIBITS) /* reserved for local use	*/
80*b30d1939SAndy Fiddaman #define LOG_LOCAL7	(23<<LOG_PRIBITS) /* reserved for local use	*/
81*b30d1939SAndy Fiddaman 
82*b30d1939SAndy Fiddaman #define LOG_NFACILITIES	24
83*b30d1939SAndy Fiddaman 
84*b30d1939SAndy Fiddaman /* openlog flags */
85*b30d1939SAndy Fiddaman 
86*b30d1939SAndy Fiddaman #define	LOG_PID		0x01	/* log the pid with each message	*/
87*b30d1939SAndy Fiddaman #define	LOG_CONS	0x02	/* log to console if errors in sending	*/
88*b30d1939SAndy Fiddaman #define LOG_NDELAY	0x08	/* open right now			*/
89*b30d1939SAndy Fiddaman #define	LOG_ODELAY	0x04	/* delay open until syslog() is called	*/
90*b30d1939SAndy Fiddaman #define LOG_NOWAIT	0x10	/* don't wait() for any child processes	*/
91*b30d1939SAndy Fiddaman #define LOG_PERROR	0x20	/* log to stderr too			*/
92*b30d1939SAndy Fiddaman #define LOG_LEVEL	0x40	/* tag messages with facility/level	*/
93*b30d1939SAndy Fiddaman 
94*b30d1939SAndy Fiddaman #ifdef LOG_TABLES
95*b30d1939SAndy Fiddaman 
96*b30d1939SAndy Fiddaman /* encoding support */
97*b30d1939SAndy Fiddaman 
98*b30d1939SAndy Fiddaman #include <ast_namval.h>
99*b30d1939SAndy Fiddaman 
100*b30d1939SAndy Fiddaman #define log_facility	_log_facility
101*b30d1939SAndy Fiddaman #define log_severity	_log_severity
102*b30d1939SAndy Fiddaman 
103*b30d1939SAndy Fiddaman #define LOG_FACILITY(p)	LOG_FAC(p)	/* get facility index from pri	*/
104*b30d1939SAndy Fiddaman #define LOG_SEVERITY(p)	LOG_PRI(p)	/* get severity from pri	*/
105*b30d1939SAndy Fiddaman 
106*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__)
107*b30d1939SAndy Fiddaman #define extern		__EXPORT__
108*b30d1939SAndy Fiddaman #endif
109*b30d1939SAndy Fiddaman #if !_BLD_ast && defined(__IMPORT__)
110*b30d1939SAndy Fiddaman #define extern		extern __IMPORT__
111*b30d1939SAndy Fiddaman #endif
112*b30d1939SAndy Fiddaman 
113*b30d1939SAndy Fiddaman extern const Namval_t	log_facility[];
114*b30d1939SAndy Fiddaman extern const Namval_t	log_severity[];
115*b30d1939SAndy Fiddaman 
116*b30d1939SAndy Fiddaman #undef	extern
117*b30d1939SAndy Fiddaman 
118*b30d1939SAndy Fiddaman #endif
119*b30d1939SAndy Fiddaman 
120*b30d1939SAndy Fiddaman #if _BLD_ast && defined(__EXPORT__)
121*b30d1939SAndy Fiddaman #define extern		__EXPORT__
122*b30d1939SAndy Fiddaman #endif
123*b30d1939SAndy Fiddaman 
124*b30d1939SAndy Fiddaman extern void	closelog(void);
125*b30d1939SAndy Fiddaman extern void	openlog(const char*, int, int);
126*b30d1939SAndy Fiddaman extern int	setlogmask(int);
127*b30d1939SAndy Fiddaman extern void	syslog(int, const char*, ...);
128*b30d1939SAndy Fiddaman extern void	vsyslog(int, const char*, va_list);
129*b30d1939SAndy Fiddaman 
130*b30d1939SAndy Fiddaman #undef	extern
131*b30d1939SAndy Fiddaman 
132*b30d1939SAndy Fiddaman #endif