From: Miek Gieben Date: Thu, 23 Jun 2005 10:05:45 +0000 (+0000) Subject: add zone push function. Moved ldns_status stuff to simple booleans X-Git-Tag: release-0.70~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=65fd9d6d57bba89943dfcddc2d2ed5d240709ebe;p=thirdparty%2Fldns.git add zone push function. Moved ldns_status stuff to simple booleans --- diff --git a/ldns/rr.h b/ldns/rr.h index be6b4989..a00ab757 100644 --- a/ldns/rr.h +++ b/ldns/rr.h @@ -438,7 +438,7 @@ void ldns_rr_list_deep_free(ldns_rr_list *rr_list); * \param[in] right the rightside * \return a left with right concatenated to it */ -ldns_status ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right); +bool ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right); /** * concatenates two ldns_rr_lists together, but makes clones of the rr's diff --git a/ldns/zone.h b/ldns/zone.h index 82f62e1d..18887089 100644 --- a/ldns/zone.h +++ b/ldns/zone.h @@ -38,7 +38,6 @@ struct ldns_struct_zone typedef struct ldns_struct_zone ldns_zone; - /** * \param[in] z the zone to read from * \return the soa record in the zone @@ -63,5 +62,23 @@ ldns_rr_list * ldns_zone_rrs(ldns_zone *z); */ void ldns_zone_set_rrs(ldns_zone *z, ldns_rr_list *rrlist); +/** + * push an rrlist to a zone structure. This function use pointer + * copying, so the rr_list structure inside z is modified! + * \param[in] z the zone to add to + * \param[in] list the list to add + * \return a true on succes otherwise falsed + */ +bool ldns_zone_push_rr_list(ldns_zone *z, ldns_rr_list *list); + +/** + * push an singkle rr to a zone structure. This function use pointer + * copying, so the rr_list structure inside z is modified! + * \param[in] z the zone to add to + * \param[in] rr the rr to add + * \return a true on succes otherwise falsed + */ +bool ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr); + #endif /* LDNS_ZONE_H */ diff --git a/rr.c b/rr.c index 59267931..34fbabc6 100644 --- a/rr.c +++ b/rr.c @@ -480,7 +480,7 @@ ldns_rr_list_deep_free(ldns_rr_list *rr_list) /* add right to left. So we modify *left! */ -ldns_status +bool ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right) { uint16_t r_rr_count; @@ -490,7 +490,7 @@ ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right) if (left) { l_rr_count = ldns_rr_list_rr_count(left); } else { - return LDNS_STATUS_NULL; + return false; } if (right) { @@ -501,14 +501,14 @@ ldns_rr_list_cat(ldns_rr_list *left, ldns_rr_list *right) if (l_rr_count + r_rr_count > LDNS_MAX_RR ) { /* overflow error */ - return LDNS_STATUS_ERR; + return false; } /* push right to left */ for(i = 0; i < r_rr_count; i++) { ldns_rr_list_push_rr(left, ldns_rr_list_rr(right, i)); } - return LDNS_STATUS_OK; + return true; } ldns_rr_list * diff --git a/zone.c b/zone.c index 896cde93..888cd010 100644 --- a/zone.c +++ b/zone.c @@ -37,6 +37,19 @@ ldns_zone_set_rrs(ldns_zone *z, ldns_rr_list *rrlist) z->_rrs = rrlist; } +bool +ldns_zone_push_rr_list(ldns_zone *z, ldns_rr_list *list) +{ + return ldns_rr_list_cat(ldns_zone_rrs(z), list); + +} + +bool +ldns_zone_push_rr(ldns_zone *z, ldns_rr *rr) +{ + return ldns_rr_list_push_rr( + ldns_zone_rrs(z), rr); +} #if 0