|
|
1.1 ! root 1: #include <stdio.h> ! 2: #include <ctype.h> ! 3: #include "sys.h" ! 4: ! 5: struct loglevellookup { ! 6: char *name; ! 7: int level; ! 8: } loglevellookup[] = { ! 9: { "emerg", LOG_EMERG }, ! 10: { "alert", LOG_ALERT }, ! 11: { "crit", LOG_CRIT }, ! 12: { "err", LOG_ERR }, ! 13: { "warning", LOG_WARNING }, ! 14: { "notice", LOG_NOTICE }, ! 15: { "info", LOG_INFO }, ! 16: { "debug", LOG_DEBUG }, ! 17: { NULL, -1 }, ! 18: }; ! 19: ! 20: ! 21: extern int debug; ! 22: ! 23: /* ! 24: * This is a poor substitute for varargs, but ! 25: * syslog doesn't have the equivalent of vfprintf, so this ! 26: * will have to do. ! 27: */ ! 28: Syslog(level, fmt, p0, p1, p2, p3, p4) ! 29: int level; ! 30: char *fmt; ! 31: { ! 32: syslog(level, fmt, p0, p1, p2, p3, p4); ! 33: if (debug) ! 34: fprintf(stderr, fmt, p0, p1, p2, p3, p4); ! 35: } ! 36: ! 37: Openlog(label, flags, log) ! 38: char *label; ! 39: int flags; ! 40: int log; ! 41: { ! 42: openlog(label, flags, log); ! 43: } ! 44: ! 45: setloglevel(arg) ! 46: char *arg; ! 47: { ! 48: int newlevel = -1, i; ! 49: char *cp; ! 50: ! 51: for (cp=arg; *cp; cp++) ! 52: if (isupper(*cp)) ! 53: *cp = tolower(*cp); ! 54: ! 55: if (isdigit(*arg)) { ! 56: newlevel = atoi(arg); ! 57: } else { ! 58: for (i=0; loglevellookup[i].name; i++) ! 59: if (strcmp(loglevellookup[i].name, arg) == 0) { ! 60: newlevel = loglevellookup[i].level; ! 61: break; ! 62: } ! 63: } ! 64: if (newlevel < 0) ! 65: Syslog(LOG_WARNING, "Illegal log parameter - %s\n", arg); ! 66: else ! 67: setlogmask(LOG_UPTO(newlevel)); ! 68: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.