projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
install correct aliases file
[unix-history]
/
usr
/
src
/
usr.sbin
/
syslogd
/
syslogd.c
diff --git
a/usr/src/usr.sbin/syslogd/syslogd.c
b/usr/src/usr.sbin/syslogd/syslogd.c
index
ff3112b
..
5211cfd
100644
(file)
--- a/
usr/src/usr.sbin/syslogd/syslogd.c
+++ b/
usr/src/usr.sbin/syslogd/syslogd.c
@@
-22,7
+22,7
@@
char copyright[] =
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)syslogd.c 5.2
4
(Berkeley) %G%";
+static char sccsid[] = "@(#)syslogd.c 5.2
7
(Berkeley) %G%";
#endif /* not lint */
/*
#endif /* not lint */
/*
@@
-184,37
+184,31
@@
main(argc, argv)
struct sockaddr_un sunx, fromunix;
struct sockaddr_in sin, frominet;
FILE *fp;
struct sockaddr_un sunx, fromunix;
struct sockaddr_in sin, frominet;
FILE *fp;
+ int ch;
char line[MSG_BSIZE + 1];
char line[MSG_BSIZE + 1];
- extern int die(), domark(), reapchild();
-
- while (--argc > 0) {
- p = *++argv;
- if (p[0] != '-')
- usage();
- switch (p[1]) {
- case 'f': /* configuration file */
- if (p[2] != '\0')
- ConfFile = &p[2];
- break;
+ extern int optind, die(), domark(), reapchild();
+ extern char *optarg;
+ while ((ch = getopt(argc, argv, "df:m:p:")) != EOF)
+ switch((char)ch) {
case 'd': /* debug */
Debug++;
break;
case 'd': /* debug */
Debug++;
break;
-
- case 'p': /* path */
- if (p[2] != '\0')
- LogName = &p[2];
+ case 'f': /* configuration file */
+ ConfFile = optarg;
break;
break;
-
case 'm': /* mark interval */
case 'm': /* mark interval */
- if (p[2] != '\0')
- MarkInterval = atoi(&p[2]) * 60;
+ MarkInterval = atoi(optarg) * 60;
break;
break;
-
+ case 'p': /* path */
+ LogName = optarg;
+ break;
+ case '?':
default:
usage();
}
default:
usage();
}
- }
+ if (argc -= optind)
+ usage();
if (!Debug) {
if (fork())
if (!Debug) {
if (fork())
@@
-348,7
+342,7
@@
main(argc, argv)
usage()
{
usage()
{
- fprintf(stderr, "usage: syslogd [-d] [-m
markinterval] [-ppath] [-f
conffile]\n");
+ fprintf(stderr, "usage: syslogd [-d] [-m
markinterval] [-p path] [-f
conffile]\n");
exit(1);
}
exit(1);
}
@@
-398,14
+392,15
@@
printline(hname, msg)
q = line;
q = line;
- while ((c = *p++ & 0177) != '\0' && c != '\n' &&
- q < &line[sizeof(line) - 1]) {
- if (iscntrl(c)) {
+ while ((c = *p++ & 0177) != '\0' &&
+ q < &line[sizeof(line) - 1])
+ if (c == '\n')
+ *q++ = ' ';
+ else if (iscntrl(c)) {
*q++ = '^';
*q++ = c ^ 0100;
} else
*q++ = c;
*q++ = '^';
*q++ = c ^ 0100;
} else
*q++ = c;
- }
*q = '\0';
logmsg(pri, line, hname, 0);
*q = '\0';
logmsg(pri, line, hname, 0);
@@
-502,7
+497,7
@@
logmsg(pri, msg, from, flags)
if (f->f_file >= 0) {
untty();
if (f->f_file >= 0) {
untty();
- fprintlog(f, flags,
(char *)NULL
);
+ fprintlog(f, flags,
msg
);
(void) close(f->f_file);
}
(void) sigsetmask(omask);
(void) close(f->f_file);
}
(void) sigsetmask(omask);
@@
-528,7
+523,7
@@
logmsg(pri, msg, from, flags)
!strcmp(from, f->f_prevhost)) {
(void) strncpy(f->f_lasttime, timestamp, 15);
f->f_prevcount++;
!strcmp(from, f->f_prevhost)) {
(void) strncpy(f->f_lasttime, timestamp, 15);
f->f_prevcount++;
- dprintf("msg repeated %d times, %d sec of %d\n",
+ dprintf("msg repeated %d times, %
l
d sec of %d\n",
f->f_prevcount, now - f->f_time,
repeatinterval[f->f_repeatcount]);
/*
f->f_prevcount, now - f->f_time,
repeatinterval[f->f_repeatcount]);
/*
@@
-1082,8
+1077,6
@@
cfline(line, f)
/* scan facilities */
while (*p && !index("\t.;", *p)) {
/* scan facilities */
while (*p && !index("\t.;", *p)) {
- int i;
-
for (bp = buf; *p && !index("\t,;.", *p); )
*bp++ = *p++;
*bp = '\0';
for (bp = buf; *p && !index("\t,;.", *p); )
*bp++ = *p++;
*bp = '\0';
@@
-1120,11
+1113,11
@@
cfline(line, f)
(void) strcpy(f->f_un.f_forw.f_hname, ++p);
hp = gethostbyname(p);
if (hp == NULL) {
(void) strcpy(f->f_un.f_forw.f_hname, ++p);
hp = gethostbyname(p);
if (hp == NULL) {
- char buf[100];
+ extern int h_errno, h_nerr;
+ extern char **h_errlist;
- (void) sprintf(buf, "unknown host %s", p);
- errno = 0;
- logerror(buf);
+ logerror((u_int)h_errno < h_nerr ?
+ h_errlist[h_errno] : "Unknown error");
break;
}
bzero((char *) &f->f_un.f_forw.f_addr,
break;
}
bzero((char *) &f->f_un.f_forw.f_addr,