diff --git a/src/const-info.h b/src/const-info.h new file mode 100644 index 00000000..38b96175 --- /dev/null +++ b/src/const-info.h @@ -0,0 +1,52 @@ +/** + * + * /brief priv_getdns_consts table with values, names and descriptions of the + * constants in getdns + * + * The priv_getdns_get_validation_chain function is called after an answer + * has been fetched when the dnssec_return_validation_chain extension is set. + * It fetches DNSKEYs, DSes and their signatures for all RRSIGs found in the + * answer. + */ + +/* + * Copyright (c) 2013, Versign, 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 name of the 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. + */ + +#ifndef CONST_INFO_H_ +#define CONST_INFO_H_ + +struct const_info { + int code; + const char *name; + const char *text; +}; + +struct const_info *priv_getdns_get_const_info(int value); + +#endif + +/* const-info.h */ diff --git a/src/getdns/getdns_error.h b/src/getdns/getdns_error.h deleted file mode 100644 index a437ee47..00000000 --- a/src/getdns/getdns_error.h +++ /dev/null @@ -1,35 +0,0 @@ -/** - * \file - * @brief defines and data structure for getdns_error_str_by_id() - * - * This source was taken from the original pseudo-implementation by - * Paul Hoffman. - */ - -#ifndef GETDNS_ERROR_H -#define GETDNS_ERROR_H - -#include - -struct getdns_struct_lookup_table -{ /* may or may not want to move this into */ - int id; /* getdns.h if it's more generally useful */ - const char *name; -}; - -typedef struct getdns_struct_lookup_table getdns_lookup_table; - -/** - * \defgroup error_table error number to string mapping - * @{ - */ - -extern getdns_lookup_table getdns_error_str[]; - -typedef enum getdns_enum_status getdns_status; -const char *getdns_get_errorstr_by_id(uint16_t err); - -/** @} - */ - -#endif /* GETDNS_ERROR_H */ diff --git a/src/mk-const-info.c.sh b/src/mk-const-info.c.sh new file mode 100755 index 00000000..17462423 --- /dev/null +++ b/src/mk-const-info.c.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +cat > const-info.c << END_OF_HEAD +/* WARNING! This file is generated by the mk-const-info.c.sh program. + * Do not edit manually! + */ +#include +#include +#include "const-info.h" + +static struct const_info consts_info[] = { + { -1, "/* */", "/* */" }, +END_OF_HEAD +awk '/^[ ]+GETDNS_[A-Z_]+[ ]+=[ ]+[0-9]+/{ print "\t{ "$3", \""$1"\", "$1"_TEXT }," }/^#define GETDNS_[A-Z_]+[ ]+[0-9]+/ && !/^#define GETDNS_RRTYPE/ && !/_TEXT/{ print "\t{ "$3", \""$2"\", "$2"_TEXT },"}' getdns/getdns.h | sed 's/,,/,/g' >> const-info.c +cat >> const-info.c << END_OF_TAIL +}; + +static int const_info_cmp(const void *a, const void *b) +{ + return ((struct const_info *) a)->code - ((struct const_info *) b)->code; +} +struct const_info * +priv_getdns_get_const_info(int value) +{ + struct const_info key = { value, "", "" }; + struct const_info *i = bsearch(&key, consts_info, + sizeof(consts_info) / sizeof(struct const_info), + sizeof(struct const_info), const_info_cmp); + if (i) + return i; + return consts_info; +} + +END_OF_TAIL + +