From 7975c98c3fe55d793345089c03b105a70ba1c217 Mon Sep 17 00:00:00 2001 From: Neel Goyal Date: Tue, 13 Aug 2013 10:02:09 -0400 Subject: [PATCH] Remove getdns_address.c. Update context to use copy. --- src/common/Makefile.am | 2 +- src/common/Makefile.in | 11 +++---- src/common/getdns_address.c | 60 ----------------------------------- src/common/getdns_context.c | 28 ++++++++++++++-- src/common/getdns_core_only.h | 6 ++-- src/common/getdns_general.c | 34 ++++++++++++++++++++ 6 files changed, 70 insertions(+), 71 deletions(-) delete mode 100644 src/common/getdns_address.c diff --git a/src/common/Makefile.am b/src/common/Makefile.am index adf45dc0..07665a5b 100644 --- a/src/common/Makefile.am +++ b/src/common/Makefile.am @@ -1,6 +1,6 @@ AM_CPPFLAGS = -Wall -Werror -g -fPIC -I$(srcdir)/ -I /usr/local/include -std=c99 lib_LTLIBRARIES = libgetdns.la -libgetdns_la_SOURCES = getdns_address.c getdns_context.c getdns_convert.c \ +libgetdns_la_SOURCES = getdns_context.c getdns_convert.c \ getdns_dict.c getdns_general.c getdns_hostname.c getdns_list.c \ getdns_service.c getdns_sync.c getdns_validate_dnssec.c \ getdns_core_only.h getdns_libevent.h getdns_context.h diff --git a/src/common/Makefile.in b/src/common/Makefile.in index b29760af..71538e12 100644 --- a/src/common/Makefile.in +++ b/src/common/Makefile.in @@ -92,10 +92,10 @@ am__uninstall_files_from_dir = { \ am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)" LTLIBRARIES = $(lib_LTLIBRARIES) libgetdns_la_LIBADD = -am_libgetdns_la_OBJECTS = getdns_address.lo getdns_context.lo \ - getdns_convert.lo getdns_dict.lo getdns_general.lo \ - getdns_hostname.lo getdns_list.lo getdns_service.lo \ - getdns_sync.lo getdns_validate_dnssec.lo +am_libgetdns_la_OBJECTS = getdns_context.lo getdns_convert.lo \ + getdns_dict.lo getdns_general.lo getdns_hostname.lo \ + getdns_list.lo getdns_service.lo getdns_sync.lo \ + getdns_validate_dnssec.lo libgetdns_la_OBJECTS = $(am_libgetdns_la_OBJECTS) DEFAULT_INCLUDES = -I.@am__isrc@ depcomp = $(SHELL) $(top_srcdir)/depcomp @@ -237,7 +237,7 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ AM_CPPFLAGS = -Wall -Werror -g -fPIC -I$(srcdir)/ -I /usr/local/include -std=c99 lib_LTLIBRARIES = libgetdns.la -libgetdns_la_SOURCES = getdns_address.c getdns_context.c getdns_convert.c \ +libgetdns_la_SOURCES = getdns_context.c getdns_convert.c \ getdns_dict.c getdns_general.c getdns_hostname.c getdns_list.c \ getdns_service.c getdns_sync.c getdns_validate_dnssec.c \ getdns_core_only.h getdns_libevent.h getdns_context.h @@ -320,7 +320,6 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdns_address.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdns_context.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdns_convert.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdns_dict.Plo@am__quote@ diff --git a/src/common/getdns_address.c b/src/common/getdns_address.c deleted file mode 100644 index d6e85a63..00000000 --- a/src/common/getdns_address.c +++ /dev/null @@ -1,60 +0,0 @@ -/** - * - * /brief getdns core functions - * - * This is the meat of the API - * Originally taken from the getdns API description pseudo implementation. - * - */ -/* The MIT License (MIT) - * Copyright (c) 2013 Verisign, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include - -/* stuff to make it compile pedantically */ -#define UNUSED_PARAM(x) ((void)(x)) - -/* - * getdns_address - * - */ -getdns_return_t -getdns_address( - getdns_context_t context, - const char *name, - struct getdns_dict *extensions, - void *userarg, - getdns_transaction_t *transaction_id, - getdns_callback_t callback -) -{ - UNUSED_PARAM(context); - UNUSED_PARAM(name); - UNUSED_PARAM(extensions); - UNUSED_PARAM(userarg); - UNUSED_PARAM(transaction_id); - UNUSED_PARAM(callback); - - return GETDNS_RETURN_GOOD; -} /* getdns_address */ - -/* getdns_address.c */ diff --git a/src/common/getdns_context.c b/src/common/getdns_context.c index 0b6c18fd..5fdd33c9 100644 --- a/src/common/getdns_context.c +++ b/src/common/getdns_context.c @@ -386,6 +386,13 @@ getdns_context_set_dns_root_servers( struct getdns_list *addresses ) { + getdns_list *copy = NULL; + if (addresses != NULL) { + if (getdns_list_copy(addresses, ©) != GETDNS_RETURN_GOOD) { + return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; + } + addresses = copy; + } getdns_list_destroy(context->dns_root_servers); context->dns_root_servers = addresses; @@ -429,8 +436,14 @@ getdns_context_set_suffix( struct getdns_list *value ) { + getdns_list *copy = NULL; + if (value != NULL) { + if (getdns_list_copy(value, ©) != GETDNS_RETURN_GOOD) { + return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; + } + value = copy; + } getdns_list_destroy(context->suffix); - context->suffix = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_SUFFIX); @@ -448,8 +461,14 @@ getdns_context_set_dnssec_trust_anchors( struct getdns_list *value ) { + getdns_list *copy = NULL; + if (value != NULL) { + if (getdns_list_copy(value, ©) != GETDNS_RETURN_GOOD) { + return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; + } + value = copy; + } getdns_list_destroy(context->dnssec_trust_anchors); - context->dnssec_trust_anchors = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_TRUST_ANCHORS); @@ -487,6 +506,11 @@ getdns_context_set_stub_resolution( if (upstream_list == NULL) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } + getdns_list *copy = NULL; + if (getdns_list_copy(upstream_list, ©) != GETDNS_RETURN_GOOD) { + return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; + } + upstream_list = copy; getdns_context_set_resolution_type(context, GETDNS_CONTEXT_STUB); diff --git a/src/common/getdns_core_only.h b/src/common/getdns_core_only.h index 82a53435..7f1e5964 100644 --- a/src/common/getdns_core_only.h +++ b/src/common/getdns_core_only.h @@ -217,9 +217,9 @@ * \defgroup extvals Values Associated With Extensions * @{ */ -#define GETDNS_EXTENSION_TRUE 1000 +#define GETDNS_EXTENSION_TRUE 1 #define GETDNS_EXTENSION_TRUE_TEXT Turn on the extension -#define GETDNS_EXTENSION_FALSE 1001 +#define GETDNS_EXTENSION_FALSE 0 #define GETDNS_EXTENSION_FALSE_TEXT Do not turn on the extension /** @} */ @@ -245,6 +245,8 @@ #define GETDNS_STR_IPV6 "IPv6" #define GETDNS_STR_ADDRESS_TYPE "address_type" #define GETDNS_STR_ADDRESS_DATA "address_data" +#define GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6 "return_both_v4_and_v6" + /** @} */ diff --git a/src/common/getdns_general.c b/src/common/getdns_general.c index e525ec7b..84aa39c6 100644 --- a/src/common/getdns_general.c +++ b/src/common/getdns_general.c @@ -57,4 +57,38 @@ getdns_general( return GETDNS_RETURN_GOOD; } /* getdns_general */ + +/* + * getdns_address + * + */ +getdns_return_t +getdns_address( + getdns_context_t context, + const char *name, + struct getdns_dict *extensions, + void *userarg, + getdns_transaction_t *transaction_id, + getdns_callback_t callback +) +{ + int cleanup_extensions = 0; + if (!extensions) { + extensions = getdns_dict_create(); + cleanup_extensions = 1; + } + getdns_dict_set_int(extensions, + GETDNS_STR_EXTENSION_RETURN_BOTH_V4_AND_V6, + GETDNS_EXTENSION_TRUE); + + getdns_return_t result = + getdns_general(context, name, GETDNS_RRTYPE_A, + extensions, userarg, transaction_id, + callback); + if (cleanup_extensions) { + getdns_dict_destroy(extensions); + } + return result; +} + /* getdns_general.c */