Commit ca6285fd authored by Daniel Salzman's avatar Daniel Salzman

utils: move strtonum to contrib

parent 46a9ce0c
...@@ -51,6 +51,7 @@ src/contrib/sockaddr.c ...@@ -51,6 +51,7 @@ src/contrib/sockaddr.c
src/contrib/sockaddr.h src/contrib/sockaddr.h
src/contrib/string.c src/contrib/string.c
src/contrib/string.h src/contrib/string.h
src/contrib/strtonum.h
src/contrib/time.h src/contrib/time.h
src/contrib/tolower.h src/contrib/tolower.h
src/contrib/trim.h src/contrib/trim.h
...@@ -157,7 +158,6 @@ src/dnssec/shared/pem.c ...@@ -157,7 +158,6 @@ src/dnssec/shared/pem.c
src/dnssec/shared/pem.h src/dnssec/shared/pem.h
src/dnssec/shared/print.h src/dnssec/shared/print.h
src/dnssec/shared/shared.h src/dnssec/shared/shared.h
src/dnssec/shared/strtonum.h
src/dnssec/shared/timestamp.c src/dnssec/shared/timestamp.c
src/dnssec/shared/timestamp.h src/dnssec/shared/timestamp.h
src/dnssec/shared/wire.h src/dnssec/shared/wire.h
...@@ -184,7 +184,6 @@ src/dnssec/tests/sample_keys.h ...@@ -184,7 +184,6 @@ src/dnssec/tests/sample_keys.h
src/dnssec/tests/shared_base32hex.c src/dnssec/tests/shared_base32hex.c
src/dnssec/tests/shared_bignum.c src/dnssec/tests/shared_bignum.c
src/dnssec/tests/shared_dname.c src/dnssec/tests/shared_dname.c
src/dnssec/tests/shared_strtonum.c
src/dnssec/tests/shared_timestamp.c src/dnssec/tests/shared_timestamp.c
src/dnssec/tests/shared_wire.c src/dnssec/tests/shared_wire.c
src/dnssec/tests/sign.c src/dnssec/tests/sign.c
...@@ -234,6 +233,18 @@ src/knot/dnssec/zone-nsec.c ...@@ -234,6 +233,18 @@ src/knot/dnssec/zone-nsec.c
src/knot/dnssec/zone-nsec.h src/knot/dnssec/zone-nsec.h
src/knot/dnssec/zone-sign.c src/knot/dnssec/zone-sign.c
src/knot/dnssec/zone-sign.h src/knot/dnssec/zone-sign.h
src/knot/events/events.c
src/knot/events/events.h
src/knot/events/handlers.h
src/knot/events/handlers/dnssec.c
src/knot/events/handlers/expire.c
src/knot/events/handlers/flush.c
src/knot/events/handlers/load.c
src/knot/events/handlers/notify.c
src/knot/events/handlers/refresh.c
src/knot/events/handlers/update.c
src/knot/events/replan.c
src/knot/events/replan.h
src/knot/modules/dnsproxy.c src/knot/modules/dnsproxy.c
src/knot/modules/dnsproxy.h src/knot/modules/dnsproxy.h
src/knot/modules/dnstap.c src/knot/modules/dnstap.c
...@@ -249,20 +260,17 @@ src/knot/modules/synth_record.c ...@@ -249,20 +260,17 @@ src/knot/modules/synth_record.c
src/knot/modules/synth_record.h src/knot/modules/synth_record.h
src/knot/nameserver/axfr.c src/knot/nameserver/axfr.c
src/knot/nameserver/axfr.h src/knot/nameserver/axfr.h
src/knot/nameserver/capture.c
src/knot/nameserver/capture.h
src/knot/nameserver/chaos.c src/knot/nameserver/chaos.c
src/knot/nameserver/chaos.h src/knot/nameserver/chaos.h
src/knot/nameserver/internet.c src/knot/nameserver/internet.c
src/knot/nameserver/internet.h src/knot/nameserver/internet.h
src/knot/nameserver/ixfr.c src/knot/nameserver/ixfr.c
src/knot/nameserver/ixfr.h src/knot/nameserver/ixfr.h
src/knot/nameserver/log.h
src/knot/nameserver/notify.c src/knot/nameserver/notify.c
src/knot/nameserver/notify.h src/knot/nameserver/notify.h
src/knot/nameserver/nsec_proofs.c src/knot/nameserver/nsec_proofs.c
src/knot/nameserver/nsec_proofs.h src/knot/nameserver/nsec_proofs.h
src/knot/nameserver/process_answer.c
src/knot/nameserver/process_answer.h
src/knot/nameserver/process_query.c src/knot/nameserver/process_query.c
src/knot/nameserver/process_query.h src/knot/nameserver/process_query.h
src/knot/nameserver/query_module.c src/knot/nameserver/query_module.c
...@@ -271,6 +279,14 @@ src/knot/nameserver/tsig_ctx.c ...@@ -271,6 +279,14 @@ src/knot/nameserver/tsig_ctx.c
src/knot/nameserver/tsig_ctx.h src/knot/nameserver/tsig_ctx.h
src/knot/nameserver/update.c src/knot/nameserver/update.c
src/knot/nameserver/update.h src/knot/nameserver/update.h
src/knot/query/capture.c
src/knot/query/capture.h
src/knot/query/layer.c
src/knot/query/layer.h
src/knot/query/query.c
src/knot/query/query.h
src/knot/query/requestor.c
src/knot/query/requestor.h
src/knot/server/dthreads.c src/knot/server/dthreads.c
src/knot/server/dthreads.h src/knot/server/dthreads.h
src/knot/server/journal.c src/knot/server/journal.c
...@@ -301,12 +317,6 @@ src/knot/worker/queue.c ...@@ -301,12 +317,6 @@ src/knot/worker/queue.c
src/knot/worker/queue.h src/knot/worker/queue.h
src/knot/zone/contents.c src/knot/zone/contents.c
src/knot/zone/contents.h src/knot/zone/contents.h
src/knot/zone/events/events.c
src/knot/zone/events/events.h
src/knot/zone/events/handlers.c
src/knot/zone/events/handlers.h
src/knot/zone/events/replan.c
src/knot/zone/events/replan.h
src/knot/zone/node.c src/knot/zone/node.c
src/knot/zone/node.h src/knot/zone/node.h
src/knot/zone/semantic-check.c src/knot/zone/semantic-check.c
...@@ -362,12 +372,6 @@ src/libknot/packet/rrset-wire.c ...@@ -362,12 +372,6 @@ src/libknot/packet/rrset-wire.c
src/libknot/packet/rrset-wire.h src/libknot/packet/rrset-wire.h
src/libknot/packet/wire.c src/libknot/packet/wire.c
src/libknot/packet/wire.h src/libknot/packet/wire.h
src/libknot/processing/layer.c
src/libknot/processing/layer.h
src/libknot/processing/overlay.c
src/libknot/processing/overlay.h
src/libknot/processing/requestor.c
src/libknot/processing/requestor.h
src/libknot/rdata.c src/libknot/rdata.c
src/libknot/rdata.h src/libknot/rdata.h
src/libknot/rdataset.c src/libknot/rdataset.c
...@@ -429,7 +433,6 @@ src/utils/common/resolv.c ...@@ -429,7 +433,6 @@ src/utils/common/resolv.c
src/utils/common/resolv.h src/utils/common/resolv.h
src/utils/common/sign.c src/utils/common/sign.c
src/utils/common/sign.h src/utils/common/sign.h
src/utils/common/strtonum.h
src/utils/common/token.c src/utils/common/token.c
src/utils/common/token.h src/utils/common/token.h
src/utils/kdig/kdig_exec.c src/utils/kdig/kdig_exec.c
...@@ -509,6 +512,7 @@ tests/conf.c ...@@ -509,6 +512,7 @@ tests/conf.c
tests/conf_tools.c tests/conf_tools.c
tests/confdb.c tests/confdb.c
tests/confio.c tests/confio.c
tests/contrib/test_strtonum.c
tests/control.c tests/control.c
tests/db.c tests/db.c
tests/descriptor.c tests/descriptor.c
...@@ -528,7 +532,6 @@ tests/modules/online_sign.c ...@@ -528,7 +532,6 @@ tests/modules/online_sign.c
tests/net.c tests/net.c
tests/net_shortwrite.c tests/net_shortwrite.c
tests/node.c tests/node.c
tests/overlay.c
tests/pkt.c tests/pkt.c
tests/process_answer.c tests/process_answer.c
tests/process_query.c tests/process_query.c
......
libtap libtap
src src
src/contrib src/contrib
src/dnssec
src/dnssec/lib src/dnssec/lib
src/dnssec/lib/dnssec src/dnssec/lib/dnssec
src/dnssec/shared src/dnssec/shared
......
...@@ -59,6 +59,7 @@ libcontrib_la_SOURCES = \ ...@@ -59,6 +59,7 @@ libcontrib_la_SOURCES = \
contrib/sockaddr.h \ contrib/sockaddr.h \
contrib/string.c \ contrib/string.c \
contrib/string.h \ contrib/string.h \
contrib/strtonum.h \
contrib/time.h \ contrib/time.h \
contrib/tolower.h \ contrib/tolower.h \
contrib/trim.h \ contrib/trim.h \
...@@ -204,7 +205,6 @@ libknotus_la_SOURCES = \ ...@@ -204,7 +205,6 @@ libknotus_la_SOURCES = \
utils/common/resolv.h \ utils/common/resolv.h \
utils/common/sign.c \ utils/common/sign.c \
utils/common/sign.h \ utils/common/sign.h \
utils/common/strtonum.h \
utils/common/token.c \ utils/common/token.c \
utils/common/token.h utils/common/token.h
......
/* Copyright (C) 2014 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -20,15 +20,14 @@ ...@@ -20,15 +20,14 @@
#include <inttypes.h> #include <inttypes.h>
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include "error.h" #include "libknot/errcode.h"
inline static int intmax_from_str(const char *src, intmax_t *dest) inline static int intmax_from_str(const char *src, intmax_t *dest)
{ {
if (!isdigit((int)*src) && *src != '-' && *src != '+') { if (!isdigit((int)*src) && *src != '-' && *src != '+') {
return DNSSEC_MALFORMED_DATA; return KNOT_EINVAL;
} }
errno = 0; errno = 0;
...@@ -36,21 +35,21 @@ inline static int intmax_from_str(const char *src, intmax_t *dest) ...@@ -36,21 +35,21 @@ inline static int intmax_from_str(const char *src, intmax_t *dest)
intmax_t result = strtoimax(src, &end, 10); intmax_t result = strtoimax(src, &end, 10);
if (errno == ERANGE) { if (errno == ERANGE) {
return DNSSEC_OUT_OF_RANGE; return KNOT_ERANGE;
} }
if (src == end || *end != '\0') { if (src == end || *end != '\0') {
return DNSSEC_MALFORMED_DATA; return KNOT_EINVAL;
} }
*dest = result; *dest = result;
return DNSSEC_EOK; return KNOT_EOK;
} }
inline static int uintmax_from_str(const char *src, uintmax_t *dest) inline static int uintmax_from_str(const char *src, uintmax_t *dest)
{ {
if (!isdigit((int)*src) && *src != '-' && *src != '+') { if (!isdigit((int)*src) && *src != '-' && *src != '+') {
return DNSSEC_MALFORMED_DATA; return KNOT_EINVAL;
} }
errno = 0; errno = 0;
...@@ -58,29 +57,29 @@ inline static int uintmax_from_str(const char *src, uintmax_t *dest) ...@@ -58,29 +57,29 @@ inline static int uintmax_from_str(const char *src, uintmax_t *dest)
uintmax_t result = strtoumax(src, &end, 10); uintmax_t result = strtoumax(src, &end, 10);
if (errno == ERANGE) { if (errno == ERANGE) {
return DNSSEC_OUT_OF_RANGE; return KNOT_ERANGE;
} }
if (src == end || *end != '\0') { if (src == end || *end != '\0') {
return DNSSEC_MALFORMED_DATA; return KNOT_EINVAL;
} }
*dest = result; *dest = result;
return DNSSEC_EOK; return KNOT_EOK;
} }
#define CONVERT(prefix, type, min, max, src, dest) \ #define CONVERT(prefix, type, min, max, src, dest) \
{ \ { \
prefix##max_t value; \ prefix##max_t value; \
int result = prefix##max_from_str(src, &value); \ int result = prefix##max_from_str(src, &value); \
if (result != DNSSEC_EOK) { \ if (result != KNOT_EOK) { \
return result; \ return result; \
} \ } \
if (CHECK_MIN_##min(value, min) || value > (max)) { \ if (CHECK_MIN_##min(value, min) || value > (max)) { \
return DNSSEC_OUT_OF_RANGE; \ return KNOT_ERANGE; \
} \ } \
*dest = (type)value; \ *dest = (type)value; \
return DNSSEC_EOK; \ return KNOT_EOK; \
} }
#define CHECK_MIN_0(value, min) 0 #define CHECK_MIN_0(value, min) 0
......
...@@ -37,7 +37,6 @@ libshared_la_SOURCES = \ ...@@ -37,7 +37,6 @@ libshared_la_SOURCES = \
shared/pem.c \ shared/pem.c \
shared/pem.h \ shared/pem.h \
shared/shared.h \ shared/shared.h \
shared/strtonum.h \
shared/timestamp.c \ shared/timestamp.c \
shared/timestamp.h \ shared/timestamp.h \
shared/wire.h shared/wire.h
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "key.h" #include "key.h"
#include "keyid.h" #include "keyid.h"
#include "shared.h" #include "shared.h"
#include "strtonum.h"
#include "timestamp.h" #include "timestamp.h"
int decode_ignore(_unused_ const json_t *value, _unused_ void *result) int decode_ignore(_unused_ const json_t *value, _unused_ void *result)
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
/shared_base32hex /shared_base32hex
/shared_bignum /shared_bignum
/shared_dname /shared_dname
/shared_strtonum
/shared_timestamp /shared_timestamp
/shared_wire /shared_wire
/sign /sign
......
...@@ -42,7 +42,6 @@ check_PROGRAMS = \ ...@@ -42,7 +42,6 @@ check_PROGRAMS = \
shared_base32hex \ shared_base32hex \
shared_bignum \ shared_bignum \
shared_dname \ shared_dname \
shared_strtonum \
shared_timestamp \ shared_timestamp \
shared_wire \ shared_wire \
tsig tsig
......
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*!
* \file strtonum.h
*
* \brief Universal interface for safe conversion of strings to numbers.
*
* \author Jan Vcelak <jan.vcelak@nic.cz>
*
* \addtogroup common_lib
* @{
*/
#pragma once
#include <limits.h>
#include <stdint.h>
#include <stdlib.h>
#include "libknot/libknot.h"
typedef long long int knot_strtoll_result_t;
typedef unsigned long long int knot_strtoull_result_t;
/*!
* \brief Convert string to signed integer.
*
* \param[in] src Input string.
* \param[out] dest Output integral value.
*
* \return Error code.
* \retval KNOT_EOK The conversion was successful.
* \retval KNOT_ERANGE The value is outside target type range.
* \retval KNOT_EMALF The input value is not terminated.
*/
static int knot_strtoll(const char *src, knot_strtoll_result_t *dest)
{
char *end;
knot_strtoll_result_t result = strtoll(src, &end, 10);
if (errno == ERANGE)
return KNOT_ERANGE;
if (src == end || *end != '\0')
return KNOT_EMALF;
*dest = result;
return KNOT_EOK;
}
/*!
* \brief Convert string to unsigned integer.
*
* \see knot_strtoll
*/
static int knot_strtoull(const char *src, knot_strtoull_result_t *dest)
{
char *end;
knot_strtoull_result_t result = strtoull(src, &end, 10);
if (errno == ERANGE)
return KNOT_ERANGE;
if (src == end || *end != '\0')
return KNOT_EMALF;
*dest = result;
return KNOT_EOK;
}
/*!
* \brief Helper macro defining body of individual conversion functions.
*
* \param type Target data type.
* \param function Underlying conversion function.
* \param min Minimal value valid for given data type.
* \param max Maximal value valid for given data type.
* \param src Pointer to source string.
* \param dest Pointer to destination type.
*
* \return Error code.
* \retval KNOT_EOK The conversion was successful.
* \retval KNOT_ERANGE The value is outside target type range.
* \retval KNOT_EMALF The input value is not terminated.
*/
#define KNOT_STR2NUM(type, function, min, max, src, dest) \
{ \
function##_result_t value; \
errno = 0; \
int result = function((src), &value); \
if (result != KNOT_EOK) \
return result; \
\
if (value < (min) || value > (max)) \
return KNOT_ERANGE; \
\
*(dest) = (type)value; \
return KNOT_EOK; \
}
inline static int knot_str2int(const char *src, int *dest)
{
KNOT_STR2NUM(int, knot_strtoll, INT_MIN, INT_MAX, src, dest)
}
inline static int knot_str2uint8t(const char *src, uint8_t *dest)
{
KNOT_STR2NUM(uint8_t, knot_strtoull, 0, UINT8_MAX, src, dest)
}
inline static int knot_str2uint16t(const char *src, uint16_t *dest)
{
KNOT_STR2NUM(uint16_t, knot_strtoull, 0, UINT16_MAX, src, dest)
}
/*! @} */
...@@ -30,11 +30,11 @@ ...@@ -30,11 +30,11 @@
#include "cmdparse/command.h" #include "cmdparse/command.h"
#include "cmdparse/parameter.h" #include "cmdparse/parameter.h"
#include "cmdparse/value.h" #include "cmdparse/value.h"
#include "contrib/strtonum.h"
#include "legacy/key.h" #include "legacy/key.h"
#include "shared/dname.h" #include "shared/dname.h"
#include "shared/print.h" #include "shared/print.h"
#include "shared/shared.h" #include "shared/shared.h"
#include "shared/strtonum.h"
#include "shared/wire.h" #include "shared/wire.h"
#define PROGRAM_NAME "keymgr" #define PROGRAM_NAME "keymgr"
...@@ -206,7 +206,7 @@ static bool keytag_match(uint16_t keytag, const char *filter) ...@@ -206,7 +206,7 @@ static bool keytag_match(uint16_t keytag, const char *filter)
{ {
uint16_t converted = 0; uint16_t converted = 0;
return str_to_u16(filter, &converted) == DNSSEC_EOK && return str_to_u16(filter, &converted) == KNOT_EOK &&
keytag == converted; keytag == converted;
} }
...@@ -300,7 +300,7 @@ static int search_str_to_keytag(const char *search) ...@@ -300,7 +300,7 @@ static int search_str_to_keytag(const char *search)
uint16_t keytag = 0; uint16_t keytag = 0;
int r = str_to_u16(search, &keytag); int r = str_to_u16(search, &keytag);
return (r == DNSSEC_EOK ? keytag : -1); return (r == KNOT_EOK ? keytag : -1);
} }
/*! /*!
......
...@@ -17,10 +17,10 @@ ...@@ -17,10 +17,10 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include "contrib/strtonum.h"
#include "dnssec/binary.h" #include "dnssec/binary.h"
#include "dnssec/error.h" #include "dnssec/error.h"
#include "shared/shared.h" #include "shared/shared.h"
#include "shared/strtonum.h"
#include "utils/keymgr/legacy/privkey.h" #include "utils/keymgr/legacy/privkey.h"
/* -- private key params conversion ---------------------------------------- */ /* -- private key params conversion ---------------------------------------- */
...@@ -95,7 +95,7 @@ static int parse_algorithm(char *string, void *_algorithm) ...@@ -95,7 +95,7 @@ static int parse_algorithm(char *string, void *_algorithm)
uint8_t *algorithm = _algorithm; uint8_t *algorithm = _algorithm;
int r = str_to_u8(string, algorithm); int r = str_to_u8(string, algorithm);
return (r == DNSSEC_EOK ? DNSSEC_EOK : DNSSEC_INVALID_KEY_ALGORITHM); return (r == KNOT_EOK ? DNSSEC_EOK : DNSSEC_INVALID_KEY_ALGORITHM);
} }
/*! /*!
......
...@@ -17,9 +17,9 @@ ...@@ -17,9 +17,9 @@
#include <getopt.h> #include <getopt.h>
#include <stdio.h> #include <stdio.h>
#include "contrib/strtonum.h"
#include "knot/common/log.h" #include "knot/common/log.h"
#include "utils/common/params.h" #include "utils/common/params.h"
#include "utils/common/strtonum.h"
#include "utils/knotc/commands.h" #include "utils/knotc/commands.h"
#include "utils/knotc/interactive.h" #include "utils/knotc/interactive.h"
#include "utils/knotc/process.h" #include "utils/knotc/process.h"
...@@ -85,7 +85,7 @@ int main(int argc, char **argv) ...@@ -85,7 +85,7 @@ int main(int argc, char **argv)
params.socket = optarg; params.socket = optarg;
break; break;
case 't': case 't':
if (knot_str2int(optarg, &params.timeout) != KNOT_EOK) { if (str_to_int(optarg, &params.timeout) != KNOT_EOK) {
print_help(); print_help();
return EXIT_FAILURE; return EXIT_FAILURE;
} }
......
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "contrib/strtonum.h"
#include "dnssec/error.h" #include "dnssec/error.h"
#include "dnssec/nsec.h" #include "dnssec/nsec.h"
#include "shared/base32hex.h" #include "shared/base32hex.h"
#include "shared/dname.h" #include "shared/dname.h"
#include "shared/hex.h" #include "shared/hex.h"
#include "shared/print.h" #include "shared/print.h"
#include "shared/strtonum.h"
#define PROGRAM_NAME "knsec3hash" #define PROGRAM_NAME "knsec3hash"
...@@ -69,15 +69,15 @@ static bool parse_nsec3_params(dnssec_nsec3_params_t *params, const char *salt_s ...@@ -69,15 +69,15 @@ static bool parse_nsec3_params(dnssec_nsec3_params_t *params, const char *salt_s
{ {
uint8_t algorithm = 0; uint8_t algorithm = 0;
int r = str_to_u8(algorithm_str, &algorithm); int r = str_to_u8(algorithm_str, &algorithm);
if (r != DNSSEC_EOK) { if (r != KNOT_EOK) {
error("Invalid algorithm number."); error("Invalid algorithm number.");
return false; return false;
} }
uint16_t iterations = 0; uint16_t iterations = 0;
r = str_to_u16(iterations_str, &iterations); r = str_to_u16(iterations_str, &iterations);
if (r != DNSSEC_EOK) { if (r != KNOT_EOK) {
error("Invalid iteration count, %s.", dnssec_strerror(r)); error("Invalid iteration count.");
return false; return false;
} }
......
...@@ -12,6 +12,7 @@ conf_tools ...@@ -12,6 +12,7 @@ conf_tools
confdb confdb
confio confio
control control
contrib/test_strtonum
db db
descriptor descriptor
dname dname
......
...@@ -64,6 +64,7 @@ check_PROGRAMS = \ ...@@ -64,6 +64,7 @@ check_PROGRAMS = \
ztree ztree
check_PROGRAMS += \ check_PROGRAMS += \
contrib/test_strtonum \
modules/online_sign \ modules/online_sign \
utils/test_lookup utils/test_lookup
......
/* Copyright (C) 2015 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz> /* Copyright (C) 2016 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -16,12 +16,11 @@ ...@@ -16,12 +16,11 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <tap/basic.h> #include <tap/basic.h>
#include <assert.h>
#include <inttypes.h>
#include "contrib/strtonum.h"
#include "dnssec/error.h" #include "dnssec/error.h"
#include "strtonum.h"
static void test_u8(const char *in, uint8_t expected, int errcode) static void test_u8(const char *in, uint8_t expected, int errcode)
{ {
...@@ -29,9 +28,9 @@ static void test_u8(const char *in, uint8_t expected, int errcode) ...@@ -29,9 +28,9 @@ static void test_u8(const char *in, uint8_t expected, int errcode)
assert(expected != out); assert(expected != out);
ok(str_to_u8(in, &out) == errcode && ok(str_to_u8(in, &out) == errcode &&
(errcode != DNSSEC_EOK || out == expected), (errcode != KNOT_EOK || out == expected),
"str_to_u8 %s on \"%s\"", "str_to_u8 %s on \"%s\"",
(errcode == DNSSEC_EOK ? "succeeds" : "fails"), in); (errcode == KNOT_EOK ? "succeeds" : "fails"), in);
} }
static void test_u16(const char *in, uint16_t expected, int errcode) static void test_u16(const char *in, uint16_t expected, int errcode)
...@@ -40,9 +39,9 @@ static void test_u16(const char *in, uint16_t expected, int errcode) ...@@ -40,9 +39,9 @@ static void test_u16(const char *in, uint16_t expected, int errcode)
assert(expected != out); assert(expected != out);
ok(str_to_u16(in, &out) == errcode && ok(str_to_u16(in, &out) == errcode &&
(errcode != DNSSEC_EOK || out == expected), (errcode != KNOT_EOK ||