Commit 90d3d6fb authored by Daniel Salzman's avatar Daniel Salzman

contents: simplify names for *_tree_apply_inorder and *_nsec3_apply_inorder

parent 552e40db
......@@ -548,7 +548,7 @@ static int zone_read(zone_t *zone, ctl_args_t *args)
ret = send_node((zone_node_t *)node, ctx);
} else if (zone->contents != NULL) {
ret = zone_contents_tree_apply_inorder(zone->contents, send_node, ctx);
ret = zone_contents_apply(zone->contents, send_node, ctx);
}
zone_read_failed:
......
......@@ -1039,10 +1039,10 @@ int zone_contents_adjust_full(zone_contents_t *contents)
return contents_adjust(contents, true);
}
int zone_contents_tree_apply_inorder(zone_contents_t *zone,
zone_contents_apply_cb_t function, void *data)
int zone_contents_apply(zone_contents_t *contents,
zone_contents_apply_cb_t function, void *data)
{
if (zone == NULL) {
if (contents == NULL) {
return KNOT_EINVAL;
}
......@@ -1051,13 +1051,13 @@ int zone_contents_tree_apply_inorder(zone_contents_t *zone,
.data = data
};
return zone_tree_apply(zone->nodes, tree_apply_cb, &f);
return zone_tree_apply(contents->nodes, tree_apply_cb, &f);
}
int zone_contents_nsec3_apply_inorder(zone_contents_t *zone,
zone_contents_apply_cb_t function, void *data)
int zone_contents_nsec3_apply(zone_contents_t *contents,
zone_contents_apply_cb_t function, void *data)
{
if (zone == NULL) {
if (contents == NULL) {
return KNOT_EINVAL;
}
......@@ -1066,7 +1066,7 @@ int zone_contents_nsec3_apply_inorder(zone_contents_t *zone,
.data = data
};
return zone_tree_apply(zone->nsec3_nodes, tree_apply_cb, &f);
return zone_tree_apply(contents->nsec3_nodes, tree_apply_cb, &f);
}
int zone_contents_shallow_copy(const zone_contents_t *from, zone_contents_t **to)
......@@ -1168,6 +1168,6 @@ bool zone_contents_is_empty(const zone_contents_t *zone)
size_t zone_contents_measure_size(zone_contents_t *zone)
{
zone->size = 0;
zone_contents_tree_apply_inorder(zone, measure_size, &zone->size);
zone_contents_apply(zone, measure_size, &zone->size);
return zone->size;
}
......@@ -193,37 +193,23 @@ int zone_contents_adjust_full(zone_contents_t *contents);
/*!
* \brief Applies the given function to each regular node in the zone.
*
* This function uses in-order depth-first forward traversal, i.e. the function
* is first recursively applied to left subtree, then to the root and then to
* the right subtree.
*
* \note This implies that the zone is stored in a binary tree. Is there a way
* to make this traversal independent on the underlying structure?
*
* \param zone Nodes of this zone will be used as parameters for the function.
* \param contents Nodes of this zone will be used as parameters for the function.
* \param function Function to be applied to each node of the zone.
* \param data Arbitrary data to be passed to the function.
*/
int zone_contents_tree_apply_inorder(zone_contents_t *zone,
zone_contents_apply_cb_t function, void *data);
int zone_contents_apply(zone_contents_t *contents,
zone_contents_apply_cb_t function, void *data);
/*!
* \brief Applies the given function to each NSEC3 node in the zone.
*
* This function uses in-order depth-first forward traversal, i.e. the function
* is first recursively applied to left subtree, then to the root and then to
* the right subtree.
*
* \note This implies that the zone is stored in a binary tree. Is there a way
* to make this traversal independent on the underlying structure?
*
* \param zone NSEC3 nodes of this zone will be used as parameters for the
* function.
* \param contents NSEC3 nodes of this zone will be used as parameters for the
* function.
* \param function Function to be applied to each node of the zone.
* \param data Arbitrary data to be passed to the function.
*/
int zone_contents_nsec3_apply_inorder(zone_contents_t *zone,
zone_contents_apply_cb_t function, void *data);
int zone_contents_nsec3_apply(zone_contents_t *contents,
zone_contents_apply_cb_t function, void *data);
/*!
* \brief Creates a shallow copy of the zone (no stored data are copied).
......
......@@ -823,6 +823,7 @@ int zone_do_sem_checks(zone_contents_t *zone, bool optional,
.fatal_error = false,
.level = MANDATORY,
};
if (optional) {
data.level |= OPTIONAL;
if (zone_contents_is_signed(zone)) {
......@@ -834,9 +835,7 @@ int zone_do_sem_checks(zone_contents_t *zone, bool optional,
}
}
int ret = zone_contents_tree_apply_inorder(zone, do_checks_in_tree,
&data);
int ret = zone_contents_apply(zone, do_checks_in_tree, &data);
if (ret != KNOT_EOK) {
return ret;
}
......
......@@ -155,7 +155,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file)
// Dump standard zone records without rrsigs.
params.dump_rrsig = false;
params.dump_nsec = false;
ret = zone_contents_tree_apply_inorder(zone, node_dump_text, &params);
ret = zone_contents_apply(zone, node_dump_text, &params);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -167,8 +167,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file)
// Dump rrsig records.
params.dump_rrsig = true;
params.dump_nsec = false;
ret = zone_contents_tree_apply_inorder(zone, node_dump_text,
&params);
ret = zone_contents_apply(zone, node_dump_text, &params);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -180,8 +179,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file)
params.dump_rrsig = false;
params.dump_nsec = true;
ret = zone_contents_nsec3_apply_inorder(zone, node_dump_text,
&params);
ret = zone_contents_nsec3_apply(zone, node_dump_text, &params);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -190,8 +188,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file)
params.dump_rrsig = true;
params.dump_nsec = false;
ret = zone_contents_nsec3_apply_inorder(zone, node_dump_text,
&params);
ret = zone_contents_nsec3_apply(zone, node_dump_text, &params);
if (ret != KNOT_EOK) {
return ret;
}
......@@ -201,8 +198,7 @@ int zone_dump_text(zone_contents_t *zone, FILE *file)
// Dump nsec records.
params.dump_rrsig = false;
params.dump_nsec = true;
ret = zone_contents_tree_apply_inorder(zone, node_dump_text,
&params);
ret = zone_contents_apply(zone, node_dump_text, &params);
if (ret != KNOT_EOK) {
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment