summary |
tags |
clone url |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
137a7cf)
SCCS-vsn: lib/libc/gen/syslog.c 5.19
*/
#if defined(LIBC_SCCS) && !defined(lint)
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)syslog.c 5.18 (Berkeley) %G%";
+static char sccsid[] = "@(#)syslog.c 5.19 (Berkeley) %G%";
#endif /* LIBC_SCCS and not lint */
/*
#endif /* LIBC_SCCS and not lint */
/*
vsyslog(pri, fmt, ap)
int pri;
vsyslog(pri, fmt, ap)
int pri;
register int cnt;
register char *p;
time_t now, time();
register int cnt;
register char *p;
time_t now, time();
- int pid;
- char tbuf[2048], *ctime();
+ int pid, saved_errno;
+ char tbuf[2048], fmt_cpy[1024], *ctime();
+
+ saved_errno = errno;
/* see if we should just throw out this message */
if ((u_int)LOG_FAC(pri) >= LOG_NFACILITIES ||
/* see if we should just throw out this message */
if ((u_int)LOG_FAC(pri) >= LOG_NFACILITIES ||
- (void)vsprintf(p, fmt, ap);
+ /* substitute error message for %m */
+ {
+ register char ch, *t1, *t2;
+ char *strerror();
+
+ for (t1 = fmt_cpy; ch = *fmt; ++fmt)
+ if (ch == '%' && fmt[1] == 'm') {
+ ++fmt;
+ for (t2 = strerror(saved_errno);
+ *t1 = *t2++; ++t1);
+ }
+ else
+ *t1++ = ch;
+ }
+
+ (void)vsprintf(p, fmt_cpy, ap);
/* output the message to the local logger */
if (send(LogFile, tbuf, cnt = strlen(tbuf), 0) >= 0 ||
/* output the message to the local logger */
if (send(LogFile, tbuf, cnt = strlen(tbuf), 0) >= 0 ||