head 1.3; access; symbols; locks alexis:1.3; strict; comment @ * @; 1.3 date 97.01.31.14.43.34; author alexis; state Exp; branches; next 1.2; 1.2 date 97.01.31.10.22.48; author alexis; state Exp; branches; next 1.1; 1.1 date 97.01.22.10.34.45; author alexis; state Exp; branches; next ; desc @@ 1.3 log @MILEPOST - MAY NOT WORK @ text @#include /* for NULL and *printf*() */ #include /* for va_*() */ #include /* for strrchr() */ #include "pppld_utils.h" static char *rcs_id = "$Id$"; char *progname; unsigned long debug_level = DBG_WARNING|DBG_ERROR; FILE *debug_handle = stderr; char *basename( char *cmdcp) { char *bncp; return(((bncp=strrchr(cmdcp, '/')) == NULL) ? cmdcp : bncp+1); } void internal( char *fmt, ...) { va_list args; va_start(args, fmt); fprintf(stderr, "%s: INTERNAL ERROR: ", progname); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); exit(1); } int error( char *fmt, ...) { va_list args; if (debug_level & DBG_ERROR) { va_start(args, fmt); fprintf(stderr, "%s: ERROR: ", progname); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); } exit(1); } void warning( char *fmt, ...) { va_list args; if (debug_level & DBG_WARNING) { va_start(args, fmt); fprintf(stderr, "%s: WARNING: ", progname); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); } } void info( char *fmt, ...) { va_list args; if (debug_level & DBG_INFO) { va_start(args, fmt); fprintf(debug_handle, "%s: INFO: ", progname); vfprintf(debug_handle, fmt, args); fprintf(debug_handle, "\n"); va_end(args); } } void debug( int level, char *fmt, ...) { va_list args; if (level & debug_level) { va_start(args, fmt); fprintf(debug_handle, "%s: DEBUG[%02x]: ", progname, level); vfprintf(debug_handle, fmt, args); fprintf(debug_handle, "\n"); va_end(args); } } /* * A string copy function. It can cope with 'left-shift' overlaps, but * not 'right-shifts'. */ char *strmove( char *dst, char *src) { while (*dst++ = *src++) ; } @ 1.2 log @WORKING MILESTONE @ text @d7 2 d10 1 a10 1 int debug_level = 2; d41 7 a47 2 /* if (1 > debug_level) return; */ a48 5 va_start(args, fmt); fprintf(stderr, "%s: ERROR: ", progname); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); d58 7 a64 8 /* if (2 > debug_level) return; */ va_start(args, fmt); fprintf(stderr, "%s: WARNING: ", progname); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); d73 7 a79 8 /* if (3 > debug_level) return; */ va_start(args, fmt); fprintf(debug_handle, "%s: INFO: ", progname); vfprintf(debug_handle, fmt, args); fprintf(debug_handle, "\n"); va_end(args); d89 8 a96 2 if (!(level & debug_level)) return; d98 4 a101 6 va_start(args, fmt); fprintf(debug_handle, "%s: DEBUG[%02x]: ", progname, level); vfprintf(debug_handle, fmt, args); fprintf(debug_handle, "\n"); va_end(args); } @ 1.1 log @Initial revision @ text @d33 1 a33 1 void error( d97 8 @