Example #1
0
/*
 * Example callback that returns a list of forms.
 */
static enum conflate_mgmt_cb_result process_ping_test(void *opaque,
                                                      conflate_handle_t *handle,
                                                      const char *cmd,
                                                      bool direct,
                                                      kvpair_t *form,
                                                      conflate_form_result *r)
{
    kvpair_t *servers_p = find_kvpair(form, "servers");
    if (!servers_p) {
        return RV_BADARG;
    }
    char **servers = servers_p->values;

    for (int i = 0; servers[i]; i++) {
        /* For each result we wish to send back, we begin a field set */
        conflate_next_fieldset(r);

        /* All fields added now fall within the current fieldset */
        conflate_add_field(r, "-set-", servers[i]);

        const char *vals[3] = { "val1", "val2", NULL };
        conflate_add_field_multi(r, "test1", vals);

        conflate_add_field(r, "test2", "some val");
    }

    return RV_OK;
}
Example #2
0
void conflate_add_field(conflate_form_result *r, const char *k, const char *v)
{
    const char *vals[2] = { v, NULL };
    conflate_add_field_multi(r, k, vals);
}