From: Miek Gieben Date: Wed, 16 Mar 2005 19:57:37 +0000 (+0000) Subject: added rdf's in a specific spot X-Git-Tag: release-0.50~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eedc685bd249644f568092fa61641472d3c7671d;p=thirdparty%2Fldns.git added rdf's in a specific spot --- diff --git a/ldns/rr.h b/ldns/rr.h index e911a7cb..8801494f 100644 --- a/ldns/rr.h +++ b/ldns/rr.h @@ -247,6 +247,7 @@ void ldns_rr_set_type(ldns_rr *, ldns_rr_type); void ldns_rr_set_class(ldns_rr *, ldns_rr_class); bool ldns_rr_push_rdf(ldns_rr *, ldns_rdf *); ldns_rdf *ldns_rr_rdf(const ldns_rr *, uint16_t); +ldns_rdf * ldns_rr_set_rdf(ldns_rr *rr, ldns_rdf *f, uint16_t position); ldns_rdf *ldns_rr_owner(const ldns_rr *); uint32_t ldns_rr_ttl(const ldns_rr *); uint16_t ldns_rr_rd_count(const ldns_rr *); diff --git a/rr.c b/rr.c index 4f4ade7d..4e4e008e 100644 --- a/rr.c +++ b/rr.c @@ -263,6 +263,30 @@ ldns_rr_set_class(ldns_rr *rr, ldns_rr_class rr_class) rr->_rr_class = rr_class; } +/** + * set a rdf member, it will be set on the + * position given. The old value is returned, like pop + */ +ldns_rdf * +ldns_rr_set_rdf(ldns_rr *rr, ldns_rdf *f, uint16_t position) +{ + uint16_t rd_count; + ldns_rdf *pop; + ldns_rdf **rdata_fields; + + rd_count = ldns_rr_rd_count(rr); + if (position > rd_count) { + return NULL; + } + + rdata_fields = rr->_rdata_fields; + /* dicard the old one */ + pop = rr->_rdata_fields[position]; + rr->_rdata_fields[position] = f; + return pop; +} + + /** * set rd_field member, it will be * placed in the next available spot