/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* SYSLOG -- print message on log file
*
* This routine looks a lot like printf, except that it
* outputs to the log file instead of the standard output.
* Also:
* adds a timestamp,
* prints the module name in front of the message,
* has some other formatting types (or will sometime),
* adds a newline on the end of the message.
*
*
* Author: Eric Allman
* Modified to use UNIX domain IPC by Ralph Campbell
*/
#include <netdb.h>
#include <strings.h>
#include <stdarg.h>
#include <vfork.h>
#include <stdio.h>
#include <errno.h>
#include <malloc.h>
static struct _syslog {
int _LogFile;
int _LogStat;
char *_LogTag;
int _LogMask;
char *_SyslogHost;
int _LogFacility;
} *_syslog;
extern char *strerror(int);
void openlog(char *, int, int);
static int
allocstatic(void)
{
if (_syslog == 0)
return (0); /* can't do it */
LogStat = 0; /* status bits, set by openlog() */
return (1);
}
void
{
}
void
{
char *b, *f, *o;
int c;
long now;
int taglen;
/*
* Maximum tag length is 256 (the pad in outline) minus the size of the
* other things that can go in the pad.
*/
if (_syslog == 0 && !allocstatic())
return;
/* see if we should just throw out this message */
return;
if (LogFile < 0)
/* set default facility if none specified */
if ((pri & LOG_FACMASK) == 0)
pri |= LogFacility;
/* build the message */
o = outline;
o += strlen(o);
if (LogTag) {
o[taglen] = '\0';
o += strlen(o);
}
o += strlen(o);
}
if (LogTag) {
(void) strcpy(o, ": ");
o += 2;
}
b = buf;
f = fmt;
char *errstr;
if (c != '%') {
*b++ = c;
continue;
}
if ((c = *f++) != 'm') {
*b++ = '%';
*b++ = c;
continue;
}
olderrno);
else {
if (*errstr == '%') {
strcpy(b, "%%");
b += 2;
}
else
*b++ = *errstr;
errstr++;
}
*b = '\0';
}
b += strlen(b);
}
*b++ = '\n';
*b = '\0';
if (c > MAXLINE) {
c = MAXLINE;
}
/* output the message to the local logger */
sizeof (SyslogAddr)) >= 0)
return;
return;
/* output the message to the console */
if (pid == -1)
return;
if (pid == 0) {
int fd;
(void) alarm(5);
(void) alarm(0);
(void) strcat(o, "\r\n");
c += 2;
}
} else
(void) alarm(0);
_exit(0);
}
if (!(LogStat & LOG_NOWAIT))
;
}
/*
* OPENLOG -- open system log
*/
void
{
if (_syslog == 0 && !allocstatic())
return;
if (ident != NULL)
LogTag = ident;
if (logfac != 0)
if (LogFile >= 0)
return;
sizeof (SyslogAddr.sa_data));
if (LogStat & LOG_NDELAY) {
}
}
/*
* CLOSELOG -- close the system log
*/
void
closelog(void)
{
if (_syslog == 0)
return;
LogFile = -1;
}
/*
* SETLOGMASK -- set the log mask level
*/
int
{
int omask;
if (_syslog == 0 && !allocstatic())
return (-1);
if (pmask != 0)
return (omask);
}
/*
* temporarily to solve bugid 1220257. Perhaps
* they could become a public interface at some
* point but not for now.
*/
extern int _doprnt();
static int
{
int count;
if (n == 0)
return (0);
return (count);
}
static int
{
int count;
if (n == 0)
return (0);
return (count);
}