home *** CD-ROM | disk | FTP | other *** search
- /*
- * syslog, openlog, closelog - hacked from Unix - use dprintf
- * perror - hacked from Unix - uses dprintf
- */
- extern int errno;
-
- #ifdef DPRINTF
- /*
- * normally supplied by caller - there's too many places to do I/O on a mac
- */
- dprintf(fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12)
- char *fmt;
- char *a1,*a2,*a3,*a4,*a5,*a6,*a7,*a8,*a9,*a10,*a11,*a12;
- {
- (void) fprintf(stderr,fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12);
- }
- #endif DPRINTF
-
- #define MAXLINE 1000
-
- static int LogMask = LOG_DEBUG;
- static char LogTag[100] = "";
-
- openlog(ident, logstat) char *ident; int logstat;
- {
- if (logstat >= LOG_ALERT && logstat <= LOG_DEBUG)
- LogMask = logstat;
-
- if (ident)
- strcpy(LogTag,ident);
- }
-
- closelog()
- {
- }
-
- syslog(pri, fmt, p0,p1,p2,p3,p4,p5,p6,p7,p8,p9) int pri; char *fmt;
- {
- register char *b, *f = fmt, c;
- char buf[MAXLINE+50];
- char oline[MAXLINE];
-
- if (pri > LogMask)
- return;
-
- b = buf;
- while ((c = *f++) != '\0' && b < buf + MAXLINE)
- {
- if (c != '%')
- {
- *b++ = c;
- continue;
- }
- c = *f++;
- if (c != 'm')
- {
- *b++ = '%', *b++ = c;
- continue;
- }
- if ((unsigned)errno > sys_nerr)
- sprintf(b, "error %d", errno);
- else
- sprintf(b, "%s", sys_errlist[errno]);
- b += strlen(b);
- }
- if (b[-1] != '\n')
- *b++ = '\n';
- *b = '\0';
-
- sprintf(oline, buf, p0, p1, p2, p3, p4, p5, p6, p7, p8, p9);
-
- dprintf("%s: %s\n", LogTag,oline);
- }
-
-