[Dhcp-agent-commits] dhcp-agent dhcp-exception.c,NONE,1.1 dhcp-exception.h,NONE,1.1 Makefile.am,1.24
Status: Alpha
Brought to you by:
actmodern
From: <act...@us...> - 2002-06-22 18:11:28
|
Update of /cvsroot/dhcp-agent/dhcp-agent In directory usw-pr-cvs1:/tmp/cvs-serv1165 Modified Files: Makefile.am Makefile.in dhcp-client-cache.c dhcp-client-conf.c dhcp-globconf.c dhcp-stringbuffer.c dhcp-stringbuffer.h dhcp-util.c dhcp-util.h dhcp-varfile.c Added Files: dhcp-exception.c dhcp-exception.h Log Message: new exception code; made stringbuffer.h part of dhcp-util.h --- NEW FILE: dhcp-exception.c --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/dhcp-exception.c,v 1.1 2002/06/22 18:11:25 actmodern Exp $ * * Copyright 2002 Thamer Alharbash * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Poor man's C exceptions. This type of exception is not meant to be catchable. * Instead it's meant to hold error strings from functions as they progress up * the stack */ #include <dhcp-agent.h> #include <dhcp-util.h> #include <dhcp-exception.h> static exception_t exceptions; /* initialize global exception module. */ void init_exceptions(void) { exceptions.cur_index = 0; return; } void push_exception(const char *module_name, const char *function_name, char *fmt, ...) { va_list ap; exceptions.module_name[exceptions.cur_index] = module_name; exceptions.function_name[exceptions.cur_index] = function_name; exceptions.exception_message[exceptions.cur_index] = create_stringbuffer(); va_start(ap, fmt); stringbuffer_avprintf(exceptions.exception_message[exceptions.cur_index], fmt, ap); va_end(ap); exceptions.cur_index++; } /* returns unrolled full stack trace. * destroys the strings as they're unrolled. */ stringbuffer *unroll_exceptions(void) { int i; stringbuffer *unrolled_exception = create_stringbuffer(); /* format is as follows. * module_name: * function_name: * msg msg msg msg msg msg msg * msg msg msg msg msg msg msg * msg msg msg msg msg msg msg */ for(i = 0; i < exceptions.cur_index; i++) { /* append module name. */ stringbuffer_aprintf(unrolled_exception, "%s:", exceptions.module_name[i]); /* append function name. */ stringbuffer_aprintf(unrolled_exception, " %s():\n", exceptions.function_name[i]); stringbuffer_aprintf_align(unrolled_exception, 4, 50, "%s\n", stringbuffer_getstring(exceptions.exception_message[i])); destroy_stringbuffer(exceptions.exception_message[i]); } exceptions.cur_index = 0; return unrolled_exception; } --- NEW FILE: dhcp-exception.h --- /* $Header: /cvsroot/dhcp-agent/dhcp-agent/dhcp-exception.h,v 1.1 2002/06/22 18:11:25 actmodern Exp $ * * Copyright 2002 Thamer Alharbash * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * 3. The names of the authors may not be used to endorse or promote * products derived from this software without specific prior * written permission. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * */ #define MAX_EXCEPTION_STACK 64 typedef struct { stringbuffer *exception_message[MAX_EXCEPTION_STACK]; const char *module_name[MAX_EXCEPTION_STACK]; const char *function_name[MAX_EXCEPTION_STACK]; int cur_index; } exception_t; extern void init_exceptions(void); extern void push_exception(const char *module_name, const char *function_name, char *fmt, ...); extern stringbuffer *unroll_exceptions(void); Index: Makefile.am =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.am,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** Makefile.am 18 Jun 2002 04:33:40 -0000 1.24 --- Makefile.am 22 Jun 2002 18:11:25 -0000 1.25 *************** *** 5,14 **** DEFS = @DEFS@ ! bin_PROGRAMS = dhcpsniff dhcpclient dhcpsniff_SOURCES = dhcp-sniff.c dhcp-print.c dhcp-util.c \ dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c \ dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-snprintf.c \ ! dhcp-sniffer-ohandlers.c dhcp-rtt.c dhcp-interface.c dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ --- 5,14 ---- DEFS = @DEFS@ ! bin_PROGRAMS = dhcpsniff dhcpclient dhcptest dhcpsniff_SOURCES = dhcp-sniff.c dhcp-print.c dhcp-util.c \ dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c \ dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-snprintf.c \ ! dhcp-sniffer-ohandlers.c dhcp-rtt.c dhcp-interface.c dhcp-stringbuffer.c dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ *************** *** 22,38 **** dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c \ dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c \ ! dhcp-parser.c dhcp-varfile.c ! #dhcptest_SOURCES = dhcp-test.c dhcp-util.c \ ! #dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c \ ! #dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c \ ! #dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c \ ! #dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c \ ! #dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c \ ! #dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c \ ! #dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c \ ! #dhcp-parser.c dhcp-varfile.c ! #dhcptest_LDADD = @PCAP_LIB@ @DNET_LIB@ dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ --- 22,38 ---- dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c \ dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c \ ! dhcp-parser.c dhcp-varfile.c dhcp-exception.c ! dhcptest_SOURCES = dhcp-test.c dhcp-util.c \ ! dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c \ ! dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c \ ! dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c \ ! dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c \ ! dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c \ ! dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c \ ! dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c \ ! dhcp-parser.c dhcp-varfile.c dhcp-exception.c ! dhcptest_LDADD = @PCAP_LIB@ @DNET_LIB@ dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ Index: Makefile.in =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/Makefile.in,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** Makefile.in 18 Jun 2002 04:33:40 -0000 1.23 --- Makefile.in 22 Jun 2002 18:11:25 -0000 1.24 *************** *** 75,99 **** DEFS = @DEFS@ ! bin_PROGRAMS = dhcpsniff dhcpclient ! dhcpsniff_SOURCES = dhcp-sniff.c dhcp-print.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-snprintf.c dhcp-sniffer-ohandlers.c dhcp-rtt.c dhcp-interface.c dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ ! dhcpclient_SOURCES = dhcp-client.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c dhcp-parser.c dhcp-varfile.c ! #dhcptest_SOURCES = dhcp-test.c dhcp-util.c \ ! #dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c \ ! #dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c \ ! #dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c \ ! #dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c \ ! #dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c \ ! #dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c \ ! #dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c \ ! #dhcp-parser.c dhcp-varfile.c ! #dhcptest_LDADD = @PCAP_LIB@ @DNET_LIB@ dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ --- 75,92 ---- DEFS = @DEFS@ ! bin_PROGRAMS = dhcpsniff dhcpclient dhcptest ! dhcpsniff_SOURCES = dhcp-sniff.c dhcp-print.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-snprintf.c dhcp-sniffer-ohandlers.c dhcp-rtt.c dhcp-interface.c dhcp-stringbuffer.c dhcpsniff_LDADD = @PCAP_LIB@ @DNET_LIB@ ! dhcpclient_SOURCES = dhcp-client.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c dhcp-parser.c dhcp-varfile.c dhcp-exception.c ! dhcptest_SOURCES = dhcp-test.c dhcp-util.c dhcp-align.c dhcp-net.c dhcp-list.c dhcp-com.c dhcp-eth.c dhcp-ip.c dhcp-udp.c dhcp-arp.c dhcp-icmp.c dhcp-log.c dhcp-daemon.c dhcp-client-cache.c dhcp-cache-entry.c dhcp-client-control.c dhcp-interface.c dhcp-client-conf.c dhcp-snprintf.c dhcp-files.c dhcp-client-states.c dhcp-options-strings.c dhcp-convert.c dhcp-sysconf.c dhcp-rtt.c dhcp-packet-build.c dhcp-icmp-discovery.c dhcp-arp-discovery.c dhcp-route.c dhcp-globconf.c dhcp-stringbuffer.c dhcp-parser.c dhcp-varfile.c dhcp-exception.c ! ! dhcptest_LDADD = @PCAP_LIB@ @DNET_LIB@ dhcpclient_LDADD = @PCAP_LIB@ @DNET_LIB@ *************** *** 117,121 **** dhcp-net.o dhcp-list.o dhcp-com.o dhcp-eth.o dhcp-ip.o dhcp-udp.o \ dhcp-arp.o dhcp-icmp.o dhcp-log.o dhcp-snprintf.o \ ! dhcp-sniffer-ohandlers.o dhcp-rtt.o dhcp-interface.o dhcpsniff_DEPENDENCIES = dhcpsniff_LDFLAGS = --- 110,115 ---- dhcp-net.o dhcp-list.o dhcp-com.o dhcp-eth.o dhcp-ip.o dhcp-udp.o \ dhcp-arp.o dhcp-icmp.o dhcp-log.o dhcp-snprintf.o \ ! dhcp-sniffer-ohandlers.o dhcp-rtt.o dhcp-interface.o \ ! dhcp-stringbuffer.o dhcpsniff_DEPENDENCIES = dhcpsniff_LDFLAGS = *************** *** 128,134 **** dhcp-packet-build.o dhcp-icmp-discovery.o dhcp-arp-discovery.o \ dhcp-route.o dhcp-globconf.o dhcp-stringbuffer.o dhcp-parser.o \ ! dhcp-varfile.o dhcpclient_DEPENDENCIES = dhcpclient_LDFLAGS = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) --- 122,139 ---- dhcp-packet-build.o dhcp-icmp-discovery.o dhcp-arp-discovery.o \ dhcp-route.o dhcp-globconf.o dhcp-stringbuffer.o dhcp-parser.o \ ! dhcp-varfile.o dhcp-exception.o dhcpclient_DEPENDENCIES = dhcpclient_LDFLAGS = + dhcptest_OBJECTS = dhcp-test.o dhcp-util.o dhcp-align.o dhcp-net.o \ + dhcp-list.o dhcp-com.o dhcp-eth.o dhcp-ip.o dhcp-udp.o dhcp-arp.o \ + dhcp-icmp.o dhcp-log.o dhcp-daemon.o dhcp-client-cache.o \ + dhcp-cache-entry.o dhcp-client-control.o dhcp-interface.o \ + dhcp-client-conf.o dhcp-snprintf.o dhcp-files.o dhcp-client-states.o \ + dhcp-options-strings.o dhcp-convert.o dhcp-sysconf.o dhcp-rtt.o \ + dhcp-packet-build.o dhcp-icmp-discovery.o dhcp-arp-discovery.o \ + dhcp-route.o dhcp-globconf.o dhcp-stringbuffer.o dhcp-parser.o \ + dhcp-varfile.o dhcp-exception.o + dhcptest_DEPENDENCIES = + dhcptest_LDFLAGS = COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) *************** *** 154,167 **** .deps/dhcp-client-states.P .deps/dhcp-client.P .deps/dhcp-com.P \ .deps/dhcp-convert.P .deps/dhcp-daemon.P .deps/dhcp-eth.P \ ! .deps/dhcp-files.P .deps/dhcp-globconf.P .deps/dhcp-icmp-discovery.P \ ! .deps/dhcp-icmp.P .deps/dhcp-interface.P .deps/dhcp-ip.P \ ! .deps/dhcp-list.P .deps/dhcp-log.P .deps/dhcp-net.P \ .deps/dhcp-options-strings.P .deps/dhcp-packet-build.P \ .deps/dhcp-parser.P .deps/dhcp-print.P .deps/dhcp-route.P \ .deps/dhcp-rtt.P .deps/dhcp-sniff.P .deps/dhcp-sniffer-ohandlers.P \ .deps/dhcp-snprintf.P .deps/dhcp-stringbuffer.P .deps/dhcp-sysconf.P \ ! .deps/dhcp-udp.P .deps/dhcp-util.P .deps/dhcp-varfile.P ! SOURCES = $(dhcpsniff_SOURCES) $(dhcpclient_SOURCES) ! OBJECTS = $(dhcpsniff_OBJECTS) $(dhcpclient_OBJECTS) all: all-redirect --- 159,173 ---- .deps/dhcp-client-states.P .deps/dhcp-client.P .deps/dhcp-com.P \ .deps/dhcp-convert.P .deps/dhcp-daemon.P .deps/dhcp-eth.P \ ! .deps/dhcp-exception.P .deps/dhcp-files.P .deps/dhcp-globconf.P \ ! .deps/dhcp-icmp-discovery.P .deps/dhcp-icmp.P .deps/dhcp-interface.P \ ! .deps/dhcp-ip.P .deps/dhcp-list.P .deps/dhcp-log.P .deps/dhcp-net.P \ .deps/dhcp-options-strings.P .deps/dhcp-packet-build.P \ .deps/dhcp-parser.P .deps/dhcp-print.P .deps/dhcp-route.P \ .deps/dhcp-rtt.P .deps/dhcp-sniff.P .deps/dhcp-sniffer-ohandlers.P \ .deps/dhcp-snprintf.P .deps/dhcp-stringbuffer.P .deps/dhcp-sysconf.P \ ! .deps/dhcp-test.P .deps/dhcp-udp.P .deps/dhcp-util.P \ ! .deps/dhcp-varfile.P ! SOURCES = $(dhcpsniff_SOURCES) $(dhcpclient_SOURCES) $(dhcptest_SOURCES) ! OBJECTS = $(dhcpsniff_OBJECTS) $(dhcpclient_OBJECTS) $(dhcptest_OBJECTS) all: all-redirect *************** *** 259,262 **** --- 265,272 ---- @rm -f dhcpclient $(LINK) $(dhcpclient_LDFLAGS) $(dhcpclient_OBJECTS) $(dhcpclient_LDADD) $(LIBS) + + dhcptest: $(dhcptest_OBJECTS) $(dhcptest_DEPENDENCIES) + @rm -f dhcptest + $(LINK) $(dhcptest_LDFLAGS) $(dhcptest_OBJECTS) $(dhcptest_LDADD) $(LIBS) install-man1: Index: dhcp-client-cache.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-cache.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** dhcp-client-cache.c 17 Jun 2002 13:23:07 -0000 1.12 --- dhcp-client-cache.c 22 Jun 2002 18:11:25 -0000 1.13 *************** *** 27,31 **** #include <dhcp-util.h> #include <dhcp-files.h> - #include <dhcp-stringbuffer.h> #include <dhcp-parser.h> #include <dhcp-varfile.h> --- 27,30 ---- Index: dhcp-client-conf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-client-conf.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** dhcp-client-conf.c 17 Jun 2002 13:23:07 -0000 1.11 --- dhcp-client-conf.c 22 Jun 2002 18:11:25 -0000 1.12 *************** *** 26,30 **** #include <dhcp-util.h> #include <dhcp-files.h> - #include <dhcp-stringbuffer.h> #include <dhcp-parser.h> #include <dhcp-varfile.h> --- 26,29 ---- Index: dhcp-globconf.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-globconf.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** dhcp-globconf.c 17 Jun 2002 13:23:08 -0000 1.8 --- dhcp-globconf.c 22 Jun 2002 18:11:25 -0000 1.9 *************** *** 33,37 **** #include <dhcp-files.h> #include <dhcp-convert.h> - #include <dhcp-stringbuffer.h> #include <dhcp-parser.h> #include <dhcp-varfile.h> --- 33,36 ---- Index: dhcp-stringbuffer.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-stringbuffer.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** dhcp-stringbuffer.c 18 Jun 2002 23:24:30 -0000 1.5 --- dhcp-stringbuffer.c 22 Jun 2002 18:11:25 -0000 1.6 *************** *** 24,28 **** #include <dhcp-agent.h> - #include <dhcp-stringbuffer.h> #include <dhcp-util.h> --- 24,27 ---- *************** *** 387,389 **** --- 386,446 ---- { stringbuffer_avprintf_align(sb, 0, 0, fmt, ap); + } + + /* mark newlines to walk through. + * our sentinel is the null terminator. + * two null terminations marks the end of the string. + * we're guaranteed it is a unique sentinel since + * we never accept null terminators from outside sources + * and never build our own strings (obviously!) with + * null terminators inside of them. + */ + void stringbuffer_marknewlines(stringbuffer *sb) + { + char *c; + + /* first append one null termination to the end + * to act as a proper terminator. */ + stringbuffer_append_c(sb, 0); + + + c = sb->buf; + while(1) { + + if(*c == '\n') + *c = 0; + + c++; + if(*c == 0) + break; + } + + return; + } + + /* called _after_ newlines are marked. */ + char *stringbuffer_getnextline(stringbuffer *sb, char *c) + { + char *ptr; + + if(c == NULL) { + + /* get first line. */ + c = sb->buf; + + } else { + + /* check for end. */ + if(*c == 0 && (*(c + 1)) == 0) + return NULL; + + else { + /* otherwise move to next line and return */ + c++; + for(ptr = c;*ptr != 0;ptr++); + c = ptr + 1; + } + } + + return c; } Index: dhcp-stringbuffer.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-stringbuffer.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** dhcp-stringbuffer.h 17 Jun 2002 13:23:08 -0000 1.4 --- dhcp-stringbuffer.h 22 Jun 2002 18:11:25 -0000 1.5 *************** *** 45,48 **** --- 45,50 ---- extern void stringbuffer_append_c(stringbuffer *sb, char c); extern void stringbuffer_clear(stringbuffer *sb); + extern char *stringbuffer_getnextline(stringbuffer *sb, char *c); + extern void stringbuffer_marknewlines(stringbuffer *sb); extern void stringbuffer_set(stringbuffer *dest, const char *s); Index: dhcp-util.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-util.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** dhcp-util.c 22 Jun 2002 01:47:57 -0000 1.19 --- dhcp-util.c 22 Jun 2002 18:11:25 -0000 1.20 *************** *** 90,93 **** --- 90,122 ---- } + /* send error message and exit. (convenience) */ + void fatal_error_exception(stringbuffer *exception_string) + { + char *c = NULL; + if(verbosity_level == QUIET_VERBOSITY_LEVEL) + return; + + stringbuffer_marknewlines(exception_string); + + if(interactive == 1) + fprintf(stderr, "%s: fatal error\n", getprogname()); + + while(1) { + + c = stringbuffer_getnextline(exception_string, c); + if(c == NULL) + break; + + if(interactive == 1) { + fprintf(stderr, "%s: %s", getprogname(), c); + fprintf(stderr,"\n"); + } else + error_log(c); + + } + + exit(1); + } + /* send info message */ void info_message(char *fmt, ...) Index: dhcp-util.h =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-util.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dhcp-util.h 22 Jun 2002 01:47:57 -0000 1.6 --- dhcp-util.h 22 Jun 2002 18:11:25 -0000 1.7 *************** *** 26,29 **** --- 26,31 ---- #define DHCP_UTIL_H + #include <dhcp-stringbuffer.h> + /* Utility functions. */ *************** *** 38,41 **** --- 40,44 ---- extern void warn_message(char *fmt, ...); extern void debug_message(char *fmt, ...); + extern void fatal_error_exception(stringbuffer *exception_string); extern int get_verbosity_level(void); Index: dhcp-varfile.c =================================================================== RCS file: /cvsroot/dhcp-agent/dhcp-agent/dhcp-varfile.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** dhcp-varfile.c 17 Jun 2002 13:23:08 -0000 1.2 --- dhcp-varfile.c 22 Jun 2002 18:11:25 -0000 1.3 *************** *** 26,30 **** #include <dhcp-agent.h> #include <dhcp-util.h> - #include <dhcp-stringbuffer.h> #include <dhcp-files.h> #include <dhcp-parser.h> --- 26,29 ---- |