From owner-svn-src-head@FreeBSD.ORG Sat Apr 13 22:44:50 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id B476BC47; Sat, 13 Apr 2013 22:44:50 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id A48F71685; Sat, 13 Apr 2013 22:44:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r3DMio5o021015; Sat, 13 Apr 2013 22:44:50 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r3DMin08021009; Sat, 13 Apr 2013 22:44:49 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201304132244.r3DMin08021009@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Sat, 13 Apr 2013 22:44:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r249453 - in head/contrib/ldns: compat ldns X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 13 Apr 2013 22:44:50 -0000 Author: des Date: Sat Apr 13 22:44:48 2013 New Revision: 249453 URL: http://svnweb.freebsd.org/changeset/base/249453 Log: Clean up the ntop / pton code. Part of a patch which has been submitted upstream but not yet adopted. Modified: head/contrib/ldns/compat/b32_ntop.c head/contrib/ldns/compat/b32_pton.c head/contrib/ldns/compat/b64_ntop.c head/contrib/ldns/compat/b64_pton.c head/contrib/ldns/ldns/config.h head/contrib/ldns/ldns/util.h Modified: head/contrib/ldns/compat/b32_ntop.c ============================================================================== --- head/contrib/ldns/compat/b32_ntop.c Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/compat/b32_ntop.c Sat Apr 13 22:44:48 2013 (r249453) @@ -40,6 +40,7 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include +#ifndef HAVE_B32_NTOP #include #include @@ -61,6 +62,8 @@ #include +#include + static const char Base32[] = "abcdefghijklmnopqrstuvwxyz234567"; /* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/ @@ -171,7 +174,7 @@ static const char Pad32 = '='; */ -int +static int ldns_b32_ntop_ar(uint8_t const *src, size_t srclength, char *target, size_t targsize, const char B32_ar[]) { size_t datalength = 0; uint8_t input[5]; @@ -331,3 +334,4 @@ b32_ntop_extended_hex(uint8_t const *src return ldns_b32_ntop_ar(src, srclength, target, targsize, Base32_extended_hex); } +#endif /* !HAVE_B32_NTOP */ Modified: head/contrib/ldns/compat/b32_pton.c ============================================================================== --- head/contrib/ldns/compat/b32_pton.c Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/compat/b32_pton.c Sat Apr 13 22:44:48 2013 (r249453) @@ -40,6 +40,7 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include +#ifndef HAVE_B32_PTON #include #include @@ -59,6 +60,8 @@ #include #include +#include + /* "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";*/ static const char Base32[] = "abcdefghijklmnopqrstuvwxyz234567"; @@ -174,7 +177,7 @@ static const char Pad32 = '='; it returns the number of data bytes stored at the target, or -1 on error. */ -int +static int ldns_b32_pton_ar(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize, const char B32_ar[]) { int tarindex, state, ch; @@ -385,3 +388,5 @@ b32_pton_extended_hex(char const *src, s { return ldns_b32_pton_ar(src, hashed_owner_str_len, target, targsize, Base32_extended_hex); } + +#endif /* !HAVE_B32_PTON */ Modified: head/contrib/ldns/compat/b64_ntop.c ============================================================================== --- head/contrib/ldns/compat/b64_ntop.c Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/compat/b64_ntop.c Sat Apr 13 22:44:48 2013 (r249453) @@ -40,6 +40,7 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include +#ifndef HAVE_B64_NTOP #include #include @@ -59,6 +60,8 @@ #include #include +#include + #define Assert(Cond) if (!(Cond)) abort() static const char Base64[] = @@ -200,3 +203,5 @@ ldns_b64_ntop(uint8_t const *src, size_t target[datalength] = '\0'; /* Returned value doesn't count \0. */ return (int) (datalength); } + +#endif /* !HAVE_B64_NTOP */ Modified: head/contrib/ldns/compat/b64_pton.c ============================================================================== --- head/contrib/ldns/compat/b64_pton.c Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/compat/b64_pton.c Sat Apr 13 22:44:48 2013 (r249453) @@ -40,6 +40,7 @@ * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. */ #include +#ifndef HAVE_B64_PTON #include #include @@ -59,7 +60,7 @@ #include #include -#define Assert(Cond) if (!(Cond)) abort() +#include static const char Base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; @@ -258,3 +259,5 @@ ldns_b64_pton(char const *src, uint8_t * return (tarindex); } + +#endif /* !HAVE_B64_PTON */ Modified: head/contrib/ldns/ldns/config.h ============================================================================== --- head/contrib/ldns/ldns/config.h Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/ldns/config.h Sat Apr 13 22:44:48 2013 (r249453) @@ -489,30 +489,6 @@ extern "C" { #endif -#ifndef B64_PTON -int ldns_b64_ntop(uint8_t const *src, size_t srclength, - char *target, size_t targsize); -/** - * calculates the size needed to store the result of b64_ntop - */ -/*@unused@*/ -static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize) -{ - return ((((srcsize + 2) / 3) * 4) + 1); -} -#endif /* !B64_PTON */ -#ifndef B64_NTOP -int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize); -/** - * calculates the size needed to store the result of ldns_b64_pton - */ -/*@unused@*/ -static inline size_t ldns_b64_pton_calculate_size(size_t srcsize) -{ - return (((((srcsize + 3) / 4) * 3)) + 1); -} -#endif /* !B64_NTOP */ - #ifndef HAVE_SLEEP /* use windows sleep, in millisecs, instead */ #define sleep(x) Sleep((x)*1000) Modified: head/contrib/ldns/ldns/util.h ============================================================================== --- head/contrib/ldns/ldns/util.h Sat Apr 13 22:30:02 2013 (r249452) +++ head/contrib/ldns/ldns/util.h Sat Apr 13 22:44:48 2013 (r249453) @@ -325,7 +325,7 @@ uint16_t ldns_get_random(void); */ char *ldns_bubblebabble(uint8_t *data, size_t len); -#ifndef B32_NTOP +#ifndef HAVE_B32_NTOP int ldns_b32_ntop(uint8_t const *src, size_t srclength, char *target, size_t targsize); int b32_ntop(uint8_t const *src, size_t srclength, @@ -343,8 +343,8 @@ INLINE size_t ldns_b32_ntop_calculate_si size_t result = ((((srcsize / 5) * 8) - 2) + 2); return result; } -#endif /* !B32_NTOP */ -#ifndef B32_PTON +#endif /* !HAVE_B32_NTOP */ +#ifndef HAVE_B32_PTON int ldns_b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize); int b32_pton(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize); int ldns_b32_pton_extended_hex(char const *src, size_t hashed_owner_str_len, uint8_t *target, size_t targsize); @@ -358,7 +358,30 @@ INLINE size_t ldns_b32_pton_calculate_si size_t result = ((((srcsize) / 8) * 5)); return result; } -#endif /* !B32_PTON */ +#endif /* !HAVE_B32_PTON */ +#ifndef HAVE_B64_NTOP +int ldns_b64_ntop(uint8_t const *src, size_t srclength, + char *target, size_t targsize); +/** + * calculates the size needed to store the result of b64_ntop + */ +/*@unused@*/ +static inline size_t ldns_b64_ntop_calculate_size(size_t srcsize) +{ + return ((((srcsize + 2) / 3) * 4) + 1); +} +#endif /* !HAVE_B64_NTOP */ +#ifndef HAVE_B64_PTON +int ldns_b64_pton(char const *src, uint8_t *target, size_t targsize); +/** + * calculates the size needed to store the result of ldns_b64_pton + */ +/*@unused@*/ +static inline size_t ldns_b64_pton_calculate_size(size_t srcsize) +{ + return (((((srcsize + 3) / 4) * 3)) + 1); +} +#endif /* !HAVE_B64_PTON */ INLINE time_t ldns_time(time_t *t) { return time(t); }