Commit b7ae9804 authored by Mark Karpilovskij's avatar Mark Karpilovskij Committed by Daniel Salzman

conf: add function to reset to first value of multi-valued item

parent 573569a1
......@@ -404,15 +404,8 @@ void conf_val(
if (val->data != NULL && val->code != KNOT_EOF) {
return;
}
assert(val->blob != NULL);
wire_ctx_t ctx = wire_ctx_init_const(val->blob, val->blob_len);
uint16_t len = wire_ctx_read_u16(&ctx);
assert(ctx.error == KNOT_EOK);
val->data = ctx.position;
val->len = len;
val->code = KNOT_EOK;
// Otherwise set to the first value.
conf_val_reset(val);
} else {
// Check for empty data.
if (val->blob_len == 0) {
......@@ -459,6 +452,22 @@ void conf_val_next(
}
}
void conf_val_reset(conf_val_t *val)
{
assert(val != NULL);
assert(val->code == KNOT_EOK || val->code == KNOT_EOF);
assert(val->item->flags & YP_FMULTI);
assert(val->blob != NULL);
wire_ctx_t ctx = wire_ctx_init_const(val->blob, val->blob_len);
uint16_t len = wire_ctx_read_u16(&ctx);
assert(ctx.error == KNOT_EOK);
val->data = ctx.position;
val->len = len;
val->code = KNOT_EOK;
}
bool conf_val_equal(
conf_val_t *val1,
conf_val_t *val2)
......
......@@ -352,7 +352,7 @@ void conf_val(
);
/*!
* Moves to the next item value.
* Moves to the next value of a multi-valued item.
*
* \param[in] val Item value.
*/
......@@ -360,6 +360,15 @@ void conf_val_next(
conf_val_t *val
);
/*!
* Resets to the first value of a multi-valued item.
*
* \param[in] val Item value.
*/
void conf_val_reset(
conf_val_t *val
);
/*!
* Gets the number of values if multivalued item.
*
......
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