|
|
1.1 root 1: #include <stdarg.h>
2: #include <stdio.h>
3: #include <time.h>
4: #include <unistd.h>
5: #include "dist.h"
6:
7: char *prog;
8:
9: void
10: eprintf(char *fmt, ...)
11: {
12: time_t now;
13: char mesg[MAXLINE];
14: va_list ap;
15: static int fd = -1;
16:
17: time(&now);
18: sprintf(mesg, "%s[%d %.24s]: ", prog, getpid(), ctime(&now));
19: va_start(ap, fmt);
20: vsprintf(mesg + strlen(mesg), fmt, ap);
21: strcat(mesg, "\n");
22: write(2, mesg, strlen(mesg));
23: if (fd < 0)
24: fd = open(SDIR "/log", 1);
25: lseek(fd, 0L, 2); /* we really want O_APPEND mode, but... */
26: write(fd, mesg, strlen(mesg));
27: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.