154359Sroberto/*
254359Sroberto * A hack for platforms which require specially built syslog facilities
354359Sroberto */
454359Sroberto
554359Sroberto#ifndef NTP_SYSLOG_H
654359Sroberto#define NTP_SYSLOG_H
754359Sroberto
8285612Sdelphij#include <ntp_types.h>		/* u_int32 type */
9285612Sdelphij
10285612Sdelphij#ifdef VMS
1154359Srobertoextern void msyslog();
12289997Sglebiusextern void mvsyslog();
13285612Sdelphij#else
14285612Sdelphij# ifndef SYS_VXWORKS
15285612Sdelphij#  include <syslog.h>
16285612Sdelphij# endif
17285612Sdelphij#endif /* VMS */
18285612Sdelphij#include <stdio.h>
1954359Sroberto
20285612Sdelphijextern int	syslogit;
21285612Sdelphijextern int	msyslog_term;	/* duplicate to stdout/err */
22285612Sdelphijextern int	msyslog_term_pid;
23285612Sdelphijextern int	msyslog_include_timestamp;
24285612Sdelphijextern FILE *	syslog_file;	/* if syslogit is FALSE, log to
25285612Sdelphij				   this file and not syslog */
26285612Sdelphijextern char *	syslog_fname;
27285612Sdelphijextern char *	syslog_abs_fname;
2854359Sroberto
2954359Sroberto#if defined(VMS) || defined (SYS_VXWORKS)
3054359Sroberto#define	LOG_EMERG	0	/* system is unusable */
3154359Sroberto#define	LOG_ALERT	1	/* action must be taken immediately */
3254359Sroberto#define	LOG_CRIT	2	/* critical conditions */
3354359Sroberto#define	LOG_ERR		3	/* error conditions */
3454359Sroberto#define	LOG_WARNING	4	/* warning conditions */
3554359Sroberto#define	LOG_NOTICE	5	/* normal but signification condition */
3654359Sroberto#define	LOG_INFO	6	/* informational */
3754359Sroberto#define	LOG_DEBUG	7	/* debug-level messages */
3854359Sroberto#endif /* VMS || VXWORKS */
3954359Sroberto
4054359Sroberto/*
4154359Sroberto * syslog output control
4254359Sroberto */
4354359Sroberto#define NLOG_INFO		0x00000001
4454359Sroberto#define NLOG_EVENT		0x00000002
4554359Sroberto#define NLOG_STATUS		0x00000004
4654359Sroberto#define NLOG_STATIST		0x00000008
4754359Sroberto
4854359Sroberto#define NLOG_OSYS			 0 /* offset for system flags */
49285612Sdelphij#define NLOG_SYSMASK		0x0000000F /* system log events */
5054359Sroberto#define NLOG_SYSINFO		0x00000001 /* system info log events */
5154359Sroberto#define NLOG_SYSEVENT		0x00000002 /* system events */
5254359Sroberto#define NLOG_SYSSTATUS		0x00000004 /* system status (sync/unsync) */
5354359Sroberto#define NLOG_SYSSTATIST		0x00000008 /* system statistics output */
5454359Sroberto
5554359Sroberto#define NLOG_OPEER			 4 /* offset for peer flags */
56285612Sdelphij#define NLOG_PEERMASK		0x000000F0 /* peer log events */
5754359Sroberto#define NLOG_PEERINFO		0x00000010 /* peer info log events */
5854359Sroberto#define NLOG_PEEREVENT		0x00000020 /* peer events */
5954359Sroberto#define NLOG_PEERSTATUS		0x00000040 /* peer status (sync/unsync) */
6054359Sroberto#define NLOG_PEERSTATIST	0x00000080 /* peer statistics output */
6154359Sroberto
6254359Sroberto#define NLOG_OCLOCK			 8 /* offset for clock flags */
63285612Sdelphij#define NLOG_CLOCKMASK		0x00000F00 /* clock log events */
6454359Sroberto#define NLOG_CLOCKINFO		0x00000100 /* clock info log events */
6554359Sroberto#define NLOG_CLOCKEVENT		0x00000200 /* clock events */
6654359Sroberto#define NLOG_CLOCKSTATUS	0x00000400 /* clock status (sync/unsync) */
6754359Sroberto#define NLOG_CLOCKSTATIST	0x00000800 /* clock statistics output */
6854359Sroberto
6954359Sroberto#define NLOG_OSYNC			12 /* offset for sync flags */
70285612Sdelphij#define NLOG_SYNCMASK		0x0000F000 /* sync log events */
7154359Sroberto#define NLOG_SYNCINFO		0x00001000 /* sync info log events */
7254359Sroberto#define NLOG_SYNCEVENT		0x00002000 /* sync events */
7354359Sroberto#define NLOG_SYNCSTATUS		0x00004000 /* sync status (sync/unsync) */
7454359Sroberto#define NLOG_SYNCSTATIST	0x00008000 /* sync statistics output */
7554359Sroberto
76285612Sdelphijextern u_int32 ntp_syslogmask;
7754359Sroberto
78285612Sdelphij#define NLOG(bits)	if (ntp_syslogmask & (bits))
79285612Sdelphij
80285612Sdelphij#define LOGIF(nlog_suffix, msl_args)				\
81285612Sdelphijdo {								\
82285612Sdelphij	NLOG(NLOG_##nlog_suffix)	/* like "if (...) */	\
83285612Sdelphij		msyslog msl_args;				\
84285612Sdelphij} while (FALSE)
85285612Sdelphij
8654359Sroberto#endif /* NTP_SYSLOG_H */
87