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:
Joachim Nilsson 2018-08-05 16:39:31 +02:00
parent ea586826be
commit 9f21a8a0f5

View File

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