mod_freetdm: Whitespace, indentation and coding-style clean up.

No functional changes.

Signed-off-by: Stefan Knoblich <stkn@openisdn.net>
This commit is contained in:
Stefan Knoblich 2012-09-11 17:12:31 +02:00
parent 02c24da081
commit adfb2ca385

View File

@ -190,7 +190,6 @@ static void stop_hold(switch_core_session_t *session_a, const char *uuid)
{
switch_core_session_t *session;
switch_channel_t *channel, *channel_a;
;
if (!uuid) {
return;
@ -247,7 +246,6 @@ static void start_hold(ftdm_channel_t *ftdmchan, switch_core_session_t *session_
stream = globals.hold_music;
}
if (zstr(stream) && !(stream = switch_channel_get_variable(channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
stream = globals.hold_music;
}
@ -275,7 +273,6 @@ static void cycle_foreground(ftdm_channel_t *ftdmchan, int flash, const char *bc
private_t *tech_pvt;
uint32_t tokencnt = ftdm_channel_get_token_count(ftdmchan);
for (i = 0; i < tokencnt; i++) {
if ((session = ftdm_channel_get_session(ftdmchan, i))) {
const char *buuid;
@ -283,7 +280,6 @@ static void cycle_foreground(ftdm_channel_t *ftdmchan, int flash, const char *bc
channel = switch_core_session_get_channel(session);
buuid = switch_channel_get_partner_uuid(channel);
if (tokencnt == 1 && flash) {
if (switch_test_flag(tech_pvt, TFLAG_HOLD)) {
stop_hold(session, buuid);
@ -405,7 +401,6 @@ init_codecs:
switch_set_flag_locked(tech_pvt, TFLAG_IO);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_init(switch_core_session_t *session)
@ -1149,7 +1144,6 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
}
return status;
}
switch_state_handler_table_t freetdm_state_handlers = {
@ -1165,7 +1159,6 @@ switch_state_handler_table_t freetdm_state_handlers = {
/*.on_park*/ NULL,
/*.on_reporting*/ NULL,
/*.on_destroy*/ channel_on_destroy
};
switch_io_routines_t freetdm_io_routines = {
@ -1243,9 +1236,11 @@ static ftdm_status_t on_channel_found(ftdm_channel_t *fchan, ftdm_caller_data_t
char spanresource[512];
snprintf(spanresource, sizeof(spanresource), "span_%s_%s", ftdm_channel_get_span_name(fchan),
caller_data->dnis.digits);
ftdm_log(FTDM_LOG_DEBUG, "Adding rate limit resource on channel %d:%d (%s/%s/%d/%d)\n",
span_id, chan_id, FREETDM_LIMIT_REALM,
spanresource, SPAN_CONFIG[span_id].limit_calls, SPAN_CONFIG[span_id].limit_seconds);
if (switch_limit_incr("hash", hdata->new_session, FREETDM_LIMIT_REALM, spanresource,
SPAN_CONFIG[span_id].limit_calls, SPAN_CONFIG[span_id].limit_seconds) != SWITCH_STATUS_SUCCESS) {
return FTDM_BREAK;
@ -1632,7 +1627,6 @@ static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *sessi
}
fail:
return cause;
}
@ -1751,7 +1745,6 @@ ftdm_status_t ftdm_channel_from_event(ftdm_sigmsg_t *sigmsg, switch_core_session
switch_channel_set_variable_printf(channel, "screening_ind", ftdm_screening2str(channel_caller_data->screen));
switch_channel_set_variable_printf(channel, "presentation_ind", ftdm_presentation2str(channel_caller_data->pres));
if (globals.sip_headers) {
switch_channel_set_variable(channel, "sip_h_X-FreeTDM-SpanName", ftdm_channel_get_span_name(sigmsg->channel));
switch_channel_set_variable_printf(channel, "sip_h_X-FreeTDM-SpanNumber", "%d", spanid);
@ -1886,13 +1879,11 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
spanid = ftdm_channel_get_span_id(sigmsg->channel);
switch (sigmsg->event_id) {
case FTDM_SIGEVENT_SMS:
{
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel);
ftdm_sms_data_t *sms = (ftdm_sms_data_t*) caller_data->priv;
ftdm_log(FTDM_LOG_INFO,"FTDM_SIGEVENT_SMS from %s: %s", sms->from, sms->body);
if (switch_event_create(&event, SWITCH_EVENT_TRAP) != SWITCH_STATUS_SUCCESS) {
ftdm_log(FTDM_LOG_ERROR, "failed to create SMS event\n");
@ -1904,7 +1895,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
}
//return FTDM_BREAK;
break;
case FTDM_SIGEVENT_ALARM_CLEAR:
case FTDM_SIGEVENT_ALARM_TRAP:
{
@ -1935,6 +1925,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
}
return FTDM_SUCCESS;
}
break;
case FTDM_SIGEVENT_TRANSFER_COMPLETED:
{
switch_core_session_t *session = NULL;
@ -1952,7 +1943,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
return FTDM_SUCCESS;
}
break;
case FTDM_SIGEVENT_RELEASED:
case FTDM_SIGEVENT_INDICATION_COMPLETED:
case FTDM_SIGEVENT_DIALING:
@ -1981,8 +1971,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_common_signal)
}
if (event) {
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-name", "%s", ftdm_channel_get_span_name(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "span-number", "%d", ftdm_channel_get_span_id(sigmsg->channel));
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "chan-number", "%d", ftdm_channel_get_id(sigmsg->channel));
@ -2027,7 +2015,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxo_signal)
ftdm_log(FTDM_LOG_DEBUG, "got FXO sig %d:%d [%s]\n", spanid, chanid, ftdm_signal_event2str(sigmsg->event_id));
switch(sigmsg->event_id) {
case FTDM_SIGEVENT_PROGRESS_MEDIA:
{
if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2069,15 +2056,14 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxo_signal)
}
}
break;
case FTDM_SIGEVENT_SIGSTATUS_CHANGED: { /* twiddle */ } break;
case FTDM_SIGEVENT_SIGSTATUS_CHANGED:
break;
default:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n",
sigmsg->event_id, spanid, chanid);
}
break;
}
return FTDM_SUCCESS;
@ -2124,7 +2110,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
}
}
break;
case FTDM_SIGEVENT_STOP:
{
private_t *tech_pvt = NULL;
@ -2181,8 +2166,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
if (session_b) {
switch_core_session_rwunlock(session_b);
}
}
while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2194,10 +2177,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
switch_core_session_rwunlock(session);
}
ftdm_channel_clear_token(sigmsg->channel, NULL);
}
break;
case FTDM_SIGEVENT_ADD_CALL:
{
cycle_foreground(sigmsg->channel, 1, NULL);
@ -2251,10 +2232,8 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
ftdm_channel_call_hold(sigmsg->channel);
}
}
}
break;
case FTDM_SIGEVENT_COLLECTED_DIGIT:
{
int span_id = ftdm_channel_get_span_id(sigmsg->channel);
@ -2296,14 +2275,12 @@ static FIO_SIGNAL_CB_FUNCTION(on_fxs_signal)
}
}
break;
default:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled msg type %d for channel %d:%d\n",
sigmsg->event_id, spanid, chanid);
}
break;
}
return status;
@ -2328,8 +2305,7 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
switch (sigmsg->event_id) {
/* on_call_disconnect from the R2 side */
case FTDM_SIGEVENT_STOP:
case FTDM_SIGEVENT_STOP: /* on_call_disconnect from the R2 side */
{
private_t *tech_pvt = NULL;
while ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2341,16 +2317,12 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
}
break;
/* on_call_offered from the R2 side */
case FTDM_SIGEVENT_START:
case FTDM_SIGEVENT_START: /* on_call_offered from the R2 side */
{
status = ftdm_channel_from_event(sigmsg, &session);
}
break;
/* on DNIS received from the R2 forward side, return status == FTDM_BREAK to stop requesting DNIS */
case FTDM_SIGEVENT_COLLECTED_DIGIT:
case FTDM_SIGEVENT_COLLECTED_DIGIT: /* on DNIS received from the R2 forward side, return status == FTDM_BREAK to stop requesting DNIS */
{
ftdm_caller_data_t *caller_data = ftdm_channel_get_caller_data(sigmsg->channel);
int span_id = ftdm_channel_get_span_id(sigmsg->channel);
@ -2387,7 +2359,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
}
break;
case FTDM_SIGEVENT_PROGRESS:
{
if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2397,7 +2368,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
}
break;
case FTDM_SIGEVENT_PROGRESS_MEDIA:
{
if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2407,7 +2377,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
}
break;
case FTDM_SIGEVENT_UP:
{
if ((session = ftdm_channel_get_session(sigmsg->channel, 0))) {
@ -2418,7 +2387,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
}
}
break;
case FTDM_SIGEVENT_SIGSTATUS_CHANGED:
{
ftdm_signaling_status_t sigstatus = sigmsg->ev_data.sigstatus.status;
@ -2426,10 +2394,9 @@ static FIO_SIGNAL_CB_FUNCTION(on_r2_signal)
spanid, chanid, ftdm_signaling_status2str(sigstatus));
}
break;
case FTDM_SIGEVENT_PROCEED:{} break;
case FTDM_SIGEVENT_INDICATION_COMPLETED:{} break;
case FTDM_SIGEVENT_PROCEED:
case FTDM_SIGEVENT_INDICATION_COMPLETED:
break;
default:
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unhandled event %d from R2 for channel %d:%d\n",
@ -2464,7 +2431,6 @@ static FIO_SIGNAL_CB_FUNCTION(on_clear_channel_signal)
return ftdm_channel_from_event(sigmsg, &session);
}
break;
case FTDM_SIGEVENT_STOP:
case FTDM_SIGEVENT_RESTART:
{
@ -2591,9 +2557,11 @@ static void ftdm_logger(const char *file, const char *func, int line, int level,
if (switch_vasprintf(&data, fmt, ap) != -1) {
switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, (char *)func, line, NULL, level, "%s", data);
}
if (data) free(data);
va_end(ap);
if (data) {
free(data);
}
va_end(ap);
}
static uint32_t enable_analog_option(const char *str, uint32_t current_options)
@ -2607,16 +2575,17 @@ static uint32_t enable_analog_option(const char *str, uint32_t current_options)
}
return current_options;
}
#define CONFIG_ERROR(...) { \
ftdm_log(FTDM_LOG_ERROR, __VA_ARGS__); \
globals.config_error = 1; \
}
/* create ftdm_conf_node_t tree based on a fixed pattern XML configuration list
/*
* Create ftdm_conf_node_t tree based on a fixed pattern XML configuration list
* last 2 args are for limited aka dumb recursivity
* */
*/
static int add_config_list_nodes(switch_xml_t swnode, ftdm_conf_node_t *rootnode,
const char *list_name, const char *list_element_name,
const char *sub_list_name, const char *sub_list_element_name)
@ -3448,7 +3417,6 @@ static switch_status_t load_config(void)
continue;
}
if (!tonegroup) {
tonegroup = "us";
}
@ -4028,7 +3996,6 @@ static void *SWITCH_THREAD_FUNC ioread_thread(switch_thread_t *thread, void *obj
data->num_times--;
wflags = FTDM_READ;
status = ftdm_channel_wait(data->fchan, &wflags, (data->interval * 10));
if (status == FTDM_FAIL) {
@ -4137,6 +4104,7 @@ end:
FTDM_CLI_DECLARE(ftdm_cmd_list)
{
int j;
for (j = 0 ; j < FTDM_MAX_SPANS_INTERFACE; j++) {
ftdm_channel_t *fchan;
ftdm_alarm_flag_t alarmbits = FTDM_ALARM_NONE;
@ -4492,16 +4460,20 @@ FTDM_CLI_DECLARE(ftdm_cmd_trace)
uint32_t chan_count = 0;
ftdm_span_t *span = NULL;
ftdm_channel_t *chan = NULL;
if (argc < 3) {
print_usage(stream, cli);
goto end;
}
ftdm_span_find_by_name(argv[2], &span);
if (!span) {
stream->write_function(stream, "-ERR failed to find span %s\n", argv[2]);
goto end;
}
chan_count = ftdm_span_get_chan_count(span);
if (argc > 3) {
chan_id = atoi(argv[3]);
if (chan_id > chan_count) {
@ -4509,7 +4481,9 @@ FTDM_CLI_DECLARE(ftdm_cmd_trace)
goto end;
}
}
span_id = ftdm_span_get_id(span);
if (chan_id) {
chan = ftdm_span_get_channel(span, chan_id);
snprintf(tracepath, sizeof(tracepath), "%s-in-s%dc%d", argv[1], span_id, chan_id);
@ -4542,6 +4516,7 @@ FTDM_CLI_DECLARE(ftdm_cmd_notrace)
print_usage(stream, cli);
goto end;
}
ftdm_span_find_by_name(argv[1], &span);
if (!span) {
stream->write_function(stream, "-ERR failed to find span %s\n", argv[1]);
@ -4549,6 +4524,7 @@ FTDM_CLI_DECLARE(ftdm_cmd_notrace)
}
chan_count = ftdm_span_get_chan_count(span);
if (argc > 2) {
chan_id = atoi(argv[2]);
if (chan_id > chan_count) {
@ -4581,10 +4557,12 @@ FTDM_CLI_DECLARE(ftdm_cmd_gains)
uint32_t ccount = 0;
ftdm_channel_t *chan;
ftdm_span_t *span = NULL;
if (argc < 4) {
print_usage(stream, cli);
goto end;
}
ftdm_span_find_by_name(argv[3], &span);
if (!span) {
stream->write_function(stream, "-ERR failed to find span %s\n", argv[3]);
@ -4598,6 +4576,7 @@ FTDM_CLI_DECLARE(ftdm_cmd_gains)
goto end;
}
}
i = sscanf(argv[1], "%f", &rxgain);
i += sscanf(argv[2], "%f", &txgain);
if (i != 2) {
@ -4681,6 +4660,7 @@ FTDM_CLI_DECLARE(ftdm_cmd_queuesize)
uint32_t ccount = 0;
ftdm_channel_t *chan;
ftdm_span_t *span = NULL;
if (argc < 4) {
print_usage(stream, cli);
goto end;
@ -4728,6 +4708,7 @@ static void exec_io_command(const char *cmd, switch_stream_handle_t *stream, ftd
{
int enable = 0;
ftdm_channel_iostats_t stats;
if (!strcasecmp("enable", cmd)) {
enable = 1;
ftdm_channel_command(fchan, FTDM_COMMAND_SWITCH_IOSTATS, &enable);
@ -4833,6 +4814,7 @@ static void print_full_usage(switch_stream_handle_t *stream)
{
int i = 0;
ftdm_cli_entry_t *entry = NULL;
stream->write_function(stream, "USAGE:\n");
stream->write_function(stream, "--------------------------------------------------------------------------------\n");
for (i = 0 ; i < ftdm_array_len(ftdm_cli_options); i++) {
@ -4878,15 +4860,14 @@ SWITCH_STANDARD_API(ft_function)
}
end:
switch_safe_free(mycmd);
return SWITCH_STATUS_SUCCESS;
}
SWITCH_STANDARD_APP(enable_dtmf_function)
{
private_t *tech_pvt;
if (!switch_core_session_check_interface(session, freetdm_endpoint_interface)) {
ftdm_log(FTDM_LOG_ERROR, "This application is only for FreeTDM channels.\n");
return;
@ -4906,6 +4887,7 @@ SWITCH_STANDARD_APP(enable_dtmf_function)
SWITCH_STANDARD_APP(disable_dtmf_function)
{
private_t *tech_pvt;
if (!switch_core_session_check_interface(session, freetdm_endpoint_interface)) {
ftdm_log(FTDM_LOG_ERROR, "This application is only for FreeTDM channels.\n");
return;
@ -5002,7 +4984,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_freetdm_load)
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_freetdm_shutdown)
{
switch_hash_index_t *hi;
const void *var;
void *val;