From: Miek Gieben Date: Thu, 6 Apr 2006 09:14:26 +0000 (+0000) Subject: change this prototype too, pkt in the first arg and return status X-Git-Tag: release-1.1.0~240 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e57fdf9ec005cd542e2f69335cb7e34586df79fd;p=thirdparty%2Fldns.git change this prototype too, pkt in the first arg and return status --- diff --git a/Changelog b/Changelog index 0fb014e8..348a3e36 100644 --- a/Changelog +++ b/Changelog @@ -53,6 +53,8 @@ XX Jan 2006: 1.1.0: ldns-team the rdf is return in the first argument * ldns_resolver_new_frm_fp: same treatment: return status and the new resolver in the first argument + * ldns_pkt_query_new_frm_str(): same: return status and the + packet in the first arg * tsig.h: internal used functions are now static: ldns_digest_name and ldns_tsig_mac_new * ldns_key_rr2ds has an extra argument to specify the hash to diff --git a/ldns/packet.h b/ldns/packet.h index e3e227b0..9e0087b7 100644 --- a/ldns/packet.h +++ b/ldns/packet.h @@ -602,13 +602,14 @@ void ldns_pkt_free(ldns_pkt *packet); /** * creates a query packet for the given name, type, class. + * \param[out] p the packet to be returned * \param[in] rr_name the name to query for (as string) * \param[in] rr_type the type to query for * \param[in] rr_class the class to query for * \param[in] flags packet flags - * \return ldns_pkt* a pointer to the new pkt + * \return LDNS_STATUS_OK or a ldns_status mesg with the error */ -ldns_pkt *ldns_pkt_query_new_frm_str(const char *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class , uint16_t flags); +ldns_status ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *rr_name, ldns_rr_type rr_type, ldns_rr_class rr_class , uint16_t flags); /** * creates a packet with a query in it for the given name, type and class. diff --git a/packet.c b/packet.c index 288c3916..2a84fe23 100644 --- a/packet.c +++ b/packet.c @@ -783,9 +783,9 @@ ldns_pkt_set_flags(ldns_pkt *packet, uint16_t flags) return true; } -ldns_pkt * -ldns_pkt_query_new_frm_str(const char *name, ldns_rr_type rr_type, ldns_rr_class rr_class, - uint16_t flags) +ldns_status +ldns_pkt_query_new_frm_str(ldns_pkt **p, const char *name, ldns_rr_type rr_type, + ldns_rr_class rr_class, uint16_t flags) { ldns_pkt *packet; ldns_rr *question_rr; @@ -793,16 +793,16 @@ ldns_pkt_query_new_frm_str(const char *name, ldns_rr_type rr_type, ldns_rr_class packet = ldns_pkt_new(); if (!packet) { - return NULL; + return LDNS_STATUS_MEM_ERR; } if (!ldns_pkt_set_flags(packet, flags)) { - return NULL; + return LDNS_STATUS_ERR; } question_rr = ldns_rr_new(); if (!question_rr) { - return NULL; + return LDNS_STATUS_MEM_ERR; } if (rr_type == 0) { @@ -821,14 +821,18 @@ ldns_pkt_query_new_frm_str(const char *name, ldns_rr_type rr_type, ldns_rr_class } else { ldns_rr_free(question_rr); ldns_pkt_free(packet); - return NULL; + return LDNS_STATUS_ERR; } packet->_tsig_rr = NULL; ldns_pkt_set_answerfrom(packet, NULL); - - return packet; + if (p) { + *p = packet; + return LDNS_STATUS_OK; + } else { + return LDNS_STATUS_NULL; + } } ldns_pkt *