diff --git a/.gitignore b/.gitignore index fce9d682..0f4482ef 100644 --- a/.gitignore +++ b/.gitignore @@ -36,9 +36,9 @@ src/test/check_getdns src/test/check_getdns_event src/test/check_getdns_uv src/test/check_getdns_ev -src/test/getdns_query src/test/scratchpad src/test/scratchpad.c +src/tools/getdns_query doc/*.3 src/getdns/getdns.h *.log diff --git a/Makefile.in b/Makefile.in index 331c889e..8364c14e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -111,10 +111,10 @@ pad: scratchpad src/test/scratchpad || ./libtool exec gdb src/test/scratchpad install-getdns_query: - cd src/test && $(MAKE) install + cd src/tools && $(MAKE) install uninstall-getdns_query: - cd src/test && $(MAKE) uninstall + cd src/tools && $(MAKE) uninstall clean: cd src && $(MAKE) $@ @@ -182,6 +182,8 @@ $(distdir): mkdir -p $(distdir)/src/compat mkdir -p $(distdir)/src/util mkdir -p $(distdir)/src/gldns + mkdir -p $(distdir)/src/tools + mkdir -p $(distdir)/src/jsmn mkdir -p $(distdir)/doc mkdir -p $(distdir)/spec mkdir -p $(distdir)/spec/example @@ -224,6 +226,11 @@ $(distdir): cp $(srcdir)/spec/*.tgz $(distdir)/spec || true cp $(srcdir)/spec/example/Makefile.in $(distdir)/spec/example cp $(srcdir)/spec/example/*.[ch] $(distdir)/spec/example + cp $(srcdir)/src/tools/Makefile.in $(distdir)/src/tools + cp $(srcdir)/src/tools/*.[ch] $(distdir)/src/tools + cp $(srcdir)/src/jsmn/*.[ch] $(distdir)/src/jsmn + cp $(srcdir)/src/jsmn/LICENSE $(distdir)/src/jsmn + cp $(srcdir)/src/jsmn/README.md $(distdir)/src/jsmn rm -f $(distdir)/Makefile $(distdir)/src/Makefile $(distdir)/src/getdns/getdns.h $(distdir)/spec/example/Makefile $(distdir)/src/test/Makefile $(distdir)/doc/Makefile $(distdir)/src/config.h distcheck: $(distdir).tar.gz diff --git a/configure.ac b/configure.ac index 468178ce..2651ec1a 100644 --- a/configure.ac +++ b/configure.ac @@ -889,9 +889,9 @@ AC_DEFINE_UNQUOTED([TRUST_ANCHOR_FILE], ["$TRUST_ANCHOR_FILE"], [Default trust a AC_SUBST(TRUST_ANCHOR_FILE) AC_MSG_NOTICE([Default trust anchor: $TRUST_ANCHOR_FILE]) -AC_ARG_WITH(getdns_query, AS_HELP_STRING([--with-getdns_query], - [Also compile and install the getdns_query tool]), - [], [withval="no"]) +AC_ARG_WITH(getdns_query, AS_HELP_STRING([--without-getdns_query], + [Do not compile and install the getdns_query tool]), + [], [withval="yes"]) if test x_$withval = x_no; then GETDNS_QUERY="" INSTALL_GETDNS_QUERY="" @@ -917,7 +917,7 @@ AC_SUBST(GETDNS_QUERY) AC_SUBST(INSTALL_GETDNS_QUERY) AC_SUBST(UNINSTALL_GETDNS_QUERY) -AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile doc/Makefile getdns.pc getdns_ext_event.pc]) +AC_CONFIG_FILES([Makefile src/Makefile src/version.c src/getdns/getdns.h src/getdns/getdns_extra.h spec/example/Makefile src/test/Makefile src/tools/Makefile doc/Makefile getdns.pc getdns_ext_event.pc]) if [ test -n "$DOXYGEN" ] then AC_CONFIG_FILES([src/Doxyfile]) fi diff --git a/src/Makefile.in b/src/Makefile.in index c9ff78db..212b7180 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -157,7 +157,7 @@ test: all cd test && $(MAKE) $@ getdns_query: all - cd test && $(MAKE) $@ + cd tools && $(MAKE) $@ scratchpad: all cd test && $(MAKE) $@ @@ -165,11 +165,13 @@ scratchpad: all pad: scratchpad clean: + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ rm -f *.o *.lo extension/*.lo extension/*.o $(PROGRAMS) libgetdns.la libgetdns_ext_*.la rm -rf .libs extension/.libs distclean : clean + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ rmdir test 2>/dev/null || true rm -f Makefile config.status config.log Doxyfile config.h version.c getdns/Makefile getdns/getdns.h getdns/getdns_extra.h @@ -177,35 +179,9 @@ distclean : clean rmdir extension 2>/dev/null || true rm -Rf autom4te.cache -$(distdir): FORCE - mkdir -p $(distdir)/src - cp configure.ac $(distdir) - cp configure $(distdir) - cp Makefile.in $(distdir) - cp src/Makefile.in $(distdir)/src - -distcheck: $(distdir).tar.gz - gzip -cd $(distdir).tar.gz | tar xvf - - cd $(distdir) && ./configure - cd $(distdir) && $(MAKE) all - cd $(distdir) && $(MAKE) check - cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst install - cd $(distdir) && $(MAKE) DESTDIR=$${PWD}/_inst uninstall - @remaining="`find $${PWD}/$(distdir)/_inst -type f | wc -l`"; \ - if test "$${remaining}" -ne 0; then - echo "@@@ $${remaining} file(s) remaining in stage directory!"; \ - exit 1; \ - fi - cd $(distdir) && $(MAKE) clean - rm -rf $(distdir) - @echo "*** Package $(distdir).tar.gz is ready for distribution" - Makefile: $(srcdir)/Makefile.in ../config.status cd .. && ./config.status src/Makefile -configure.status: configure - cd .. && ./config.status --recheck - depend: (cd $(srcdir) ; awk 'BEGIN{P=1}{if(P)print}/^# Dependencies/{P=0}' Makefile.in > Makefile.in.new ) (blddir=`pwd`; cd $(srcdir) ; gcc -MM -I. -I"$$blddir" *.c gldns/*.c compat/*.c util/*.c jsmn/*.c extension/*.c| \ @@ -225,6 +201,7 @@ depend: -e 's!\(.*\)\.o[ :]*!\1.lo \1.o: !g' >> Makefile.in.new ) (cd $(srcdir) ; diff Makefile.in.new Makefile.in && rm Makefile.in.new \ || mv Makefile.in.new Makefile.in ) + cd tools && $(MAKE) $@ cd test && $(MAKE) $@ .PHONY: clean test diff --git a/src/test/Makefile.in b/src/test/Makefile.in index a33ec15f..83e9e9c6 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -67,13 +67,13 @@ CHECK_OBJS=check_getdns_common.lo check_getdns_context_set_timeout.lo \ check_getdns.lo check_getdns_transport.lo ALL_OBJS=$(CHECK_OBJS) check_getdns_libevent.lo check_getdns_libev.lo \ - check_getdns_selectloop.lo getdns_query.lo scratchpad.lo \ + check_getdns_selectloop.lo scratchpad.lo \ testmessages.lo tests_dict.lo tests_list.lo tests_namespaces.lo \ tests_stub_async.lo tests_stub_sync.lo NON_C99_OBJS=check_getdns_libuv.lo -PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync getdns_query $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) +PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync $(CHECK_GETDNS) $(CHECK_EV_PROG) $(CHECK_EVENT_PROG) $(CHECK_UV_PROG) .SUFFIXES: .c .o .a .lo .h @@ -124,9 +124,6 @@ check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo ../libgetdns_ext_ev.la $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -getdns_query: getdns_query.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(LDFLAGS) $(LDLIBS) - scratchpad: scratchpad.lo $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS) @@ -135,12 +132,11 @@ scratchpad.lo: scratchpad.c $(srcdir)/scratchpad.c: scratchpad.template.c [ ! -f $(srcdir)/scratchpad.c ] && cp -p $(srcdir)/scratchpad.template.c $(srcdir)/scratchpad.c || true -install: getdns_query - $(INSTALL) -m 755 -d $(DESTDIR)$(bindir) - $(LIBTOOL) --mode=install cp getdns_query $(DESTDIR)$(bindir) +install: + echo nothing to install uninstall: - $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(bindir)/getdns_query + echo nothing to uninstall nolibcheck: @echo "***" @@ -263,8 +259,6 @@ check_getdns_selectloop.lo check_getdns_selectloop.o: $(srcdir)/check_getdns_sel check_getdns_transport.lo check_getdns_transport.o: $(srcdir)/check_getdns_transport.c \ $(srcdir)/check_getdns_transport.h $(srcdir)/check_getdns_common.h ../getdns/getdns.h \ ../getdns/getdns_extra.h -getdns_query.lo getdns_query.o: $(srcdir)/getdns_query.c ../config.h $(srcdir)/../debug.h ../config.h \ - ../getdns/getdns.h ../getdns/getdns_extra.h scratchpad.template.lo scratchpad.template.o: scratchpad.template.c ../getdns/getdns.h \ ../getdns/getdns_extra.h testmessages.lo testmessages.o: $(srcdir)/testmessages.c $(srcdir)/testmessages.h diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c deleted file mode 100644 index 81ebd79d..00000000 --- a/src/test/getdns_query.c +++ /dev/null @@ -1,1614 +0,0 @@ -/* - * Copyright (c) 2013, NLNet Labs, Verisign, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * 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. - * * Neither the names of the copyright holders nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL Verisign, Inc. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "debug.h" -#include -#include -#include -#include -#include -#include -#include -#ifndef USE_WINSOCK -#include -#include -#include -#else -#include -#include -typedef unsigned short in_port_t; -#include -#include -#endif - -#define EXAMPLE_PIN "pin-sha256=\"E9CZ9INDbd+2eRQozYqqbQ2yXLVKB9+xcprMF+44U1g=\"" - -static int quiet = 0; -static int batch_mode = 0; -static char *query_file = NULL; -static int json = 0; -static char *the_root = "."; -static char *name; -static getdns_context *context; -static getdns_dict *extensions; -static getdns_dict *query_extensions_spc = NULL; -static getdns_list *pubkey_pinset = NULL; -static getdns_list *listen_list = NULL; -int touched_listen_list; -static getdns_dict *listen_dict = NULL; -static size_t pincount = 0; -static size_t listen_count = 0; -static uint16_t request_type = GETDNS_RRTYPE_NS; -static int timeout, edns0_size, padding_blocksize; -static int async = 0, interactive = 0; -static enum { GENERAL, ADDRESS, HOSTNAME, SERVICE } calltype = GENERAL; - -static int get_rrtype(const char *t) -{ - char buf[1024] = "GETDNS_RRTYPE_"; - uint32_t rrtype; - long int l; - size_t i; - char *endptr; - - if (strlen(t) > sizeof(buf) - 15) - return -1; - for (i = 14; *t && i < sizeof(buf) - 1; i++, t++) - buf[i] = toupper(*t); - buf[i] = '\0'; - - if (!getdns_str2int(buf, &rrtype)) - return (int)rrtype; - - if (strncasecmp(buf + 14, "TYPE", 4) == 0) { - l = strtol(buf + 18, &endptr, 10); - if (!*endptr && l >= 0 && l < 65536) - return l; - } - return -1; -} - -static int get_rrclass(const char *t) -{ - char buf[1024] = "GETDNS_RRCLASS_"; - uint32_t rrclass; - long int l; - size_t i; - char *endptr; - - if (strlen(t) > sizeof(buf) - 16) - return -1; - for (i = 15; *t && i < sizeof(buf) - 1; i++, t++) - buf[i] = toupper(*t); - buf[i] = '\0'; - - if (!getdns_str2int(buf, &rrclass)) - return (int)rrclass; - - if (strncasecmp(buf + 15, "CLASS", 5) == 0) { - l = strtol(buf + 20, &endptr, 10); - if (!*endptr && l >= 0 && l < 65536) - return l; - } - return -1; -} - -static getdns_return_t -fill_transport_list(getdns_context *context, char *transport_list_str, - getdns_transport_list_t *transports, size_t *transport_count) -{ - size_t max_transports = *transport_count; - *transport_count = 0; - for ( size_t i = 0 - ; i < max_transports && i < strlen(transport_list_str) - ; i++, (*transport_count)++) { - switch(*(transport_list_str + i)) { - case 'U': - transports[i] = GETDNS_TRANSPORT_UDP; - break; - case 'T': - transports[i] = GETDNS_TRANSPORT_TCP; - break; - case 'L': - transports[i] = GETDNS_TRANSPORT_TLS; - break; - default: - fprintf(stderr, "Unrecognised transport '%c' in string %s\n", - *(transport_list_str + i), transport_list_str); - return GETDNS_RETURN_GENERIC_ERROR; - } - } - return GETDNS_RETURN_GOOD; -} - -void -print_usage(FILE *out, const char *progname) -{ - fprintf(out, "usage: %s [