msyslog.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 1996,1999,2002 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* msyslog - either send a message to the terminal or print it on
* the standard output.
*
* Converted to use varargs, much better ... jks
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <stdio.h>
#include <errno.h>
/* alternative, as Solaris 2.x defines __STDC__ as 0 in a largely standard
conforming environment
#if __STDC__ || (defined(SYS_SOLARIS) && defined(__STDC__))
*/
#ifdef __STDC__
# include <stdarg.h>
#else
# include <varargs.h>
#endif
#include "ntp_types.h"
#include "ntp_string.h"
#include "ntp_stdlib.h"
#include "ntp_syslog.h"
#ifdef SYS_WINNT
# include "log.h"
# include "messages.h"
#endif
int syslogit = 1;
#ifndef VMS
#ifndef SYS_WINNT
extern int errno;
#else
static WORD event_type[] = {
};
#endif /* SYS_WINNT */
#endif /* VMS */
extern char *progname;
#if defined(__STDC__)
#else
/*VARARGS*/
#endif
{
#ifndef __STDC__
int level;
const char *fmt;
#endif
#if !defined(VMS)
char xerr[50];
#endif
register int c;
register char *n, *prog;
register const char *f;
#ifdef CHAR_SYS_ERRLIST
extern int sys_nerr;
extern char *sys_errlist[];
#endif
register int l;
int olderrno;
const char *err;
#ifdef __STDC__
#else
#endif
#ifdef SYS_SOLARIS
if (syslogit) {
return;
}
#endif
n = nfmt;
f = fmt;
if (c != '%') {
*n++ = c;
continue;
}
if ((c = *f++) != 'm') {
*n++ = '%';
*n++ = c;
continue;
}
err = 0;
else
#else /* SYS_WINNT */
NULL,
GetLastError(),
sizeof(xerr),
NULL);
#endif /* VMS && SYS_WINNT */
}
}
#if !defined(VMS)
if (!syslogit)
#endif /* VMS */
*n++ = '\n';
*n = '\0';
#if !defined(VMS) && !defined (SYS_VXWORKS)
if (syslogit)
#ifndef SYS_WINNT
#else
{
lpszStrings[0] = buf;
switch (event_type[level])
{
case EVENTLOG_ERROR_TYPE :
{
break;
}
case EVENTLOG_INFORMATION_TYPE :
{
break;
}
case EVENTLOG_WARNING_TYPE :
{
break;
}
} /* switch end */
}
#endif /* SYS_WINNT */
else {
#else
{
#endif /* VMS && SYS_VXWORKS*/
extern char * humanlogtime P((void));
/* syslog() provides the timestamp, so if we're not using
syslog, we must provide it. */
else
prog++;
}
}