{
const char *const *values;
+ if (!dict_iterate_values(ctx, key_r, &values))
+ return FALSE;
+ *value_r = values[0];
+ return TRUE;
+}
+
+bool dict_iterate_values(struct dict_iterate_context *ctx,
+ const char **key_r, const char *const **values_r)
+{
+
if (ctx->max_rows > 0 && ctx->row_count >= ctx->max_rows) {
e_debug(ctx->event, "Maximum row count (%"PRIu64") reached",
ctx->max_rows);
ctx->has_more = FALSE;
return FALSE;
}
- if (!ctx->dict->v.iterate(ctx, key_r, &values))
+ if (!ctx->dict->v.iterate(ctx, key_r, values_r))
return FALSE;
if ((ctx->flags & DICT_ITERATE_FLAG_NO_VALUE) != 0) {
/* always return value as NULL to be consistent across
drivers */
- *value_r = NULL;
+ *values_r = NULL;
} else {
- i_assert(values[0] != NULL);
- *value_r = values[0];
+ i_assert(values_r[0] != NULL);
}
ctx->row_count++;
return TRUE;
uint64_t max_rows);
/* If dict_iterate() returns FALSE, the iteration may be finished or if this
is an async iteration it may be waiting for more data. If this function
- returns TRUE, the dict callback is called again with more data. */
+ returns TRUE, the dict callback is called again with more data. If dict
+ supports multiple values, dict_iterate_values() can be used to return all
+ of them. dict_iterate() returns only the first value and ignores the rest. */
bool dict_iterate_has_more(struct dict_iterate_context *ctx);
bool dict_iterate(struct dict_iterate_context *ctx,
const char **key_r, const char **value_r);
+bool dict_iterate_values(struct dict_iterate_context *ctx,
+ const char **key_r, const char *const **values_r);
/* Returns 0 = ok, -1 = iteration failed */
int dict_iterate_deinit(struct dict_iterate_context **ctx, const char **error_r);