int cli_start_tasks(struct cli_state *s) { int status; status = rxtx_startup(cli_state, BLADERF_MODULE_RX); if (status != 0) { cli_err(s, "Error", "Failed to start RX task.\n"); return CLI_RET_UNKNOWN; } status = rxtx_startup(cli_state, BLADERF_MODULE_TX); if (status != 0) { cli_err(s, "Error", "Failed to start TX task.\n"); return CLI_RET_UNKNOWN; } return 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; } 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; }
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; }