diff --git a/include/ares.h b/include/ares.h index b3661bd1..8c45622c 100644 --- a/include/ares.h +++ b/include/ares.h @@ -158,6 +158,11 @@ typedef enum { } ares_status_t; +typedef enum { + ARES_FALSE = 0, + ARES_TRUE = 1 +} ares_bool_t; + /* Flag values */ #define ARES_FLAG_USEVC (1 << 0) #define ARES_FLAG_PRIMARY (1 << 1) diff --git a/src/lib/ares__buf.c b/src/lib/ares__buf.c index e4ba84ed..f965db6c 100644 --- a/src/lib/ares__buf.c +++ b/src/lib/ares__buf.c @@ -84,15 +84,15 @@ void ares__buf_destroy(ares__buf_t *buf) } -static int ares__buf_is_const(const ares__buf_t *buf) +static ares_bool_t ares__buf_is_const(const ares__buf_t *buf) { if (buf == NULL) - return 0; + return ARES_FALSE; if (buf->data != NULL && buf->alloc_buf == NULL) - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } diff --git a/src/lib/ares__htable.c b/src/lib/ares__htable.c index 3ea65642..7ea9ec3f 100644 --- a/src/lib/ares__htable.c +++ b/src/lib/ares__htable.c @@ -160,7 +160,7 @@ static ares__llist_node_t *ares__htable_find(ares__htable_t *htable, } -static unsigned int ares__htable_expand(ares__htable_t *htable) +static ares_bool_t ares__htable_expand(ares__htable_t *htable) { ares__llist_t **buckets = NULL; unsigned int old_size = htable->size; @@ -168,7 +168,7 @@ static unsigned int ares__htable_expand(ares__htable_t *htable) /* Not a failure, just won't expand */ if (old_size == ARES__HTABLE_MAX_BUCKETS) - return 1; + return ARES_TRUE; htable->size <<= 1; @@ -207,24 +207,24 @@ static unsigned int ares__htable_expand(ares__htable_t *htable) /* Swap out buckets */ ares__htable_buckets_destroy(htable->buckets, old_size, 0); htable->buckets = buckets; - return 1; + return ARES_TRUE; fail: ares__htable_buckets_destroy(buckets, htable->size, 0); htable->size = old_size; - return 0; + return ARES_FALSE; } -unsigned int ares__htable_insert(ares__htable_t *htable, void *bucket) +ares_bool_t ares__htable_insert(ares__htable_t *htable, void *bucket) { unsigned int idx = 0; ares__llist_node_t *node = NULL; const void *key = NULL; if (htable == NULL || bucket == NULL) - return 0; + return ARES_FALSE; key = htable->bucket_key(bucket); @@ -234,14 +234,14 @@ unsigned int ares__htable_insert(ares__htable_t *htable, void *bucket) node = ares__htable_find(htable, idx, key); if (node != NULL) { ares__llist_node_replace(node, bucket); - return 1; + return ARES_TRUE; } /* Check to see if we should rehash because likelihood of collisions has * increased beyond our threshold */ if (htable->num_keys+1 > (htable->size * ARES__HTABLE_EXPAND_PERCENT) / 100) { if (!ares__htable_expand(htable)) { - return 0; + return ARES_FALSE; } /* If we expanded, need to calculate a new index */ idx = HASH_IDX(htable, key); @@ -251,16 +251,16 @@ unsigned int ares__htable_insert(ares__htable_t *htable, void *bucket) if (htable->buckets[idx] == NULL) { htable->buckets[idx] = ares__llist_create(htable->bucket_free); if (htable->buckets[idx] == NULL) - return 0; + return ARES_FALSE; } node = ares__llist_insert_first(htable->buckets[idx], bucket); if (node == NULL) - return 0; + return ARES_FALSE; htable->num_keys++; - return 1; + return ARES_TRUE; } @@ -277,22 +277,22 @@ void *ares__htable_get(ares__htable_t *htable, const void *key) } -unsigned int ares__htable_remove(ares__htable_t *htable, const void *key) +ares_bool_t ares__htable_remove(ares__htable_t *htable, const void *key) { ares__llist_node_t *node; unsigned int idx; if (htable == NULL || key == NULL) - return 0; + return ARES_FALSE; idx = HASH_IDX(htable, key); node = ares__htable_find(htable, idx, key); if (node == NULL) - return 0; + return ARES_FALSE; htable->num_keys--; ares__llist_node_destroy(node); - return 1; + return ARES_TRUE; } size_t ares__htable_num_keys(ares__htable_t *htable) diff --git a/src/lib/ares__htable.h b/src/lib/ares__htable.h index bbd36f77..7e343185 100644 --- a/src/lib/ares__htable.h +++ b/src/lib/ares__htable.h @@ -78,10 +78,10 @@ typedef const void *(*ares__htable_bucket_key_t)(const void *bucket); * * \param[in] key1 first key * \param[in] key2 second key - * \return 1 if equal, 0 if not + * \return ARES_TRUE if equal, ARES_FALSE if not */ -typedef unsigned int (*ares__htable_key_eq_t)(const void *key1, - const void *key2); +typedef ares_bool_t (*ares__htable_key_eq_t)(const void *key1, + const void *key2); /*! Destroy the initialized hashtable @@ -115,9 +115,9 @@ size_t ares__htable_num_keys(ares__htable_t *htable); * \param[in] htable Initialized hashtable. * \param[in] bucket User-provided bucket to insert. Takes "ownership". Not * allowed to be NULL. - * \return 1 on success, 0 if out of memory + * \return ARES_TRUE on success, ARES_FALSE if out of memory */ -unsigned int ares__htable_insert(ares__htable_t *htable, void *bucket); +ares_bool_t ares__htable_insert(ares__htable_t *htable, void *bucket); /*! Retrieve bucket from hashtable based on key. * @@ -131,9 +131,9 @@ void *ares__htable_get(ares__htable_t *htable, const void *key); * * \param[in] htable Initialized hashtable * \param[in] key Pointer to key to use for comparison - * \return 1 if found, 0 if not found + * \return ARES_TRUE if found, ARES_FALSE if not found */ -unsigned int ares__htable_remove(ares__htable_t *htable, const void *key); +ares_bool_t ares__htable_remove(ares__htable_t *htable, const void *key); /*! FNV1a hash algorithm. Can be used as underlying primitive for building * a wrapper hashtable. diff --git a/src/lib/ares__htable_asvp.c b/src/lib/ares__htable_asvp.c index 70265241..821db665 100644 --- a/src/lib/ares__htable_asvp.c +++ b/src/lib/ares__htable_asvp.c @@ -79,15 +79,15 @@ static void bucket_free(void *bucket) } -static unsigned int key_eq(const void *key1, const void *key2) +static ares_bool_t key_eq(const void *key1, const void *key2) { const ares_socket_t *k1 = key1; const ares_socket_t *k2 = key2; if (*k1 == *k2) - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } @@ -118,8 +118,8 @@ fail: } -unsigned int ares__htable_asvp_insert(ares__htable_asvp_t *htable, - ares_socket_t key, void *val) +ares_bool_t ares__htable_asvp_insert(ares__htable_asvp_t *htable, + ares_socket_t key, void *val) { ares__htable_asvp_bucket_t *bucket = NULL; @@ -137,17 +137,17 @@ unsigned int ares__htable_asvp_insert(ares__htable_asvp_t *htable, if (!ares__htable_insert(htable->hash, bucket)) goto fail; - return 1; + return ARES_TRUE; fail: if (bucket) { ares_free(bucket); } - return 0; + return ARES_FALSE; } -unsigned int ares__htable_asvp_get(ares__htable_asvp_t *htable, +ares_bool_t ares__htable_asvp_get(ares__htable_asvp_t *htable, ares_socket_t key, void **val) { ares__htable_asvp_bucket_t *bucket = NULL; @@ -156,15 +156,15 @@ unsigned int ares__htable_asvp_get(ares__htable_asvp_t *htable, *val = NULL; if (htable == NULL) - return 0; + return ARES_FALSE; bucket = ares__htable_get(htable->hash, &key); if (bucket == NULL) - return 0; + return ARES_FALSE; if (val) *val = bucket->val; - return 1; + return ARES_TRUE; } @@ -177,11 +177,11 @@ void *ares__htable_asvp_get_direct(ares__htable_asvp_t *htable, } -unsigned int ares__htable_asvp_remove(ares__htable_asvp_t *htable, +ares_bool_t ares__htable_asvp_remove(ares__htable_asvp_t *htable, ares_socket_t key) { if (htable == NULL) - return 0; + return ARES_FALSE; return ares__htable_remove(htable->hash, &key); } diff --git a/src/lib/ares__htable_asvp.h b/src/lib/ares__htable_asvp.h index f53b2775..eb74a001 100644 --- a/src/lib/ares__htable_asvp.h +++ b/src/lib/ares__htable_asvp.h @@ -73,9 +73,9 @@ ares__htable_asvp_t *ares__htable_asvp_create( * \param[in] htable Initialized hash table * \param[in] key key to associate with value * \param[in] val value to store (takes ownership). May be NULL. - * \return 1 on success, 0 on out of memory or misuse + * \return ARES_TRUE on success, ARES_FALSE on out of memory or misuse */ -unsigned int ares__htable_asvp_insert(ares__htable_asvp_t *htable, +ares_bool_t ares__htable_asvp_insert(ares__htable_asvp_t *htable, ares_socket_t key, void *val); /*! Retrieve value from hashtable based on key @@ -83,9 +83,9 @@ unsigned int ares__htable_asvp_insert(ares__htable_asvp_t *htable, * \param[in] htable Initialized hash table * \param[in] key key to use to search * \param[out] val Optional. Pointer to store value. - * \return 1 on success, 0 on failure + * \return ARES_TRUE on success, ARES_FALSE on failure */ -unsigned int ares__htable_asvp_get(ares__htable_asvp_t *htable, +ares_bool_t ares__htable_asvp_get(ares__htable_asvp_t *htable, ares_socket_t key, void **val); /*! Retrieve value from hashtable directly as return value. Caveat to this @@ -103,9 +103,9 @@ void *ares__htable_asvp_get_direct(ares__htable_asvp_t *htable, * * \param[in] htable Initialized hash table * \param[in] key key to use to search - * \return 1 if found, 0 if not + * \return ARES_TRUE if found, ARES_FALSE if not found */ -unsigned int ares__htable_asvp_remove(ares__htable_asvp_t *htable, +ares_bool_t ares__htable_asvp_remove(ares__htable_asvp_t *htable, ares_socket_t key); /*! Retrieve the number of keys stored in the hash table diff --git a/src/lib/ares__htable_stvp.c b/src/lib/ares__htable_stvp.c index 7a4cd40a..47ab7a87 100644 --- a/src/lib/ares__htable_stvp.c +++ b/src/lib/ares__htable_stvp.c @@ -79,15 +79,15 @@ static void bucket_free(void *bucket) } -static unsigned int key_eq(const void *key1, const void *key2) +static ares_bool_t key_eq(const void *key1, const void *key2) { const size_t *k1 = key1; const size_t *k2 = key2; if (*k1 == *k2) - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } @@ -118,7 +118,7 @@ fail: } -unsigned int ares__htable_stvp_insert(ares__htable_stvp_t *htable, size_t key, +ares_bool_t ares__htable_stvp_insert(ares__htable_stvp_t *htable, size_t key, void *val) { ares__htable_stvp_bucket_t *bucket = NULL; @@ -137,17 +137,17 @@ unsigned int ares__htable_stvp_insert(ares__htable_stvp_t *htable, size_t key, if (!ares__htable_insert(htable->hash, bucket)) goto fail; - return 1; + return ARES_TRUE; fail: if (bucket) { ares_free(bucket); } - return 0; + return ARES_FALSE; } -unsigned int ares__htable_stvp_get(ares__htable_stvp_t *htable, size_t key, +ares_bool_t ares__htable_stvp_get(ares__htable_stvp_t *htable, size_t key, void **val) { ares__htable_stvp_bucket_t *bucket = NULL; @@ -156,15 +156,15 @@ unsigned int ares__htable_stvp_get(ares__htable_stvp_t *htable, size_t key, *val = NULL; if (htable == NULL) - return 0; + return ARES_FALSE; bucket = ares__htable_get(htable->hash, &key); if (bucket == NULL) - return 0; + return ARES_FALSE; if (val) *val = bucket->val; - return 1; + return ARES_TRUE; } @@ -176,10 +176,10 @@ void *ares__htable_stvp_get_direct(ares__htable_stvp_t *htable, size_t key) } -unsigned int ares__htable_stvp_remove(ares__htable_stvp_t *htable, size_t key) +ares_bool_t ares__htable_stvp_remove(ares__htable_stvp_t *htable, size_t key) { if (htable == NULL) - return 0; + return ARES_FALSE; return ares__htable_remove(htable->hash, &key); } diff --git a/src/lib/ares__htable_stvp.h b/src/lib/ares__htable_stvp.h index 11d9d5ed..a2376676 100644 --- a/src/lib/ares__htable_stvp.h +++ b/src/lib/ares__htable_stvp.h @@ -70,20 +70,20 @@ ares__htable_stvp_t *ares__htable_stvp_create( * \param[in] htable Initialized hash table * \param[in] key key to associate with value * \param[in] val value to store (takes ownership). May be NULL. - * \return 1 on success, 0 on out of memory or misuse + * \return ARES_TRUE on success, ARES_FALSE on failure or out of memory */ -unsigned int ares__htable_stvp_insert(ares__htable_stvp_t *htable, size_t key, - void *val); +ares_bool_t ares__htable_stvp_insert(ares__htable_stvp_t *htable, size_t key, + void *val); /*! Retrieve value from hashtable based on key * * \param[in] htable Initialized hash table * \param[in] key key to use to search * \param[out] val Optional. Pointer to store value. - * \return 1 on success, 0 on failure + * \return ARES_TRUE on success, ARES_FALSE on failure */ -unsigned int ares__htable_stvp_get(ares__htable_stvp_t *htable, size_t key, - void **val); +ares_bool_t ares__htable_stvp_get(ares__htable_stvp_t *htable, size_t key, + void **val); /*! Retrieve value from hashtable directly as return value. Caveat to this * function over ares__htable_stvp_get() is that if a NULL value is stored @@ -99,9 +99,9 @@ void *ares__htable_stvp_get_direct(ares__htable_stvp_t *htable, size_t key); * * \param[in] htable Initialized hash table * \param[in] key key to use to search - * \return 1 if found, 0 if not + * \return ARES_TRUE if found, ARES_FALSE if not */ -unsigned int ares__htable_stvp_remove(ares__htable_stvp_t *htable, size_t key); +ares_bool_t ares__htable_stvp_remove(ares__htable_stvp_t *htable, size_t key); /*! Retrieve the number of keys stored in the hash table * diff --git a/src/lib/ares__parse_into_addrinfo.c b/src/lib/ares__parse_into_addrinfo.c index d8bb17cc..0d5ab77a 100644 --- a/src/lib/ares__parse_into_addrinfo.c +++ b/src/lib/ares__parse_into_addrinfo.c @@ -50,14 +50,15 @@ #include "ares_private.h" ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, - int alen, int cname_only_is_enodata, + int alen, + ares_bool_t cname_only_is_enodata, unsigned short port, struct ares_addrinfo *ai) { unsigned int qdcount, ancount; ares_status_t status; int i, rr_type, rr_class, rr_len, rr_ttl; - int got_a = 0, got_aaaa = 0, got_cname = 0; + ares_bool_t got_a = ARES_FALSE, got_aaaa = ARES_FALSE, got_cname = ARES_FALSE; long len; const unsigned char *aptr; char *question_hostname = NULL; @@ -123,7 +124,7 @@ ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, && rr_len == sizeof(struct in_addr) && strcasecmp(rr_name, hostname) == 0) { - got_a = 1; + got_a = ARES_TRUE; if (aptr + sizeof(struct in_addr) > abuf + alen) { /* LCOV_EXCL_START: already checked above */ status = ARES_EBADRESP; @@ -138,7 +139,7 @@ ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, && rr_len == sizeof(struct ares_in6_addr) && strcasecmp(rr_name, hostname) == 0) { - got_aaaa = 1; + got_aaaa = ARES_TRUE; if (aptr + sizeof(struct ares_in6_addr) > abuf + alen) { /* LCOV_EXCL_START: already checked above */ status = ARES_EBADRESP; @@ -152,7 +153,7 @@ ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, if (rr_class == C_IN && rr_type == T_CNAME) { - got_cname = 1; + got_cname = ARES_TRUE; status = ares__expand_name_for_response(aptr, abuf, alen, &rr_data, &len, 1); if (status != ARES_SUCCESS) diff --git a/src/lib/ares__readaddrinfo.c b/src/lib/ares__readaddrinfo.c index a81324d2..b78c913e 100644 --- a/src/lib/ares__readaddrinfo.c +++ b/src/lib/ares__readaddrinfo.c @@ -57,8 +57,8 @@ ares_status_t ares__readaddrinfo(FILE *fp, size_t linesize; struct ares_addrinfo_cname *cname = NULL, *cnames = NULL; struct ares_addrinfo_node *nodes = NULL; - int match_with_alias, match_with_canonical; - int want_cname = hints->ai_flags & ARES_AI_CANONNAME; + ares_bool_t match_with_alias, match_with_canonical; + ares_bool_t want_cname = (hints->ai_flags & ARES_AI_CANONNAME)?ARES_TRUE:ARES_FALSE; /* Validate family */ switch (hints->ai_family) { @@ -79,8 +79,8 @@ ares_status_t ares__readaddrinfo(FILE *fp, while ((status = ares__read_line(fp, &line, &linesize)) == ARES_SUCCESS) { - match_with_alias = 0; - match_with_canonical = 0; + match_with_alias = ARES_FALSE; + match_with_canonical = ARES_FALSE; alias_count = 0; /* Trim line comment. */ p = line; @@ -147,7 +147,7 @@ ares_status_t ares__readaddrinfo(FILE *fp, /* Find out if host name matches with canonical host name. */ if (strcasecmp(txthost, name) == 0) { - match_with_canonical = 1; + match_with_canonical = ARES_TRUE; } /* Find out if host name matches with one of the aliases. */ @@ -162,7 +162,7 @@ ares_status_t ares__readaddrinfo(FILE *fp, *p = '\0'; if (strcasecmp(txtalias, name) == 0) { - match_with_alias = 1; + match_with_alias = ARES_TRUE; if (!want_cname) break; } diff --git a/src/lib/ares__slist.c b/src/lib/ares__slist.c index 9974bc04..e151053f 100644 --- a/src/lib/ares__slist.c +++ b/src/lib/ares__slist.c @@ -90,7 +90,7 @@ ares__slist_t *ares__slist_create(ares_rand_state *rand_state, } -static unsigned int ares__slist_coin_flip(ares__slist_t *list) +static ares_bool_t ares__slist_coin_flip(ares__slist_t *list) { size_t total_bits = sizeof(list->rand_data) * 8; size_t bit; @@ -108,7 +108,7 @@ static unsigned int ares__slist_coin_flip(ares__slist_t *list) bit = total_bits - list->rand_bits; list->rand_bits--; - return (list->rand_data[bit / 8] & (1 << (bit % 8)))?1:0; + return (list->rand_data[bit / 8] & (1 << (bit % 8)))?ARES_TRUE:ARES_FALSE; } diff --git a/src/lib/ares__timeval.c b/src/lib/ares__timeval.c index 5716c53e..e7a04008 100644 --- a/src/lib/ares__timeval.c +++ b/src/lib/ares__timeval.c @@ -106,18 +106,3 @@ struct timeval ares__tvnow(void) } #endif - -#if 0 /* Not used */ -/* - * Make sure that the first argument is the more recent time, as otherwise - * we'll get a weird negative time-diff back... - * - * Returns: the time difference in number of milliseconds. - */ -long ares__tvdiff(struct timeval newer, struct timeval older) -{ - return (newer.tv_sec-older.tv_sec)*1000+ - (newer.tv_usec-older.tv_usec)/1000; -} -#endif - diff --git a/src/lib/ares_android.c b/src/lib/ares_android.c index ec0a3387..13b89631 100644 --- a/src/lib/ares_android.c +++ b/src/lib/ares_android.c @@ -96,7 +96,7 @@ int ares_library_init_android(jobject connectivity_manager) JNIEnv *env = NULL; int need_detatch = 0; int res; - int ret = ARES_ENOTINITIALIZED; + ares_status_t ret = ARES_ENOTINITIALIZED; jclass obj_cls = NULL; if (android_jvm == NULL) diff --git a/src/lib/ares_expand_name.c b/src/lib/ares_expand_name.c index 28d46499..4d52f341 100644 --- a/src/lib/ares_expand_name.c +++ b/src/lib/ares_expand_name.c @@ -41,10 +41,10 @@ #define MAX_INDIRS 50 static int name_length(const unsigned char *encoded, const unsigned char *abuf, - int alen, int is_hostname); + int alen, ares_bool_t is_hostname); /* Reserved characters for names that need to be escaped */ -static int is_reservedch(int ch) +static ares_bool_t is_reservedch(int ch) { switch (ch) { case '"': @@ -55,19 +55,19 @@ static int is_reservedch(int ch) case ')': case '@': case '$': - return 1; + return ARES_TRUE; default: break; } - return 0; + return ARES_FALSE; } -static int ares__isprint(int ch) +static ares_bool_t ares__isprint(int ch) { if (ch >= 0x20 && ch <= 0x7E) - return 1; - return 0; + return ARES_TRUE; + return ARES_FALSE; } /* Character set allowed by hostnames. This is to include the normal @@ -82,21 +82,21 @@ static int ares__isprint(int ch) * reported when this validation is not performed. Security is more * important than edge-case compatibility (which is probably invalid * anyhow). */ -static int is_hostnamech(int ch) +static ares_bool_t is_hostnamech(int ch) { /* [A-Za-z0-9-*._/] * Don't use isalnum() as it is locale-specific */ if (ch >= 'A' && ch <= 'Z') - return 1; + return ARES_TRUE; if (ch >= 'a' && ch <= 'z') - return 1; + return ARES_TRUE; if (ch >= '0' && ch <= '9') - return 1; + return ARES_TRUE; if (ch == '-' || ch == '.' || ch == '_' || ch == '/' || ch == '*') - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } /* Expand an RFC1035-encoded domain name given by encoded. The @@ -129,14 +129,14 @@ static int is_hostnamech(int ch) ares_status_t ares__expand_name_validated(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen, - int is_hostname) + ares_bool_t is_hostname) { int len, indir = 0; char *q; const unsigned char *p; union { ares_ssize_t sig; - size_t uns; + size_t uns; } nlen; nlen.sig = name_length(encoded, abuf, alen, is_hostname); @@ -225,14 +225,14 @@ ares_status_t ares__expand_name_validated(const unsigned char *encoded, int ares_expand_name(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen) { - return ares__expand_name_validated(encoded, abuf, alen, s, enclen, 0); + return ares__expand_name_validated(encoded, abuf, alen, s, enclen, ARES_FALSE); } /* Return the length of the expansion of an encoded domain name, or * -1 if the encoding is invalid. */ static int name_length(const unsigned char *encoded, const unsigned char *abuf, - int alen, int is_hostname) + int alen, ares_bool_t is_hostname) { int n = 0, offset, indir = 0, top; @@ -313,7 +313,7 @@ static int name_length(const unsigned char *encoded, const unsigned char *abuf, ares_status_t ares__expand_name_for_response(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen, - int is_hostname) + ares_bool_t is_hostname) { ares_status_t status = ares__expand_name_validated(encoded, abuf, alen, s, enclen, is_hostname); diff --git a/src/lib/ares_getaddrinfo.c b/src/lib/ares_getaddrinfo.c index 3c79adc2..41e7e32c 100644 --- a/src/lib/ares_getaddrinfo.c +++ b/src/lib/ares_getaddrinfo.c @@ -123,9 +123,9 @@ static const struct ares_addrinfo empty_addrinfo = { /* forward declarations */ static void host_callback(void *arg, int status, int timeouts, unsigned char *abuf, int alen); -static int as_is_first(const struct host_query *hquery); -static int as_is_only(const struct host_query* hquery); -static int next_dns_lookup(struct host_query *hquery); +static ares_bool_t as_is_first(const struct host_query *hquery); +static ares_bool_t as_is_only(const struct host_query* hquery); +static ares_bool_t next_dns_lookup(struct host_query *hquery); static struct ares_addrinfo_cname *ares__malloc_addrinfo_cname(void) { @@ -419,25 +419,25 @@ static void end_hquery(struct host_query *hquery, ares_status_t status) ares_free(hquery); } -static int is_localhost(const char *name) +static ares_bool_t is_localhost(const char *name) { /* RFC6761 6.3 says : The domain "localhost." and any names falling within ".localhost." */ size_t len; if (name == NULL) - return 0; + return ARES_FALSE; if (strcmp(name, "localhost") == 0) - return 1; + return ARES_TRUE; len = strlen(name); if (len < 10 /* strlen(".localhost") */) - return 0; + return ARES_FALSE; if (strcmp(name + (len - 10 /* strlen(".localhost") */), ".localhost") == 0) - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } static ares_status_t file_lookup(struct host_query *hquery) @@ -593,7 +593,7 @@ static void terminate_retries(struct host_query *hquery, unsigned short qid) if (query == NULL) return; - query->no_retries = 1; + query->no_retries = ARES_TRUE; } @@ -772,10 +772,10 @@ void ares_getaddrinfo(ares_channel channel, next_lookup(hquery, ARES_ECONNREFUSED /* initial error code */); } -static int next_dns_lookup(struct host_query *hquery) +static ares_bool_t next_dns_lookup(struct host_query *hquery) { char *s = NULL; - int is_s_allocated = 0; + ares_bool_t is_s_allocated = ARES_FALSE; ares_status_t status; /* if next_domain == -1 and as_is_first is true, try hquery->name */ @@ -805,7 +805,7 @@ static int next_dns_lookup(struct host_query *hquery) &s); if (status == ARES_SUCCESS) { - is_s_allocated = 1; + is_s_allocated = ARES_TRUE; } } @@ -838,16 +838,16 @@ static int next_dns_lookup(struct host_query *hquery) { ares_free(s); } - return 1; + return ARES_TRUE; } else { assert(!hquery->ai->nodes); - return 0; + return ARES_FALSE; } } -static int as_is_first(const struct host_query* hquery) +static ares_bool_t as_is_first(const struct host_query* hquery) { char* p; int ndots = 0; @@ -862,16 +862,16 @@ static int as_is_first(const struct host_query* hquery) if (nname && hquery->name[nname-1] == '.') { /* prevent ARES_EBADNAME for valid FQDN, where ndots < channel->ndots */ - return 1; + return ARES_TRUE; } - return ndots >= hquery->channel->ndots; + return ndots >= hquery->channel->ndots?ARES_TRUE:ARES_FALSE; } -static int as_is_only(const struct host_query* hquery) +static ares_bool_t as_is_only(const struct host_query* hquery) { size_t nname = hquery->name?strlen(hquery->name):0; if (nname && hquery->name[nname-1] == '.') - return 1; - return 0; + return ARES_TRUE; + return ARES_FALSE; } diff --git a/src/lib/ares_getnameinfo.c b/src/lib/ares_getnameinfo.c index 0d97a318..63d9cc01 100644 --- a/src/lib/ares_getnameinfo.c +++ b/src/lib/ares_getnameinfo.c @@ -445,13 +445,13 @@ STATIC_TESTABLE char *ares_striendstr(const char *s1, const char *s2) return (char *)c1_begin; } -int ares__is_onion_domain(const char *name) +ares_bool_t ares__is_onion_domain(const char *name) { if (ares_striendstr(name, ".onion")) - return 1; + return ARES_TRUE; if (ares_striendstr(name, ".onion.")) - return 1; + return ARES_TRUE; - return 0; + return ARES_FALSE; } diff --git a/src/lib/ares_init.c b/src/lib/ares_init.c index 1f7f2cae..64fef735 100644 --- a/src/lib/ares_init.c +++ b/src/lib/ares_init.c @@ -89,8 +89,8 @@ static const char *try_option(const char *p, const char *q, const char *opt); static ares_status_t config_sortlist(struct apattern **sortlist, int *nsort, const char *str); -static int sortlist_alloc(struct apattern **sortlist, int *nsort, - struct apattern *pat); +static ares_bool_t sortlist_alloc(struct apattern **sortlist, int *nsort, + struct apattern *pat); static int ip_addr(const char *s, ares_ssize_t len, struct in_addr *addr); static void natural_mask(struct apattern *pat); #if !defined(WIN32) && !defined(WATT32) && \ @@ -639,7 +639,7 @@ static ares_status_t init_by_environment(ares_channel channel) * * Supported on Windows NT 3.5 and newer. */ -static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) +static ares_bool_t get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) { DWORD size = 0; int res; @@ -649,13 +649,13 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) /* Find out size of string stored in registry */ res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, NULL, &size); if ((res != ERROR_SUCCESS && res != ERROR_MORE_DATA) || !size) - return 0; + return ARES_FALSE; /* Allocate buffer of indicated size plus one given that string might have been stored without null termination */ *outptr = ares_malloc(size+1); if (!*outptr) - return 0; + return ARES_FALSE; /* Get the value for real */ res = RegQueryValueExA(hKey, leafKeyName, 0, NULL, @@ -664,13 +664,13 @@ static int get_REG_SZ(HKEY hKey, const char *leafKeyName, char **outptr) { ares_free(*outptr); *outptr = NULL; - return 0; + return ARES_FALSE; } /* Null terminate buffer allways */ *(*outptr + size) = '\0'; - return 1; + return ARES_TRUE; } static void commanjoin(char** dst, const char* const src, const size_t len) @@ -837,7 +837,7 @@ static ULONG getBestRouteMetric(IF_LUID * const luid, /* Can't be const :( */ */ #define IPAA_INITIAL_BUF_SZ 15 * 1024 #define IPAA_MAX_TRIES 3 -static int get_DNS_Windows(char **outptr) +static ares_bool_t get_DNS_Windows(char **outptr) { IP_ADAPTER_DNS_SERVER_ADDRESS *ipaDNSAddr; IP_ADAPTER_ADDRESSES *ipaa, *newipaa, *ipaaEntry; @@ -864,7 +864,7 @@ static int get_DNS_Windows(char **outptr) ipaa = ares_malloc(Bufsz); if (!ipaa) - return 0; + return ARES_FALSE; /* Start with enough room for a few DNS server addresses and we'll grow it * as we encounter more. @@ -874,7 +874,7 @@ static int get_DNS_Windows(char **outptr) if(addresses == NULL) { /* We need room for at least some addresses to function. */ ares_free(ipaa); - return 0; + return ARES_FALSE; } /* Usually this call suceeds with initial buffer size */ @@ -1028,10 +1028,10 @@ done: ares_free(ipaa); if (!*outptr) { - return 0; + return ARES_FALSE; } - return 1; + return ARES_TRUE; } /* @@ -1047,7 +1047,7 @@ done: * * Implementation supports Windows Server 2003 and newer */ -static int get_SuffixList_Windows(char **outptr) +static ares_bool_t get_SuffixList_Windows(char **outptr) { HKEY hKey, hKeyEnum; char keyName[256]; @@ -1058,7 +1058,7 @@ static int get_SuffixList_Windows(char **outptr) *outptr = NULL; if (ares__getplatform() != WIN_NT) - return 0; + return ARES_FALSE; /* 1. Global DNS Suffix Search List */ if (RegOpenKeyExA(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, @@ -1138,7 +1138,7 @@ static int get_SuffixList_Windows(char **outptr) RegCloseKey(hKey); } - return *outptr != NULL; + return *outptr != NULL?ARES_TRUE:ARES_FALSE; } #endif @@ -1791,7 +1791,7 @@ static ares_status_t config_lookup(ares_channel channel, const char *str, { char lookups[3], *l; const char *vqualifier p; - int found; + ares_bool_t found; if (altbindch == NULL) altbindch = bindch; @@ -1802,13 +1802,13 @@ static ares_status_t config_lookup(ares_channel channel, const char *str, */ l = lookups; p = str; - found = 0; + found = ARES_FALSE; while (*p) { if ((*p == *bindch || *p == *altbindch || *p == *filech) && l < lookups + 2) { if (*p == *bindch || *p == *altbindch) *l++ = 'b'; else *l++ = 'f'; - found = 1; + found = ARES_TRUE; } while (*p && !ISSPACE(*p) && (*p != ',')) p++; @@ -1828,7 +1828,7 @@ static ares_status_t config_lookup(ares_channel channel, const char *str, * mask) specified. Addresses are specified in standard Network Byte Order as * 16 bytes, and the netmask is 0 to 128 (bits). */ -static int ares_ipv6_subnet_matches(const unsigned char netbase[16], +static ares_bool_t ares_ipv6_subnet_matches(const unsigned char netbase[16], unsigned char netmask, const unsigned char ipaddr[16]) { @@ -1837,7 +1837,7 @@ static int ares_ipv6_subnet_matches(const unsigned char netbase[16], /* Misuse */ if (netmask > 128) - return 0; + return ARES_FALSE; /* Quickly set whole bytes */ memset(mask, 0xFF, netmask / 8); @@ -1849,14 +1849,14 @@ static int ares_ipv6_subnet_matches(const unsigned char netbase[16], for (i=0; i<16; i++) { if ((netbase[i] & mask[i]) != (ipaddr[i] & mask[i])) - return 0; + return ARES_FALSE; } - return 1; + return ARES_TRUE; } /* Return true iff the IPv6 ipaddr is blacklisted. */ -static int ares_ipv6_server_blacklisted(const unsigned char ipaddr[16]) +static ares_bool_t ares_ipv6_server_blacklisted(const unsigned char ipaddr[16]) { /* A list of blacklisted IPv6 subnets. */ const struct { @@ -1881,9 +1881,9 @@ static int ares_ipv6_server_blacklisted(const unsigned char ipaddr[16]) for (i = 0; i < sizeof(blacklist) / sizeof(blacklist[0]); ++i) { if (ares_ipv6_subnet_matches( blacklist[i].netbase, blacklist[i].netmask, ipaddr)) - return 1; + return ARES_TRUE; } - return 0; + return ARES_FALSE; } /* Parse address and port in these formats, either ipv4 or ipv6 addresses @@ -2317,17 +2317,17 @@ static void natural_mask(struct apattern *pat) pat->mask.addr4.s_addr = htonl(IN_CLASSC_NET); } -static int sortlist_alloc(struct apattern **sortlist, int *nsort, - struct apattern *pat) +static ares_bool_t sortlist_alloc(struct apattern **sortlist, int *nsort, + struct apattern *pat) { struct apattern *newsort; newsort = ares_realloc(*sortlist, (*nsort + 1) * sizeof(struct apattern)); if (!newsort) - return 0; + return ARES_FALSE; newsort[*nsort] = *pat; *sortlist = newsort; (*nsort)++; - return 1; + return ARES_TRUE; } diff --git a/src/lib/ares_private.h b/src/lib/ares_private.h index 94c9ca9e..a86f8c0b 100644 --- a/src/lib/ares_private.h +++ b/src/lib/ares_private.h @@ -163,7 +163,7 @@ struct server_state; struct server_connection { struct server_state *server; ares_socket_t fd; - int is_tcp; + ares_bool_t is_tcp; /* total number of queries run on this connection since it was established */ size_t total_queries; /* list of outstanding queries to this connection */ @@ -226,16 +226,16 @@ struct query { int try_count; /* Number of times we tried this query already. */ int server; /* Server this query has last been sent to. */ struct query_server_info *server_info; /* per-server state */ - int using_tcp; + ares_bool_t using_tcp; ares_status_t error_status; int timeouts; /* number of timeouts we saw for this request */ - int no_retries; /* do not perform any additional retries, this is set when - * a query is to be canceled */ + ares_bool_t no_retries; /* do not perform any additional retries, this is set when + * a query is to be canceled */ }; /* Per-server state for a query */ struct query_server_info { - int skip_server; /* should we skip server, due to errors, etc? */ + ares_bool_t skip_server; /* should we skip server, due to errors, etc? */ int tcp_connection_generation; /* into which TCP connection did we send? */ }; @@ -336,7 +336,7 @@ struct ares_channeldata { }; /* Does the domain end in ".onion" or ".onion."? Case-insensitive. */ -int ares__is_onion_domain(const char *name); +ares_bool_t ares__is_onion_domain(const char *name); /* Memory management functions */ extern void *(*ares_malloc)(size_t size); @@ -344,8 +344,8 @@ extern void *(*ares_realloc)(void *ptr, size_t size); extern void (*ares_free)(void *ptr); /* return true if now is exactly check time or later */ -int ares__timedout(struct timeval *now, - struct timeval *check); +ares_bool_t ares__timedout(struct timeval *now, + struct timeval *check); /* Returns one of the normal ares status codes like ARES_SUCCESS */ ares_status_t ares__send_query(ares_channel channel, struct query *query, @@ -377,11 +377,11 @@ struct timeval ares__tvnow(void); ares_status_t ares__expand_name_validated(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen, - int is_hostname); + ares_bool_t is_hostname); ares_status_t ares__expand_name_for_response(const unsigned char *encoded, const unsigned char *abuf, int alen, char **s, long *enclen, - int is_hostname); + ares_bool_t is_hostname); ares_status_t ares__init_servers_state(ares_channel channel); void ares__destroy_servers_state(ares_channel channel); ares_status_t ares__single_domain(ares_channel channel, const char *name, @@ -412,7 +412,8 @@ void ares__addrinfo_cat_cnames(struct ares_addrinfo_cname **head, struct ares_addrinfo_cname *tail); ares_status_t ares__parse_into_addrinfo(const unsigned char *abuf, - int alen, int cname_only_is_enodata, + int alen, + ares_bool_t cname_only_is_enodata, unsigned short port, struct ares_addrinfo *ai); @@ -427,10 +428,6 @@ ares_status_t ares__addrinfo_localhost(const char *name, unsigned short port, const struct ares_addrinfo_hints *hints, struct ares_addrinfo *ai); -#if 0 /* Not used */ -long ares__tvdiff(struct timeval t1, struct timeval t2); -#endif - ares_socket_t ares__open_socket(ares_channel channel, int af, int type, int protocol); void ares__close_socket(ares_channel, ares_socket_t); diff --git a/src/lib/ares_process.c b/src/lib/ares_process.c index 2f8e4de3..3348bd52 100644 --- a/src/lib/ares_process.c +++ b/src/lib/ares_process.c @@ -65,7 +65,7 @@ #include "ares_private.h" -static int try_again(int errnum); +static ares_bool_t try_again(int errnum); static void write_tcp_data(ares_channel channel, fd_set *write_fds, ares_socket_t write_fd, struct timeval *now); static void read_packets(ares_channel channel, fd_set *read_fds, @@ -80,29 +80,29 @@ static void skip_server(ares_channel channel, struct query *query, static ares_status_t next_server(ares_channel channel, struct query *query, struct timeval *now); static ares_status_t open_socket(ares_channel channel, - struct server_state *server, int is_tcp); -static int same_questions(const unsigned char *qbuf, int qlen, - const unsigned char *abuf, int alen); -static int same_address(struct sockaddr *sa, struct ares_addr *aa); + struct server_state *server, + ares_bool_t is_tcp); +static ares_bool_t same_questions(const unsigned char *qbuf, int qlen, + const unsigned char *abuf, int alen); +static ares_bool_t same_address(struct sockaddr *sa, struct ares_addr *aa); static int has_opt_rr(const unsigned char *abuf, int alen); -static void end_query(ares_channel channel, struct query *query, int status, - const unsigned char *abuf, int alen); +static void end_query(ares_channel channel, struct query *query, + ares_status_t status, const unsigned char *abuf, int alen); static ares_ssize_t ares__socket_write(ares_channel channel, ares_socket_t s, const void * data, size_t len); /* return true if now is exactly check time or later */ -int ares__timedout(struct timeval *now, - struct timeval *check) +ares_bool_t ares__timedout(struct timeval *now, struct timeval *check) { long secs = (now->tv_sec - check->tv_sec); if(secs > 0) - return 1; /* yes, timed out */ + return ARES_TRUE; /* yes, timed out */ if(secs < 0) - return 0; /* nope, not timed out */ + return ARES_FALSE; /* nope, not timed out */ /* if the full seconds were identical, check the sub second parts */ - return (now->tv_usec - check->tv_usec >= 0); + return (now->tv_usec - check->tv_usec) >= 0?ARES_TRUE:ARES_FALSE; } /* add the specific number of milliseconds to the time in the first argument */ @@ -158,7 +158,7 @@ void ares_process_fd(ares_channel channel, * http://devrsrc1.external.hp.com/STKS/cgi-bin/man2html? * manpage=/usr/share/man/man2.Z/send.2 */ -static int try_again(int errnum) +static ares_bool_t try_again(int errnum) { #if !defined EWOULDBLOCK && !defined EAGAIN #error "Neither EWOULDBLOCK nor EAGAIN defined" @@ -167,14 +167,14 @@ static int try_again(int errnum) { #ifdef EWOULDBLOCK case EWOULDBLOCK: - return 1; + return ARES_TRUE; #endif #if defined EAGAIN && EAGAIN != EWOULDBLOCK case EAGAIN: - return 1; + return ARES_TRUE; #endif } - return 0; + return ARES_FALSE; } @@ -634,7 +634,7 @@ static void process_answer(ares_channel channel, const unsigned char *abuf, { if (!query->using_tcp) { - query->using_tcp = 1; + query->using_tcp = ARES_TRUE; ares__send_query(channel, query, now); } ares__check_cleanup_conn(channel, fd); @@ -721,7 +721,7 @@ static void skip_server(ares_channel channel, struct query *query, */ if (channel->nservers > 1) { - query->server_info[server->idx].skip_server = 1; + query->server_info[server->idx].skip_server = ARES_TRUE; } } @@ -1052,7 +1052,8 @@ static int configure_socket(ares_socket_t s, int family, ares_channel channel) } static ares_status_t open_socket(ares_channel channel, - struct server_state *server, int is_tcp) + struct server_state *server, + ares_bool_t is_tcp) { ares_socket_t s; int opt; @@ -1206,8 +1207,8 @@ static ares_status_t open_socket(ares_channel channel, } -static int same_questions(const unsigned char *qbuf, int qlen, - const unsigned char *abuf, int alen) +static ares_bool_t same_questions(const unsigned char *qbuf, int qlen, + const unsigned char *abuf, int alen) { struct { const unsigned char *p; @@ -1220,13 +1221,13 @@ static int same_questions(const unsigned char *qbuf, int qlen, int i, j; if (qlen < HFIXEDSZ || alen < HFIXEDSZ) - return 0; + return ARES_FALSE; /* Extract qdcount from the request and reply buffers and compare them. */ q.qdcount = DNS_HEADER_QDCOUNT(qbuf); a.qdcount = DNS_HEADER_QDCOUNT(abuf); if (q.qdcount != a.qdcount) - return 0; + return ARES_FALSE; /* For each question in qbuf, find it in abuf. */ q.p = qbuf + HFIXEDSZ; @@ -1235,12 +1236,12 @@ static int same_questions(const unsigned char *qbuf, int qlen, /* Decode the question in the query. */ if (ares_expand_name(q.p, qbuf, qlen, &q.name, &q.namelen) != ARES_SUCCESS) - return 0; + return ARES_FALSE; q.p += q.namelen; if (q.p + QFIXEDSZ > qbuf + qlen) { ares_free(q.name); - return 0; + return ARES_FALSE; } q.type = DNS_QUESTION_TYPE(q.p); q.dnsclass = DNS_QUESTION_CLASS(q.p); @@ -1255,14 +1256,14 @@ static int same_questions(const unsigned char *qbuf, int qlen, != ARES_SUCCESS) { ares_free(q.name); - return 0; + return ARES_FALSE; } a.p += a.namelen; if (a.p + QFIXEDSZ > abuf + alen) { ares_free(q.name); ares_free(a.name); - return 0; + return ARES_FALSE; } a.type = DNS_QUESTION_TYPE(a.p); a.dnsclass = DNS_QUESTION_CLASS(a.p); @@ -1280,12 +1281,12 @@ static int same_questions(const unsigned char *qbuf, int qlen, ares_free(q.name); if (j == a.qdcount) - return 0; + return ARES_FALSE; } - return 1; + return ARES_TRUE; } -static int same_address(struct sockaddr *sa, struct ares_addr *aa) +static ares_bool_t same_address(struct sockaddr *sa, struct ares_addr *aa) { void *addr1; void *addr2; @@ -1298,19 +1299,19 @@ static int same_address(struct sockaddr *sa, struct ares_addr *aa) addr1 = &aa->addrV4; addr2 = &(CARES_INADDR_CAST(struct sockaddr_in *, sa))->sin_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV4)) == 0) - return 1; /* match */ + return ARES_TRUE; /* match */ break; case AF_INET6: addr1 = &aa->addrV6; addr2 = &(CARES_INADDR_CAST(struct sockaddr_in6 *, sa))->sin6_addr; if (memcmp(addr1, addr2, sizeof(aa->addrV6)) == 0) - return 1; /* match */ + return ARES_TRUE; /* match */ break; default: break; /* LCOV_EXCL_LINE */ } } - return 0; /* different */ + return ARES_FALSE; /* different */ } /* search for an OPT RR in the response */ @@ -1404,8 +1405,8 @@ static void ares_detach_query(struct query *query) query->node_all_queries = NULL; } -static void end_query(ares_channel channel, struct query *query, int status, - const unsigned char *abuf, int alen) +static void end_query(ares_channel channel, struct query *query, + ares_status_t status, const unsigned char *abuf, int alen) { (void)channel; diff --git a/src/lib/ares_rand.c b/src/lib/ares_rand.c index 99a5a04c..2c5fa1c3 100644 --- a/src/lib/ares_rand.c +++ b/src/lib/ares_rand.c @@ -186,19 +186,19 @@ BOOLEAN WINAPI SystemFunction036(PVOID RandomBuffer, ULONG RandomBufferLength); #endif -static int ares__init_rand_engine(ares_rand_state *state) +static ares_bool_t ares__init_rand_engine(ares_rand_state *state) { memset(state, 0, sizeof(*state)); #if defined(HAVE_ARC4RANDOM_BUF) || defined(HAVE_GETRANDOM) || defined(_WIN32) state->type = ARES_RAND_OS; - return 1; + return ARES_TRUE; #elif defined(CARES_RANDOM_FILE) state->type = ARES_RAND_FILE; state->state.rand_file = fopen(CARES_RANDOM_FILE, "rb"); if (state->state.rand_file) { setvbuf(state->state.rand_file, NULL, _IONBF, 0); - return 1; + return ARES_TRUE; } /* Fall-Thru on failure to RC4 */ #endif @@ -208,7 +208,7 @@ static int ares__init_rand_engine(ares_rand_state *state) ares_rc4_init(&state->state.rc4); /* Currently cannot fail */ - return 1; + return ARES_TRUE; #endif } diff --git a/src/lib/ares_search.c b/src/lib/ares_search.c index a1f5402f..ec13b633 100644 --- a/src/lib/ares_search.c +++ b/src/lib/ares_search.c @@ -45,9 +45,9 @@ struct search_query { int status_as_is; /* error status from trying as-is */ int next_domain; /* next search domain to try */ - int trying_as_is; /* current query is for name as-is */ + ares_bool_t trying_as_is; /* current query is for name as-is */ int timeouts; /* number of timeouts we saw for this request */ - int ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */ + ares_bool_t ever_got_nodata; /* did we ever get ARES_ENODATA along the way? */ }; static void search_callback(void *arg, int status, int timeouts, @@ -110,7 +110,7 @@ void ares_search(ares_channel channel, const char *name, int dnsclass, squery->callback = callback; squery->arg = arg; squery->timeouts = 0; - squery->ever_got_nodata = 0; + squery->ever_got_nodata = ARES_FALSE; /* Count the number of dots in name. */ ndots = 0; @@ -128,14 +128,14 @@ void ares_search(ares_channel channel, const char *name, int dnsclass, { /* Try the name as-is first. */ squery->next_domain = 0; - squery->trying_as_is = 1; + squery->trying_as_is = ARES_TRUE; ares_query(channel, name, dnsclass, type, search_callback, squery); } else { /* Try the name as-is last; start with the first search domain. */ squery->next_domain = 1; - squery->trying_as_is = 0; + squery->trying_as_is = ARES_FALSE; status = ares__cat_domain(name, channel->domains[0], &s); if (status == ARES_SUCCESS) { @@ -179,7 +179,7 @@ static void search_callback(void *arg, int status, int timeouts, * returned ARES_ENOTFOUND. */ if (status == ARES_ENODATA) - squery->ever_got_nodata = 1; + squery->ever_got_nodata = ARES_TRUE; if (squery->next_domain < channel->ndomains) { @@ -190,7 +190,7 @@ static void search_callback(void *arg, int status, int timeouts, end_squery(squery, status, NULL, 0); else { - squery->trying_as_is = 0; + squery->trying_as_is = ARES_FALSE; squery->next_domain++; ares_query(channel, s, squery->dnsclass, squery->type, search_callback, squery); @@ -200,7 +200,7 @@ static void search_callback(void *arg, int status, int timeouts, else if (squery->status_as_is == -1) { /* Try the name as-is at the end. */ - squery->trying_as_is = 1; + squery->trying_as_is = ARES_TRUE; ares_query(channel, squery->name, squery->dnsclass, squery->type, search_callback, squery); } diff --git a/src/lib/ares_send.c b/src/lib/ares_send.c index a1bda2cf..f0c302fe 100644 --- a/src/lib/ares_send.c +++ b/src/lib/ares_send.c @@ -111,7 +111,7 @@ ares_status_t ares_send_ex(ares_channel channel, const unsigned char *qbuf, for (i = 0; i < channel->nservers; i++) { - query->server_info[i].skip_server = 0; + query->server_info[i].skip_server = ARES_FALSE; query->server_info[i].tcp_connection_generation = 0; }