| File: | src/mod/applications/mod_spandsp/mod_spandsp.c |
| Location: | line 470, column 4 |
| Description: | Value stored to 'locked' is never read |
| 1 | /* |
| 2 | * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application |
| 3 | * Copyright (C) 2005-2014, Anthony Minessale II <anthm@freeswitch.org> |
| 4 | * |
| 5 | * Version: MPL 1.1 |
| 6 | * |
| 7 | * The contents of this file are subject to the Mozilla Public License Version |
| 8 | * 1.1 (the "License"); you may not use this file except in compliance with |
| 9 | * the License. You may obtain a copy of the License at |
| 10 | * http://www.mozilla.org/MPL/ |
| 11 | * |
| 12 | * Software distributed under the License is distributed on an "AS IS" basis, |
| 13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| 14 | * for the specific language governing rights and limitations under the |
| 15 | * License. |
| 16 | * |
| 17 | * The Original Code is FreeSWITCH mod_spandsp. |
| 18 | * |
| 19 | * The Initial Developer of the Original Code is |
| 20 | * Michael Jerris <mike@jerris.com |
| 21 | * |
| 22 | * Portions created by the Initial Developer are Copyright (C) |
| 23 | * the Initial Developer. All Rights Reserved. |
| 24 | * |
| 25 | * Contributor(s): |
| 26 | * |
| 27 | * Massimo Cetra <devel@navynet.it> |
| 28 | * Anthony Minessale II <anthm@freeswitch.org> |
| 29 | * Brian West <brian@freeswitch.org> |
| 30 | * Steve Underwood <steveu@coppice.org> |
| 31 | * Antonio Gallo <agx@linux.it> |
| 32 | * Christopher M. Rienzo <chris@rienzo.com> |
| 33 | * mod_spandsp.c -- Module implementing spandsp fax, dsp, and codec functionality |
| 34 | * |
| 35 | */ |
| 36 | |
| 37 | |
| 38 | |
| 39 | #include "mod_spandsp.h" |
| 40 | #include <spandsp/version.h> |
| 41 | #include "mod_spandsp_modem.h" |
| 42 | |
| 43 | /* ************************************************************************** |
| 44 | FREESWITCH MODULE DEFINITIONS |
| 45 | ************************************************************************* */ |
| 46 | |
| 47 | struct spandsp_globals spandsp_globals = { 0 }; |
| 48 | |
| 49 | #define SPANFAX_RX_USAGE"<filename>" "<filename>" |
| 50 | #define SPANFAX_TX_USAGE"<filename>" "<filename>" |
| 51 | |
| 52 | SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init)switch_status_t mod_spandsp_init (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool); |
| 53 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown)switch_status_t mod_spandsp_shutdown (void); |
| 54 | SWITCH_MODULE_DEFINITION(mod_spandsp, mod_spandsp_init, mod_spandsp_shutdown, NULL)static const char modname[] = "mod_spandsp" ; __attribute__(( visibility("default"))) switch_loadable_module_function_table_t mod_spandsp_module_interface = { 5, mod_spandsp_init, mod_spandsp_shutdown , ((void*)0), SMODF_NONE }; |
| 55 | |
| 56 | |
| 57 | SWITCH_STANDARD_APP(spanfax_tx_function)static void spanfax_tx_function (switch_core_session_t *session , const char *data) |
| 58 | { |
| 59 | mod_spandsp_fax_process_fax(session, data, FUNCTION_TX); |
| 60 | } |
| 61 | |
| 62 | SWITCH_STANDARD_APP(spanfax_rx_function)static void spanfax_rx_function (switch_core_session_t *session , const char *data) |
| 63 | { |
| 64 | mod_spandsp_fax_process_fax(session, data, FUNCTION_RX); |
| 65 | } |
| 66 | |
| 67 | SWITCH_STANDARD_APP(spanfax_stop_function)static void spanfax_stop_function (switch_core_session_t *session , const char *data) |
| 68 | { |
| 69 | mod_spandsp_fax_stop_fax(session); |
| 70 | } |
| 71 | |
| 72 | SWITCH_STANDARD_APP(dtmf_session_function)static void dtmf_session_function (switch_core_session_t *session , const char *data) |
| 73 | { |
| 74 | spandsp_inband_dtmf_session(session); |
| 75 | } |
| 76 | |
| 77 | SWITCH_STANDARD_APP(stop_dtmf_session_function)static void stop_dtmf_session_function (switch_core_session_t *session, const char *data) |
| 78 | { |
| 79 | spandsp_stop_inband_dtmf_session(session); |
| 80 | } |
| 81 | |
| 82 | |
| 83 | SWITCH_STANDARD_APP(tdd_encode_function)static void tdd_encode_function (switch_core_session_t *session , const char *data) |
| 84 | { |
| 85 | char *text = (char *) data; |
| 86 | |
| 87 | if (!zstr(text)_zstr(text)) { |
| 88 | spandsp_tdd_encode_session(session, text); |
| 89 | } else { |
| 90 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 90, (const char*)(session), SWITCH_LOG_ERROR, "Missing text data\n"); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | SWITCH_STANDARD_APP(tdd_send_function)static void tdd_send_function (switch_core_session_t *session , const char *data) |
| 95 | { |
| 96 | char *text = (char *) data; |
| 97 | |
| 98 | if (!zstr(text)_zstr(text)) { |
| 99 | spandsp_tdd_send_session(session, text); |
| 100 | } else { |
| 101 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 101, (const char*)(session), SWITCH_LOG_ERROR, "Missing text data\n"); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | SWITCH_STANDARD_APP(stop_tdd_encode_function)static void stop_tdd_encode_function (switch_core_session_t * session, const char *data) |
| 106 | { |
| 107 | spandsp_stop_tdd_encode_session(session); |
| 108 | } |
| 109 | |
| 110 | |
| 111 | |
| 112 | |
| 113 | SWITCH_STANDARD_APP(tdd_decode_function)static void tdd_decode_function (switch_core_session_t *session , const char *data) |
| 114 | { |
| 115 | spandsp_tdd_decode_session(session); |
| 116 | } |
| 117 | |
| 118 | SWITCH_STANDARD_APP(stop_tdd_decode_function)static void stop_tdd_decode_function (switch_core_session_t * session, const char *data) |
| 119 | { |
| 120 | spandsp_stop_tdd_decode_session(session); |
| 121 | } |
| 122 | |
| 123 | |
| 124 | SWITCH_STANDARD_APP(spandsp_fax_detect_session_function)static void spandsp_fax_detect_session_function (switch_core_session_t *session, const char *data) |
| 125 | { |
| 126 | int argc = 0; |
| 127 | char *argv[4] = { 0 }; |
| 128 | char *dupdata; |
| 129 | const char *app = NULL((void*)0), *arg = NULL((void*)0); |
| 130 | int timeout = 0; |
| 131 | int tone_type = MODEM_CONNECT_TONES_FAX_CNG; |
| 132 | |
| 133 | if (!zstr(data)_zstr(data) && (dupdata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_spandsp.c" , (const char *)__func__, 133))) { |
| 134 | if ((argc = switch_split(dupdata, ' ', argv)switch_separate_string(dupdata, ' ', argv, (sizeof(argv) / sizeof (argv[0])))) >= 2) { |
| 135 | app = argv[0]; |
| 136 | arg = argv[1]; |
| 137 | if (argc > 2) { |
| 138 | timeout = atoi(argv[2]); |
| 139 | if (timeout < 0) { |
| 140 | timeout = 0; |
| 141 | } |
| 142 | } |
| 143 | if (argc > 3) { |
| 144 | if (!strcmp(argv[3], "ced")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (argv[3]) && __builtin_constant_p ("ced") && (__s1_len = __builtin_strlen (argv[3]), __s2_len = __builtin_strlen ("ced"), (!((size_t)(const void *)((argv[3]) + 1) - (size_t) (const void *)(argv[3]) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("ced") + 1) - (size_t)(const void *)("ced") == 1) || __s2_len >= 4)) ? __builtin_strcmp (argv [3], "ced") : (__builtin_constant_p (argv[3]) && ((size_t )(const void *)((argv[3]) + 1) - (size_t)(const void *)(argv[ 3]) == 1) && (__s1_len = __builtin_strlen (argv[3]), __s1_len < 4) ? (__builtin_constant_p ("ced") && ((size_t) (const void *)(("ced") + 1) - (size_t)(const void *)("ced") == 1) ? __builtin_strcmp (argv[3], "ced") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ced"); int __result = (((const unsigned char *) (const char *) (argv[3]))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( argv[3]))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( argv[3]))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (argv [3]))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("ced") && ((size_t)(const void *)(("ced") + 1) - (size_t )(const void *)("ced") == 1) && (__s2_len = __builtin_strlen ("ced"), __s2_len < 4) ? (__builtin_constant_p (argv[3]) && ((size_t)(const void *)((argv[3]) + 1) - (size_t)(const void *)(argv[3]) == 1) ? __builtin_strcmp (argv[3], "ced") : (- ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (argv[3]); int __result = (((const unsigned char *) (const char *) ("ced"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ced"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ced"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) ("ced"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (argv[3], "ced")))); })) { |
| 145 | tone_type = MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE; |
| 146 | } else { |
| 147 | tone_type = MODEM_CONNECT_TONES_FAX_CNG; |
| 148 | } |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (app) { |
| 154 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 154, (const char*)(session), SWITCH_LOG_NOTICE, "Enabling fax detection '%s' '%s'\n", argv[0], argv[1]); |
| 155 | spandsp_fax_detect_session(session, "rw", timeout, tone_type, 1, app, arg, NULL((void*)0)); |
| 156 | } else { |
| 157 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 157, (const char*)(session), SWITCH_LOG_ERROR, "Cannot Enable fax detection '%s' '%s'\n", argv[0], argv[1]); |
| 158 | } |
| 159 | } |
| 160 | |
| 161 | SWITCH_STANDARD_APP(spandsp_stop_fax_detect_session_function)static void spandsp_stop_fax_detect_session_function (switch_core_session_t *session, const char *data) |
| 162 | { |
| 163 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 163, (const char*)(session), SWITCH_LOG_NOTICE, "Disabling fax detection\n"); |
| 164 | spandsp_fax_stop_detect_session(session); |
| 165 | } |
| 166 | |
| 167 | static void tdd_event_handler(switch_event_t *event) |
| 168 | { |
| 169 | const char *uuid = switch_event_get_header(event, "tdd-uuid")switch_event_get_header_idx(event, "tdd-uuid", -1); |
| 170 | const char *message = switch_event_get_body(event); |
| 171 | switch_core_session_t *session; |
| 172 | |
| 173 | if (zstr(message)_zstr(message)) { |
| 174 | message = switch_event_get_header(event, "tdd-message")switch_event_get_header_idx(event, "tdd-message", -1); |
| 175 | } |
| 176 | |
| 177 | if (zstr(message)_zstr(message)) { |
| 178 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 178, ((void*)0), SWITCH_LOG_WARNING, "No message for tdd handler\n"); |
| 179 | return; |
| 180 | } |
| 181 | |
| 182 | if (zstr(uuid)_zstr(uuid)) { |
| 183 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 183, ((void*)0), SWITCH_LOG_WARNING, "No uuid for tdd handler\n"); |
| 184 | return; |
| 185 | } |
| 186 | |
| 187 | if ((session = switch_core_session_locate(uuid)switch_core_session_perform_locate(uuid, "mod_spandsp.c", (const char *)__func__, 187))) { |
| 188 | |
| 189 | spandsp_tdd_encode_session(session, message); |
| 190 | |
| 191 | switch_core_session_rwunlock(session); |
| 192 | } else { |
| 193 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 193, ((void*)0), SWITCH_LOG_WARNING, "No session for supplied uuid.\n"); |
| 194 | } |
| 195 | } |
| 196 | |
| 197 | static void event_handler(switch_event_t *event) |
| 198 | { |
| 199 | load_configuration(1); |
| 200 | } |
| 201 | |
| 202 | SWITCH_STANDARD_APP(t38_gateway_function)static void t38_gateway_function (switch_core_session_t *session , const char *data) |
| 203 | { |
| 204 | switch_channel_t *channel = switch_core_session_get_channel(session); |
| 205 | int timeout = 20; |
| 206 | const char *var; |
| 207 | int argc = 0; |
| 208 | char *argv[2] = { 0 }; |
| 209 | char *dupdata; |
| 210 | const char *direction = NULL((void*)0), *flags = NULL((void*)0); |
| 211 | |
| 212 | if (!zstr(data)_zstr(data) && (dupdata = switch_core_session_strdup(session, data)switch_core_perform_session_strdup(session, data, "mod_spandsp.c" , (const char *)__func__, 212))) { |
| 213 | if ((argc = switch_split(dupdata, ' ', argv)switch_separate_string(dupdata, ' ', argv, (sizeof(argv) / sizeof (argv[0]))))) { |
| 214 | if (argc > 0) { |
| 215 | direction = argv[0]; |
| 216 | } |
| 217 | |
| 218 | if (argc > 1) { |
| 219 | flags = argv[1]; |
| 220 | } |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | if (zstr(direction)_zstr(direction) || strcasecmp(direction, "self")) { |
| 225 | direction = "peer"; |
| 226 | } |
| 227 | |
| 228 | switch_channel_set_variable(channel, "t38_leg", direction)switch_channel_set_variable_var_check(channel, "t38_leg", direction , SWITCH_TRUE); |
| 229 | |
| 230 | if (!zstr(flags)_zstr(flags) && !strcasecmp(flags, "nocng")) { |
| 231 | t38_gateway_start(session, direction, NULL((void*)0)); |
| 232 | } else { |
| 233 | if ((var = switch_channel_get_variable(channel, "t38_gateway_detect_timeout")switch_channel_get_variable_dup(channel, "t38_gateway_detect_timeout" , SWITCH_TRUE, -1))) { |
| 234 | int to = atoi(var); |
| 235 | if (to > -1) { |
| 236 | timeout = to; |
| 237 | } else { |
| 238 | switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session)SWITCH_CHANNEL_ID_SESSION, "mod_spandsp.c", (const char *)__func__ , 238, (const char*)(session), SWITCH_LOG_WARNING, "%s invalid timeout value.\n", switch_channel_get_name(channel)); |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | //switch_ivr_tone_detect_session(session, "t38", "1100.0", "rw", timeout, 1, direction, NULL, t38_gateway_start); |
| 243 | spandsp_fax_detect_session(session, "rw", timeout, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, 1, direction, NULL((void*)0), t38_gateway_start); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /** |
| 248 | * Start tone detector application |
| 249 | * |
| 250 | * @param data the command string |
| 251 | */ |
| 252 | SWITCH_STANDARD_APP(start_tone_detect_app)static void start_tone_detect_app (switch_core_session_t *session , const char *data) |
| 253 | { |
| 254 | switch_channel_t *channel; |
| 255 | if (!session) { |
| 256 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 256, ((void*)0), SWITCH_LOG_ERROR, "No session\n"); |
| 257 | return; |
| 258 | } |
| 259 | channel = switch_core_session_get_channel(session); |
| 260 | if (zstr(data)_zstr(data)) { |
| 261 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "-ERR missing descriptor name")switch_channel_set_variable_var_check(channel, "current_application_response" , "-ERR missing descriptor name", SWITCH_TRUE); |
| 262 | } else if (callprogress_detector_start(session, data) != SWITCH_STATUS_SUCCESS) { |
| 263 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "-ERR failed to start tone detector")switch_channel_set_variable_var_check(channel, "current_application_response" , "-ERR failed to start tone detector", SWITCH_TRUE); |
| 264 | } else { |
| 265 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "+OK started")switch_channel_set_variable_var_check(channel, "current_application_response" , "+OK started", SWITCH_TRUE); |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | |
| 270 | SWITCH_STANDARD_API(start_tone_detect_api)static switch_status_t start_tone_detect_api ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
| 271 | { |
| 272 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 273 | switch_core_session_t *psession = NULL((void*)0); |
| 274 | char *puuid = NULL((void*)0), *descriptor = NULL((void*)0); |
| 275 | |
| 276 | if (zstr(cmd)_zstr(cmd)) { |
| 277 | stream->write_function(stream, "-ERR missing uuid\n"); |
| 278 | return SWITCH_STATUS_SUCCESS; |
| 279 | } |
| 280 | |
| 281 | puuid = strdup((char *)cmd)(__extension__ (__builtin_constant_p ((char *)cmd) && ((size_t)(const void *)(((char *)cmd) + 1) - (size_t)(const void *)((char *)cmd) == 1) ? (((const char *) ((char *)cmd))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen ((char *)cmd) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, (char *)cmd, __len); __retval; })) : __strdup ((char *)cmd))); |
| 282 | |
| 283 | if ((descriptor = strchr(puuid, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (puuid) && (' ') == '\0' ? (char *) __rawmemchr (puuid , ' ') : __builtin_strchr (puuid, ' '))))) { |
| 284 | *descriptor++ = '\0'; |
| 285 | } |
| 286 | |
| 287 | if (zstr(descriptor)_zstr(descriptor)) { |
| 288 | stream->write_function(stream, "-ERR missing descriptor name\n"); |
| 289 | goto end; |
| 290 | } |
| 291 | |
| 292 | if (!(psession = switch_core_session_locate(puuid)switch_core_session_perform_locate(puuid, "mod_spandsp.c", (const char *)__func__, 292))) { |
| 293 | stream->write_function(stream, "-ERR Cannot locate session\n"); |
| 294 | goto end; |
| 295 | } |
| 296 | |
| 297 | status = callprogress_detector_start(psession, descriptor); |
| 298 | |
| 299 | if (status == SWITCH_STATUS_SUCCESS) { |
| 300 | stream->write_function(stream, "+OK started\n"); |
| 301 | } else { |
| 302 | stream->write_function(stream, "-ERR failed to start tone detector\n"); |
| 303 | } |
| 304 | |
| 305 | switch_core_session_rwunlock(psession); |
| 306 | |
| 307 | end: |
| 308 | |
| 309 | switch_safe_free(puuid)if (puuid) {free(puuid);puuid=((void*)0);}; |
| 310 | |
| 311 | return status; |
| 312 | } |
| 313 | |
| 314 | /** |
| 315 | * Stop tone detector application |
| 316 | * |
| 317 | * @param data the command string |
| 318 | */ |
| 319 | SWITCH_STANDARD_APP(stop_tone_detect_app)static void stop_tone_detect_app (switch_core_session_t *session , const char *data) |
| 320 | { |
| 321 | switch_channel_t *channel; |
| 322 | if (!session) { |
| 323 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 323, ((void*)0), SWITCH_LOG_ERROR, "No session\n"); |
| 324 | return; |
| 325 | } |
| 326 | channel = switch_core_session_get_channel(session); |
| 327 | callprogress_detector_stop(session); |
| 328 | switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, "+OK stopped")switch_channel_set_variable_var_check(channel, "current_application_response" , "+OK stopped", SWITCH_TRUE); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Stop tone detector API |
| 333 | */ |
| 334 | SWITCH_STANDARD_API(stop_tone_detect_api)static switch_status_t stop_tone_detect_api ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
| 335 | { |
| 336 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 337 | switch_core_session_t *psession = NULL((void*)0); |
| 338 | |
| 339 | if (zstr(cmd)_zstr(cmd)) { |
| 340 | stream->write_function(stream, "-ERR missing session UUID\n"); |
| 341 | return SWITCH_STATUS_SUCCESS; |
| 342 | } |
| 343 | |
| 344 | if (!(psession = switch_core_session_locate(cmd)switch_core_session_perform_locate(cmd, "mod_spandsp.c", (const char *)__func__, 344))) { |
| 345 | stream->write_function(stream, "-ERR Cannot locate session\n"); |
| 346 | return SWITCH_STATUS_SUCCESS; |
| 347 | } |
| 348 | |
| 349 | callprogress_detector_stop(psession); |
| 350 | stream->write_function(stream, "+OK stopped\n"); |
| 351 | switch_core_session_rwunlock(psession); |
| 352 | |
| 353 | return status; |
| 354 | } |
| 355 | |
| 356 | |
| 357 | |
| 358 | SWITCH_STANDARD_API(start_tdd_detect_api)static switch_status_t start_tdd_detect_api ( const char *cmd , switch_core_session_t *session, switch_stream_handle_t *stream ) |
| 359 | { |
| 360 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 361 | switch_core_session_t *psession = NULL((void*)0); |
| 362 | |
| 363 | if (!(psession = switch_core_session_locate(cmd)switch_core_session_perform_locate(cmd, "mod_spandsp.c", (const char *)__func__, 363))) { |
| 364 | stream->write_function(stream, "-ERR Cannot locate session\n"); |
| 365 | return SWITCH_STATUS_SUCCESS; |
| 366 | } |
| 367 | |
| 368 | spandsp_tdd_decode_session(psession); |
| 369 | |
| 370 | if (status == SWITCH_STATUS_SUCCESS) { |
| 371 | stream->write_function(stream, "+OK started\n"); |
| 372 | } else { |
| 373 | stream->write_function(stream, "-ERR failed to start tdd detector\n"); |
| 374 | } |
| 375 | |
| 376 | switch_core_session_rwunlock(psession); |
| 377 | |
| 378 | return status; |
| 379 | } |
| 380 | |
| 381 | |
| 382 | SWITCH_STANDARD_API(stop_tdd_detect_api)static switch_status_t stop_tdd_detect_api ( const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream ) |
| 383 | { |
| 384 | switch_status_t status = SWITCH_STATUS_SUCCESS; |
| 385 | switch_core_session_t *psession = NULL((void*)0); |
| 386 | |
| 387 | |
| 388 | if (!(psession = switch_core_session_locate(cmd)switch_core_session_perform_locate(cmd, "mod_spandsp.c", (const char *)__func__, 388))) { |
| 389 | stream->write_function(stream, "-ERR Cannot locate session\n"); |
| 390 | return SWITCH_STATUS_SUCCESS; |
| 391 | } |
| 392 | |
| 393 | spandsp_stop_tdd_decode_session(psession); |
| 394 | |
| 395 | stream->write_function(stream, "+OK stopped\n"); |
| 396 | switch_core_session_rwunlock(psession); |
| 397 | |
| 398 | return status; |
| 399 | } |
| 400 | |
| 401 | |
| 402 | SWITCH_STANDARD_API(start_send_tdd_api)static switch_status_t start_send_tdd_api ( const char *cmd, switch_core_session_t *session, switch_stream_handle_t *stream) |
| 403 | { |
| 404 | switch_core_session_t *psession = NULL((void*)0); |
| 405 | char *puuid = NULL((void*)0), *text = NULL((void*)0); |
| 406 | |
| 407 | if (zstr(cmd)_zstr(cmd)) { |
| 408 | stream->write_function(stream, "-ERR missing uuid\n"); |
| 409 | return SWITCH_STATUS_SUCCESS; |
| 410 | } |
| 411 | |
| 412 | puuid = strdup((char *)cmd)(__extension__ (__builtin_constant_p ((char *)cmd) && ((size_t)(const void *)(((char *)cmd) + 1) - (size_t)(const void *)((char *)cmd) == 1) ? (((const char *) ((char *)cmd))[0] == '\0' ? (char *) calloc ((size_t) 1, (size_t) 1) : ({ size_t __len = strlen ((char *)cmd) + 1; char *__retval = (char *) malloc (__len); if (__retval != ((void*)0)) __retval = (char *) memcpy (__retval, (char *)cmd, __len); __retval; })) : __strdup ((char *)cmd))); |
| 413 | |
| 414 | if ((text = strchr(puuid, ' ')(__extension__ (__builtin_constant_p (' ') && !__builtin_constant_p (puuid) && (' ') == '\0' ? (char *) __rawmemchr (puuid , ' ') : __builtin_strchr (puuid, ' '))))) { |
| 415 | *text++ = '\0'; |
| 416 | } |
| 417 | |
| 418 | if (zstr(text)_zstr(text)) { |
| 419 | stream->write_function(stream, "-ERR missing text\n"); |
| 420 | goto end; |
| 421 | } |
| 422 | |
| 423 | |
| 424 | if (!(psession = switch_core_session_locate(puuid)switch_core_session_perform_locate(puuid, "mod_spandsp.c", (const char *)__func__, 424))) { |
| 425 | stream->write_function(stream, "-ERR Cannot locate session\n"); |
| 426 | goto end; |
| 427 | } |
| 428 | |
| 429 | |
| 430 | spandsp_tdd_encode_session(psession, text); |
| 431 | |
| 432 | stream->write_function(stream, "+OK\n"); |
| 433 | switch_core_session_rwunlock(psession); |
| 434 | |
| 435 | end: |
| 436 | |
| 437 | switch_safe_free(puuid)if (puuid) {free(puuid);puuid=((void*)0);}; |
| 438 | |
| 439 | return SWITCH_STATUS_SUCCESS; |
| 440 | } |
| 441 | |
| 442 | void mod_spandsp_indicate_data(switch_core_session_t *session, switch_bool_t self, switch_bool_t on) |
| 443 | { |
| 444 | switch_core_session_t *target_session = NULL((void*)0); |
| 445 | int locked = 0; |
| 446 | |
| 447 | if (self) { |
| 448 | target_session = session; |
| 449 | } else { |
| 450 | if (switch_core_session_get_partner(session, &target_session)switch_core_session_perform_get_partner(session, &target_session , "mod_spandsp.c", (const char *)__func__, 450) == SWITCH_STATUS_SUCCESS) { |
| 451 | locked = 1; |
| 452 | } else { |
| 453 | target_session = NULL((void*)0); |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | if (target_session) { |
| 458 | switch_core_session_message_t *msg; |
| 459 | |
| 460 | msg = switch_core_session_alloc(target_session, sizeof(*msg))switch_core_perform_session_alloc(target_session, sizeof(*msg ), "mod_spandsp.c", (const char *)__func__, 460); |
| 461 | MESSAGE_STAMP_FFL(msg)msg->_file = "mod_spandsp.c"; msg->_func = (const char * )__func__; msg->_line = 461; |
| 462 | msg->message_id = SWITCH_MESSAGE_INDICATE_AUDIO_DATA; |
| 463 | msg->from = __FILE__"mod_spandsp.c"; |
| 464 | msg->numeric_arg = on; |
| 465 | |
| 466 | switch_core_session_queue_message(target_session, msg); |
| 467 | |
| 468 | if (locked) { |
| 469 | switch_core_session_rwunlock(target_session); |
| 470 | locked = 0; |
Value stored to 'locked' is never read | |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | |
| 476 | /* ************************************************************************** |
| 477 | CONFIGURATION |
| 478 | ************************************************************************* */ |
| 479 | static void destroy_descriptor(void *ptr) |
| 480 | { |
| 481 | tone_descriptor_t *d = (tone_descriptor_t *) ptr; |
| 482 | |
| 483 | super_tone_rx_free_descriptor(d->spandsp_tone_descriptor); |
| 484 | } |
| 485 | |
| 486 | switch_status_t load_configuration(switch_bool_t reload) |
| 487 | { |
| 488 | switch_xml_t xml = NULL((void*)0), x_lists = NULL((void*)0), x_list = NULL((void*)0), cfg = NULL((void*)0), callprogress = NULL((void*)0), xdescriptor = NULL((void*)0); |
| 489 | switch_status_t status = SWITCH_STATUS_FALSE; |
| 490 | |
| 491 | switch_mutex_lock(spandsp_globals.mutex); |
| 492 | |
| 493 | if (spandsp_globals.tones) { |
| 494 | switch_core_hash_destroy(&spandsp_globals.tones); |
| 495 | } |
| 496 | |
| 497 | if (spandsp_globals.config_pool) { |
| 498 | switch_core_destroy_memory_pool(&spandsp_globals.config_pool)switch_core_perform_destroy_memory_pool(&spandsp_globals. config_pool, "mod_spandsp.c", (const char *)__func__, 498); |
| 499 | } |
| 500 | |
| 501 | switch_core_new_memory_pool(&spandsp_globals.config_pool)switch_core_perform_new_memory_pool(&spandsp_globals.config_pool , "mod_spandsp.c", (const char *)__func__, 501); |
| 502 | switch_core_hash_init(&spandsp_globals.tones)switch_core_hash_init_case(&spandsp_globals.tones, SWITCH_TRUE ); |
| 503 | |
| 504 | spandsp_globals.modem_dialplan = "XML"; |
| 505 | spandsp_globals.modem_context = "default"; |
| 506 | spandsp_globals.modem_directory = "/dev"; |
| 507 | spandsp_globals.modem_count = 0; |
| 508 | |
| 509 | |
| 510 | spandsp_globals.enable_t38 = 1; |
| 511 | spandsp_globals.enable_tep = 0; |
| 512 | spandsp_globals.total_sessions = 0; |
| 513 | spandsp_globals.verbose = 0; |
| 514 | spandsp_globals.use_ecm = 1; |
| 515 | spandsp_globals.disable_v17 = 0; |
| 516 | spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, "fax")switch_core_perform_strdup(spandsp_globals.config_pool, "fax" , "mod_spandsp.c", (const char *)__func__, 516); |
| 517 | spandsp_globals.spool = switch_core_strdup(spandsp_globals.config_pool, "/tmp")switch_core_perform_strdup(spandsp_globals.config_pool, "/tmp" , "mod_spandsp.c", (const char *)__func__, 517); |
| 518 | spandsp_globals.ident = "SpanDSP Fax Ident"; |
| 519 | spandsp_globals.header = "SpanDSP Fax Header"; |
| 520 | spandsp_globals.timezone = ""; |
| 521 | spandsp_globals.tonedebug = 0; |
| 522 | |
| 523 | if ((xml = switch_xml_open_cfg("spandsp.conf", &cfg, NULL((void*)0))) || (xml = switch_xml_open_cfg("fax.conf", &cfg, NULL((void*)0)))) { |
| 524 | status = SWITCH_STATUS_SUCCESS; |
| 525 | |
| 526 | if ((x_lists = switch_xml_child(cfg, "modem-settings"))) { |
| 527 | for (x_list = switch_xml_child(x_lists, "param"); x_list; x_list = x_list->next) { |
| 528 | const char *name = switch_xml_attr(x_list, "name"); |
| 529 | const char *value = switch_xml_attr(x_list, "value"); |
| 530 | |
| 531 | if (zstr(name)_zstr(name)) { |
| 532 | continue; |
| 533 | } |
| 534 | |
| 535 | if (zstr(value)_zstr(value)) { |
| 536 | continue; |
| 537 | } |
| 538 | |
| 539 | |
| 540 | if (!reload && !strcmp(name, "total-modems")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("total-modems") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("total-modems"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("total-modems") + 1) - (size_t)(const void *)("total-modems") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "total-modems") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("total-modems") && ( (size_t)(const void *)(("total-modems") + 1) - (size_t)(const void *)("total-modems") == 1) ? __builtin_strcmp (name, "total-modems" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("total-modems"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("total-modems") && ((size_t)(const void *)(("total-modems") + 1) - (size_t)(const void *)("total-modems" ) == 1) && (__s2_len = __builtin_strlen ("total-modems" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "total-modems") : (- ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("total-modems"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("total-modems"))[1] - __s2[1]); if ( __s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("total-modems"))[2] - __s2[ 2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("total-modems"))[3 ] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "total-modems" )))); })) { |
| 541 | int tmp = atoi(value); |
| 542 | |
| 543 | if (tmp > -1 && tmp < MAX_MODEMS1024) { |
| 544 | spandsp_globals.modem_count = tmp; |
| 545 | } else { |
| 546 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 546, ((void*)0), SWITCH_LOG_ERROR, "Invalid value [%d] for total-modems\n", tmp); |
| 547 | } |
| 548 | } else if (!strcmp(name, "directory")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("directory") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("directory"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("directory") + 1) - (size_t)(const void *)("directory") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "directory") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("directory") && ((size_t )(const void *)(("directory") + 1) - (size_t)(const void *)("directory" ) == 1) ? __builtin_strcmp (name, "directory") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("directory"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("directory") && ((size_t)(const void *)(("directory") + 1) - (size_t)(const void *)("directory" ) == 1) && (__s2_len = __builtin_strlen ("directory") , __s2_len < 4) ? (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) ? __builtin_strcmp (name, "directory") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("directory"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("directory"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("directory"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("directory"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "directory")))); })) { |
| 549 | spandsp_globals.modem_directory = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 549); |
| 550 | } else if (!strcmp(name, "dialplan")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("dialplan") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("dialplan"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("dialplan") + 1) - (size_t)(const void *)("dialplan") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "dialplan") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("dialplan") && ((size_t )(const void *)(("dialplan") + 1) - (size_t)(const void *)("dialplan" ) == 1) ? __builtin_strcmp (name, "dialplan") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("dialplan"); int __result = (((const unsigned char * ) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("dialplan") && ((size_t)(const void *)(("dialplan") + 1) - (size_t)(const void *)("dialplan") == 1) && ( __s2_len = __builtin_strlen ("dialplan"), __s2_len < 4) ? ( __builtin_constant_p (name) && ((size_t)(const void * )((name) + 1) - (size_t)(const void *)(name) == 1) ? __builtin_strcmp (name, "dialplan") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("dialplan"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dialplan"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("dialplan"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("dialplan"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "dialplan" )))); })) { |
| 551 | spandsp_globals.modem_dialplan = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 551); |
| 552 | } else if (!strcmp(name, "context")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("context") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("context"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("context") + 1) - (size_t)(const void *)("context") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "context") : (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("context") && ((size_t )(const void *)(("context") + 1) - (size_t)(const void *)("context" ) == 1) ? __builtin_strcmp (name, "context") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("context"); int __result = (((const unsigned char * ) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("context") && ((size_t)(const void *)(("context") + 1) - (size_t)(const void *)("context") == 1) && (__s2_len = __builtin_strlen ("context"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "context" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("context"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("context"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("context"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("context"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "context")))); })) { |
| 553 | spandsp_globals.modem_context = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 553); |
| 554 | } else if (!strcmp(name, "verbose")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("verbose") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("verbose"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "verbose") : (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("verbose") && ((size_t )(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose" ) == 1) ? __builtin_strcmp (name, "verbose") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("verbose"); int __result = (((const unsigned char * ) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("verbose") && ((size_t)(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose") == 1) && (__s2_len = __builtin_strlen ("verbose"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "verbose" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("verbose"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("verbose"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("verbose"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("verbose"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "verbose")))); })) { |
| 555 | if (switch_true(value)) { |
| 556 | spandsp_globals.modem_verbose = 1; |
| 557 | } else { |
| 558 | spandsp_globals.modem_verbose = 0; |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | if ((x_lists = switch_xml_child(cfg, "fax-settings")) || (x_lists = switch_xml_child(cfg, "settings"))) { |
| 565 | for (x_list = switch_xml_child(x_lists, "param"); x_list; x_list = x_list->next) { |
| 566 | const char *name = switch_xml_attr(x_list, "name"); |
| 567 | const char *value = switch_xml_attr(x_list, "value"); |
| 568 | |
| 569 | if (zstr(name)_zstr(name)) { |
| 570 | continue; |
| 571 | } |
| 572 | |
| 573 | if (zstr(value)_zstr(value)) { |
| 574 | continue; |
| 575 | } |
| 576 | |
| 577 | if (!strcmp(name, "use-ecm")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("use-ecm") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("use-ecm"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("use-ecm") + 1) - (size_t)(const void *)("use-ecm") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "use-ecm") : (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("use-ecm") && ((size_t )(const void *)(("use-ecm") + 1) - (size_t)(const void *)("use-ecm" ) == 1) ? __builtin_strcmp (name, "use-ecm") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("use-ecm"); int __result = (((const unsigned char * ) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("use-ecm") && ((size_t)(const void *)(("use-ecm") + 1) - (size_t)(const void *)("use-ecm") == 1) && (__s2_len = __builtin_strlen ("use-ecm"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "use-ecm" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("use-ecm"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("use-ecm"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("use-ecm"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("use-ecm"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "use-ecm")))); })) { |
| 578 | if (switch_true(value)) |
| 579 | spandsp_globals.use_ecm = 1; |
| 580 | else |
| 581 | spandsp_globals.use_ecm = 0; |
| 582 | } else if (!strcmp(name, "verbose")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("verbose") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("verbose"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "verbose") : (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("verbose") && ((size_t )(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose" ) == 1) ? __builtin_strcmp (name, "verbose") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("verbose"); int __result = (((const unsigned char * ) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("verbose") && ((size_t)(const void *)(("verbose") + 1) - (size_t)(const void *)("verbose") == 1) && (__s2_len = __builtin_strlen ("verbose"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "verbose" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("verbose"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("verbose"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("verbose"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("verbose"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "verbose")))); })) { |
| 583 | if (switch_true(value)) |
| 584 | spandsp_globals.verbose = 1; |
| 585 | else |
| 586 | spandsp_globals.verbose = 0; |
| 587 | } else if (!strcmp(name, "disable-v17")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("disable-v17") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("disable-v17"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("disable-v17") + 1) - (size_t)(const void *)("disable-v17") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "disable-v17") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("disable-v17") && ( (size_t)(const void *)(("disable-v17") + 1) - (size_t)(const void *)("disable-v17") == 1) ? __builtin_strcmp (name, "disable-v17" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("disable-v17"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("disable-v17") && ((size_t)(const void *)(("disable-v17") + 1) - (size_t)(const void *)("disable-v17" ) == 1) && (__s2_len = __builtin_strlen ("disable-v17" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "disable-v17") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("disable-v17"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disable-v17"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("disable-v17"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("disable-v17"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "disable-v17")))); })) { |
| 588 | if (switch_true(value)) |
| 589 | spandsp_globals.disable_v17 = 1; |
| 590 | else |
| 591 | spandsp_globals.disable_v17 = 0; |
| 592 | } else if (!strcmp(name, "enable-colour")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-colour") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-colour"), (!((size_t)(const void *)((name) + 1) - ( size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("enable-colour") + 1) - (size_t)( const void *)("enable-colour") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-colour") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-colour") && ((size_t)(const void *)(("enable-colour") + 1) - (size_t)(const void *)("enable-colour") == 1) ? __builtin_strcmp (name, "enable-colour" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-colour"); int __result = ((( const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("enable-colour") && ((size_t) (const void *)(("enable-colour") + 1) - (size_t)(const void * )("enable-colour") == 1) && (__s2_len = __builtin_strlen ("enable-colour"), __s2_len < 4) ? (__builtin_constant_p ( name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "enable-colour" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-colour"))[0] - __s2[0]); if ( __s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-colour"))[1] - __s2 [1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-colour") )[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("enable-colour" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "enable-colour")))); })) { |
| 593 | if (switch_true(value)) |
| 594 | spandsp_globals.enable_colour_fax = 1; |
| 595 | else |
| 596 | spandsp_globals.enable_colour_fax = 0; |
| 597 | } else if (!strcmp(name, "enable-image-resizing")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-image-resizing" ) && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-image-resizing"), (!((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("enable-image-resizing" ) + 1) - (size_t)(const void *)("enable-image-resizing") == 1 ) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-image-resizing" ) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-image-resizing") && ((size_t)(const void *) (("enable-image-resizing") + 1) - (size_t)(const void *)("enable-image-resizing" ) == 1) ? __builtin_strcmp (name, "enable-image-resizing") : ( __extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-image-resizing"); int __result = ( ((const unsigned char *) (const char *) (name))[0] - __s2[0]) ; if (__s1_len > 0 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (name))[1] - __s2[1]) ; if (__s1_len > 1 && __result == 0) { __result = ( ((const unsigned char *) (const char *) (name))[2] - __s2[2]) ; if (__s1_len > 2 && __result == 0) __result = (( (const unsigned char *) (const char *) (name))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("enable-image-resizing" ) && ((size_t)(const void *)(("enable-image-resizing" ) + 1) - (size_t)(const void *)("enable-image-resizing") == 1 ) && (__s2_len = __builtin_strlen ("enable-image-resizing" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "enable-image-resizing" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-image-resizing"))[0] - __s2[ 0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-image-resizing" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("enable-image-resizing" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("enable-image-resizing" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "enable-image-resizing")))); })) { |
| 598 | if (switch_true(value)) |
| 599 | spandsp_globals.enable_image_resizing = 1; |
| 600 | else |
| 601 | spandsp_globals.enable_image_resizing = 0; |
| 602 | } else if (!strcmp(name, "enable-colour-to-bilevel")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-colour-to-bilevel" ) && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-colour-to-bilevel"), (!((size_t)(const void *)((name ) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("enable-colour-to-bilevel" ) + 1) - (size_t)(const void *)("enable-colour-to-bilevel") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-colour-to-bilevel" ) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-colour-to-bilevel") && ((size_t)(const void *)(("enable-colour-to-bilevel") + 1) - (size_t)(const void * )("enable-colour-to-bilevel") == 1) ? __builtin_strcmp (name, "enable-colour-to-bilevel") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-colour-to-bilevel" ); int __result = (((const unsigned char *) (const char *) (name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (name)) [3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("enable-colour-to-bilevel" ) && ((size_t)(const void *)(("enable-colour-to-bilevel" ) + 1) - (size_t)(const void *)("enable-colour-to-bilevel") == 1) && (__s2_len = __builtin_strlen ("enable-colour-to-bilevel" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "enable-colour-to-bilevel" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-colour-to-bilevel"))[0] - __s2 [0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-colour-to-bilevel" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("enable-colour-to-bilevel" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("enable-colour-to-bilevel" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "enable-colour-to-bilevel")))); })) { |
| 603 | if (switch_true(value)) |
| 604 | spandsp_globals.enable_colour_to_bilevel = 1; |
| 605 | else |
| 606 | spandsp_globals.enable_colour_to_bilevel = 0; |
| 607 | } else if (!strcmp(name, "enable-grayscale-to-bilevel")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-grayscale-to-bilevel" ) && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-grayscale-to-bilevel"), (!((size_t)(const void *)(( name) + 1) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("enable-grayscale-to-bilevel" ) + 1) - (size_t)(const void *)("enable-grayscale-to-bilevel" ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-grayscale-to-bilevel" ) : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-grayscale-to-bilevel") && ((size_t)(const void *)(("enable-grayscale-to-bilevel") + 1) - (size_t)(const void *)("enable-grayscale-to-bilevel") == 1) ? __builtin_strcmp ( name, "enable-grayscale-to-bilevel") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-grayscale-to-bilevel"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("enable-grayscale-to-bilevel") && ((size_t)(const void *)(("enable-grayscale-to-bilevel") + 1) - (size_t)(const void *)("enable-grayscale-to-bilevel") == 1 ) && (__s2_len = __builtin_strlen ("enable-grayscale-to-bilevel" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "enable-grayscale-to-bilevel" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-grayscale-to-bilevel"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-grayscale-to-bilevel" ))[1] - __s2[1]); if (__s2_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) ("enable-grayscale-to-bilevel" ))[2] - __s2[2]); if (__s2_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) ("enable-grayscale-to-bilevel" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "enable-grayscale-to-bilevel")))); })) { |
| 608 | if (switch_true(value)) |
| 609 | spandsp_globals.enable_grayscale_to_bilevel = 1; |
| 610 | else |
| 611 | spandsp_globals.enable_grayscale_to_bilevel = 0; |
| 612 | } else if (!strcmp(name, "enable-tep")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-tep") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-tep"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("enable-tep") + 1) - (size_t)(const void *)("enable-tep") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-tep") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-tep") && (( size_t)(const void *)(("enable-tep") + 1) - (size_t)(const void *)("enable-tep") == 1) ? __builtin_strcmp (name, "enable-tep" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-tep"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("enable-tep") && ((size_t)(const void *)(("enable-tep") + 1) - (size_t)(const void *)("enable-tep" ) == 1) && (__s2_len = __builtin_strlen ("enable-tep" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "enable-tep") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-tep"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-tep"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-tep"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("enable-tep"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "enable-tep")))); })) { |
| 613 | if (switch_true(value)) { |
| 614 | spandsp_globals.enable_tep= 1; |
| 615 | } else { |
| 616 | spandsp_globals.enable_tep = 0; |
| 617 | } |
| 618 | } else if (!strcmp(name, "enable-t38")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-t38") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-t38"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("enable-t38") + 1) - (size_t)(const void *)("enable-t38") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-t38") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-t38") && (( size_t)(const void *)(("enable-t38") + 1) - (size_t)(const void *)("enable-t38") == 1) ? __builtin_strcmp (name, "enable-t38" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-t38"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("enable-t38") && ((size_t)(const void *)(("enable-t38") + 1) - (size_t)(const void *)("enable-t38" ) == 1) && (__s2_len = __builtin_strlen ("enable-t38" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "enable-t38") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-t38"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-t38"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-t38"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("enable-t38"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "enable-t38")))); })) { |
| 619 | if (switch_true(value)) { |
| 620 | spandsp_globals.enable_t38= 1; |
| 621 | } else { |
| 622 | spandsp_globals.enable_t38 = 0; |
| 623 | } |
| 624 | } else if (!strcmp(name, "enable-t38-request")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("enable-t38-request" ) && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("enable-t38-request"), (!((size_t)(const void *)((name) + 1 ) - (size_t)(const void *)(name) == 1) || __s1_len >= 4) && (!((size_t)(const void *)(("enable-t38-request") + 1) - (size_t )(const void *)("enable-t38-request") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "enable-t38-request") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("enable-t38-request" ) && ((size_t)(const void *)(("enable-t38-request") + 1) - (size_t)(const void *)("enable-t38-request") == 1) ? __builtin_strcmp (name, "enable-t38-request") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("enable-t38-request" ); int __result = (((const unsigned char *) (const char *) (name ))[0] - __s2[0]); if (__s1_len > 0 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[1] - __s2[1]); if (__s1_len > 1 && __result == 0 ) { __result = (((const unsigned char *) (const char *) (name ))[2] - __s2[2]); if (__s1_len > 2 && __result == 0 ) __result = (((const unsigned char *) (const char *) (name)) [3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ("enable-t38-request" ) && ((size_t)(const void *)(("enable-t38-request") + 1) - (size_t)(const void *)("enable-t38-request") == 1) && (__s2_len = __builtin_strlen ("enable-t38-request"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)( const void *)((name) + 1) - (size_t)(const void *)(name) == 1 ) ? __builtin_strcmp (name, "enable-t38-request") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("enable-t38-request"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-t38-request"))[1] - __s2[1]); if ( __s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("enable-t38-request"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("enable-t38-request" ))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name , "enable-t38-request")))); })) { |
| 625 | if (switch_true(value)) { |
| 626 | spandsp_globals.enable_t38_request = 1; |
| 627 | } else { |
| 628 | spandsp_globals.enable_t38_request = 0; |
| 629 | } |
| 630 | } else if (!strcmp(name, "ident")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("ident") && ( __s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("ident"), (!((size_t)(const void *)((name) + 1) - (size_t)( const void *)(name) == 1) || __s1_len >= 4) && (!( (size_t)(const void *)(("ident") + 1) - (size_t)(const void * )("ident") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name , "ident") : (__builtin_constant_p (name) && ((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("ident") && ((size_t)(const void *)(("ident") + 1) - (size_t)(const void *)("ident") == 1 ) ? __builtin_strcmp (name, "ident") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("ident"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "ident") && ((size_t)(const void *)(("ident") + 1) - ( size_t)(const void *)("ident") == 1) && (__s2_len = __builtin_strlen ("ident"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "ident") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("ident"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ident"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("ident"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("ident"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "ident")))); })) { |
| 631 | spandsp_globals.ident = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 631); |
| 632 | } else if (!strcmp(name, "header")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("header") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("header"), (!((size_t)(const void *)((name) + 1) - (size_t) (const void *)(name) == 1) || __s1_len >= 4) && (! ((size_t)(const void *)(("header") + 1) - (size_t)(const void *)("header") == 1) || __s2_len >= 4)) ? __builtin_strcmp ( name, "header") : (__builtin_constant_p (name) && ((size_t )(const void *)((name) + 1) - (size_t)(const void *)(name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("header") && ((size_t)(const void *)(("header") + 1) - (size_t)(const void *)("header") == 1) ? __builtin_strcmp (name, "header") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("header"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ( name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ( name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) (name ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p ( "header") && ((size_t)(const void *)(("header") + 1) - (size_t)(const void *)("header") == 1) && (__s2_len = __builtin_strlen ("header"), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) ? __builtin_strcmp (name, "header" ) : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("header"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("header"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("header"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("header"))[3] - __s2[3]); } } __result ; })))) : __builtin_strcmp (name, "header")))); })) { |
| 633 | spandsp_globals.header = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 633); |
| 634 | } else if (!strcmp(name, "spool-dir")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("spool-dir") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("spool-dir"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("spool-dir") + 1) - (size_t)(const void *)("spool-dir") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "spool-dir") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("spool-dir") && ((size_t )(const void *)(("spool-dir") + 1) - (size_t)(const void *)("spool-dir" ) == 1) ? __builtin_strcmp (name, "spool-dir") : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("spool-dir"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("spool-dir") && ((size_t)(const void *)(("spool-dir") + 1) - (size_t)(const void *)("spool-dir" ) == 1) && (__s2_len = __builtin_strlen ("spool-dir") , __s2_len < 4) ? (__builtin_constant_p (name) && ( (size_t)(const void *)((name) + 1) - (size_t)(const void *)(name ) == 1) ? __builtin_strcmp (name, "spool-dir") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("spool-dir"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("spool-dir"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("spool-dir"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("spool-dir"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "spool-dir")))); })) { |
| 635 | spandsp_globals.spool = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 635); |
| 636 | } else if (!strcmp(name, "file-prefix")__extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (name) && __builtin_constant_p ("file-prefix") && (__s1_len = __builtin_strlen (name), __s2_len = __builtin_strlen ("file-prefix"), (!((size_t)(const void *)((name) + 1) - (size_t )(const void *)(name) == 1) || __s1_len >= 4) && ( !((size_t)(const void *)(("file-prefix") + 1) - (size_t)(const void *)("file-prefix") == 1) || __s2_len >= 4)) ? __builtin_strcmp (name, "file-prefix") : (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) && (__s1_len = __builtin_strlen (name), __s1_len < 4) ? (__builtin_constant_p ("file-prefix") && ( (size_t)(const void *)(("file-prefix") + 1) - (size_t)(const void *)("file-prefix") == 1) ? __builtin_strcmp (name, "file-prefix" ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) ("file-prefix"); int __result = (((const unsigned char *) (const char *) (name))[0] - __s2[0]); if (__s1_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[1] - __s2[1]); if (__s1_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) (name))[2] - __s2[2]); if (__s1_len > 2 && __result == 0) __result = (((const unsigned char * ) (const char *) (name))[3] - __s2[3]); } } __result; }))) : ( __builtin_constant_p ("file-prefix") && ((size_t)(const void *)(("file-prefix") + 1) - (size_t)(const void *)("file-prefix" ) == 1) && (__s2_len = __builtin_strlen ("file-prefix" ), __s2_len < 4) ? (__builtin_constant_p (name) && ((size_t)(const void *)((name) + 1) - (size_t)(const void *) (name) == 1) ? __builtin_strcmp (name, "file-prefix") : (- (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (name); int __result = (((const unsigned char *) (const char *) ("file-prefix"))[0] - __s2[0]); if (__s2_len > 0 && __result == 0) { __result = (((const unsigned char *) (const char *) ("file-prefix"))[1] - __s2[1]); if (__s2_len > 1 && __result == 0) { __result = (((const unsigned char *) (const char *) ("file-prefix"))[2] - __s2[2]); if (__s2_len > 2 && __result == 0) __result = (((const unsigned char *) (const char *) ("file-prefix"))[3] - __s2[3]); } } __result; })))) : __builtin_strcmp (name, "file-prefix")))); })) { |
| 637 | spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, value)switch_core_perform_strdup(spandsp_globals.config_pool, value , "mod_spandsp.c", (const char *)__func__, 637); |
| 638 | } else { |
| 639 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 639, ((void*)0), SWITCH_LOG_WARNING, "Unknown parameter %s\n", name); |
| 640 | } |
| 641 | |
| 642 | } |
| 643 | } |
| 644 | |
| 645 | /* Configure call progress detector */ |
| 646 | if ((callprogress = switch_xml_child(cfg, "descriptors"))) { |
| 647 | /* check if debugging is enabled */ |
| 648 | const char *debug = switch_xml_attr(callprogress, "debug-level"); |
| 649 | if (!zstr(debug)_zstr(debug) && switch_is_number(debug)) { |
| 650 | int debug_val = atoi(debug); |
| 651 | if (debug_val > 0) { |
| 652 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 652, ((void*)0), SWITCH_LOG_DEBUG, "Setting tone detector debug-level to : %d\n", debug_val); |
| 653 | spandsp_globals.tonedebug = debug_val; |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | for (xdescriptor = switch_xml_child(callprogress, "descriptor"); xdescriptor; xdescriptor = switch_xml_next(xdescriptor)((xdescriptor) ? xdescriptor->next : ((void*)0))) { |
| 658 | const char *name = switch_xml_attr(xdescriptor, "name"); |
| 659 | const char *tone_name = NULL((void*)0); |
| 660 | switch_xml_t tone = NULL((void*)0), element = NULL((void*)0); |
| 661 | tone_descriptor_t *descriptor = NULL((void*)0); |
| 662 | |
| 663 | /* create descriptor */ |
| 664 | if (zstr(name)_zstr(name)) { |
| 665 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 665, ((void*)0), SWITCH_LOG_WARNING, "Missing <descriptor> name\n"); |
| 666 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 667 | } |
| 668 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 668, ((void*)0), SWITCH_LOG_DEBUG10, "Adding tone_descriptor: %s\n", name); |
| 669 | if (tone_descriptor_create(&descriptor, name, spandsp_globals.config_pool) != SWITCH_STATUS_SUCCESS) { |
| 670 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 670, ((void*)0), SWITCH_LOG_CRIT, "Unable to allocate tone_descriptor: %s\n", name); |
| 671 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 672 | } |
| 673 | |
| 674 | switch_core_hash_insert_destructor(spandsp_globals.tones, name, descriptor, destroy_descriptor); |
| 675 | |
| 676 | /* add tones to descriptor */ |
| 677 | for (tone = switch_xml_child(xdescriptor, "tone"); tone; tone = switch_xml_next(tone)((tone) ? tone->next : ((void*)0))) { |
| 678 | int id = 0; |
| 679 | tone_name = switch_xml_attr(tone, "name"); |
| 680 | if (zstr(tone_name)_zstr(tone_name)) { |
| 681 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 681, ((void*)0), SWITCH_LOG_WARNING, "Missing <tone> name for <descriptor> %s\n", name); |
| 682 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 683 | } |
| 684 | id = tone_descriptor_add_tone(descriptor, tone_name); |
| 685 | if (id == -1) { |
| 686 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 686, ((void*)0), SWITCH_LOG_WARNING, |
| 687 | "Unable to add tone_descriptor: %s, tone: %s. (too many tones)\n", name, tone_name); |
| 688 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 689 | } |
| 690 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 690, ((void*)0), SWITCH_LOG_DEBUG10, |
| 691 | "Adding tone_descriptor: %s, tone: %s(%d)\n", name, tone_name, id); |
| 692 | /* add elements to tone */ |
| 693 | for (element = switch_xml_child(tone, "element"); element; element = switch_xml_next(element)((element) ? element->next : ((void*)0))) { |
| 694 | const char *freq1_attr = switch_xml_attr(element, "freq1"); |
| 695 | const char *freq2_attr = switch_xml_attr(element, "freq2"); |
| 696 | const char *min_attr = switch_xml_attr(element, "min"); |
| 697 | const char *max_attr = switch_xml_attr(element, "max"); |
| 698 | int freq1, freq2, min, max; |
| 699 | if (zstr(freq1_attr)_zstr(freq1_attr)) { |
| 700 | freq1 = 0; |
| 701 | } else { |
| 702 | freq1 = atoi(freq1_attr); |
| 703 | } |
| 704 | if (zstr(freq2_attr)_zstr(freq2_attr)) { |
| 705 | freq2 = 0; |
| 706 | } else { |
| 707 | freq2 = atoi(freq2_attr); |
| 708 | } |
| 709 | if (zstr(min_attr)_zstr(min_attr)) { |
| 710 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 710, ((void*)0), SWITCH_LOG_WARNING, |
| 711 | "Missing min in <element> of <descriptor> %s <tone> %s(%d)\n", name, tone_name, id); |
| 712 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 713 | } |
| 714 | min = atoi(min_attr); |
| 715 | if (zstr(max_attr)_zstr(max_attr)) { |
| 716 | max = 0; |
| 717 | } else { |
| 718 | max = atoi(max_attr); |
| 719 | } |
| 720 | /* check params */ |
| 721 | if ((freq1 < 0 || freq2 < 0 || min < 0 || max < 0) || (freq1 == 0 && min == 0 && max == 0)) { |
| 722 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 722, ((void*)0), SWITCH_LOG_WARNING, "Invalid element param.\n"); |
| 723 | switch_goto_status(SWITCH_STATUS_FALSE, done)status = SWITCH_STATUS_FALSE; goto done; |
| 724 | } |
| 725 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 725, ((void*)0), SWITCH_LOG_DEBUG10, |
| 726 | "Adding tone_descriptor: %s, tone: %s(%d), element (%d, %d, %d, %d)\n", name, tone_name, id, freq1, freq2, min, max); |
| 727 | tone_descriptor_add_tone_element(descriptor, id, freq1, freq2, min, max); |
| 728 | } |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | done: |
| 734 | |
| 735 | switch_xml_free(xml); |
| 736 | } |
| 737 | |
| 738 | switch_mutex_unlock(spandsp_globals.mutex); |
| 739 | |
| 740 | return status; |
| 741 | } |
| 742 | |
| 743 | |
| 744 | SWITCH_MODULE_LOAD_FUNCTION(mod_spandsp_init)switch_status_t mod_spandsp_init (switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) |
| 745 | { |
| 746 | switch_application_interface_t *app_interface; |
| 747 | switch_api_interface_t *api_interface; |
| 748 | |
| 749 | memset(&spandsp_globals, 0, sizeof(spandsp_globals)); |
| 750 | spandsp_globals.pool = pool; |
| 751 | |
| 752 | *module_interface = switch_loadable_module_create_module_interface(pool, modname); |
| 753 | switch_mutex_init(&spandsp_globals.mutex, SWITCH_MUTEX_NESTED0x1, pool); |
| 754 | |
| 755 | SWITCH_ADD_APP(app_interface, "t38_gateway", "Convert to T38 Gateway if tones are heard", "Convert to T38 Gateway if tones are heard",for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "t38_gateway"; app_interface ->application_function = t38_gateway_function; app_interface ->short_desc = "Convert to T38 Gateway if tones are heard" ; app_interface->long_desc = "Convert to T38 Gateway if tones are heard" ; app_interface->syntax = ""; app_interface->flags = SAF_MEDIA_TAP ; break; } |
| 756 | t38_gateway_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "t38_gateway"; app_interface ->application_function = t38_gateway_function; app_interface ->short_desc = "Convert to T38 Gateway if tones are heard" ; app_interface->long_desc = "Convert to T38 Gateway if tones are heard" ; app_interface->syntax = ""; app_interface->flags = SAF_MEDIA_TAP ; break; }; |
| 757 | |
| 758 | SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "rxfax"; app_interface-> application_function = spanfax_rx_function; app_interface-> short_desc = "FAX Receive Application"; app_interface->long_desc = "FAX Receive Application"; app_interface->syntax = "<filename>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK ; break; } |
| 759 | SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "rxfax"; app_interface-> application_function = spanfax_rx_function; app_interface-> short_desc = "FAX Receive Application"; app_interface->long_desc = "FAX Receive Application"; app_interface->syntax = "<filename>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK ; break; }; |
| 760 | SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "txfax"; app_interface-> application_function = spanfax_tx_function; app_interface-> short_desc = "FAX Transmit Application"; app_interface->long_desc = "FAX Transmit Application"; app_interface->syntax = "<filename>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK ; break; } |
| 761 | SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "txfax"; app_interface-> application_function = spanfax_tx_function; app_interface-> short_desc = "FAX Transmit Application"; app_interface->long_desc = "FAX Transmit Application"; app_interface->syntax = "<filename>" ; app_interface->flags = SAF_SUPPORT_NOMEDIA | SAF_NO_LOOPBACK ; break; }; |
| 762 | SWITCH_ADD_APP(app_interface, "stopfax", "Stop FAX Application", "Stop FAX Application", spanfax_stop_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "stopfax"; app_interface ->application_function = spanfax_stop_function; app_interface ->short_desc = "Stop FAX Application"; app_interface->long_desc = "Stop FAX Application"; app_interface->syntax = ""; app_interface ->flags = SAF_NONE; break; }; |
| 763 | |
| 764 | SWITCH_ADD_APP(app_interface, "spandsp_stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_stop_dtmf"; app_interface ->application_function = stop_dtmf_session_function; app_interface ->short_desc = "stop inband dtmf"; app_interface->long_desc = "Stop detecting inband dtmf."; app_interface->syntax = "" ; app_interface->flags = SAF_NONE; break; }; |
| 765 | SWITCH_ADD_APP(app_interface, "spandsp_start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_start_dtmf"; app_interface ->application_function = dtmf_session_function; app_interface ->short_desc = "Detect dtmf"; app_interface->long_desc = "Detect inband dtmf on the session"; app_interface->syntax = ""; app_interface->flags = SAF_MEDIA_TAP; break; }; |
| 766 | |
| 767 | |
| 768 | SWITCH_ADD_APP(app_interface, "spandsp_stop_inject_tdd", "stop sending tdd", "", stop_tdd_encode_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_stop_inject_tdd" ; app_interface->application_function = stop_tdd_encode_function ; app_interface->short_desc = "stop sending tdd"; app_interface ->long_desc = ""; app_interface->syntax = ""; app_interface ->flags = SAF_NONE; break; }; |
| 769 | SWITCH_ADD_APP(app_interface, "spandsp_inject_tdd", "Send TDD data", "Send TDD data", tdd_encode_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_inject_tdd"; app_interface ->application_function = tdd_encode_function; app_interface ->short_desc = "Send TDD data"; app_interface->long_desc = "Send TDD data"; app_interface->syntax = ""; app_interface ->flags = SAF_MEDIA_TAP; break; }; |
| 770 | |
| 771 | SWITCH_ADD_APP(app_interface, "spandsp_stop_detect_tdd", "stop sending tdd", "", stop_tdd_decode_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_stop_detect_tdd" ; app_interface->application_function = stop_tdd_decode_function ; app_interface->short_desc = "stop sending tdd"; app_interface ->long_desc = ""; app_interface->syntax = ""; app_interface ->flags = SAF_NONE; break; }; |
| 772 | SWITCH_ADD_APP(app_interface, "spandsp_detect_tdd", "Detect TDD data", "Detect TDD data", tdd_decode_function, "", SAF_MEDIA_TAP)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_detect_tdd"; app_interface ->application_function = tdd_decode_function; app_interface ->short_desc = "Detect TDD data"; app_interface->long_desc = "Detect TDD data"; app_interface->syntax = ""; app_interface ->flags = SAF_MEDIA_TAP; break; }; |
| 773 | |
| 774 | |
| 775 | SWITCH_ADD_APP(app_interface, "spandsp_send_tdd", "Send TDD data", "Send TDD data", tdd_send_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_send_tdd"; app_interface ->application_function = tdd_send_function; app_interface-> short_desc = "Send TDD data"; app_interface->long_desc = "Send TDD data" ; app_interface->syntax = ""; app_interface->flags = SAF_NONE ; break; }; |
| 776 | |
| 777 | SWITCH_ADD_APP(app_interface, "spandsp_start_fax_detect", "start fax detect", "start fax detect", spandsp_fax_detect_session_function,for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_start_fax_detect" ; app_interface->application_function = spandsp_fax_detect_session_function ; app_interface->short_desc = "start fax detect"; app_interface ->long_desc = "start fax detect"; app_interface->syntax = "<app>[ <arg>][ <timeout>][ <tone_type>]" ; app_interface->flags = SAF_NONE; break; } |
| 778 | "<app>[ <arg>][ <timeout>][ <tone_type>]", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_start_fax_detect" ; app_interface->application_function = spandsp_fax_detect_session_function ; app_interface->short_desc = "start fax detect"; app_interface ->long_desc = "start fax detect"; app_interface->syntax = "<app>[ <arg>][ <timeout>][ <tone_type>]" ; app_interface->flags = SAF_NONE; break; }; |
| 779 | |
| 780 | SWITCH_ADD_APP(app_interface, "spandsp_stop_fax_detect", "stop fax detect", "stop fax detect", spandsp_stop_fax_detect_session_function, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_stop_fax_detect" ; app_interface->application_function = spandsp_stop_fax_detect_session_function ; app_interface->short_desc = "stop fax detect"; app_interface ->long_desc = "stop fax detect"; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; }; |
| 781 | |
| 782 | load_configuration(0); |
| 783 | |
| 784 | mod_spandsp_fax_load(pool); |
| 785 | mod_spandsp_codecs_load(module_interface, pool); |
| 786 | |
| 787 | |
| 788 | if (mod_spandsp_dsp_load(module_interface, pool) != SWITCH_STATUS_SUCCESS) { |
| 789 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 789, ((void*)0), SWITCH_LOG_ERROR, "Couldn't load or process spandsp.conf, not adding tone_detect applications\n"); |
| 790 | } else { |
| 791 | SWITCH_ADD_APP(app_interface, "spandsp_start_tone_detect", "Start background tone detection with cadence", "", start_tone_detect_app, "<name>", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_start_tone_detect" ; app_interface->application_function = start_tone_detect_app ; app_interface->short_desc = "Start background tone detection with cadence" ; app_interface->long_desc = ""; app_interface->syntax = "<name>"; app_interface->flags = SAF_NONE; break; }; |
| 792 | SWITCH_ADD_APP(app_interface, "spandsp_stop_tone_detect", "Stop background tone detection with cadence", "", stop_tone_detect_app, "", SAF_NONE)for (;;) { app_interface = (switch_application_interface_t *) switch_loadable_module_create_interface(*module_interface, SWITCH_APPLICATION_INTERFACE ); app_interface->interface_name = "spandsp_stop_tone_detect" ; app_interface->application_function = stop_tone_detect_app ; app_interface->short_desc = "Stop background tone detection with cadence" ; app_interface->long_desc = ""; app_interface->syntax = ""; app_interface->flags = SAF_NONE; break; }; |
| 793 | SWITCH_ADD_API(api_interface, "spandsp_start_tone_detect", "Start background tone detection with cadence", start_tone_detect_api, "<uuid> <name>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "spandsp_start_tone_detect"; api_interface-> desc = "Start background tone detection with cadence"; api_interface ->function = start_tone_detect_api; api_interface->syntax = "<uuid> <name>"; break; }; |
| 794 | SWITCH_ADD_API(api_interface, "spandsp_stop_tone_detect", "Stop background tone detection with cadence", stop_tone_detect_api, "<uuid>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "spandsp_stop_tone_detect"; api_interface-> desc = "Stop background tone detection with cadence"; api_interface ->function = stop_tone_detect_api; api_interface->syntax = "<uuid>"; break; }; |
| 795 | switch_console_set_complete("add spandsp_start_tone_detect ::console::list_uuid"); |
| 796 | switch_console_set_complete("add spandsp_stop_tone_detect ::console::list_uuid"); |
| 797 | } |
| 798 | |
| 799 | SWITCH_ADD_API(api_interface, "start_tdd_detect", "Start background tdd detection", start_tdd_detect_api, "<uuid>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "start_tdd_detect"; api_interface->desc = "Start background tdd detection"; api_interface->function = start_tdd_detect_api; api_interface->syntax = "<uuid>" ; break; }; |
| 800 | SWITCH_ADD_API(api_interface, "stop_tdd_detect", "Stop background tdd detection", stop_tdd_detect_api, "<uuid>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "stop_tdd_detect"; api_interface->desc = "Stop background tdd detection" ; api_interface->function = stop_tdd_detect_api; api_interface ->syntax = "<uuid>"; break; }; |
| 801 | |
| 802 | SWITCH_ADD_API(api_interface, "uuid_send_tdd", "send tdd data to a uuid", start_send_tdd_api, "<uuid> <text>")for (;;) { api_interface = (switch_api_interface_t *)switch_loadable_module_create_interface (*module_interface, SWITCH_API_INTERFACE); api_interface-> interface_name = "uuid_send_tdd"; api_interface->desc = "send tdd data to a uuid" ; api_interface->function = start_send_tdd_api; api_interface ->syntax = "<uuid> <text>"; break; }; |
| 803 | |
| 804 | switch_console_set_complete("add uuid_send_tdd ::console::list_uuid"); |
| 805 | |
| 806 | |
| 807 | |
| 808 | if ((switch_event_bind(modname, SWITCH_EVENT_RELOADXML, NULL((void*)0), event_handler, NULL((void*)0)) != SWITCH_STATUS_SUCCESS)) { |
| 809 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 809, ((void*)0), SWITCH_LOG_ERROR, "Couldn't bind our reloadxml handler!\n"); |
| 810 | /* Not such severe to prevent loading */ |
| 811 | } |
| 812 | |
| 813 | |
| 814 | if (switch_event_bind(modname, SWITCH_EVENT_CUSTOM, MY_EVENT_TDD_SEND_MESSAGE"TDD::SEND_MESSAGE", tdd_event_handler, NULL((void*)0)) != SWITCH_STATUS_SUCCESS) { |
| 815 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 815, ((void*)0), SWITCH_LOG_ERROR, "Couldn't bind!\n"); |
| 816 | } |
| 817 | |
| 818 | #if defined(MODEM_SUPPORT1) |
| 819 | modem_global_init(module_interface, pool); |
| 820 | #endif |
| 821 | |
| 822 | switch_log_printf(SWITCH_CHANNEL_LOGSWITCH_CHANNEL_ID_LOG, "mod_spandsp.c", (const char *)__func__ , 822, ((void*)0), SWITCH_LOG_DEBUG, "mod_spandsp loaded, using spandsp library version [%s]\n", SPANDSP_RELEASE_DATETIME_STRING"20120902 163333"); |
| 823 | |
| 824 | return SWITCH_STATUS_SUCCESS; |
| 825 | } |
| 826 | |
| 827 | SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spandsp_shutdown)switch_status_t mod_spandsp_shutdown (void) |
| 828 | { |
| 829 | switch_event_unbind_callback(event_handler); |
| 830 | switch_event_unbind_callback(tdd_event_handler); |
| 831 | |
| 832 | |
| 833 | mod_spandsp_fax_shutdown(); |
| 834 | mod_spandsp_dsp_shutdown(); |
| 835 | #if defined(MODEM_SUPPORT1) |
| 836 | modem_global_shutdown(); |
| 837 | #endif |
| 838 | |
| 839 | if (spandsp_globals.tones) { |
| 840 | switch_core_hash_destroy(&spandsp_globals.tones); |
| 841 | } |
| 842 | |
| 843 | if (spandsp_globals.config_pool) { |
| 844 | switch_core_destroy_memory_pool(&spandsp_globals.config_pool)switch_core_perform_destroy_memory_pool(&spandsp_globals. config_pool, "mod_spandsp.c", (const char *)__func__, 844); |
| 845 | } |
| 846 | |
| 847 | memset(&spandsp_globals, 0, sizeof(spandsp_globals)); |
| 848 | |
| 849 | return SWITCH_STATUS_UNLOAD; |
| 850 | } |
| 851 | |
| 852 | /* For Emacs: |
| 853 | * Local Variables: |
| 854 | * mode:c |
| 855 | * indent-tabs-mode:nil |
| 856 | * tab-width:4 |
| 857 | * c-basic-offset:4 |
| 858 | * End: |
| 859 | * For VIM: |
| 860 | * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: |
| 861 | */ |