Commit 1084b40b authored by Ondřej Surý's avatar Ondřej Surý
Browse files

Replace custom isc_boolean_t with C standard bool type

(cherry picked from commit 994e6569)
(cherry picked from commit 88492940)
parent aaa76dc6
......@@ -14,6 +14,7 @@
#include <config.h>
#include <stdbool.h>
#include <stdio.h>
#include <inttypes.h>
......@@ -87,15 +88,15 @@ static const char *dbtype[] = { "rbt" };
int debug = 0;
const char *journal = NULL;
isc_boolean_t nomerge = ISC_TRUE;
bool nomerge = true;
#if CHECK_LOCAL
isc_boolean_t docheckmx = ISC_TRUE;
isc_boolean_t dochecksrv = ISC_TRUE;
isc_boolean_t docheckns = ISC_TRUE;
bool docheckmx = true;
bool dochecksrv = true;
bool docheckns = true;
#else
isc_boolean_t docheckmx = ISC_FALSE;
isc_boolean_t dochecksrv = ISC_FALSE;
isc_boolean_t docheckns = ISC_FALSE;
bool docheckmx = false;
bool dochecksrv = false;
bool docheckns = false;
#endif
unsigned int zone_options = DNS_ZONEOPT_CHECKNS |
DNS_ZONEOPT_CHECKMX |
......@@ -149,7 +150,7 @@ add(char *key, int value) {
if (symtab == NULL) {
result = isc_symtab_create(sym_mctx, 100, freekey, sym_mctx,
ISC_FALSE, &symtab);
false, &symtab);
if (result != ISC_R_SUCCESS)
return;
}
......@@ -165,20 +166,20 @@ add(char *key, int value) {
isc_mem_free(sym_mctx, key);
}
static isc_boolean_t
static bool
logged(char *key, int value) {
isc_result_t result;
if (symtab == NULL)
return (ISC_FALSE);
return (false);
result = isc_symtab_lookup(symtab, key, value, NULL);
if (result == ISC_R_SUCCESS)
return (ISC_TRUE);
return (ISC_FALSE);
return (true);
return (false);
}
static isc_boolean_t
static bool
checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
dns_rdataset_t *a, dns_rdataset_t *aaaa)
{
......@@ -189,8 +190,8 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
char addrbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:123.123.123.123")];
isc_boolean_t answer = ISC_TRUE;
isc_boolean_t match;
bool answer = true;
bool match;
const char *type;
void *ptr = NULL;
int result;
......@@ -239,7 +240,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
ownerbuf, namebuf,
cur->ai_canonname);
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
/* answer = false; */
add(namebuf, ERR_IS_CNAME);
}
break;
......@@ -255,7 +256,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
add(namebuf, ERR_NO_ADDRESSES);
}
/* XXX950 make fatal for 9.5.0 */
return (ISC_TRUE);
return (true);
default:
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
......@@ -264,7 +265,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
namebuf, gai_strerror(result));
add(namebuf, ERR_LOOKUP_FAILURE);
}
return (ISC_TRUE);
return (true);
}
/*
......@@ -275,13 +276,13 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
result = dns_rdataset_first(a);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(a, &rdata);
match = ISC_FALSE;
match = false;
for (cur = ai; cur != NULL; cur = cur->ai_next) {
if (cur->ai_family != AF_INET)
continue;
ptr = &((struct sockaddr_in *)(cur->ai_addr))->sin_addr;
if (memcmp(ptr, rdata.data, rdata.length) == 0) {
match = ISC_TRUE;
match = true;
break;
}
}
......@@ -293,7 +294,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
addrbuf, sizeof(addrbuf)));
add(namebuf, ERR_EXTRA_A);
/* XXX950 make fatal for 9.5.0 */
/* answer = ISC_FALSE; */
/* answer = false; */
}
dns_rdata_reset(&rdata);
result = dns_rdataset_next(a);
......@@ -305,13 +306,13 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
result = dns_rdataset_first(aaaa);
while (result == ISC_R_SUCCESS) {
dns_rdataset_current(aaaa, &rdata);
match = ISC_FALSE;
match = false;
for (cur = ai; cur != NULL; cur = cur->ai_next) {
if (cur->ai_family != AF_INET6)
continue;
ptr = &((struct sockaddr_in6 *)(cur->ai_addr))->sin6_addr;
if (memcmp(ptr, rdata.data, rdata.length) == 0) {
match = ISC_TRUE;
match = true;
break;
}
}
......@@ -323,7 +324,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
addrbuf, sizeof(addrbuf)));
add(namebuf, ERR_EXTRA_AAAA);
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
/* answer = false; */
}
dns_rdata_reset(&rdata);
result = dns_rdataset_next(aaaa);
......@@ -334,7 +335,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
* Check that all addresses appear in the glue.
*/
if (!logged(namebuf, ERR_MISSING_GLUE)) {
isc_boolean_t missing_glue = ISC_FALSE;
bool missing_glue = false;
for (cur = ai; cur != NULL; cur = cur->ai_next) {
switch (cur->ai_family) {
case AF_INET:
......@@ -350,7 +351,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
default:
continue;
}
match = ISC_FALSE;
match = false;
if (dns_rdataset_isassociated(rdataset))
result = dns_rdataset_first(rdataset);
else
......@@ -358,7 +359,7 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
while (result == ISC_R_SUCCESS && !match) {
dns_rdataset_current(rdataset, &rdata);
if (memcmp(ptr, rdata.data, rdata.length) == 0)
match = ISC_TRUE;
match = true;
dns_rdata_reset(&rdata);
result = dns_rdataset_next(rdataset);
}
......@@ -369,8 +370,8 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
inet_ntop(cur->ai_family, ptr,
addrbuf, sizeof(addrbuf)));
/* XXX950 make fatal for 9.5.0. */
/* answer = ISC_FALSE; */
missing_glue = ISC_TRUE;
/* answer = false; */
missing_glue = true;
}
}
if (missing_glue)
......@@ -379,11 +380,11 @@ checkns(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner,
freeaddrinfo(ai);
return (answer);
#else
return (ISC_TRUE);
return (true);
#endif
}
static isc_boolean_t
static bool
checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
#ifdef USE_GETADDRINFO
struct addrinfo hints, *ai, *cur;
......@@ -391,7 +392,7 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
isc_boolean_t answer = ISC_TRUE;
bool answer = true;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
......@@ -435,7 +436,7 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
add(namebuf, ERR_IS_MXCNAME);
}
if (level == ISC_LOG_ERROR)
answer = ISC_FALSE;
answer = false;
}
}
freeaddrinfo(ai);
......@@ -453,7 +454,7 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
add(namebuf, ERR_NO_ADDRESSES);
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
return (true);
default:
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
......@@ -462,14 +463,14 @@ checkmx(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
namebuf, gai_strerror(result));
add(namebuf, ERR_LOOKUP_FAILURE);
}
return (ISC_TRUE);
return (true);
}
#else
return (ISC_TRUE);
return (true);
#endif
}
static isc_boolean_t
static bool
checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
#ifdef USE_GETADDRINFO
struct addrinfo hints, *ai, *cur;
......@@ -477,7 +478,7 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
isc_boolean_t answer = ISC_TRUE;
bool answer = true;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
......@@ -520,7 +521,7 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
add(namebuf, ERR_IS_SRVCNAME);
}
if (level == ISC_LOG_ERROR)
answer = ISC_FALSE;
answer = false;
}
}
freeaddrinfo(ai);
......@@ -538,7 +539,7 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
add(namebuf, ERR_NO_ADDRESSES);
}
/* XXX950 make fatal for 9.5.0. */
return (ISC_TRUE);
return (true);
default:
if (!logged(namebuf, ERR_LOOKUP_FAILURE)) {
......@@ -547,10 +548,10 @@ checksrv(dns_zone_t *zone, dns_name_t *name, dns_name_t *owner) {
namebuf, gai_strerror(result));
add(namebuf, ERR_LOOKUP_FAILURE);
}
return (ISC_TRUE);
return (true);
}
#else
return (ISC_TRUE);
return (true);
#endif
}
......@@ -656,7 +657,7 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
if (dbiter != NULL)
dns_dbiterator_destroy(&dbiter);
if (version != NULL)
dns_db_closeversion(db, &version, ISC_FALSE);
dns_db_closeversion(db, &version, false);
if (db != NULL)
dns_db_detach(&db);
......@@ -702,8 +703,8 @@ load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
CHECK(dns_rdataclass_fromtext(&rdclass, &region));
dns_zone_setclass(zone, rdclass);
dns_zone_setoption(zone, zone_options, ISC_TRUE);
dns_zone_setoption2(zone, zone_options2, ISC_TRUE);
dns_zone_setoption(zone, zone_options, true);
dns_zone_setoption2(zone, zone_options2, true);
dns_zone_setoption(zone, DNS_ZONEOPT_NOMERGE, nomerge);
dns_zone_setmaxttl(zone, maxttl);
......@@ -795,4 +796,3 @@ DestroySockets(void) {
WSACleanup();
}
#endif
......@@ -16,6 +16,7 @@
/*! \file */
#include <inttypes.h>
#include <stdbool.h>
#include <isc/lang.h>
#include <isc/stdio.h>
......@@ -46,10 +47,10 @@ void DestroySockets(void);
extern int debug;
extern const char *journal;
extern isc_boolean_t nomerge;
extern isc_boolean_t docheckmx;
extern isc_boolean_t docheckns;
extern isc_boolean_t dochecksrv;
extern bool nomerge;
extern bool docheckmx;
extern bool docheckns;
extern bool dochecksrv;
extern unsigned int zone_options;
extern unsigned int zone_options2;
......
......@@ -15,6 +15,7 @@
#include <config.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdio.h>
......@@ -92,18 +93,18 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
return (ISC_R_SUCCESS);
}
static isc_boolean_t
static bool
get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
int i;
for (i = 0;; i++) {
if (maps[i] == NULL)
return (ISC_FALSE);
return (false);
if (cfg_map_get(maps[i], name, obj) == ISC_R_SUCCESS)
return (ISC_TRUE);
return (true);
}
}
static isc_boolean_t
static bool
get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
const cfg_listelt_t *element;
const cfg_obj_t *checknames;
......@@ -114,14 +115,14 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
for (i = 0;; i++) {
if (maps[i] == NULL)
return (ISC_FALSE);
return (false);
checknames = NULL;
result = cfg_map_get(maps[i], "check-names", &checknames);
if (result != ISC_R_SUCCESS)
continue;
if (checknames != NULL && !cfg_obj_islist(checknames)) {
*obj = checknames;
return (ISC_TRUE);
return (true);
}
for (element = cfg_list_first(checknames);
element != NULL;
......@@ -131,7 +132,7 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
if (strcasecmp(cfg_obj_asstring(type), "master") != 0)
continue;
*obj = cfg_tuple_get(value, "mode");
return (ISC_TRUE);
return (true);
}
}
}
......@@ -517,11 +518,11 @@ main(int argc, char **argv) {
isc_result_t result;
int exit_status = 0;
isc_entropy_t *ectx = NULL;
isc_boolean_t load_zones = ISC_FALSE;
isc_boolean_t print = ISC_FALSE;
bool load_zones = false;
bool print = false;
unsigned int flags = 0;
isc_commandline_errprint = ISC_FALSE;
isc_commandline_errprint = false;
/*
* Process memory debugging argument first.
......@@ -545,7 +546,7 @@ main(int argc, char **argv) {
break;
}
}
isc_commandline_reset = ISC_TRUE;
isc_commandline_reset = true;
RUNTIME_CHECK(isc_mem_create(0, 0, &mctx) == ISC_R_SUCCESS);
......@@ -556,7 +557,7 @@ main(int argc, char **argv) {
break;
case 'j':
nomerge = ISC_FALSE;
nomerge = false;
break;
case 'm':
......@@ -572,7 +573,7 @@ main(int argc, char **argv) {
break;
case 'p':
print = ISC_TRUE;
print = true;
break;
case 'v':
......@@ -584,10 +585,10 @@ main(int argc, char **argv) {
break;
case 'z':
load_zones = ISC_TRUE;
docheckmx = ISC_FALSE;
docheckns = ISC_FALSE;
dochecksrv = ISC_FALSE;
load_zones = true;
docheckmx = false;
docheckns = false;
dochecksrv = false;
break;
case '?':
......
......@@ -14,6 +14,7 @@
#include <config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <inttypes.h>
......@@ -111,8 +112,8 @@ main(int argc, char **argv) {
dns_masterrawheader_t header;
uint32_t rawversion = 1, serialnum = 0;
dns_ttl_t maxttl = 0;
isc_boolean_t snset = ISC_FALSE;
isc_boolean_t logdump = ISC_FALSE;
bool snset = false;
bool logdump = false;
FILE *errout = stdout;
char *endp;
......@@ -162,7 +163,7 @@ main(int argc, char **argv) {
#define ARGCMP(X) (strcmp(isc_commandline_argument, X) == 0)
isc_commandline_errprint = ISC_FALSE;
isc_commandline_errprint = false;
while ((c = isc_commandline_parse(argc, argv,
"c:df:hi:jJ:k:L:l:m:n:qr:s:t:o:vw:DF:M:S:T:W:"))
......@@ -180,33 +181,33 @@ main(int argc, char **argv) {
if (ARGCMP("full")) {
zone_options |= DNS_ZONEOPT_CHECKINTEGRITY |
DNS_ZONEOPT_CHECKSIBLING;
docheckmx = ISC_TRUE;
docheckns = ISC_TRUE;
dochecksrv = ISC_TRUE;
docheckmx = true;
docheckns = true;
dochecksrv = true;
} else if (ARGCMP("full-sibling")) {
zone_options |= DNS_ZONEOPT_CHECKINTEGRITY;
zone_options &= ~DNS_ZONEOPT_CHECKSIBLING;
docheckmx = ISC_TRUE;
docheckns = ISC_TRUE;
dochecksrv = ISC_TRUE;
docheckmx = true;
docheckns = true;
dochecksrv = true;
} else if (ARGCMP("local")) {
zone_options |= DNS_ZONEOPT_CHECKINTEGRITY;
zone_options |= DNS_ZONEOPT_CHECKSIBLING;
docheckmx = ISC_FALSE;
docheckns = ISC_FALSE;
dochecksrv = ISC_FALSE;
docheckmx = false;
docheckns = false;
dochecksrv = false;
} else if (ARGCMP("local-sibling")) {
zone_options |= DNS_ZONEOPT_CHECKINTEGRITY;
zone_options &= ~DNS_ZONEOPT_CHECKSIBLING;
docheckmx = ISC_FALSE;
docheckns = ISC_FALSE;
dochecksrv = ISC_FALSE;
docheckmx = false;
docheckns = false;
dochecksrv = false;
} else if (ARGCMP("none")) {
zone_options &= ~DNS_ZONEOPT_CHECKINTEGRITY;
zone_options &= ~DNS_ZONEOPT_CHECKSIBLING;
docheckmx = ISC_FALSE;
docheckns = ISC_FALSE;
dochecksrv = ISC_FALSE;
docheckmx = false;
docheckns = false;
dochecksrv = false;
} else {
fprintf(stderr, "invalid argument to -i: %s\n",
isc_commandline_argument);
......@@ -223,12 +224,12 @@ main(int argc, char **argv) {
break;
case 'j':
nomerge = ISC_FALSE;
nomerge = false;
break;
case 'J':
journal = isc_commandline_argument;
nomerge = ISC_FALSE;
nomerge = false;
break;
case 'k':
......@@ -249,7 +250,7 @@ main(int argc, char **argv) {
break;
case 'L':
snset = ISC_TRUE;
snset = true;
endp = NULL;
serialnum = strtol(isc_commandline_argument, &endp, 0);
if (*endp != '\0') {
......@@ -508,7 +509,7 @@ main(int argc, char **argv) {
strcmp(output_filename, "/dev/fd/1") == 0 ||
strcmp(output_filename, "/dev/stdout") == 0)) {
errout = stderr;
logdump = ISC_FALSE;
logdump = false;
}
if (isc_commandline_index + 2 != argc)
......
......@@ -19,6 +19,7 @@
#include <config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
......@@ -57,7 +58,7 @@
static char program[256];
const char *progname;
static enum { progmode_keygen, progmode_confgen} progmode;
isc_boolean_t verbose = ISC_FALSE; /* needed by util.c but not used here */
bool verbose = false; /* needed by util.c but not used here */
ISC_PLATFORM_NORETURN_PRE static void
usage(int status) ISC_PLATFORM_NORETURN_POST;
......@@ -90,8 +91,8 @@ Usage:\n\
int
main(int argc, char **argv) {
isc_result_t result = ISC_R_SUCCESS;
isc_boolean_t show_final_mem = ISC_FALSE;
isc_boolean_t quiet = ISC_FALSE;
bool show_final_mem = false;
bool quiet = false;
isc_buffer_t key_txtbuffer;
char key_txtsecret[256];
isc_mem_t *mctx = NULL;
......@@ -128,13 +129,13 @@ main(int argc, char **argv) {
if (PROGCMP("tsig-keygen")) {
progmode = progmode_keygen;
quiet = ISC_TRUE;
quiet = true;
} else if (PROGCMP("ddns-confgen"))
progmode = progmode_confgen;
else
INSIST(0);
isc_commandline_errprint = ISC_FALSE;
isc_commandline_errprint = false;
while ((ch = isc_commandline_parse(argc, argv,
"a:hk:Mmr:qs:y:z:")) != -1) {
......@@ -159,11 +160,11 @@ main(int argc, char **argv) {
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
break;
case 'm':
show_final_mem = ISC_TRUE;
show_final_mem = true;
break;
case 'q':
if (progmode == progmode_confgen)
quiet = ISC_TRUE;
quiet = true;
else
usage(1);
break;
......
......@@ -226,4 +226,3 @@ write_key_file(const char *keyfile, const char *user,
fatal("fclose(%s) failed\n", keyfile);
fprintf(stderr, "wrote key file \"%s\"\n", keyfile);
}
......@@ -24,6 +24,7 @@
#include <config.h>
#include <stdbool.h>
#include <stdlib.h>
#include <stdarg.h>
......@@ -60,7 +61,7 @@
static char program[256];
const char *progname;
isc_boolean_t verbose = ISC_FALSE;
bool verbose = false;
const char *keyfile, *keydef;
......@@ -109,7 +110,7 @@ Usage:\n\
int
main(int argc, char **argv) {
isc_boolean_t show_final_mem = ISC_FALSE;
bool show_final_mem = false;
isc_buffer_t key_txtbuffer;