Example #1
0
//  --------------------------------------------------------------------------
//  Set tree value from specified blob.  Note that the data is copied.
//
int
zfl_tree_set_value (zfl_tree_t *self, zfl_blob_t *blob)
{
    assert (self);
    zfl_blob_destroy (&self->blob);
    if (blob)
        self->blob = zfl_blob_new (zfl_blob_data (blob), zfl_blob_size (blob));
    return 0;
}
Example #2
0
int
zfl_config_set_string (zfl_config_t *self, char *string)
{
    assert (self);
    zfl_blob_t *blob = zfl_blob_new (NULL, 0);
    zfl_blob_set_dptr (blob, (byte *) string, string? strlen (string) + 1: 0);
    zfl_config_set_value (self, blob);
    zfl_blob_destroy (&blob);
    return 0;
}
Example #3
0
int
zfl_config_set_printf (zfl_config_t *self, char *format, ...)
{
    char value [255 + 1];
    va_list args;

    assert (self);
    va_start (args, format);
    vsnprintf (value, 255, format, args);
    va_end (args);

    zfl_blob_t *blob = zfl_blob_new (NULL, 0);
    zfl_blob_set_dptr (blob, (byte *) value, strlen (value) + 1);
    zfl_config_set_value (self, blob);
    zfl_blob_destroy (&blob);
    return 0;
}
Example #4
0
void
zfl_config_destroy (zfl_config_t **self_p)
{
    assert (self_p);
    if (*self_p) {
        zfl_config_t *self = *self_p;

        //  Recurse like it's a normal binary config
        if (self->child)
            zfl_config_destroy (&self->child);
        if (self->next)
            zfl_config_destroy (&self->next);

        zfl_blob_destroy (&self->blob);
        zfree (self->name);
        zfree (self);
        *self_p = NULL;
    }
}