]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
added rdf's in a specific spot
authorMiek Gieben <miekg@NLnetLabs.nl>
Wed, 16 Mar 2005 19:57:37 +0000 (19:57 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Wed, 16 Mar 2005 19:57:37 +0000 (19:57 +0000)
ldns/rr.h
rr.c

index e911a7cb765369c1210be22812b14cefb1743c8d..8801494f15d3e3045d52dfc4dabe0b72b26d9c2f 100644 (file)
--- 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 4f4ade7dd4689506361c763281faad58a9112367..4e4e008eb1ec5dbe618cacc8d812899c9b4997f0 100644 (file)
--- 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