Пример #1
0
struct cli_state *cli_state_create()
{
    cli_state = malloc(sizeof(*cli_state));

    if (cli_state) {
        cli_state->dev = NULL;
        cli_state->last_lib_error = 0;
        cli_state->scripts = NULL;

        pthread_mutex_init(&cli_state->dev_lock, NULL);

        cli_state->rx = rxtx_data_alloc(BLADERF_MODULE_RX);
        if (!cli_state->rx) {
            goto cli_state_create_fail;
        }

        cli_state->tx = rxtx_data_alloc(BLADERF_MODULE_TX);
        if (!cli_state->tx) {
            goto cli_state_create_fail;
        }
    }

    init_signal_handling();

    return cli_state;

cli_state_create_fail:
    cli_state_destroy(cli_state);
    return NULL;
}
Пример #2
0
struct cli_state *cli_state_create()
{
    cli_state = malloc(sizeof(*cli_state));

    if (cli_state) {
        cli_state->dev = NULL;
        cli_state->last_lib_error = 0;
        cli_state->scripts = NULL;

        cli_state->rx = rxtx_data_alloc(BLADERF_MODULE_RX);
        if (!cli_state->rx) {
            goto cli_state_create_fail;
        }

        cli_state->tx = rxtx_data_alloc(BLADERF_MODULE_TX);
        if (!cli_state->tx) {
            goto cli_state_create_fail;
        }

        if (rxtx_startup(cli_state, BLADERF_MODULE_RX)) {
            rxtx_data_free(cli_state->rx);
            cli_state->rx = NULL;
            goto cli_state_create_fail;
        }

        if (rxtx_startup(cli_state, BLADERF_MODULE_TX)) {
            rxtx_data_free(cli_state->tx);
            cli_state->tx = NULL;
            goto cli_state_create_fail;
        }
    }

    init_signal_handling();

    return cli_state;

cli_state_create_fail:
    cli_state_destroy(cli_state);
    return NULL;
}
Пример #3
0
struct cli_state *cli_state_create()
{
    struct cli_state *ret = malloc(sizeof(*ret));

    if (ret) {
        ret->dev = NULL;
        ret->last_lib_error = 0;
        ret->script = NULL;
        ret->lineno = 0;

        ret->rx = rxtx_data_alloc(BLADERF_MODULE_RX);
        if (!ret->rx) {
            goto cli_state_create_fail;
        }

        ret->tx = rxtx_data_alloc(BLADERF_MODULE_TX);
        if (!ret->tx) {
            goto cli_state_create_fail;
        }

        if (rxtx_startup(ret, BLADERF_MODULE_RX)) {
            rxtx_data_free(ret->rx);
            ret->rx = NULL;
            goto cli_state_create_fail;
        }

        if (rxtx_startup(ret, BLADERF_MODULE_TX)) {
            rxtx_data_free(ret->tx);
            ret->tx = NULL;
            goto cli_state_create_fail;
        }
    }

    return ret;

cli_state_create_fail:
    cli_state_destroy(ret);
    return NULL;
}
Пример #4
0
struct cli_state *cli_state_create()
{
    struct cli_state *ret = malloc(sizeof(*ret));

    if (ret) {
        ret->dev = NULL;
        ret->last_lib_error = 0;
        ret->script = NULL;
        ret->lineno = 0;

        ret->rxtx_data = rxtx_data_alloc(ret);
        if (!ret->rxtx_data) {
            fprintf(stderr, "Failed to allocate RX/TX task data\n");
            free(ret);
            ret = NULL;
        }
    }

    return ret;
}