1: #if !defined(lint) && defined(DOSCCS) 2: static char *sccsid = "@(#)fakesyslog.c 1.3.1 (2.11BSD) 1996/3/21"; 3: #endif 4: 5: /* 6: * Fake syslog routines for systems that don't have syslog. 7: * Taken from an idea by Paul McKenny, <mckenny@sri-unix.arpa>. 8: * (Unfortunately, Paul, I can't distribute the real syslog code 9: * as you suggested ... sigh.) 10: * 11: * Warning: this file contains joe code that may offend you. 12: */ 13: 14: #include <stdio.h> 15: #include <string.h> 16: #include <errno.h> 17: 18: #include "../common/conf.h" 19: 20: #ifdef FAKESYSLOG 21: 22: static FILE *logfp; 23: 24: char *ctime(); 25: 26: openlog() 27: { 28: logfp = fopen(FAKESYSLOG, "a"); 29: } 30: 31: 32: syslog(pri, msg, x1, x2, x3, x4, x5, x6) 33: int pri; 34: char *msg, *x1, *x2, *x3, *x4, *x5, *x6; 35: { 36: char buf[1024]; 37: char *cp, *bp; 38: long clock; 39: static int failed = 0; 40: 41: if (failed) 42: return; 43: 44: if (logfp == NULL) { 45: openlog(); 46: if (logfp == NULL) { 47: failed = 1; 48: return; 49: } 50: } 51: 52: (void) time(&clock); 53: (void) strcpy(buf, ctime(&clock)); 54: 55: bp = buf + strlen(buf)-1; 56: *bp++ = ' '; 57: *bp = '\0'; 58: for (cp = msg; *cp; cp++) { 59: if (*cp == '%' && cp[1] == 'm') { 60: *bp = '\0'; 61: (void) strcat(bp, strerror(errno)); 62: bp = buf + strlen(buf); 63: cp++; 64: } else { 65: *bp++ = *cp; 66: } 67: } 68: *bp = '\0'; 69: /* Ah, the semantic security of C ... */ 70: if (bp[-1] != '\n') 71: (void) strcat(bp, "\n"); 72: 73: fprintf(logfp, buf, x1, x2, x3, x4, x5, x6); 74: } 75: 76: #endif