Refactor, replace reserved dprintf() with logit()
dprintf() was standardized by POSIX.1-2008. This patch replaces all occurrences with logit(). Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
parent
ea586826be
commit
9f21a8a0f5
165
src/syslogd.c
165
src/syslogd.c
@ -845,10 +845,7 @@ void doexit(int sig);
|
||||
void init();
|
||||
void cfline(char *line, register struct filed *f);
|
||||
int decode(char *name, struct code *codetab);
|
||||
#if defined(__GLIBC__)
|
||||
#define dprintf mydprintf
|
||||
#endif /* __GLIBC__ */
|
||||
static void dprintf(char *, ...);
|
||||
static void logit(char *, ...);
|
||||
static void allocate_log(void);
|
||||
void sighup_handler();
|
||||
|
||||
@ -990,7 +987,7 @@ int main(argc, argv)
|
||||
#ifndef TESTING
|
||||
if ( !(Debug || NoFork) )
|
||||
{
|
||||
dprintf("Checking pidfile.\n");
|
||||
logit("Checking pidfile.\n");
|
||||
if (!check_pid(PidFile))
|
||||
{
|
||||
signal (SIGTERM, doexit);
|
||||
@ -1033,12 +1030,12 @@ int main(argc, argv)
|
||||
/* tuck my process id away */
|
||||
if ( !Debug )
|
||||
{
|
||||
dprintf("Writing pidfile.\n");
|
||||
logit("Writing pidfile.\n");
|
||||
if (!check_pid(PidFile))
|
||||
{
|
||||
if (!write_pid(PidFile))
|
||||
{
|
||||
dprintf("Can't write pid.\n");
|
||||
logit("Can't write pid.\n");
|
||||
if (getpid() != ppid)
|
||||
kill (ppid, SIGTERM);
|
||||
exit(1);
|
||||
@ -1046,7 +1043,7 @@ int main(argc, argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf("Pidfile (and pid) already exist.\n");
|
||||
logit("Pidfile (and pid) already exist.\n");
|
||||
if (getpid() != ppid)
|
||||
kill (ppid, SIGTERM);
|
||||
exit(1);
|
||||
@ -1074,7 +1071,7 @@ int main(argc, argv)
|
||||
|
||||
/* Create a partial message table for all file descriptors. */
|
||||
num_fds = getdtablesize();
|
||||
dprintf("Allocated parts table for %d file descriptors.\n", num_fds);
|
||||
logit("Allocated parts table for %d file descriptors.\n", num_fds);
|
||||
if ( (parts = (char **) malloc(num_fds * sizeof(char *))) == \
|
||||
(char **) 0 )
|
||||
{
|
||||
@ -1088,12 +1085,12 @@ int main(argc, argv)
|
||||
for(i= 0; i < num_fds; ++i)
|
||||
parts[i] = (char *) 0;
|
||||
|
||||
dprintf("Starting.\n");
|
||||
logit("Starting.\n");
|
||||
init();
|
||||
#ifndef TESTING
|
||||
if ( Debug )
|
||||
{
|
||||
dprintf("Debugging disabled, SIGUSR1 to turn on debugging.\n");
|
||||
logit("Debugging disabled, SIGUSR1 to turn on debugging.\n");
|
||||
debugging_on = 0;
|
||||
}
|
||||
/*
|
||||
@ -1136,7 +1133,7 @@ int main(argc, argv)
|
||||
FD_SET(finet[i+1], &readfds);
|
||||
if (finet[i+1]>maxfds) maxfds=finet[i+1];
|
||||
}
|
||||
dprintf("Listening on syslog UDP port.\n");
|
||||
logit("Listening on syslog UDP port.\n");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@ -1144,23 +1141,23 @@ int main(argc, argv)
|
||||
FD_SET(fileno(stdin), &readfds);
|
||||
if (fileno(stdin) > maxfds) maxfds = fileno(stdin);
|
||||
|
||||
dprintf("Listening on stdin. Press Ctrl-C to interrupt.\n");
|
||||
logit("Listening on stdin. Press Ctrl-C to interrupt.\n");
|
||||
#endif
|
||||
|
||||
if ( debugging_on )
|
||||
{
|
||||
dprintf("Calling select, active file descriptors (max %d): ", maxfds);
|
||||
logit("Calling select, active file descriptors (max %d): ", maxfds);
|
||||
for (nfds= 0; nfds <= maxfds; ++nfds)
|
||||
if ( FD_ISSET(nfds, &readfds) )
|
||||
dprintf("%d ", nfds);
|
||||
dprintf("\n");
|
||||
logit("%d ", nfds);
|
||||
logit("\n");
|
||||
}
|
||||
nfds = select(maxfds+1, (fd_set *) &readfds, (fd_set *) NULL,
|
||||
(fd_set *) NULL, (struct timeval *) NULL);
|
||||
if ( restart )
|
||||
{
|
||||
restart = 0;
|
||||
dprintf("\nReceived SIGHUP, reloading syslogd.\n");
|
||||
logit("\nReceived SIGHUP, reloading syslogd.\n");
|
||||
init();
|
||||
if (check_pid(PidFile)) {
|
||||
if (touch_pid(PidFile))
|
||||
@ -1172,24 +1169,24 @@ int main(argc, argv)
|
||||
continue;
|
||||
}
|
||||
if (nfds == 0) {
|
||||
dprintf("No select activity.\n");
|
||||
logit("No select activity.\n");
|
||||
continue;
|
||||
}
|
||||
if (nfds < 0) {
|
||||
if (errno != EINTR)
|
||||
logerror("select");
|
||||
dprintf("Select interrupted.\n");
|
||||
logit("Select interrupted.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( debugging_on )
|
||||
{
|
||||
dprintf("\nSuccessful select, descriptor count = %d, " \
|
||||
logit("\nSuccessful select, descriptor count = %d, " \
|
||||
"Activity on: ", nfds);
|
||||
for (nfds= 0; nfds <= maxfds; ++nfds)
|
||||
if ( FD_ISSET(nfds, &readfds) )
|
||||
dprintf("%d ", nfds);
|
||||
dprintf(("\n"));
|
||||
logit("%d ", nfds);
|
||||
logit("\n");
|
||||
}
|
||||
|
||||
#ifndef TESTING
|
||||
@ -1198,11 +1195,11 @@ int main(argc, argv)
|
||||
if ((fd = funix[i]) != -1 && FD_ISSET(fd, &readfds)) {
|
||||
memset(line, 0, sizeof(line));
|
||||
msglen = recv(fd, line, MAXLINE - 2, 0);
|
||||
dprintf("Message from UNIX socket: #%d\n", fd);
|
||||
logit("Message from UNIX socket: #%d\n", fd);
|
||||
if (msglen > 0)
|
||||
printchopped(LocalHostName, line, msglen + 2, fd);
|
||||
else if (msglen < 0 && errno != EINTR) {
|
||||
dprintf("UNIX socket error: %d = %s.\n", \
|
||||
logit("UNIX socket error: %d = %s.\n", \
|
||||
errno, strerror(errno));
|
||||
logerror("recvfrom UNIX");
|
||||
}
|
||||
@ -1220,7 +1217,7 @@ int main(argc, argv)
|
||||
(struct sockaddr *) &frominet, &len);
|
||||
if (Debug) {
|
||||
const char *addr = cvtaddr(&frominet, len);
|
||||
dprintf("Message from inetd socket: #%d, host: %s\n",
|
||||
logit("Message from inetd socket: #%d, host: %s\n",
|
||||
i+1, addr);
|
||||
}
|
||||
if (msglen > 0) {
|
||||
@ -1231,7 +1228,7 @@ int main(argc, argv)
|
||||
printchopped(from, line,
|
||||
msglen + 2, finet[i+1]);
|
||||
} else if (msglen < 0 && errno != EINTR && errno != EAGAIN) {
|
||||
dprintf("INET socket error: %d = %s.\n", \
|
||||
logit("INET socket error: %d = %s.\n", \
|
||||
errno, strerror(errno));
|
||||
logerror("recvfrom inet");
|
||||
/* should be harmless now that we set
|
||||
@ -1244,7 +1241,7 @@ int main(argc, argv)
|
||||
#endif
|
||||
#else
|
||||
if ( FD_ISSET(fileno(stdin), &readfds) ) {
|
||||
dprintf("Message from stdin.\n");
|
||||
logit("Message from stdin.\n");
|
||||
memset(line, '\0', sizeof(line));
|
||||
line[0] = '.';
|
||||
parts[fileno(stdin)] = (char *) 0;
|
||||
@ -1331,7 +1328,7 @@ static int create_unix_socket(const char *path)
|
||||
chmod(path, 0666) < 0) {
|
||||
(void) snprintf(line, sizeof(line), "cannot create %s", path);
|
||||
logerror(line);
|
||||
dprintf("cannot create %s (%d).\n", path, errno);
|
||||
logit("cannot create %s (%d).\n", path, errno);
|
||||
close(fd);
|
||||
#ifndef SYSV
|
||||
die(0);
|
||||
@ -1486,7 +1483,7 @@ crunch_list(list)
|
||||
#if 0
|
||||
m = 0;
|
||||
while (result[m])
|
||||
dprintf ("#%d: %s\n", m, result[m++]);
|
||||
logit("#%d: %s\n", m, result[m++]);
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
@ -1534,11 +1531,11 @@ void printchopped(hname, msg, len, fd)
|
||||
*end,
|
||||
tmpline[MAXLINE + 1];
|
||||
|
||||
dprintf("Message length: %d, File descriptor: %d.\n", len, fd);
|
||||
logit("Message length: %d, File descriptor: %d.\n", len, fd);
|
||||
tmpline[0] = '\0';
|
||||
if ( parts[fd] != (char *) 0 )
|
||||
{
|
||||
dprintf("Including part from messages.\n");
|
||||
logit("Including part from messages.\n");
|
||||
strcpy(tmpline, parts[fd]);
|
||||
free(parts[fd]);
|
||||
parts[fd] = (char *) 0;
|
||||
@ -1550,8 +1547,8 @@ void printchopped(hname, msg, len, fd)
|
||||
}
|
||||
else
|
||||
{
|
||||
dprintf("Previous: %s\n", tmpline);
|
||||
dprintf("Next: %s\n", msg);
|
||||
logit("Previous: %s\n", tmpline);
|
||||
logit("Next: %s\n", msg);
|
||||
strcat(tmpline, msg); /* length checked above */
|
||||
printline(hname, tmpline);
|
||||
if ( (strlen(msg) + 1) == len )
|
||||
@ -1573,7 +1570,7 @@ void printchopped(hname, msg, len, fd)
|
||||
else
|
||||
{
|
||||
strcpy(parts[fd], p);
|
||||
dprintf("Saving partial msg: %s\n", parts[fd]);
|
||||
logit("Saving partial msg: %s\n", parts[fd]);
|
||||
memset(p, '\0', ptlngth);
|
||||
}
|
||||
}
|
||||
@ -1731,7 +1728,7 @@ void logmsg(pri, msg, from, flags)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
dprintf("logmsg: %s, flags %x, from %s, msg %s\n", textpri(pri), flags, from, msg);
|
||||
logit("logmsg: %s, flags %x, from %s, msg %s\n", textpri(pri), flags, from, msg);
|
||||
|
||||
#ifdef __gnu_linux__
|
||||
sigemptyset(&mask);
|
||||
@ -1816,13 +1813,13 @@ void logmsg(pri, msg, from, flags)
|
||||
!strcmp(from, f->f_prevhost)) {
|
||||
(void) strncpy(f->f_lasttime, timestamp, 15);
|
||||
f->f_prevcount++;
|
||||
dprintf("msg repeated %d times, %ld sec of %d.\n",
|
||||
logit("msg repeated %d times, %ld sec of %d.\n",
|
||||
f->f_prevcount, now - f->f_time,
|
||||
repeatinterval[f->f_repeatcount]);
|
||||
|
||||
if (f->f_prevcount == 1 && DupesPending++ == 0) {
|
||||
int seconds;
|
||||
dprintf("setting alarm to flush duplicate messages\n");
|
||||
logit("setting alarm to flush duplicate messages\n");
|
||||
|
||||
seconds = alarm(0);
|
||||
MarkSeq += LastAlarm - seconds;
|
||||
@ -1848,7 +1845,7 @@ void logmsg(pri, msg, from, flags)
|
||||
fprintlog(f, (char *)from, 0, (char *)NULL);
|
||||
|
||||
if (--DupesPending == 0) {
|
||||
dprintf("unsetting duplicate message flush alarm\n");
|
||||
logit("unsetting duplicate message flush alarm\n");
|
||||
|
||||
MarkSeq += LastAlarm - alarm(0);
|
||||
LastAlarm = MarkInterval - MarkSeq;
|
||||
@ -1934,7 +1931,7 @@ void fprintlog(f, from, flags, msg)
|
||||
int err;
|
||||
#endif
|
||||
|
||||
dprintf("Called fprintlog, ");
|
||||
logit("Called fprintlog, ");
|
||||
|
||||
v->iov_base = f->f_lasttime;
|
||||
v->iov_len = 15;
|
||||
@ -1962,26 +1959,26 @@ void fprintlog(f, from, flags, msg)
|
||||
}
|
||||
v++;
|
||||
|
||||
dprintf("logging to %s", TypeNames[f->f_type]);
|
||||
logit("logging to %s", TypeNames[f->f_type]);
|
||||
|
||||
switch (f->f_type) {
|
||||
case F_UNUSED:
|
||||
f->f_time = now;
|
||||
dprintf("\n");
|
||||
logit("\n");
|
||||
break;
|
||||
|
||||
#ifdef SYSLOG_INET
|
||||
case F_FORW_SUSP:
|
||||
fwd_suspend = time((time_t *) 0) - f->f_time;
|
||||
if ( fwd_suspend >= INET_SUSPEND_TIME ) {
|
||||
dprintf("\nForwarding suspension over, " \
|
||||
logit("\nForwarding suspension over, " \
|
||||
"retrying FORW ");
|
||||
f->f_type = F_FORW;
|
||||
goto f_forw;
|
||||
}
|
||||
else {
|
||||
dprintf(" %s\n", f->f_un.f_forw.f_hname);
|
||||
dprintf("Forwarding suspension not over, time " \
|
||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
||||
logit("Forwarding suspension not over, time " \
|
||||
"left: %d.\n", INET_SUSPEND_TIME - \
|
||||
fwd_suspend);
|
||||
}
|
||||
@ -1996,25 +1993,25 @@ void fprintlog(f, from, flags, msg)
|
||||
* is started after syslogd.
|
||||
*/
|
||||
case F_FORW_UNKN:
|
||||
dprintf(" %s\n", f->f_un.f_forw.f_hname);
|
||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
||||
fwd_suspend = time((time_t *) 0) - f->f_time;
|
||||
if ( fwd_suspend >= INET_SUSPEND_TIME ) {
|
||||
dprintf("Forwarding suspension to unknown over, retrying\n");
|
||||
logit("Forwarding suspension to unknown over, retrying\n");
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
if ((err = getaddrinfo(f->f_un.f_forw.f_hname, "syslog", &hints, &ai))) {
|
||||
dprintf("Failure: %s\n", gai_strerror(err));
|
||||
dprintf("Retries: %d\n", f->f_prevcount);
|
||||
logit("Failure: %s\n", gai_strerror(err));
|
||||
logit("Retries: %d\n", f->f_prevcount);
|
||||
if ( --f->f_prevcount < 0 ) {
|
||||
dprintf("Giving up.\n");
|
||||
logit("Giving up.\n");
|
||||
f->f_type = F_UNUSED;
|
||||
}
|
||||
else
|
||||
dprintf("Left retries: %d\n", f->f_prevcount);
|
||||
logit("Left retries: %d\n", f->f_prevcount);
|
||||
}
|
||||
else {
|
||||
dprintf("%s found, resuming.\n", f->f_un.f_forw.f_hname);
|
||||
logit("%s found, resuming.\n", f->f_un.f_forw.f_hname);
|
||||
f->f_un.f_forw.f_addr = ai;
|
||||
f->f_prevcount = 0;
|
||||
f->f_type = F_FORW;
|
||||
@ -2022,7 +2019,7 @@ void fprintlog(f, from, flags, msg)
|
||||
}
|
||||
}
|
||||
else
|
||||
dprintf("Forwarding suspension not over, time " \
|
||||
logit("Forwarding suspension not over, time " \
|
||||
"left: %d\n", INET_SUSPEND_TIME - fwd_suspend);
|
||||
break;
|
||||
|
||||
@ -2033,9 +2030,9 @@ void fprintlog(f, from, flags, msg)
|
||||
* sent the message, we don't send it anyway) -Joey
|
||||
*/
|
||||
f_forw:
|
||||
dprintf(" %s\n", f->f_un.f_forw.f_hname);
|
||||
logit(" %s\n", f->f_un.f_forw.f_hname);
|
||||
if ( strcmp(from, LocalHostName) && NoHops )
|
||||
dprintf("Not sending message to remote.\n");
|
||||
logit("Not sending message to remote.\n");
|
||||
else if (finet) {
|
||||
int i;
|
||||
f->f_time = now;
|
||||
@ -2060,7 +2057,7 @@ void fprintlog(f, from, flags, msg)
|
||||
break;
|
||||
}
|
||||
if (err != -1) {
|
||||
dprintf("INET sendto error: %d = %s.\n",
|
||||
logit("INET sendto error: %d = %s.\n",
|
||||
err, strerror(err));
|
||||
f->f_type = F_FORW_SUSP;
|
||||
errno = err;
|
||||
@ -2077,7 +2074,7 @@ void fprintlog(f, from, flags, msg)
|
||||
#else
|
||||
if (flags & IGN_CONS) {
|
||||
#endif
|
||||
dprintf(" (ignored).\n");
|
||||
logit(" (ignored).\n");
|
||||
break;
|
||||
}
|
||||
/* FALLTHROUGH */
|
||||
@ -2086,7 +2083,7 @@ void fprintlog(f, from, flags, msg)
|
||||
case F_FILE:
|
||||
case F_PIPE:
|
||||
f->f_time = now;
|
||||
dprintf(" %s\n", f->f_un.f_fname);
|
||||
logit(" %s\n", f->f_un.f_fname);
|
||||
if (f->f_type == F_TTY || f->f_type == F_CONSOLE) {
|
||||
v->iov_base = "\r\n";
|
||||
v->iov_len = 2;
|
||||
@ -2154,7 +2151,7 @@ void fprintlog(f, from, flags, msg)
|
||||
case F_USERS:
|
||||
case F_WALL:
|
||||
f->f_time = now;
|
||||
dprintf("\n");
|
||||
logit("\n");
|
||||
v->iov_base = "\r\n";
|
||||
v->iov_len = 2;
|
||||
wallmsg(f, iov);
|
||||
@ -2324,10 +2321,10 @@ const char *cvthname(struct sockaddr_storage *f, int len)
|
||||
|
||||
if ((error = getnameinfo((struct sockaddr *) f, len,
|
||||
hname, NI_MAXHOST, NULL, 0, NI_NAMEREQD))) {
|
||||
dprintf("Host name for your address (%s) unknown: %s\n", gai_strerror(error));
|
||||
logit("Host name for your address (%s) unknown: %s\n", gai_strerror(error));
|
||||
if ((error = getnameinfo((struct sockaddr *) f, len,
|
||||
hname, NI_MAXHOST, NULL, 0, NI_NUMERICHOST))) {
|
||||
dprintf("Malformed from address: %s\n", gai_strerror(error));
|
||||
logit("Malformed from address: %s\n", gai_strerror(error));
|
||||
return "???";
|
||||
}
|
||||
return hname;
|
||||
@ -2397,7 +2394,7 @@ void domark()
|
||||
for (f = Files; f; f = f->f_next) {
|
||||
#endif
|
||||
if (f->f_prevcount && now >= REPEATTIME(f)) {
|
||||
dprintf("flush %s: repeated %d times, %d sec.\n",
|
||||
logit("flush %s: repeated %d times, %d sec.\n",
|
||||
TypeNames[f->f_type], f->f_prevcount,
|
||||
repeatinterval[f->f_repeatcount]);
|
||||
fprintlog(f, LocalHostName, 0, (char *)NULL);
|
||||
@ -2417,7 +2414,7 @@ void domark()
|
||||
void debug_switch()
|
||||
|
||||
{
|
||||
dprintf("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false");
|
||||
logit("Switching debugging_on to %s\n", (debugging_on == 0) ? "true" : "false");
|
||||
debugging_on = (debugging_on == 0) ? 1 : 0;
|
||||
signal(SIGUSR1, debug_switch);
|
||||
}
|
||||
@ -2430,7 +2427,7 @@ void logerror(const char *type)
|
||||
{
|
||||
char buf[100];
|
||||
|
||||
dprintf("Called logerr, msg: %s\n", type);
|
||||
logit("Called logerr, msg: %s\n", type);
|
||||
|
||||
if (errno == 0)
|
||||
(void) snprintf(buf, sizeof(buf), "syslogd: %s", type);
|
||||
@ -2464,7 +2461,7 @@ void die(sig)
|
||||
|
||||
Initialized = was_initialized;
|
||||
if (sig) {
|
||||
dprintf("syslogd: exiting on signal %d\n", sig);
|
||||
logit("syslogd: exiting on signal %d\n", sig);
|
||||
(void) snprintf(buf, sizeof(buf), "exiting on signal %d", sig);
|
||||
errno = 0;
|
||||
logmsg(LOG_SYSLOG|LOG_INFO, buf, LocalHostName, ADDDATE);
|
||||
@ -2529,11 +2526,11 @@ void init()
|
||||
/*
|
||||
* Close all open log files and free log descriptor array.
|
||||
*/
|
||||
dprintf("Called init.\n");
|
||||
logit("Called init.\n");
|
||||
Initialized = 0;
|
||||
if ( nlogs > -1 )
|
||||
{
|
||||
dprintf("Initializing log structures.\n");
|
||||
logit("Initializing log structures.\n");
|
||||
|
||||
for (lognum = 0; lognum <= nlogs; lognum++ ) {
|
||||
f = &Files[lognum];
|
||||
@ -2612,7 +2609,7 @@ void init()
|
||||
|
||||
/* open the configuration file */
|
||||
if ((cf = fopen(ConfFile, "r")) == NULL) {
|
||||
dprintf("cannot open %s.\n", ConfFile);
|
||||
logit("cannot open %s.\n", ConfFile);
|
||||
#ifdef SYSV
|
||||
allocate_log();
|
||||
f = &Files[lognum++];
|
||||
@ -2694,7 +2691,7 @@ void init()
|
||||
*/
|
||||
continue;
|
||||
if ((funix[i] = create_unix_socket(funixn[i])) != -1)
|
||||
dprintf("Opened UNIX socket `%s'.\n", funixn[i]);
|
||||
logit("Opened UNIX socket `%s'.\n", funixn[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -2704,7 +2701,7 @@ void init()
|
||||
finet = create_inet_sockets();
|
||||
if (finet) {
|
||||
InetInuse = 1;
|
||||
dprintf("Opened syslog UDP port.\n");
|
||||
logit("Opened syslog UDP port.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2773,7 +2770,7 @@ void init()
|
||||
": restart." , LocalHostName, ADDDATE);
|
||||
|
||||
(void) signal(SIGHUP, sighup_handler);
|
||||
dprintf("syslogd: restarted.\n");
|
||||
logit("syslogd: restarted.\n");
|
||||
}
|
||||
#if FALSE
|
||||
}}} /* balance parentheses for emacs */
|
||||
@ -2801,7 +2798,7 @@ void cfline(line, f)
|
||||
char buf[MAXLINE];
|
||||
char xbuf[200];
|
||||
|
||||
dprintf("cfline(%s)\n", line);
|
||||
logit("cfline(%s)\n", line);
|
||||
|
||||
errno = 0; /* keep strerror() stuff out of logerror messages */
|
||||
|
||||
@ -2947,13 +2944,13 @@ void cfline(line, f)
|
||||
} else
|
||||
syncfile = 1;
|
||||
|
||||
dprintf("leading char in action: %c\n", *p);
|
||||
logit("leading char in action: %c\n", *p);
|
||||
switch (*p)
|
||||
{
|
||||
case '@':
|
||||
#ifdef SYSLOG_INET
|
||||
(void) strcpy(f->f_un.f_forw.f_hname, ++p);
|
||||
dprintf("forwarding host: %s\n", p); /*ASP*/
|
||||
logit("forwarding host: %s\n", p); /*ASP*/
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_family = family;
|
||||
hints.ai_socktype = SOCK_DGRAM;
|
||||
@ -2978,7 +2975,7 @@ void cfline(line, f)
|
||||
case '|':
|
||||
case '/':
|
||||
(void) strcpy(f->f_un.f_fname, p);
|
||||
dprintf ("filename: %s\n", p); /*ASP*/
|
||||
logit("filename: %s\n", p); /*ASP*/
|
||||
if (syncfile)
|
||||
f->f_flags |= SYNC_FILE;
|
||||
if ( *p == '|' ) {
|
||||
@ -2992,7 +2989,7 @@ void cfline(line, f)
|
||||
|
||||
if ( f->f_file < 0 ){
|
||||
f->f_file = -1;
|
||||
dprintf("Error opening log file: %s\n", p);
|
||||
logit("Error opening log file: %s\n", p);
|
||||
logerror(p);
|
||||
break;
|
||||
}
|
||||
@ -3005,12 +3002,12 @@ void cfline(line, f)
|
||||
break;
|
||||
|
||||
case '*':
|
||||
dprintf ("write-all\n");
|
||||
logit("write-all\n");
|
||||
f->f_type = F_WALL;
|
||||
break;
|
||||
|
||||
default:
|
||||
dprintf ("users: %s\n", p); /* ASP */
|
||||
logit("users: %s\n", p); /* ASP */
|
||||
for (i = 0; i < MAXUNAMES && *p; i++) {
|
||||
for (q = p; *q && *q != ','; )
|
||||
q++;
|
||||
@ -3042,10 +3039,10 @@ int decode(name, codetab)
|
||||
register char *p;
|
||||
char buf[80];
|
||||
|
||||
dprintf ("symbolic name: %s", name);
|
||||
logit("symbolic name: %s", name);
|
||||
if (isdigit(*name))
|
||||
{
|
||||
dprintf ("\n");
|
||||
logit("\n");
|
||||
return (atoi(name));
|
||||
}
|
||||
(void) strncpy(buf, name, 79);
|
||||
@ -3055,13 +3052,13 @@ int decode(name, codetab)
|
||||
for (c = codetab; c->c_name; c++)
|
||||
if (!strcmp(buf, c->c_name))
|
||||
{
|
||||
dprintf (" ==> %d\n", c->c_val);
|
||||
logit(" ==> %d\n", c->c_val);
|
||||
return (c->c_val);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
static void dprintf(char *fmt, ...)
|
||||
static void logit(char *fmt, ...)
|
||||
|
||||
{
|
||||
va_list ap;
|
||||
@ -3085,7 +3082,7 @@ static void dprintf(char *fmt, ...)
|
||||
static void allocate_log()
|
||||
|
||||
{
|
||||
dprintf("Called allocate_log, nlogs = %d.\n", nlogs);
|
||||
logit("Called allocate_log, nlogs = %d.\n", nlogs);
|
||||
|
||||
/*
|
||||
* Decide whether the array needs to be initialized or needs to
|
||||
@ -3096,7 +3093,7 @@ static void allocate_log()
|
||||
Files = (struct filed *) malloc(sizeof(struct filed));
|
||||
if ( Files == (void *) 0 )
|
||||
{
|
||||
dprintf("Cannot initialize log structure.");
|
||||
logit("Cannot initialize log structure.");
|
||||
logerror("Cannot initialize log structure.");
|
||||
return;
|
||||
}
|
||||
@ -3108,7 +3105,7 @@ static void allocate_log()
|
||||
sizeof(struct filed));
|
||||
if ( Files == (struct filed *) 0 )
|
||||
{
|
||||
dprintf("Cannot grow log structure.");
|
||||
logit("Cannot grow log structure.");
|
||||
logerror("Cannot grow log structure.");
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user