Exemplo n.º 1
0
/**
 * Store the per-transaction data for use with the operator.
 *
 * @param[in] m This module.
 * @param[in,out] tx Transaction to store the data in.
 * @param[in] instance_data Pointer to the operator instance data.
 * @param[in] tx_data Data to be stored.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_ENOENT if the structure does not exist.
 */
static
ib_status_t set_ee_tx_data(
    const ib_module_t  *m,
    ib_tx_t            *tx,
    ee_operator_data_t *instance_data,
    ee_tx_data_t       *tx_data
)
{
    assert(tx != NULL);
    assert(instance_data != NULL);
    assert(tx_data != NULL);

    ib_hash_t *hash;
    ib_status_t rc;

    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    rc = ib_hash_set_ex(hash,
                        instance_data->id,
                        IB_UUID_LENGTH - 1,
                        tx_data);

    return rc;
}
Exemplo n.º 2
0
Arquivo: pcre.c Projeto: niubl/ironbee
/**
 * Return the per-transaction data for use with the dfa operator.
 *
 * @param[in] m PCRE module.
 * @param[in,out] tx Transaction to store the value in.
 * @param[in] id The operator identifier used to get it's workspace.
 * @param[out] workspace Retrieved.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_ENOENT if the structure does not exist. Call alloc_dfa_tx_data then.
 *   - IB_EALLOC on an allocation error.
 */
static
ib_status_t get_dfa_tx_data(
    const ib_module_t  *m,
    ib_tx_t            *tx,
    const char         *id,
    dfa_workspace_t   **workspace
)
{
    assert(tx);
    assert(tx->mp);
    assert(id);
    assert(workspace);

    ib_hash_t *hash;
    ib_status_t rc;

    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    rc = ib_hash_get(hash, workspace, id);
    if (rc != IB_OK) {
        *workspace = NULL;
    }

    return rc;
}
Exemplo n.º 3
0
/**
 * Store the per-transaction data for use with the operator.
 *
 * @param[in] m This module.
 * @param[in,out] tx Transaction to store the data in.
 * @param[in] instance_data Pointer to the operator instance data.
 * @param[in] eudoxus_state State to be stored.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_ENOENT if the structure does not exist.
 */
static
ib_status_t set_ee_tx_data(
    const ib_module_t  *m,
    ib_tx_t            *tx,
    ee_operator_data_t *instance_data,
    ia_eudoxus_state_t *eudoxus_state
)
{
    assert(tx != NULL);
    assert(tx->mp != NULL);
    assert(instance_data != NULL);
    assert(eudoxus_state != NULL);

    ib_hash_t *hash;
    ib_status_t rc;

    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    rc = ib_hash_set_ex(hash,
                        (const char *)&instance_data,
                        sizeof(ee_operator_data_t *),
                        eudoxus_state);

    return rc;
}
Exemplo n.º 4
0
Arquivo: pcre.c Projeto: niubl/ironbee
/**
 * Create the per-transaction data for use with the dfa operator.
 *
 * @param[in] m PCRE module.
 * @param[in,out] tx Transaction to store the value in.
 * @param[in] cpatt_data Compiled pattern data
 * @param[in] id The operator identifier used to get it's workspace.
 * @param[out] workspace Created.
 *
 * @returns
 *   - IB_OK on success.
 *   - IB_EALLOC on an allocation error.
 */
static
ib_status_t alloc_dfa_tx_data(
    const ib_module_t          *m,
    ib_tx_t                    *tx,
    const modpcre_cpat_data_t  *cpatt_data,
    const char                 *id,
    dfa_workspace_t           **workspace
)
{
    assert(tx);
    assert(tx->mp);
    assert(id);
    assert(workspace);

    ib_hash_t *hash;
    ib_status_t rc;
    dfa_workspace_t *ws;
    size_t size;

    *workspace = NULL;
    rc = get_or_create_operator_data_hash(m, tx, &hash);
    if (rc != IB_OK) {
        return rc;
    }

    ws = (dfa_workspace_t *)ib_mpool_alloc(tx->mp, sizeof(*ws));
    if (ws == NULL) {
        return IB_EALLOC;
    }

    ws->wscount = cpatt_data->dfa_ws_size;
    size = sizeof(*(ws->workspace)) * (ws->wscount);
    ws->workspace = (int *)ib_mpool_alloc(tx->mp, size);
    if (ws->workspace == NULL) {
        return IB_EALLOC;
    }

    rc = ib_hash_set(hash, id, ws);
    if (rc == IB_OK) {
        *workspace = ws;
    }

    return rc;
}