From 3829dca0cc17ddc44d2fbce0fe182b44542d88c8 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 6 Dec 2013 15:54:06 +0100 Subject: [PATCH] Get rid of typedefs for structs --- src/context.c | 122 +++++++++++++-------------- src/context.h | 10 +-- src/dict.c | 2 +- src/example/example_all_functions.c | 4 +- src/example/example_simple_answers.c | 4 +- src/example/example_synchronous.c | 2 +- src/example/example_tree.c | 4 +- src/general.c | 14 +-- src/general.h | 2 +- src/getdns/getdns.h | 84 +++++++++--------- src/hostname.c | 2 +- src/list.c | 2 +- src/list.h | 6 +- src/request-internal.c | 8 +- src/service.c | 2 +- src/sync.c | 12 +-- src/test/tests_stub_async.c | 4 +- src/test/tests_stub_sync.c | 6 +- src/types-internal.h | 6 +- src/util-internal.c | 84 +++++++++--------- src/util-internal.h | 14 +-- 21 files changed, 196 insertions(+), 198 deletions(-) diff --git a/src/context.c b/src/context.c index 18ec3b48..a861273d 100644 --- a/src/context.c +++ b/src/context.c @@ -47,19 +47,19 @@ #include "util-internal.h" /* Private functions */ -static uint16_t *create_default_namespaces(getdns_context_t context); +static uint16_t *create_default_namespaces(struct getdns_context *context); static struct getdns_list *create_default_root_servers(); -static getdns_return_t add_ip_str(getdns_dict *); -static struct getdns_dict *create_ipaddr_dict_from_rdf(getdns_context_t, +static getdns_return_t add_ip_str(struct getdns_dict *); +static struct getdns_dict *create_ipaddr_dict_from_rdf(struct getdns_context *, ldns_rdf *); -static struct getdns_list *create_from_ldns_list(getdns_context_t, +static struct getdns_list *create_from_ldns_list(struct getdns_context *, ldns_rdf **, size_t); -static getdns_return_t set_os_defaults(getdns_context_t); +static getdns_return_t set_os_defaults(struct getdns_context *); static int transaction_id_cmp(const void *, const void *); -static void set_ub_string_opt(getdns_context_t, char *, char *); -static void set_ub_number_opt(getdns_context_t, char *, uint16_t); -static inline void clear_resolution_type_set_flag(getdns_context_t, uint16_t); -static void dispatch_updated(getdns_context_t, uint16_t); +static void set_ub_string_opt(struct getdns_context *, char *, char *); +static void set_ub_number_opt(struct getdns_context *, char *, uint16_t); +static inline void clear_resolution_type_set_flag(struct getdns_context *, uint16_t); +static void dispatch_updated(struct getdns_context *, uint16_t); static void cancel_dns_req(getdns_dns_req *); /* Stuff to make it compile pedantically */ @@ -70,7 +70,7 @@ static void cancel_dns_req(getdns_dns_req *); * TODO: Determine from OS */ static uint16_t * -create_default_namespaces(getdns_context_t context) +create_default_namespaces(struct getdns_context *context) { uint16_t *result = GETDNS_XMALLOC(context, uint16_t, 2); result[0] = GETDNS_CONTEXT_NAMESPACE_LOCALNAMES; @@ -89,7 +89,7 @@ create_default_root_servers() } static getdns_return_t -add_ip_str(getdns_dict * ip) +add_ip_str(struct getdns_dict * ip) { struct sockaddr_storage storage; char buff[256]; @@ -123,11 +123,11 @@ add_ip_str(getdns_dict * ip) } static struct getdns_dict * -create_ipaddr_dict_from_rdf(getdns_context_t context, ldns_rdf * rdf) +create_ipaddr_dict_from_rdf(struct getdns_context *context, ldns_rdf * rdf) { ldns_rdf_type rt = ldns_rdf_get_type(rdf); size_t sz = ldns_rdf_size(rdf); - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); /* set type */ if (rt == LDNS_RDF_TYPE_A) { getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE, @@ -137,14 +137,14 @@ create_ipaddr_dict_from_rdf(getdns_context_t context, ldns_rdf * rdf) GETDNS_STR_IPV6); } /* set data */ - getdns_bindata data_bin = { sz, ldns_rdf_data(rdf) }; + struct getdns_bindata data_bin = { sz, ldns_rdf_data(rdf) }; getdns_dict_set_bindata(result, GETDNS_STR_ADDRESS_DATA, &data_bin); add_ip_str(result); return result; } static struct getdns_list * -create_from_ldns_list(getdns_context_t context, ldns_rdf ** ldns_list, +create_from_ldns_list(struct getdns_context *context, ldns_rdf ** ldns_list, size_t count) { size_t i = 0; @@ -156,7 +156,7 @@ create_from_ldns_list(getdns_context_t context, ldns_rdf ** ldns_list, case LDNS_RDF_TYPE_A: case LDNS_RDF_TYPE_AAAA: { - getdns_dict *ipaddr = + struct getdns_dict *ipaddr = create_ipaddr_dict_from_rdf(context, rdf); getdns_list_add_item(result, &idx); getdns_list_set_dict(result, idx, ipaddr); @@ -166,7 +166,7 @@ create_from_ldns_list(getdns_context_t context, ldns_rdf ** ldns_list, case LDNS_RDF_TYPE_DNAME: { - getdns_bindata item; + struct getdns_bindata item; char *srch = ldns_rdf2str(rdf); item.size = strlen(srch) + 1; item.data = (uint8_t *) srch; @@ -184,7 +184,7 @@ create_from_ldns_list(getdns_context_t context, ldns_rdf ** ldns_list, } static getdns_return_t -set_os_defaults(getdns_context_t context) +set_os_defaults(struct getdns_context *context) { ldns_resolver *lr = NULL; if (ldns_resolver_new_frm_file(&lr, NULL) != LDNS_STATUS_OK) { @@ -237,20 +237,20 @@ transaction_id_cmp(const void *id1, const void *id2) * Call this to initialize the context that is used in other getdns calls. */ getdns_return_t -getdns_context_create_with_memory_functions(getdns_context_t * context, +getdns_context_create_with_memory_functions(struct getdns_context ** context, int set_from_os, void *(*malloc)(size_t), void *(*realloc)(void *, size_t), void (*free)(void *) ) { - getdns_context_t result = NULL; + struct getdns_context *result = NULL; if (!context || !malloc || !realloc || !free) return GETDNS_RETURN_GENERIC_ERROR; /** default init **/ - result = (*malloc)(sizeof(struct getdns_context_t)); + result = (*malloc)(sizeof(struct getdns_context)); if (!result) { return GETDNS_RETURN_GENERIC_ERROR; } @@ -310,7 +310,7 @@ getdns_context_create_with_memory_functions(getdns_context_t * context, * Call this to initialize the context that is used in other getdns calls. */ getdns_return_t -getdns_context_create(getdns_context_t * context, int set_from_os) +getdns_context_create(struct getdns_context ** context, int set_from_os) { return getdns_context_create_with_memory_functions(context, set_from_os, malloc, realloc, free); @@ -324,7 +324,7 @@ getdns_context_create(getdns_context_t * context, int set_from_os) * are done with it. */ void -getdns_context_destroy(getdns_context_t context) +getdns_context_destroy(struct getdns_context *context) { if (context == NULL) { return; @@ -354,8 +354,8 @@ getdns_context_destroy(getdns_context_t context) * */ getdns_return_t -getdns_context_set_context_update_callback(getdns_context_t context, - void (*value) (getdns_context_t context, uint16_t changed_item) +getdns_context_set_context_update_callback(struct getdns_context *context, + void (*value) (struct getdns_context *context, uint16_t changed_item) ) { context->update_callback = value; @@ -367,14 +367,14 @@ getdns_context_set_context_update_callback(getdns_context_t context, */ static void -set_ub_string_opt(getdns_context_t ctx, char *opt, char *value) +set_ub_string_opt(struct getdns_context *ctx, char *opt, char *value) { ub_ctx_set_option(ctx->unbound_sync, opt, value); ub_ctx_set_option(ctx->unbound_async, opt, value); } static void -set_ub_number_opt(getdns_context_t ctx, char *opt, uint16_t value) +set_ub_number_opt(struct getdns_context *ctx, char *opt, uint16_t value) { char buffer[64]; snprintf(buffer, 64, "%hu", value); @@ -385,7 +385,7 @@ set_ub_number_opt(getdns_context_t ctx, char *opt, uint16_t value) * Clear the resolution type set flag if needed */ static inline void -clear_resolution_type_set_flag(getdns_context_t context, uint16_t type) +clear_resolution_type_set_flag(struct getdns_context *context, uint16_t type) { if (context->resolution_type_set == type) { context->resolution_type_set = 0; @@ -397,7 +397,7 @@ clear_resolution_type_set_flag(getdns_context_t context, uint16_t type) * */ getdns_return_t -getdns_context_set_context_update(getdns_context_t context, uint16_t value) +getdns_context_set_context_update(struct getdns_context *context, uint16_t value) { UNUSED_PARAM(context); UNUSED_PARAM(value); @@ -408,7 +408,7 @@ getdns_context_set_context_update(getdns_context_t context, uint16_t value) * Helper to dispatch the updated callback */ static void -dispatch_updated(getdns_context_t context, uint16_t item) +dispatch_updated(struct getdns_context *context, uint16_t item) { if (context->update_callback) { context->update_callback(context, item); @@ -420,7 +420,7 @@ dispatch_updated(getdns_context_t context, uint16_t item) * */ getdns_return_t -getdns_context_set_resolution_type(getdns_context_t context, uint16_t value) +getdns_context_set_resolution_type(struct getdns_context *context, uint16_t value) { if (value != GETDNS_CONTEXT_STUB && value != GETDNS_CONTEXT_RECURSING) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; @@ -438,7 +438,7 @@ getdns_context_set_resolution_type(getdns_context_t context, uint16_t value) * */ getdns_return_t -getdns_context_set_namespaces(getdns_context_t context, +getdns_context_set_namespaces(struct getdns_context *context, size_t namespace_count, uint16_t * namespaces) { if (namespace_count == 0 || namespaces == NULL) { @@ -464,7 +464,7 @@ getdns_context_set_namespaces(getdns_context_t context, * */ getdns_return_t -getdns_context_set_dns_transport(getdns_context_t context, uint16_t value) +getdns_context_set_dns_transport(struct getdns_context *context, uint16_t value) { switch (value) { @@ -495,7 +495,7 @@ getdns_context_set_dns_transport(getdns_context_t context, uint16_t value) * */ getdns_return_t -getdns_context_set_limit_outstanding_queries(getdns_context_t context, +getdns_context_set_limit_outstanding_queries(struct getdns_context *context, uint16_t limit) { /* num-queries-per-thread */ @@ -512,7 +512,7 @@ getdns_context_set_limit_outstanding_queries(getdns_context_t context, * */ getdns_return_t -getdns_context_set_timeout(getdns_context_t context, uint16_t timeout) +getdns_context_set_timeout(struct getdns_context *context, uint16_t timeout) { context->timeout = timeout; @@ -526,7 +526,7 @@ getdns_context_set_timeout(getdns_context_t context, uint16_t timeout) * */ getdns_return_t -getdns_context_set_follow_redirects(getdns_context_t context, uint16_t value) +getdns_context_set_follow_redirects(struct getdns_context *context, uint16_t value) { context->follow_redirects = value; @@ -541,10 +541,10 @@ getdns_context_set_follow_redirects(getdns_context_t context, uint16_t value) * */ getdns_return_t -getdns_context_set_dns_root_servers(getdns_context_t context, +getdns_context_set_dns_root_servers(struct getdns_context *context, struct getdns_list * addresses) { - getdns_list *copy = NULL; + struct getdns_list *copy = NULL; size_t count = 0; if (addresses != NULL) { if (getdns_list_copy(addresses, ©) != GETDNS_RETURN_GOOD) { @@ -560,7 +560,7 @@ getdns_context_set_dns_root_servers(getdns_context_t context, getdns_return_t r = GETDNS_RETURN_GOOD; /* validate and add ip str */ for (i = 0; i < count; ++i) { - getdns_dict *dict = NULL; + struct getdns_dict *dict = NULL; getdns_list_get_dict(addresses, i, &dict); r = add_ip_str(dict); if (r != GETDNS_RETURN_GOOD) { @@ -589,7 +589,7 @@ getdns_context_set_dns_root_servers(getdns_context_t context, * */ getdns_return_t -getdns_context_set_append_name(getdns_context_t context, uint16_t value) +getdns_context_set_append_name(struct getdns_context *context, uint16_t value) { if (value != GETDNS_CONTEXT_APPEND_NAME_ALWAYS && value != @@ -612,9 +612,9 @@ getdns_context_set_append_name(getdns_context_t context, uint16_t value) * */ getdns_return_t -getdns_context_set_suffix(getdns_context_t context, struct getdns_list * value) +getdns_context_set_suffix(struct getdns_context *context, struct getdns_list * value) { - getdns_list *copy = NULL; + struct getdns_list *copy = NULL; if (value != NULL) { if (getdns_list_copy(value, ©) != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; @@ -636,10 +636,10 @@ getdns_context_set_suffix(getdns_context_t context, struct getdns_list * value) * */ getdns_return_t -getdns_context_set_dnssec_trust_anchors(getdns_context_t context, +getdns_context_set_dnssec_trust_anchors(struct getdns_context *context, struct getdns_list * value) { - getdns_list *copy = NULL; + struct getdns_list *copy = NULL; if (value != NULL) { if (getdns_list_copy(value, ©) != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; @@ -659,7 +659,7 @@ getdns_context_set_dnssec_trust_anchors(getdns_context_t context, * */ getdns_return_t -getdns_context_set_dnssec_allowed_skew(getdns_context_t context, +getdns_context_set_dnssec_allowed_skew(struct getdns_context *context, uint16_t value) { set_ub_number_opt(context, "val-sig-skew-min", value); @@ -674,7 +674,7 @@ getdns_context_set_dnssec_allowed_skew(getdns_context_t context, * */ getdns_return_t -getdns_context_set_stub_resolution(getdns_context_t context, +getdns_context_set_stub_resolution(struct getdns_context *context, struct getdns_list * upstream_list) { size_t count = 0; @@ -683,14 +683,14 @@ getdns_context_set_stub_resolution(getdns_context_t context, if (count == 0 || r != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } - getdns_list *copy = NULL; + struct getdns_list *copy = NULL; if (getdns_list_copy(upstream_list, ©) != GETDNS_RETURN_GOOD) { return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; } upstream_list = copy; /* validate and add ip str */ for (i = 0; i < count; ++i) { - getdns_dict *dict = NULL; + struct getdns_dict *dict = NULL; getdns_list_get_dict(upstream_list, i, &dict); r = add_ip_str(dict); if (r != GETDNS_RETURN_GOOD) { @@ -719,7 +719,7 @@ getdns_context_set_stub_resolution(getdns_context_t context, * */ getdns_return_t -getdns_context_set_edns_maximum_udp_payload_size(getdns_context_t context, +getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context, uint16_t value) { /* check for < 512. uint16_t won't let it go above max) */ @@ -741,7 +741,7 @@ getdns_context_set_edns_maximum_udp_payload_size(getdns_context_t context, * */ getdns_return_t -getdns_context_set_edns_extended_rcode(getdns_context_t context, uint8_t value) +getdns_context_set_edns_extended_rcode(struct getdns_context *context, uint8_t value) { context->edns_extended_rcode = value; @@ -755,7 +755,7 @@ getdns_context_set_edns_extended_rcode(getdns_context_t context, uint8_t value) * */ getdns_return_t -getdns_context_set_edns_version(getdns_context_t context, uint8_t value) +getdns_context_set_edns_version(struct getdns_context *context, uint8_t value) { context->edns_version = value; @@ -769,7 +769,7 @@ getdns_context_set_edns_version(getdns_context_t context, uint8_t value) * */ getdns_return_t -getdns_context_set_edns_do_bit(getdns_context_t context, uint8_t value) +getdns_context_set_edns_do_bit(struct getdns_context *context, uint8_t value) { /* 0 or 1 */ if (value > 1) { @@ -788,7 +788,7 @@ getdns_context_set_edns_do_bit(getdns_context_t context, uint8_t value) * */ getdns_return_t -getdns_context_set_memory_functions(getdns_context_t context, +getdns_context_set_memory_functions(struct getdns_context *context, void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *) @@ -815,7 +815,7 @@ getdns_context_set_memory_functions(getdns_context_t context, * */ getdns_return_t -getdns_extension_set_libevent_base(getdns_context_t context, +getdns_extension_set_libevent_base(struct getdns_context *context, struct event_base * this_event_base) { if (this_event_base) { @@ -849,7 +849,7 @@ cancel_dns_req(getdns_dns_req * req) } getdns_return_t -getdns_context_cancel_request(getdns_context_t context, +getdns_context_cancel_request(struct getdns_context *context, getdns_transaction_t transaction_id, int fire_callback) { getdns_dns_req *req = NULL; @@ -890,20 +890,20 @@ getdns_context_cancel_request(getdns_context_t context, * */ getdns_return_t -getdns_cancel_callback(getdns_context_t context, +getdns_cancel_callback(struct getdns_context *context, getdns_transaction_t transaction_id) { return getdns_context_cancel_request(context, transaction_id, 1); } /* getdns_cancel_callback */ static void -ub_setup_stub(struct ub_ctx *ctx, getdns_list * upstreams, size_t count) +ub_setup_stub(struct ub_ctx *ctx, struct getdns_list * upstreams, size_t count) { size_t i; /* reset forwarding servers */ ub_ctx_set_fwd(ctx, NULL); for (i = 0; i < count; ++i) { - getdns_dict *dict = NULL; + struct getdns_dict *dict = NULL; char *ip_str = NULL; getdns_list_get_dict(upstreams, i, &dict); getdns_dict_util_get_string(dict, GETDNS_STR_ADDRESS_STRING, @@ -913,7 +913,7 @@ ub_setup_stub(struct ub_ctx *ctx, getdns_list * upstreams, size_t count) } getdns_return_t -getdns_context_prepare_for_resolution(getdns_context_t context) +getdns_context_prepare_for_resolution(struct getdns_context *context) { if (context->resolution_type_set == context->resolution_type) { /* already set and no config changes have caused this to be @@ -958,7 +958,7 @@ getdns_context_track_outbound_request(getdns_dns_req * req) if (!req) { return GETDNS_RETURN_GENERIC_ERROR; } - getdns_context_t context = req->context; + struct getdns_context *context = req->context; ldns_rbnode_t *node = GETDNS_MALLOC(context, ldns_rbnode_t); if (!node) { return GETDNS_RETURN_GENERIC_ERROR; @@ -979,7 +979,7 @@ getdns_context_clear_outbound_request(getdns_dns_req * req) if (!req) { return GETDNS_RETURN_GENERIC_ERROR; } - getdns_context_t context = req->context; + struct getdns_context *context = req->context; ldns_rbnode_t *node = ldns_rbtree_delete(context->outbound_requests, &(req->trans_id)); if (node) { diff --git a/src/context.h b/src/context.h index f1aa337c..2a04b147 100644 --- a/src/context.h +++ b/src/context.h @@ -38,10 +38,9 @@ struct ldns_rbtree_t; struct ub_ctx; /** function pointer typedefs */ -typedef void (*getdns_update_callback) (getdns_context_t, uint16_t); +typedef void (*getdns_update_callback) (struct getdns_context *, uint16_t); -struct getdns_context_t -{ +struct getdns_context { /* Context values */ uint16_t resolution_type; @@ -89,8 +88,7 @@ struct getdns_context_t * Sets up the unbound contexts with stub or recursive behavior * if needed. */ -getdns_return_t getdns_context_prepare_for_resolution(getdns_context_t - context); +getdns_return_t getdns_context_prepare_for_resolution(struct getdns_context *context); /* track an outbound request */ getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req @@ -99,7 +97,7 @@ getdns_return_t getdns_context_track_outbound_request(struct getdns_dns_req getdns_return_t getdns_context_clear_outbound_request(struct getdns_dns_req *req); /* cancel callback internal - flag to indicate if req should be freed and callback fired */ -getdns_return_t getdns_context_cancel_request(getdns_context_t context, +getdns_return_t getdns_context_cancel_request(struct getdns_context *context, getdns_transaction_t transaction_id, int fire_callback); char *getdns_strdup(void *(*malloc)(size_t), const char *str); diff --git a/src/dict.c b/src/dict.c index 7cfeee7b..0592ec32 100644 --- a/src/dict.c +++ b/src/dict.c @@ -211,7 +211,7 @@ getdns_dict_create_with_memory_functions(void *(*malloc)(size_t), /*-------------------------- getdns_dict_create_with_context */ struct getdns_dict * -getdns_dict_create_with_context(getdns_context_t context) +getdns_dict_create_with_context(struct getdns_context *context) { if (context) return getdns_dict_create_with_memory_functions(context->malloc, diff --git a/src/example/example_all_functions.c b/src/example/example_all_functions.c index 55a90f02..e8719fae 100644 --- a/src/example/example_all_functions.c +++ b/src/example/example_all_functions.c @@ -31,7 +31,7 @@ struct getdns_list **listptrarg; size_t sizetarg; size_t *sizetptrarg; -getdns_context_t contextarg = NULL; +struct getdns_context *contextarg = NULL; uint8_t uint8arg; uint16_t uint16arg; uint32_t uint32arg; @@ -61,7 +61,7 @@ deallocfunctionarg(void *foo) } void -setcallbackfunctionarg(struct getdns_context_t *foo1, uint16_t foo2) +setcallbackfunctionarg(struct getdns_context *foo1, uint16_t foo2) { UNUSED_PARAM(foo1); UNUSED_PARAM(foo2); diff --git a/src/example/example_simple_answers.c b/src/example/example_simple_answers.c index cd2cedd5..d29fd97d 100644 --- a/src/example/example_simple_answers.c +++ b/src/example/example_simple_answers.c @@ -43,7 +43,7 @@ /* Set up the callback function, which will also do the processing of the results */ void -this_callbackfn(struct getdns_context_t *this_context, +this_callbackfn(struct getdns_context *this_context, uint16_t this_callback_type, struct getdns_dict *this_response, void *this_userarg, getdns_transaction_t this_transaction_id) @@ -109,7 +109,7 @@ int main() { /* Create the DNS context for this call */ - struct getdns_context_t *this_context = NULL; + struct getdns_context *this_context = NULL; getdns_return_t context_create_return = getdns_context_create(&this_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { diff --git a/src/example/example_synchronous.c b/src/example/example_synchronous.c index 33ec12f3..87c14bba 100644 --- a/src/example/example_synchronous.c +++ b/src/example/example_synchronous.c @@ -40,7 +40,7 @@ main() size_t num_addresses = 0; size_t rec_count; struct getdns_bindata *this_address_data; - struct getdns_context_t *this_context = NULL; + struct getdns_context *this_context = NULL; uint32_t this_error = 0; struct getdns_dict *this_extensions = NULL; const char *this_name = "www.example.com"; diff --git a/src/example/example_tree.c b/src/example/example_tree.c index 4c27611f..edadd190 100644 --- a/src/example/example_tree.c +++ b/src/example/example_tree.c @@ -15,7 +15,7 @@ /* Set up the callback function, which will also do the processing of the results */ void -this_callbackfn(struct getdns_context_t *this_context, +this_callbackfn(struct getdns_context *this_context, getdns_return_t this_callback_type, struct getdns_dict *this_response, void *this_userarg, getdns_transaction_t this_transaction_id) @@ -120,7 +120,7 @@ int main() { /* Create the DNS context for this call */ - struct getdns_context_t *this_context = NULL; + struct getdns_context *this_context = NULL; getdns_return_t context_create_return = getdns_context_create(&this_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { diff --git a/src/general.c b/src/general.c index d33c01cb..58b632d7 100644 --- a/src/general.c +++ b/src/general.c @@ -92,7 +92,7 @@ static void ub_resolve_timeout(evutil_socket_t fd, short what, void *arg) { getdns_dns_req *dns_req = (getdns_dns_req *) arg; - getdns_context_t context = dns_req->context; + struct getdns_context *context = dns_req->context; getdns_transaction_t trans_id = dns_req->trans_id; getdns_callback_t cb = dns_req->user_callback; void *user_arg = dns_req->user_pointer; @@ -135,7 +135,7 @@ static void handle_network_request_error(getdns_network_req * netreq, int err) { getdns_dns_req *dns_req = netreq->owner; - getdns_context_t context = dns_req->context; + struct getdns_context *context = dns_req->context; getdns_transaction_t trans_id = dns_req->trans_id; getdns_callback_t cb = dns_req->user_callback; void *user_arg = dns_req->user_pointer; @@ -151,9 +151,9 @@ handle_network_request_error(getdns_network_req * netreq, int err) static void handle_dns_request_complete(getdns_dns_req * dns_req) { - getdns_dict *response = create_getdns_response(dns_req); + struct getdns_dict *response = create_getdns_response(dns_req); - getdns_context_t context = dns_req->context; + struct getdns_context *context = dns_req->context; getdns_transaction_t trans_id = dns_req->trans_id; getdns_callback_t cb = dns_req->user_callback; void *user_arg = dns_req->user_pointer; @@ -256,7 +256,7 @@ ub_resolve_callback(void *arg, int err, ldns_buffer * result, int sec, getdns_return_t getdns_general_ub(struct ub_ctx *unbound, struct event_base *ev_base, - getdns_context_t context, + struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict *extensions, @@ -320,7 +320,7 @@ getdns_general_ub(struct ub_ctx *unbound, * getdns_general */ getdns_return_t -getdns_general(getdns_context_t context, +getdns_general(struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict * extensions, @@ -352,7 +352,7 @@ getdns_general(getdns_context_t context, * */ getdns_return_t -getdns_address(getdns_context_t context, +getdns_address(struct getdns_context *context, const char *name, struct getdns_dict * extensions, void *userarg, diff --git a/src/general.h b/src/general.h index 31743771..3885e37b 100644 --- a/src/general.h +++ b/src/general.h @@ -46,7 +46,7 @@ struct event_base; getdns_return_t getdns_general_ub(struct ub_ctx *unbound, struct event_base *ev_base, - getdns_context_t context, + struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict *extensions, diff --git a/src/getdns/getdns.h b/src/getdns/getdns.h index 48433d14..e6288bd2 100644 --- a/src/getdns/getdns.h +++ b/src/getdns/getdns.h @@ -323,7 +323,7 @@ struct event_base; /** @} */ -typedef struct getdns_context_t *getdns_context_t; +struct getdns_context; typedef uint16_t getdns_return_t; typedef uint64_t getdns_transaction_t; /** @@ -333,24 +333,24 @@ typedef enum getdns_data_type { t_dict, t_list, t_int, t_bindata } getdns_data_type; -typedef struct getdns_bindata +struct getdns_bindata { size_t size; uint8_t *data; -} getdns_bindata; +}; /** * getdns dictionary data type * Use helper functions getdns_dict_* to manipulate and iterate dictionaries */ -typedef struct getdns_dict getdns_dict; +struct getdns_dict; /** * getdns list data type * Use helper functions getdns_list_* to manipulate and iterate lists * Indexes are 0 based. */ -typedef struct getdns_list getdns_list; +struct getdns_list; /** * translate an error code to a string value, not in the original api description @@ -504,7 +504,7 @@ getdns_return_t getdns_dict_get_int(struct getdns_dict *this_dict, char *name, * @return pointer to an allocated list, NULL if insufficient memory */ struct getdns_list *getdns_list_create(); -struct getdns_list *getdns_list_create_with_context(getdns_context_t context); +struct getdns_list *getdns_list_create_with_context(struct getdns_context *context); struct getdns_list *getdns_list_create_with_memory_functions( void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *)); @@ -565,7 +565,7 @@ getdns_return_t getdns_list_set_int(struct getdns_list *this_list, size_t index, * @return pointer to an allocated dictionary, NULL if insufficient memory */ struct getdns_dict *getdns_dict_create(); -struct getdns_dict *getdns_dict_create_with_context(getdns_context_t context); +struct getdns_dict *getdns_dict_create_with_context(struct getdns_context *context); struct getdns_dict *getdns_dict_create_with_memory_functions( void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *)); @@ -610,7 +610,7 @@ getdns_return_t getdns_dict_set_int(struct getdns_dict *this_dict, char *name, uint32_t child_uint32); /* Callback arguments */ -typedef void (*getdns_callback_t) (getdns_context_t context, +typedef void (*getdns_callback_t) (struct getdns_context *context, uint16_t callback_type, struct getdns_dict * response, void *userarg, getdns_transaction_t transaction_id); @@ -618,46 +618,46 @@ typedef void (*getdns_callback_t) (getdns_context_t context, /* Function definitions */ getdns_return_t -getdns_general(getdns_context_t context, +getdns_general(struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict *extensions, void *userarg, getdns_transaction_t * transaction_id, getdns_callback_t callbackfn); getdns_return_t -getdns_address(getdns_context_t context, +getdns_address(struct getdns_context *context, const char *name, struct getdns_dict *extensions, void *userarg, getdns_transaction_t * transaction_id, getdns_callback_t callbackfn); getdns_return_t -getdns_hostname(getdns_context_t context, +getdns_hostname(struct getdns_context *context, struct getdns_dict *address, struct getdns_dict *extensions, void *userarg, getdns_transaction_t * transaction_id, getdns_callback_t callbackfn); getdns_return_t -getdns_service(getdns_context_t context, +getdns_service(struct getdns_context *context, const char *name, struct getdns_dict *extensions, void *userarg, getdns_transaction_t * transaction_id, getdns_callback_t callbackfn); getdns_return_t getdns_context_create_with_memory_functions( - getdns_context_t * context, + struct getdns_context ** context, int set_from_os, void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *) ); -getdns_return_t getdns_context_create(getdns_context_t * context, +getdns_return_t getdns_context_create(struct getdns_context ** context, int set_from_os); -void getdns_context_destroy(getdns_context_t context); +void getdns_context_destroy(struct getdns_context *context); getdns_return_t -getdns_cancel_callback(getdns_context_t context, +getdns_cancel_callback(struct getdns_context *context, getdns_transaction_t transaction_id); /** @@ -679,7 +679,7 @@ getdns_cancel_callback(getdns_context_t context, * @return GETDNS_RETURN_GOOD on success */ getdns_return_t -getdns_general_sync(getdns_context_t context, +getdns_general_sync(struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict *extensions, @@ -695,7 +695,7 @@ getdns_general_sync(getdns_context_t context, */ getdns_return_t -getdns_address_sync(getdns_context_t context, +getdns_address_sync(struct getdns_context *context, const char *name, struct getdns_dict *extensions, struct getdns_dict **response); @@ -709,7 +709,7 @@ getdns_address_sync(getdns_context_t context, * @return GETDNS_RETURN_GOOD on success */ getdns_return_t -getdns_hostname_sync(getdns_context_t context, +getdns_hostname_sync(struct getdns_context *context, struct getdns_dict *address, struct getdns_dict *extensions, struct getdns_dict **response); @@ -723,7 +723,7 @@ getdns_hostname_sync(getdns_context_t context, * @return GETDNS_RETURN_GOOD on success */ getdns_return_t -getdns_service_sync(getdns_context_t context, +getdns_service_sync(struct getdns_context *context, const char *name, struct getdns_dict *extensions, struct getdns_dict **response); @@ -758,75 +758,75 @@ char *getdns_display_ip_address(struct getdns_bindata /* getdns_return_t getdns_context_set_context_update_callback( - getdns_context_t context, - void (*value) (getdns_context_t context, uint16_t changed_item) + struct getdns_context *context, + void (*value) (struct getdns_context *context, uint16_t changed_item) ); */ getdns_return_t getdns_context_set_context_update_callback( - getdns_context_t context, - void (*value)(getdns_context_t context, uint16_t changed_item) + struct getdns_context * context, + void (*value)(struct getdns_context *context, uint16_t changed_item) ); getdns_return_t -getdns_context_set_resolution_type(getdns_context_t context, uint16_t value); +getdns_context_set_resolution_type(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_namespaces(getdns_context_t context, +getdns_context_set_namespaces(struct getdns_context *context, size_t namespace_count, uint16_t * namespaces); getdns_return_t -getdns_context_set_dns_transport(getdns_context_t context, uint16_t value); +getdns_context_set_dns_transport(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_limit_outstanding_queries(getdns_context_t context, +getdns_context_set_limit_outstanding_queries(struct getdns_context *context, uint16_t limit); getdns_return_t -getdns_context_set_timeout(getdns_context_t context, uint16_t timeout); +getdns_context_set_timeout(struct getdns_context *context, uint16_t timeout); getdns_return_t -getdns_context_set_follow_redirects(getdns_context_t context, uint16_t value); +getdns_context_set_follow_redirects(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_dns_root_servers(getdns_context_t context, +getdns_context_set_dns_root_servers(struct getdns_context *context, struct getdns_list *addresses); getdns_return_t -getdns_context_set_append_name(getdns_context_t context, uint16_t value); +getdns_context_set_append_name(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_suffix(getdns_context_t context, struct getdns_list *value); +getdns_context_set_suffix(struct getdns_context *context, struct getdns_list *value); getdns_return_t -getdns_context_set_dnssec_trust_anchors(getdns_context_t context, +getdns_context_set_dnssec_trust_anchors(struct getdns_context *context, struct getdns_list *value); getdns_return_t -getdns_context_set_dnssec_allowed_skew(getdns_context_t context, +getdns_context_set_dnssec_allowed_skew(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_stub_resolution(getdns_context_t context, +getdns_context_set_stub_resolution(struct getdns_context *context, struct getdns_list *upstream_list); getdns_return_t -getdns_context_set_edns_maximum_udp_payload_size(getdns_context_t context, +getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context, uint16_t value); getdns_return_t -getdns_context_set_edns_extended_rcode(getdns_context_t context, +getdns_context_set_edns_extended_rcode(struct getdns_context *context, uint8_t value); getdns_return_t -getdns_context_set_edns_version(getdns_context_t context, uint8_t value); +getdns_context_set_edns_version(struct getdns_context *context, uint8_t value); getdns_return_t -getdns_context_set_edns_do_bit(getdns_context_t context, uint8_t value); +getdns_context_set_edns_do_bit(struct getdns_context *context, uint8_t value); getdns_return_t -getdns_context_set_memory_functions(getdns_context_t context, +getdns_context_set_memory_functions(struct getdns_context *context, void *(*malloc) (size_t), void *(*realloc) (void *, size_t), void (*free) (void *) @@ -835,7 +835,7 @@ getdns_context_set_memory_functions(getdns_context_t context, /* Extension - refactor to abstract async evt loop */ /* For libevent, which we are using for these examples */ getdns_return_t -getdns_extension_set_libevent_base(getdns_context_t context, +getdns_extension_set_libevent_base(struct getdns_context *context, struct event_base *this_event_base); #endif /* GETDNS_H */ diff --git a/src/hostname.c b/src/hostname.c index 98947917..66326fd5 100644 --- a/src/hostname.c +++ b/src/hostname.c @@ -43,7 +43,7 @@ * */ getdns_return_t -getdns_hostname(getdns_context_t context, +getdns_hostname(struct getdns_context *context, struct getdns_dict * address, struct getdns_dict * extensions, void *userarg, diff --git a/src/list.c b/src/list.c index f1d88c33..c3890487 100644 --- a/src/list.c +++ b/src/list.c @@ -234,7 +234,7 @@ getdns_list_create_with_memory_functions(void *(*malloc)(size_t), /*-------------------------- getdns_list_create_with_context */ struct getdns_list * -getdns_list_create_with_context(getdns_context_t context) +getdns_list_create_with_context(struct getdns_context *context) { if (context) return getdns_list_create_with_memory_functions(context->malloc, diff --git a/src/list.h b/src/list.h index 2119e458..d5267769 100644 --- a/src/list.h +++ b/src/list.h @@ -42,10 +42,10 @@ struct getdns_list_item getdns_data_type dtype; union { - getdns_list *list; - getdns_dict *dict; + struct getdns_list *list; + struct getdns_dict *dict; int n; - getdns_bindata *bindata; + struct getdns_bindata *bindata; } data; }; diff --git a/src/request-internal.c b/src/request-internal.c index ab1db272..093a90db 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -54,7 +54,7 @@ network_req_free(getdns_network_req * net_req) if (!net_req) { return; } - getdns_context_t context = net_req->owner->context; + struct getdns_context *context = net_req->owner->context; if (net_req->result) { ldns_pkt_free(net_req->result); } @@ -67,7 +67,7 @@ network_req_new(getdns_dns_req * owner, uint16_t request_class, struct getdns_dict *extensions) { - getdns_context_t context = owner->context; + struct getdns_context *context = owner->context; getdns_network_req *net_req = gd_malloc(sizeof(getdns_network_req)); if (!net_req) { return NULL; @@ -93,7 +93,7 @@ dns_req_free(getdns_dns_req * req) return; } getdns_network_req *net_req = NULL; - getdns_context_t context = req->context; + struct getdns_context *context = req->context; /* free extensions */ getdns_dict_destroy(req->extensions); @@ -125,7 +125,7 @@ dns_req_free(getdns_dns_req * req) /* create a new dns req to be submitted */ getdns_dns_req * -dns_req_new(getdns_context_t context, +dns_req_new(struct getdns_context *context, struct ub_ctx *unbound, const char *name, uint16_t request_type, struct getdns_dict *extensions) { diff --git a/src/service.c b/src/service.c index 73cd8b12..39061de0 100644 --- a/src/service.c +++ b/src/service.c @@ -38,7 +38,7 @@ * */ getdns_return_t -getdns_service(getdns_context_t context, +getdns_service(struct getdns_context *context, const char *name, struct getdns_dict * extensions, void *userarg, diff --git a/src/sync.c b/src/sync.c index bb2fc3b3..45c63887 100644 --- a/src/sync.c +++ b/src/sync.c @@ -51,17 +51,17 @@ #define UNUSED_PARAM(x) ((void)(x)) static void -sync_callback_func(getdns_context_t context, +sync_callback_func(struct getdns_context *context, uint16_t callback_type, struct getdns_dict *response, void *userarg, getdns_transaction_t transaction_id) { - *((getdns_dict **) userarg) = response; + *((struct getdns_dict **) userarg) = response; } getdns_return_t -getdns_general_sync(getdns_context_t context, +getdns_general_sync(struct getdns_context *context, const char *name, uint16_t request_type, struct getdns_dict *extensions, @@ -82,7 +82,7 @@ getdns_general_sync(getdns_context_t context, } getdns_return_t -getdns_address_sync(getdns_context_t context, +getdns_address_sync(struct getdns_context *context, const char *name, struct getdns_dict * extensions, struct getdns_dict ** response) @@ -105,7 +105,7 @@ getdns_address_sync(getdns_context_t context, } getdns_return_t -getdns_hostname_sync(getdns_context_t context, +getdns_hostname_sync(struct getdns_context *context, struct getdns_dict * address, struct getdns_dict * extensions, struct getdns_dict ** response) @@ -138,7 +138,7 @@ getdns_hostname_sync(getdns_context_t context, } getdns_return_t -getdns_service_sync(getdns_context_t context, +getdns_service_sync(struct getdns_context *context, const char *name, struct getdns_dict * extensions, struct getdns_dict ** response) diff --git a/src/test/tests_stub_async.c b/src/test/tests_stub_async.c index 0d4d72fc..613444c3 100644 --- a/src/test/tests_stub_async.c +++ b/src/test/tests_stub_async.c @@ -40,7 +40,7 @@ /* Set up the callback function, which will also do the processing of the results */ void -this_callbackfn(struct getdns_context_t *this_context, +this_callbackfn(struct getdns_context *this_context, uint16_t this_callback_type, struct getdns_dict *this_response, void *this_userarg, getdns_transaction_t this_transaction_id) @@ -65,7 +65,7 @@ int main(int argc, char** argv) { /* Create the DNS context for this call */ - struct getdns_context_t *this_context = NULL; + struct getdns_context *this_context = NULL; getdns_return_t context_create_return = getdns_context_create(&this_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { diff --git a/src/test/tests_stub_sync.c b/src/test/tests_stub_sync.c index e5117664..86edd768 100644 --- a/src/test/tests_stub_sync.c +++ b/src/test/tests_stub_sync.c @@ -33,7 +33,7 @@ #include static void -print_response(getdns_dict * response) +print_response(struct getdns_dict * response) { char *dict_str = getdns_pretty_print_dict(response); if (dict_str) { @@ -46,7 +46,7 @@ int main() { /* Create the DNS context for this call */ - struct getdns_context_t *this_context = NULL; + struct getdns_context *this_context = NULL; getdns_return_t context_create_return = getdns_context_create(&this_context, 1); if (context_create_return != GETDNS_RETURN_GOOD) { @@ -56,7 +56,7 @@ main() } getdns_context_set_resolution_type(this_context, GETDNS_CONTEXT_STUB); - getdns_dict *response = NULL; + struct getdns_dict *response = NULL; getdns_return_t ret = getdns_address_sync(this_context, "www.google.com", NULL, &response); diff --git a/src/types-internal.h b/src/types-internal.h index 6c9126ec..2859f6d2 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -158,13 +158,13 @@ typedef struct getdns_dns_req struct event_base *ev_base; /* context that owns the request */ - getdns_context_t context; + struct getdns_context *context; /* ub_ctx issuing the request */ struct ub_ctx *unbound; /* request extensions */ - getdns_dict *extensions; + struct getdns_dict *extensions; /* callback data */ getdns_callback_t user_callback; @@ -200,7 +200,7 @@ getdns_network_req *network_req_new(getdns_dns_req * owner, uint16_t request_class, struct getdns_dict *extensions); /* dns request utils */ -getdns_dns_req *dns_req_new(getdns_context_t context, +getdns_dns_req *dns_req_new(struct getdns_context *context, struct ub_ctx *unbound, const char *name, uint16_t request_type, struct getdns_dict *extensions); diff --git a/src/util-internal.c b/src/util-internal.c index 8667b8f6..d6a44943 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -60,18 +60,18 @@ getdns_extension_format extformats[] = { }; getdns_return_t -getdns_dict_util_set_string(getdns_dict * dict, char *name, const char *value) +getdns_dict_util_set_string(struct getdns_dict * dict, char *name, const char *value) { /* account for the null term */ if (value == NULL) { return GETDNS_RETURN_WRONG_TYPE_REQUESTED; } - getdns_bindata type_bin = { strlen(value) + 1, (uint8_t *) value }; + struct getdns_bindata type_bin = { strlen(value) + 1, (uint8_t *) value }; return getdns_dict_set_bindata(dict, name, &type_bin); } getdns_return_t -getdns_dict_util_get_string(getdns_dict * dict, char *name, char **result) +getdns_dict_util_get_string(struct getdns_dict * dict, char *name, char **result) { struct getdns_bindata *bindata = NULL; if (!result) { @@ -87,7 +87,7 @@ getdns_dict_util_get_string(getdns_dict * dict, char *name, char **result) } getdns_return_t -dict_to_sockaddr(getdns_dict * ns, struct sockaddr_storage * output) +dict_to_sockaddr(struct getdns_dict * ns, struct sockaddr_storage * output) { char *address_type = NULL; struct getdns_bindata *address_data = NULL; @@ -127,15 +127,15 @@ dict_to_sockaddr(getdns_dict * ns, struct sockaddr_storage * output) } getdns_return_t -sockaddr_to_dict(getdns_context_t context, struct sockaddr_storage *address, - getdns_dict ** output) +sockaddr_to_dict(struct getdns_context *context, struct sockaddr_storage *address, + struct getdns_dict ** output) { if (!output || !address) { return GETDNS_RETURN_GENERIC_ERROR; } - getdns_bindata addr_data; + struct getdns_bindata addr_data; *output = NULL; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); if (address->ss_family == AF_INET) { struct sockaddr_in *addr = (struct sockaddr_in *) address; getdns_dict_util_set_string(result, GETDNS_STR_ADDRESS_TYPE, @@ -172,12 +172,12 @@ convert_rdf_to_str(ldns_rdf * rdf) } /* create the header dict */ -static getdns_dict * -create_reply_header_dict(getdns_context_t context, ldns_pkt * reply) +static struct getdns_dict * +create_reply_header_dict(struct getdns_context *context, ldns_pkt * reply) { /* { "id": 23456, "qr": 1, "opcode": 0, ... }, */ int r = 0; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); if (!result) { return NULL; } @@ -196,14 +196,14 @@ create_reply_header_dict(getdns_context_t context, ldns_pkt * reply) return result; } -static getdns_dict * -create_reply_question_dict(getdns_context_t context, ldns_pkt * reply) +static struct getdns_dict * +create_reply_question_dict(struct getdns_context *context, ldns_pkt * reply) { /* { "qname": , "qtype": 1, "qclass": 1 } */ int r = 0; ldns_rr *question = NULL; char *qname; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); if (!result) { return NULL; } @@ -227,8 +227,8 @@ create_reply_question_dict(getdns_context_t context, ldns_pkt * reply) return result; } -static getdns_dict * -create_dict_from_rdf(getdns_context_t context, ldns_rdf * rdf) +static struct getdns_dict * +create_dict_from_rdf(struct getdns_context *context, ldns_rdf * rdf) { /* * create a dict w/ rdata_raw and special fields if needed @@ -239,8 +239,8 @@ create_dict_from_rdf(getdns_context_t context, ldns_rdf * rdf) * } */ int r = 0; - getdns_bindata rbin = { ldns_rdf_size(rdf), ldns_rdf_data(rdf) }; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_bindata rbin = { ldns_rdf_size(rdf), ldns_rdf_data(rdf) }; + struct getdns_dict *result = getdns_dict_create_with_context(context); r |= getdns_dict_set_bindata(result, GETDNS_STR_KEY_RDATA_RAW, &rbin); if (ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_AAAA) { r |= getdns_dict_set_bindata(result, GETDNS_STR_KEY_V6_ADDR, @@ -256,8 +256,8 @@ create_dict_from_rdf(getdns_context_t context, ldns_rdf * rdf) return result; } -static getdns_dict * -create_dict_from_rr(getdns_context_t context, ldns_rr * rr) +static struct getdns_dict * +create_dict_from_rr(struct getdns_context *context, ldns_rr * rr) { /* * { @@ -274,7 +274,7 @@ create_dict_from_rr(getdns_context_t context, ldns_rr * rr) */ int r = 0; char *name = NULL; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); size_t rd_count = ldns_rr_rd_count(rr); ldns_rdf *owner = ldns_rr_owner(rr); r |= getdns_dict_set_int(result, GETDNS_STR_KEY_TYPE, @@ -294,7 +294,7 @@ create_dict_from_rr(getdns_context_t context, ldns_rr * rr) } /* create rdatas */ if (rd_count >= 1) { - getdns_dict *rdata = create_dict_from_rdf(context, + struct getdns_dict *rdata = create_dict_from_rdf(context, ldns_rr_rdf(rr, 0)); r |= getdns_dict_set_dict(result, GETDNS_STR_KEY_RDATA, rdata); getdns_dict_destroy(rdata); @@ -311,16 +311,16 @@ create_dict_from_rr(getdns_context_t context, ldns_rr * rr) /* helper to convert an rr_list to getdns_list. returns a list of objects where each object is a result from create_dict_from_rr */ -static getdns_list * -create_list_from_rr_list(getdns_context_t context, ldns_rr_list * rr_list) +static struct getdns_list * +create_list_from_rr_list(struct getdns_context *context, ldns_rr_list * rr_list) { size_t i = 0; size_t idx = 0; int r = 0; - getdns_list *result = getdns_list_create_with_context(context); + struct getdns_list *result = getdns_list_create_with_context(context); for (i = 0; i < ldns_rr_list_rr_count(rr_list); ++i) { ldns_rr *rr = ldns_rr_list_rr(rr_list, i); - getdns_dict *rrdict = create_dict_from_rr(context, rr); + struct getdns_dict *rrdict = create_dict_from_rr(context, rr); r |= getdns_list_add_item(result, &idx); r |= getdns_list_set_dict(result, idx, rrdict); getdns_dict_destroy(rrdict); @@ -334,7 +334,7 @@ create_list_from_rr_list(getdns_context_t context, ldns_rr_list * rr_list) /* helper to add the ipv4 or ipv6 bin data to the list of addrs */ static getdns_return_t -add_only_addresses(getdns_list * addrs, ldns_rr_list * rr_list) +add_only_addresses(struct getdns_list * addrs, ldns_rr_list * rr_list) { int r = 0; size_t i = 0; @@ -347,7 +347,7 @@ add_only_addresses(getdns_list * addrs, ldns_rr_list * rr_list) ldns_rdf *rdf = ldns_rr_rdf(rr, j); if (ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_A || ldns_rdf_get_type(rdf) == LDNS_RDF_TYPE_AAAA) { - getdns_bindata rbin = + struct getdns_bindata rbin = { ldns_rdf_size(rdf), ldns_rdf_data(rdf) }; r |= getdns_list_add_item(addrs, &item_idx); r |= getdns_list_set_bindata(addrs, item_idx, @@ -358,9 +358,9 @@ add_only_addresses(getdns_list * addrs, ldns_rr_list * rr_list) return r; } -static getdns_dict * -create_reply_dict(getdns_context_t context, getdns_network_req * req, - getdns_list * just_addrs) +static struct getdns_dict * +create_reply_dict(struct getdns_context *context, getdns_network_req * req, + struct getdns_list * just_addrs) { /* turn a packet into this glorious structure * @@ -405,11 +405,11 @@ create_reply_dict(getdns_context_t context, getdns_network_req * req, ldns_pkt *reply = req->result; ldns_rr_list *rr_list = NULL; ldns_rr *question = NULL; - getdns_dict *subdict = NULL; - getdns_list *sublist = NULL; + struct getdns_dict *subdict = NULL; + struct getdns_list *sublist = NULL; char *name = NULL; - getdns_dict *result = getdns_dict_create_with_context(context); + struct getdns_dict *result = getdns_dict_create_with_context(context); if (!result) { return NULL; } @@ -478,14 +478,14 @@ get_canonical_name(const char *name) return result; } -getdns_dict * +struct getdns_dict * create_getdns_response(struct getdns_dns_req * completed_request) { - getdns_dict *result = getdns_dict_create_with_context(completed_request->context); - getdns_list *replies_full = getdns_list_create_with_context( + struct getdns_dict *result = getdns_dict_create_with_context(completed_request->context); + struct getdns_list *replies_full = getdns_list_create_with_context( completed_request->context); - getdns_list *just_addrs = NULL; - getdns_list *replies_tree = getdns_list_create_with_context( + struct getdns_list *just_addrs = NULL; + struct getdns_list *replies_tree = getdns_list_create_with_context( completed_request->context); getdns_network_req *netreq = completed_request->first_req; char *canonical_name = NULL; @@ -509,7 +509,7 @@ create_getdns_response(struct getdns_dns_req * completed_request) GETDNS_NAMETYPE_DNS); while (netreq) { - getdns_bindata full_data; + struct getdns_bindata full_data; full_data.data = NULL; full_data.size = 0; ldns_pkt *pkt = netreq->result; @@ -517,7 +517,7 @@ create_getdns_response(struct getdns_dns_req * completed_request) ldns_pkt2wire(&(full_data.data), pkt, &(full_data.size)); size_t idx = 0; /* reply tree */ - getdns_dict *reply = create_reply_dict( + struct getdns_dict *reply = create_reply_dict( completed_request->context, netreq, just_addrs); r |= getdns_list_add_item(replies_tree, &idx); r |= getdns_list_set_dict(replies_tree, idx, reply); @@ -596,7 +596,7 @@ extformatcmp(const void *a, const void *b) /*---------------------------------------- validate_extensions */ getdns_return_t -validate_extensions(getdns_dict * extensions) +validate_extensions(struct getdns_dict * extensions) { struct getdns_dict_item *item; getdns_extension_format *extformat; diff --git a/src/util-internal.h b/src/util-internal.h index 1048cda0..94d2b5d3 100644 --- a/src/util-internal.h +++ b/src/util-internal.h @@ -78,21 +78,21 @@ getdns_return_t getdns_dict_copy(struct getdns_dict *srcdict, struct getdns_dict **dstdict); /* convert an ip address dict to a sock storage */ -getdns_return_t dict_to_sockaddr(getdns_dict * ns, +getdns_return_t dict_to_sockaddr(struct getdns_dict * ns, struct sockaddr_storage *output); -getdns_return_t sockaddr_to_dict(getdns_context_t context, - struct sockaddr_storage *sockaddr, getdns_dict ** output); +getdns_return_t sockaddr_to_dict(struct getdns_context *context, + struct sockaddr_storage *sockaddr, struct getdns_dict ** output); struct getdns_dns_req; -getdns_dict *create_getdns_response(struct getdns_dns_req *completed_request); +struct getdns_dict *create_getdns_response(struct getdns_dns_req *completed_request); /* dict util */ /* set a string as bindata */ -getdns_return_t getdns_dict_util_set_string(getdns_dict * dict, char *name, +getdns_return_t getdns_dict_util_set_string(struct getdns_dict * dict, char *name, const char *value); /* get a string from a dict. result is valid as long as dict is valid */ -getdns_return_t getdns_dict_util_get_string(getdns_dict * dict, char *name, +getdns_return_t getdns_dict_util_get_string(struct getdns_dict * dict, char *name, char **result); char *reverse_address(char *addr_str); @@ -104,6 +104,6 @@ char *reverse_address(char *addr_str); * @return GETDNS_RETURN_NO_SUCH_EXTENSION A name in the extensions dict is not a valid extension. * @return GETDNS_RETURN_EXTENSION_MISFORMAT One or more of the extensions has a bad format. */ -getdns_return_t validate_extensions(getdns_dict * extensions); +getdns_return_t validate_extensions(struct getdns_dict * extensions); /* util-internal.h */