Example #1
0
static void core_vars_gen_list(ib_tx_t *tx, const char *name)
{
    assert(tx != NULL);
    assert(name != NULL);

    ib_status_t rc;
    ib_var_source_t *source;

    rc = ib_var_source_acquire(
             &source,
             tx->mp,
             ib_var_store_config(tx->var_store),
             name, strlen(name)
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to acquire \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_initialize(source, NULL, tx->var_store, IB_FTYPE_LIST);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
                          "Failed add \"%s\" var to transaction: %s",
                          name, ib_status_to_string(rc)
                         );
    }
}
Example #2
0
static void core_gen_tx_numeric_field(ib_tx_t *tx,
                                      const char *name,
                                      ib_num_t val)
{
    ib_field_t *f;

    assert(tx != NULL);
    assert(name != NULL);

    ib_num_t num = val;
    ib_status_t rc = ib_field_create(&f, tx->mp,
                                     name, strlen(name),
                                     IB_FTYPE_NUM,
                                     &num);
    if (rc != IB_OK) {
        ib_log_warning(tx->ib, "Failed to create \"%s\" field: %s",
                       name, ib_status_to_string(rc));
        return;
    }

    rc = ib_data_add(tx->data, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
            "Failed add \"%s\" field to transaction data store: %s",
            name, ib_status_to_string(rc)
        );
    }
}
Example #3
0
static void core_gen_tx_bytestr_alias_field(ib_tx_t *tx,
                                            const char *name,
                                            ib_bytestr_t *val)
{
    ib_field_t *f;

    assert(tx != NULL);
    assert(name != NULL);
    assert(val != NULL);

    ib_status_t rc = ib_field_create_no_copy(&f, tx->mp,
                                             name, strlen(name),
                                             IB_FTYPE_BYTESTR,
                                             val);
    if (rc != IB_OK) {
        ib_log_warning(tx->ib, "Failed to create \"%s\" field: %s",
                       name, ib_status_to_string(rc));
        return;
    }

    rc = ib_data_add(tx->data, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
            "Failed add \"%s\" field to transaction data store: %s",
            name, ib_status_to_string(rc)
        );
    }
}
Example #4
0
static void core_gen_tx_bytestr_alias2(
    ib_tx_t *tx,
    const char *name,
    const char *val, size_t val_length
)
{
    assert(tx != NULL);
    assert(name != NULL);
    assert(val != NULL);

    ib_status_t rc;
    ib_bytestr_t *bytestr;

    rc = ib_bytestr_alias_mem(
             &bytestr,
             tx->mp,
             (const uint8_t *)val,
             val_length
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to create alias for \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    core_gen_tx_bytestr_alias(tx, name, bytestr);
}
Example #5
0
static void core_gen_tx_bytestr_alias(ib_tx_t *tx,
                                      const char *name,
                                      ib_bytestr_t *val)
{

    assert(tx != NULL);
    assert(name != NULL);
    assert(val != NULL);

    ib_field_t *f;
    ib_var_source_t *source;
    ib_status_t rc;

    rc = ib_field_create_no_copy(
             &f,
             tx->mp,
             name, strlen(name),
             IB_FTYPE_BYTESTR,
             val
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to create \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_acquire(
             &source,
             tx->mp,
             ib_var_store_config(tx->var_store),
             name, strlen(name)
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to acquire \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_set(source, tx->var_store, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
                          "Failed add \"%s\" var to transaction: %s",
                          name, ib_status_to_string(rc)
                         );
    }
}
Example #6
0
static void core_gen_tx_numeric(ib_tx_t *tx,
                                const char *name,
                                ib_num_t val)
{
    assert(tx != NULL);
    assert(name != NULL);

    ib_field_t *f;
    ib_num_t num = val;
    ib_status_t rc;
    ib_var_source_t *source;

    rc = ib_field_create(&f, tx->mp,
                         name, strlen(name),
                         IB_FTYPE_NUM,
                         &num);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to create \"%s\" field: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_acquire(
             &source,
             tx->mp,
             ib_var_store_config(tx->var_store),
             name, strlen(name)
         );
    if (rc != IB_OK) {
        ib_log_warning_tx(tx, "Failed to acquire \"%s\" var: %s",
                          name, ib_status_to_string(rc));
        return;
    }

    rc = ib_var_source_set(source, tx->var_store, f);
    if (rc != IB_OK) {
        ib_log_warning_tx(tx,
                          "Failed add \"%s\" var to transaction: %s",
                          name, ib_status_to_string(rc)
                         );
    }
}