#! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh 'Makefile' <<'END_OF_FILE' X## syslog routine makefile XCFLAGS=-O Xall: syslog.c X $(CC) $(CFLAGS) -c syslog.c X ar c libsyslog.a syslog.o X @rm -f syslog.o X Xinstall: all X @echo install according to local conventions. END_OF_FILE if test 185 -ne `wc -c <'Makefile'`; then echo shar: \"'Makefile'\" unpacked with wrong size! fi # end of 'Makefile' fi if test -f 'syslog.3' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'syslog.3'\" else echo shar: Extracting \"'syslog.3'\" \(1246 characters\) sed "s/^X//" >'syslog.3' <<'END_OF_FILE' X.TH SYSLOG 3 LOCAL X.SH NAME Xsyslog, openlog, closelog \- logging routines X.SH SYNOPSIS X.nf X#include X.sp Xopenlog(ident, arg1, arg2) X char *ident; X int arg1; X int arg2; X.sp Xsyslog(priority, message, parameters ... ) X char *message; X.sp Xcloselog() X.fi X.SH DESCRIPTION X.I Syslog Xis intended to provide a standard error and general notification interface. XThis version sends errors to the standard error; versions on other system Xuse IPC mechanisms to talk to a logging daemon. X.PP XEach log message is tagged with a X.IR priority , Xdefined in the header file. XVarious filtering mechanisms are used on other systems to direct the Xdifferent levels to different destinations. X.PP XThe message looks like a X.IR printf (3) Xstring except that X.B %m Xis replaced by the current error message (collected from X.IR errno ). XA newline will be output if the the format string doesn't end with one. X.PP XThe X.I openlog Xroutine can be called to initialize the logger. XThis routine takes three parameters. XThe first is a text string to be output before each message; it is Xconventionally the program name. XThe other two parameters are currently ignored, and should be supplied Xfor compatibility. X.PP XThe X.I closelog Xroutine can be used to close the log file. END_OF_FILE if test 1246 -ne `wc -c <'syslog.3'`; then echo shar: \"'syslog.3'\" unpacked with wrong size! fi # end of 'syslog.3' fi if test -f 'syslog.c' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'syslog.c'\" else echo shar: Extracting \"'syslog.c'\" \(2405 characters\) sed "s/^X//" >'syslog.c' <<'END_OF_FILE' X/* X * syslog.c X * X * Dummy version of syslog routines that use stdio to stderr. X * Designed for debugging during development. X * X * Arnold Robbins X * Emory University Computing Center X * 7/87 X */ X Xextern int errno; Xextern int sys_nerr; Xextern char *sys_errlist[]; X X/* X * Surround each header with an ifdef so that X * the whole file may be included if desired. X */ X X#ifndef NULL X#include X#endif X X#ifndef LOG_EMERG X#include X#endif X X#ifndef va_dcl X#include X#endif X Xstatic char *str; X Xint openlog (s, i, j) Xchar *s; Xint i, j; X{ X str = s; X#ifdef lint X i = i; X j = j; X#endif X return(0); X} X Xcloselog () { } X Xsetlogmask (mask) Xint mask; X{ X#ifdef lint X mask = mask; X#endif X} X Xsyslog (va_alist) Xva_dcl X{ X va_list ap; X char *format, c, form[30]; X int i, j; X double d; X char *cp, *x; X int err = errno, pri; X static char *level[] = { X "emergency", X "alert", X "critical", X "error", X "warning", X "notice", X "info", X "debug" X }; X X va_start(ap); X pri = va_arg(ap, int); X X x = "unknown"; X if (pri >= LOG_EMERG && pri <= LOG_DEBUG) X x = level[pri]; X X fprintf (stderr, "%s: %s: ", str, x); X X format = va_arg(ap, char *); X while (c = *format++) X { X int done; X X if (c != '%') X { X putc (c, stderr); X continue; X } X j = 0; X form[j++] = c; X done = 0; X while (! done) X { X c = *format++; X switch (c) { X default: /* XXX */ X case 'o': case 'c': case 'd': case 's': case 'u': X case 'e': case 'E': case 'f': case 'g': case 'G': X case 'x': case 'X': X done++; X /* fall thru */ X case ' ': case '+': case '-': case '.': case '#': X case '0': case '1': case '2': case '3': case '4': X case '5': case '6': case '7': case '8': case '9': X case 'l': X form[j++] = c; X break; X case 'm': X errno = err; X if (errno < sys_nerr) X fputs (sys_errlist[errno], stderr); X else X fprintf (stderr, "error %d", errno); X goto out; X case '%': X putc ('%', stderr); X goto out; X } X } X form[j] = '\0'; X switch (form[j-1]) { X case 'x': X case 'X': X case 'o': X case 'c': X case 'd': X case 'u': X i = va_arg(ap, int); X fprintf (stderr, form, i); X break; X case 'e': X case 'E': X case 'f': X case 'g': X case 'G': X d = va_arg(ap, double); X fprintf (stderr, form, d); X break; X case 's': X cp = va_arg(ap, char *); X fprintf (stderr, form, cp); X break; X } X out: ; X } X if (format[-1] != '\n') X putc ('\n', stderr); X X va_end(ap); X} END_OF_FILE if test 2405 -ne `wc -c <'syslog.c'`; then echo shar: \"'syslog.c'\" unpacked with wrong size! fi # end of 'syslog.c' fi if test -f 'syslog.h' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'syslog.h'\" else echo shar: Extracting \"'syslog.h'\" \(673 characters\) sed "s/^X//" >'syslog.h' <<'END_OF_FILE' X/* X** SYSLOG HEADER FILE X*/ X X/* X** These are #define's for the various levels, and representative X** messages that might indicate their class. X*/ X#define LOG_ALERT 1 /* The disk is on fire */ X#define LOG_SALERT 2 /* /bin/rmail is filling up /usr/spool */ X#define LOG_EMERG 3 /* ??Like SALERT, but send to a file?? */ X#define LOG_ERR 4 /* Network was unreachable, is back */ X#define LOG_CRIT 5 /* Can't read /usr/lib/news/history */ X#define LOG_WARNING 6 /* Rnews just dropped an article */ X#define LOG_NOTICE 7 /* /usr/spool/news is filling up */ X#define LOG_INFO 8 /* Have 100 new articles in talk.foo */ X#define LOG_DEBUG 9 /* Expired article <34@site.uucp> */ END_OF_FILE if test 669 -ne `wc -c <'syslog.h'`; then echo shar: \"'syslog.h'\" unpacked with wrong size! fi # end of 'syslog.h' fi echo shar: End of shell archive. exit 0 -- Rich $alz Cronus Project, BBN Labs rsalz@bbn.com Moderator, comp.sources.unix sources@uunet.uu.net