mirror of
https://github.com/isc-projects/bind9.git
synced 2026-04-20 21:58:03 -04:00
Split fatal(), notify() into util.c.
Put DO() and the fatal()/notify() declarations in util.h. Makefile adjusted to build rndc with util.o, and to also build and install rndc-confgen.
This commit is contained in:
parent
f8644da8d9
commit
4cd7656507
4 changed files with 134 additions and 53 deletions
|
|
@ -13,7 +13,7 @@
|
|||
# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
# $Id: Makefile.in,v 1.25 2001/06/01 00:45:03 bwelling Exp $
|
||||
# $Id: Makefile.in,v 1.26 2001/06/22 17:22:24 tale Exp $
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
|
@ -23,8 +23,11 @@ top_srcdir = @top_srcdir@
|
|||
|
||||
@BIND9_INCLUDES@
|
||||
|
||||
CINCLUDES = -I${top_srcdir}/bin/named/include \
|
||||
${ISC_INCLUDES} ${ISCCC_INCLUDES} ${ISCCFG_INCLUDES}
|
||||
CINCLUDES = ${ISC_INCLUDES}
|
||||
|
||||
RNDCINCLUDES = ${CINCLUDES} ${ISCCC_INCLUDES} ${ISCCFG_INCLUDES}
|
||||
|
||||
CONFINCLUDES = ${CINCLUDES} ${DNS_INCLUDES}
|
||||
|
||||
CDEFINES =
|
||||
CWARNINGS =
|
||||
|
|
@ -32,20 +35,20 @@ CWARNINGS =
|
|||
ISCCFGLIBS = ../../lib/isccfg/libisccfg.@A@
|
||||
ISCCCLIBS = ../../lib/isccc/libisccc.@A@
|
||||
ISCLIBS = ../../lib/isc/libisc.@A@
|
||||
DNSLIBS = ../../lib/dns/libdns.@A@
|
||||
|
||||
ISCCFGDEPLIBS = ../../lib/isccfg/libisccfg.@A@
|
||||
ISCCCDEPLIBS = ../../lib/isccc/libisccc.@A@
|
||||
ISCDEPLIBS = ../../lib/isc/libisc.@A@
|
||||
DNSDEPLIBS = ../../lib/dns/libdns.@A@
|
||||
|
||||
DEPLIBS = ${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
|
||||
RNDCLIBS = ${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} @LIBS@
|
||||
RNDCDEPLIBS = ${ISCCFGDEPLIBS} ${ISCCCDEPLIBS} ${ISCDEPLIBS}
|
||||
|
||||
LIBS = ${ISCCFGLIBS} ${ISCCCLIBS} ${ISCLIBS} @LIBS@
|
||||
CONFLIBS = ${DNSLIBS} ${ISCLIBS} @LIBS@
|
||||
CONFDEPLIBS = ${DNSLIBS} ${ISCLIBS}
|
||||
|
||||
TARGETS = rndc
|
||||
|
||||
OBJS = rndc.@O@
|
||||
|
||||
SRCS = rndc.c
|
||||
TARGETS = rndc rndc-confgen
|
||||
|
||||
MANPAGES = rndc.8 rndc.conf.5
|
||||
|
||||
|
|
@ -56,12 +59,22 @@ MANOBJS = ${MANPAGES} ${HTMLPAGES}
|
|||
@BIND9_MAKE_RULES@
|
||||
|
||||
rndc.@O@: rndc.c
|
||||
${LIBTOOL} ${CC} ${ALL_CFLAGS} -DVERSION=\"${VERSION}\" \
|
||||
${LIBTOOL} ${CC} ${ALL_CFLAGS} ${RNDCINCLUDES} \
|
||||
-DVERSION=\"${VERSION}\" \
|
||||
-DRNDC_SYSCONFDIR=\"${sysconfdir}\" \
|
||||
-DNS_LOCALSTATEDIR=\"${localstatedir}\" -c ${srcdir}/rndc.c
|
||||
|
||||
rndc: ${OBJS} ${DEPLIBS}
|
||||
${LIBTOOL} ${PURIFY} ${CC} ${CFLAGS} -o $@ ${OBJS} ${LIBS}
|
||||
rndc-confgen.@O@: rndc-confgen.c
|
||||
${LIBTOOL} ${CC} ${ALL_CFLAGS} ${CONFINCLUDES} \
|
||||
-DRNDC_SYSCONFDIR=\"${sysconfdir}\" -c ${srcdir}/rndc-confgen.c
|
||||
|
||||
rndc: rndc.@O@ util.@O@ ${RNDCDEPLIBS}
|
||||
${LIBTOOL} ${PURIFY} ${CC} ${CFLAGS} -o $@ rndc.@O@ util.@O@ \
|
||||
${RNDCLIBS}
|
||||
|
||||
rndc-confgen: rndc-confgen.@O@ util.@O@ ${CONFDEPLIBS}
|
||||
${LIBTOOL} ${PURIFY} ${CC} ${CFLAGS} -o $@ rndc-confgen.@O@ util.@O@ \
|
||||
${CONFLIBS}
|
||||
|
||||
doc man:: ${MANOBJS}
|
||||
|
||||
|
|
@ -75,6 +88,7 @@ installdirs:
|
|||
|
||||
install:: rndc installdirs
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} rndc ${DESTDIR}${sbindir}
|
||||
${LIBTOOL} ${INSTALL_PROGRAM} rndc-confgen ${DESTDIR}${sbindir}
|
||||
${INSTALL_DATA} ${srcdir}/rndc.8 ${DESTDIR}${mandir}/man8
|
||||
${INSTALL_DATA} ${srcdir}/rndc.conf.5 ${DESTDIR}${mandir}/man5
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@
|
|||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: rndc.c,v 1.64 2001/06/15 01:20:09 gson Exp $ */
|
||||
/* $Id: rndc.c,v 1.65 2001/06/22 17:22:25 tale Exp $ */
|
||||
|
||||
/*
|
||||
* Principal Author: DCL
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <isccc/types.h>
|
||||
#include <isccc/util.h>
|
||||
|
||||
#define NS_CONTROL_PORT 953
|
||||
#include "util.h"
|
||||
|
||||
#ifdef HAVE_ADDRINFO
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
|
|
@ -64,6 +64,9 @@
|
|||
extern int h_errno;
|
||||
#endif
|
||||
|
||||
char progname[256];
|
||||
isc_boolean_t verbose;
|
||||
|
||||
static const char *admin_conffile = RNDC_SYSCONFDIR "/rndc.conf";
|
||||
static const char *auto_conffile = NS_LOCALSTATEDIR "/run/named.key";
|
||||
static const char *version = VERSION;
|
||||
|
|
@ -71,28 +74,14 @@ static const char *servername = NULL;
|
|||
static unsigned int remoteport = NS_CONTROL_PORT;
|
||||
static isc_socketmgr_t *socketmgr = NULL;
|
||||
static unsigned char databuf[2048];
|
||||
static char progname[256];
|
||||
static isccc_ccmsg_t ccmsg;
|
||||
static isccc_region_t secret;
|
||||
static isc_boolean_t verbose;
|
||||
static isc_boolean_t failed = ISC_FALSE;
|
||||
static isc_mem_t *mctx;
|
||||
static int sends, recvs, connects;
|
||||
static char *command;
|
||||
static char *args;
|
||||
|
||||
static void
|
||||
notify(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
if (verbose) {
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
usage(int status) {
|
||||
fprintf(stderr, "\
|
||||
|
|
@ -126,30 +115,6 @@ Version: %s\n",
|
|||
exit(status);
|
||||
}
|
||||
|
||||
static void
|
||||
fatal(const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
#undef DO
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
fatal("%s: %s", name, isc_result_totext(result)); \
|
||||
else \
|
||||
notify(name); \
|
||||
} while (0)
|
||||
|
||||
|
||||
static void
|
||||
get_address(const char *host, in_port_t port, isc_sockaddr_t *sockaddr) {
|
||||
struct in_addr in4;
|
||||
|
|
|
|||
55
bin/rndc/util.c
Normal file
55
bin/rndc/util.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright (C) 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: util.c,v 1.1 2001/06/22 17:22:26 tale Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <isc/boolean.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
extern isc_boolean_t verbose;
|
||||
extern const char *progname;
|
||||
|
||||
void
|
||||
notify(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
if (verbose) {
|
||||
va_start(ap, fmt);
|
||||
vfprintf(stderr, fmt, ap);
|
||||
va_end(ap);
|
||||
fputs("\n", stderr);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
fatal(const char *format, ...) {
|
||||
va_list args;
|
||||
|
||||
fprintf(stderr, "%s: ", progname);
|
||||
va_start(args, format);
|
||||
vfprintf(stderr, format, args);
|
||||
va_end(args);
|
||||
fprintf(stderr, "\n");
|
||||
exit(1);
|
||||
}
|
||||
47
bin/rndc/util.h
Normal file
47
bin/rndc/util.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2001 Internet Software Consortium.
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
|
||||
* DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
|
||||
* INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
|
||||
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
|
||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: util.h,v 1.1 2001/06/22 17:22:26 tale Exp $ */
|
||||
|
||||
#ifndef RNDC_UTIL_H
|
||||
#define RNDC_UTIL_H 1
|
||||
|
||||
#include <isc/lang.h>
|
||||
|
||||
#define NS_CONTROL_PORT 953
|
||||
|
||||
#undef DO
|
||||
#define DO(name, function) \
|
||||
do { \
|
||||
result = function; \
|
||||
if (result != ISC_R_SUCCESS) \
|
||||
fatal("%s: %s", name, isc_result_totext(result)); \
|
||||
else \
|
||||
notify(name); \
|
||||
} while (0)
|
||||
|
||||
ISC_LANG_BEGINDECLS
|
||||
|
||||
void
|
||||
notify(const char *fmt, ...);
|
||||
|
||||
void
|
||||
fatal(const char *format, ...);
|
||||
|
||||
ISC_LANG_ENDDECLS
|
||||
|
||||
#endif /* RNDC_UTIL_H */
|
||||
Loading…
Reference in a new issue