From 0d2f3a5bd9fe39d42039fa6583082900c66e2dd3 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 10 Jul 2015 00:57:58 +0200 Subject: [PATCH] functions and defines to get versions About the library and the API In both strings and in numbers --- ChangeLog | 6 ++ configure | 20 ++++++- configure.ac | 10 +++- src/Makefile.in | 14 +++-- .../{getdns_extra.h => getdns_extra.h.in} | 9 +++ src/libgetdns.symbols | 4 ++ src/version.c.in | 56 +++++++++++++++++++ 7 files changed, 109 insertions(+), 10 deletions(-) rename src/getdns/{getdns_extra.h => getdns_extra.h.in} (97%) create mode 100644 src/version.c.in diff --git a/ChangeLog b/ChangeLog index 402ddd1d..b7d0f398 100644 --- a/ChangeLog +++ b/ChangeLog @@ -12,6 +12,12 @@ * getdns_validate_dnssec() accept replies from the replies_tree * getdns_validate_dnssec() asses negative and insecure responses. * Native stub dnssec validation + * Implemented getdns_context_set_dnssec_trust_anchors() + * Switch freely between stub and recursive mode + * getdns_query -k shows default trust anchors + * functions and defines to get library and API versions in string + and numeric values: getdns_get_version(), getdns_get_version_number(), + getdns_get_api_version() and getdns_get_api_version_number() * 2015-05-21: Version 0.2.0 * Fix libversion numbering: Thanks Daniel Kahn Gillmor diff --git a/configure b/configure index b3b5a75f..d1b39ef2 100755 --- a/configure +++ b/configure @@ -707,6 +707,10 @@ CFLAGS CC GETDNS_LIBVERSION GETDNS_COMPILATION_COMMENT +API_NUMERIC_VERSION +API_VERSION +GETDNS_NUMERIC_VERSION +GETDNS_VERSION RELEASE_CANDIDATE target_alias host_alias @@ -2381,7 +2385,17 @@ else CURRENT_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`" fi -GETDNS_COMPILATION_COMMENT="getdns 0.3.0 configured on $CURRENT_DATE for the January 2015 version of the API" + +GETDNS_VERSION="0.3.0$RELEASE_CANDIDATE" + +GETDNS_NUMERIC_VERSION=0x00030000 + +API_VERSION="July 2015" + +API_NUMERIC_VERSION=0x07df0700 + +GETDNS_COMPILATION_COMMENT="getdns $GETDNS_VERSION configured on $CURRENT_DATE for the $API_VERSION version of the API" + # Library version # --------------- @@ -13895,7 +13909,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: Default trust anchor: $TRUST_ANCHOR_FILE" >&5 $as_echo "$as_me: Default trust anchor: $TRUST_ANCHOR_FILE" >&6;} -ac_config_files="$ac_config_files Makefile src/Makefile src/getdns/getdns.h spec/example/Makefile src/test/Makefile doc/Makefile" +ac_config_files="$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" if test -n "$DOXYGEN" then ac_config_files="$ac_config_files src/Doxyfile" @@ -15349,7 +15363,9 @@ do "disable-rpath") CONFIG_COMMANDS="$CONFIG_COMMANDS disable-rpath" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile" ;; + "src/version.c") CONFIG_FILES="$CONFIG_FILES src/version.c" ;; "src/getdns/getdns.h") CONFIG_FILES="$CONFIG_FILES src/getdns/getdns.h" ;; + "src/getdns/getdns_extra.h") CONFIG_FILES="$CONFIG_FILES src/getdns/getdns_extra.h" ;; "spec/example/Makefile") CONFIG_FILES="$CONFIG_FILES spec/example/Makefile" ;; "src/test/Makefile") CONFIG_FILES="$CONFIG_FILES src/test/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; diff --git a/configure.ac b/configure.ac index c67d8ec8..252dc377 100644 --- a/configure.ac +++ b/configure.ac @@ -40,7 +40,13 @@ AC_ARG_WITH([current-date], [current date of the compilation, set to fixed date for reproducible builds @<:@default=system@:>@])], [CURRENT_DATE="$with_current_date"], [CURRENT_DATE="`date -u +%Y-%m-%dT%H:%M:%SZ`"]) -GETDNS_COMPILATION_COMMENT="AC_PACKAGE_STRING configured on $CURRENT_DATE for the January 2015 version of the API" + +AC_SUBST(GETDNS_VERSION, ["AC_PACKAGE_VERSION$RELEASE_CANDIDATE"]) +AC_SUBST(GETDNS_NUMERIC_VERSION, [0x00030000]) +AC_SUBST(API_VERSION, ["July 2015"]) +AC_SUBST(API_NUMERIC_VERSION, [0x07df0700]) +GETDNS_COMPILATION_COMMENT="AC_PACKAGE_NAME $GETDNS_VERSION configured on $CURRENT_DATE for the $API_VERSION version of the API" + # Library version # --------------- @@ -590,7 +596,7 @@ 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_CONFIG_FILES([Makefile src/Makefile src/getdns/getdns.h spec/example/Makefile src/test/Makefile doc/Makefile]) +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]) if [ test -n "$DOXYGEN" ] then AC_CONFIG_FILES([src/Doxyfile]) fi diff --git a/src/Makefile.in b/src/Makefile.in index d409096c..e368fa1f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -65,7 +65,7 @@ C99COMPATFLAGS=@C99COMPATFLAGS@ GETDNS_OBJ=const-info.lo convert.lo dict.lo dnssec.lo general.lo \ list.lo request-internal.lo rr-dict.lo rr-iter.lo stub.lo sync.lo \ - util-internal.lo + util-internal.lo version.lo GLDNS_OBJ=keyraw.lo gbuffer.lo wire2str.lo parse.lo parseutil.lo rrdef.lo \ str2wire.lo @@ -218,11 +218,12 @@ FORCE: # Dependencies for gldns, utils, the extensions and compat functions const-info.lo const-info.o: $(srcdir)/const-info.c getdns/getdns.h $(srcdir)/const-info.h -context.lo context.o: $(srcdir)/context.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h $(srcdir)/context.h \ - getdns/getdns.h $(srcdir)/getdns/getdns_extra.h getdns/getdns.h $(srcdir)/types-internal.h \ - $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h \ - $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \ - $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/list.h +context.lo context.o: $(srcdir)/context.c config.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h \ + $(srcdir)/gldns/wire2str.h $(srcdir)/context.h getdns/getdns.h $(srcdir)/getdns/getdns_extra.h \ + getdns/getdns.h $(srcdir)/types-internal.h $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h \ + config.h $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h \ + $(srcdir)/util-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h \ + $(srcdir)/dnssec.h $(srcdir)/stub.h $(srcdir)/list.h convert.lo convert.o: $(srcdir)/convert.c getdns/getdns.h $(srcdir)/getdns/getdns_extra.h \ getdns/getdns.h $(srcdir)/util-internal.h config.h $(srcdir)/context.h $(srcdir)/types-internal.h \ $(srcdir)/util/rbtree.h $(srcdir)/extension/libmini_event.h config.h $(srcdir)/util/mini_event.h \ @@ -277,6 +278,7 @@ util-internal.lo util-internal.o: $(srcdir)/util-internal.c getdns/getdns.h $(sr $(srcdir)/util-internal.h config.h $(srcdir)/context.h $(srcdir)/extension/libmini_event.h config.h \ $(srcdir)/util/mini_event.h $(srcdir)/util/rbtree.h $(srcdir)/types-internal.h $(srcdir)/rr-iter.h $(srcdir)/rr-dict.h \ $(srcdir)/gldns/gbuffer.h $(srcdir)/gldns/pkthdr.h $(srcdir)/gldns/str2wire.h $(srcdir)/gldns/rrdef.h +version.lo version.o: $(srcdir)/version.c gbuffer.lo gbuffer.o: $(srcdir)/gldns/gbuffer.c config.h $(srcdir)/gldns/gbuffer.h keyraw.lo keyraw.o: $(srcdir)/gldns/keyraw.c config.h $(srcdir)/gldns/keyraw.h $(srcdir)/gldns/rrdef.h parse.lo parse.o: $(srcdir)/gldns/parse.c config.h $(srcdir)/gldns/parse.h $(srcdir)/gldns/parseutil.h \ diff --git a/src/getdns/getdns_extra.h b/src/getdns/getdns_extra.h.in similarity index 97% rename from src/getdns/getdns_extra.h rename to src/getdns/getdns_extra.h.in index 36e0497d..55c71254 100644 --- a/src/getdns/getdns_extra.h +++ b/src/getdns/getdns_extra.h.in @@ -339,6 +339,15 @@ const char *getdns_get_errorstr_by_id(uint16_t err); */ getdns_return_t getdns_strerror(getdns_return_t err, char *buf, size_t buflen); +#define GETDNS_VERSION "@GETDNS_VERSION@" +#define GETDNS_NUMERIC_VERSION @GETDNS_NUMERIC_VERSION@ +#define GETDNS_API_VERSION "@API_VERSION@" +#define GETDNS_API_NUMERIC_VERSION @API_NUMERIC_VERSION@ + +const char *getdns_get_version(void); +uint32_t getdns_get_version_number(void); +const char *getdns_get_api_version(void); +uint32_t getdns_get_api_version_number(void); #ifdef __cplusplus } diff --git a/src/libgetdns.symbols b/src/libgetdns.symbols index 182b4d7b..3eb60c4a 100644 --- a/src/libgetdns.symbols +++ b/src/libgetdns.symbols @@ -79,7 +79,11 @@ getdns_dict_util_set_string getdns_display_ip_address getdns_general getdns_general_sync +getdns_get_api_version +getdns_get_api_version_number getdns_get_errorstr_by_id +getdns_get_version +getdns_get_version_number getdns_hostname getdns_hostname_sync getdns_list_create diff --git a/src/version.c.in b/src/version.c.in new file mode 100644 index 00000000..94d862c9 --- /dev/null +++ b/src/version.c.in @@ -0,0 +1,56 @@ +/** + * + * /brief function for returning version info about the library and the API + * + */ + +/* + * 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 + +const char *getdns_get_version(void) +{ + return "@GETDNS_VERSION@"; +} + +uint32_t getdns_get_version_number(void) +{ + return @GETDNS_NUMERIC_VERSION@; +} + +const char *getdns_get_api_version(void) +{ + return "@API_VERSION@"; +} + +uint32_t getdns_get_api_version_number(void) +{ + return @API_NUMERIC_VERSION@; +} + +/* version.c */