From 886e1ddb4de699dd68270054c9b95d26f1c60c73 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Sat, 6 Feb 2010 03:38:24 +0000 Subject: [PATCH] run indent on the whole tree and update copyright dates in prep for 1.0.5 git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16579 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- build/indent_options.sh | 4 +- src/g711.c | 76 +- src/include/SimpleGlob.h | 20 +- src/include/private/switch_core_pvt.h | 6 +- src/include/switch.h | 2 +- src/include/switch_apr.h | 88 +- src/include/switch_bitpack.h | 2 +- src/include/switch_buffer.h | 2 +- src/include/switch_caller.h | 8 +- src/include/switch_channel.h | 42 +- src/include/switch_config.h | 2 +- src/include/switch_console.h | 8 +- src/include/switch_core.h | 124 +- src/include/switch_core_db.h | 2 +- src/include/switch_core_event_hook.h | 4 +- src/include/switch_dso.h | 5 +- src/include/switch_event.h | 9 +- src/include/switch_frame.h | 4 +- src/include/switch_ivr.h | 90 +- src/include/switch_loadable_module.h | 15 +- src/include/switch_log.h | 9 +- src/include/switch_module_interfaces.h | 34 +- src/include/switch_mprintf.h | 1 - src/include/switch_nat.h | 9 +- src/include/switch_odbc.h | 24 +- src/include/switch_platform.h | 4 +- src/include/switch_regex.h | 4 +- src/include/switch_resample.h | 18 +- src/include/switch_rtp.h | 14 +- src/include/switch_scheduler.h | 2 +- src/include/switch_stun.h | 5 +- src/include/switch_types.h | 52 +- src/include/switch_utils.h | 125 +- src/include/switch_xml.h | 41 +- src/include/switch_xml_config.h | 70 +- src/inet_pton.c | 249 +- .../mod_cidlookup/mod_cidlookup.c | 277 +- .../applications/mod_cluechoo/mod_cluechoo.c | 345 +- .../applications/mod_commands/mod_commands.c | 430 ++- .../mod_conference/mod_conference.c | 581 ++- src/mod/applications/mod_curl/mod_curl.c | 121 +- .../mod_directory/mod_directory.c | 239 +- .../mod_distributor/mod_distributor.c | 63 +- .../applications/mod_dptools/mod_dptools.c | 349 +- .../mod_easyroute/mod_easyroute.c | 129 +- src/mod/applications/mod_enum/mod_enum.c | 10 +- src/mod/applications/mod_esf/mod_esf.c | 13 +- src/mod/applications/mod_expr/conio.h | 95 +- src/mod/applications/mod_expr/expreval.h | 141 +- src/mod/applications/mod_expr/exprilfs.h | 1407 ++++--- src/mod/applications/mod_expr/exprmem.h | 2 +- src/mod/applications/mod_expr/exprpriv.h | 290 +- src/mod/applications/mod_expr/mod_expr.c | 2 +- src/mod/applications/mod_fax/mod_fax.c | 84 +- src/mod/applications/mod_fifo/mod_fifo.c | 263 +- src/mod/applications/mod_fsv/mod_fsv.c | 8 +- src/mod/applications/mod_lcr/mod_lcr.c | 422 +-- src/mod/applications/mod_limit/mod_limit.c | 293 +- .../applications/mod_memcache/mod_memcache.c | 111 +- .../mod_nibblebill/mod_nibblebill.c | 160 +- src/mod/applications/mod_rss/mod_rss.c | 6 +- src/mod/applications/mod_skel/mod_skel.c | 60 +- .../applications/mod_snapshot/mod_snapshot.c | 53 +- .../mod_snipe_hunt/mod_snipe_hunt.c | 60 +- src/mod/applications/mod_snom/mod_snom.c | 25 +- .../mod_soundtouch/mod_soundtouch.cpp | 2 +- src/mod/applications/mod_spy/mod_spy.c | 154 +- src/mod/applications/mod_stress/FFTReal.h | 84 +- .../applications/mod_stress/mod_stress.cpp | 2 +- .../mod_t38gateway/mod_t38gateway.c | 352 +- src/mod/applications/mod_t38gateway/udptl.c | 885 +++-- src/mod/applications/mod_t38gateway/udptl.h | 117 +- .../mod_valet_parking/mod_valet_parking.c | 47 +- src/mod/applications/mod_vmd/mod_vmd.c | 702 ++-- .../mod_voicemail/mod_voicemail.c | 800 ++-- src/mod/asr_tts/mod_cepstral/mod_cepstral.c | 2 +- src/mod/asr_tts/mod_flite/mod_flite.c | 24 +- .../mod_pocketsphinx/mod_pocketsphinx.c | 95 +- .../mod_tts_commandline/mod_tts_commandline.c | 50 +- src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c | 745 ++-- src/mod/codecs/mod_amr/mod_amr.c | 43 +- src/mod/codecs/mod_amrwb/mod_amrwb.c | 32 +- src/mod/codecs/mod_bv/mod_bv.c | 106 +- src/mod/codecs/mod_celt/mod_celt.c | 138 +- .../codecs/mod_dahdi_codec/mod_dahdi_codec.c | 227 +- src/mod/codecs/mod_g723_1/mod_g723_1.c | 9 +- src/mod/codecs/mod_g729/mod_g729.c | 2 +- src/mod/codecs/mod_h26x/mod_h26x.c | 2 +- src/mod/codecs/mod_ilbc/mod_ilbc.c | 82 +- src/mod/codecs/mod_siren/mod_siren.c | 104 +- .../codecs/mod_skel_codec/mod_skel_codec.c | 80 +- src/mod/codecs/mod_speex/mod_speex.c | 38 +- .../codecs/mod_voipcodecs/mod_voipcodecs.c | 577 ++- .../mod_dialplan_asterisk.c | 14 +- .../mod_dialplan_directory.c | 6 +- .../mod_dialplan_xml/mod_dialplan_xml.c | 61 +- src/mod/directories/mod_ldap/mod_ldap.c | 2 +- src/mod/endpoints/mod_alsa/mod_alsa.c | 28 +- .../endpoints/mod_dingaling/mod_dingaling.c | 211 +- src/mod/endpoints/mod_h323/mod_h323.h | 470 ++- src/mod/endpoints/mod_loopback/mod_loopback.c | 173 +- src/mod/endpoints/mod_opal/mod_opal.h | 244 +- .../endpoints/mod_portaudio/mod_portaudio.c | 129 +- src/mod/endpoints/mod_portaudio/pablio.c | 57 +- src/mod/endpoints/mod_portaudio/pablio.h | 2 +- .../endpoints/mod_reference/mod_reference.c | 29 +- src/mod/endpoints/mod_skypiax/alsa/dummy.c | 475 ++- .../mod_skypiax/asterisk/chan_skypiax.c | 3326 ++++++++--------- .../asterisk/cyg_no_pthread_kill.c | 12 +- .../endpoints/mod_skypiax/asterisk/skypiax.h | 159 +- .../endpoints/mod_skypiax/configs/client.c | 376 +- .../mod_skypiax/configs/skypiax_auth.c | 289 +- src/mod/endpoints/mod_skypiax/mod_skypiax.c | 2 +- .../endpoints/mod_skypiax/skypiax_protocol.c | 2 +- src/mod/endpoints/mod_sofia/mod_sofia.c | 890 ++--- src/mod/endpoints/mod_sofia/mod_sofia.h | 105 +- src/mod/endpoints/mod_sofia/sofia.c | 1176 +++--- src/mod/endpoints/mod_sofia/sofia_glue.c | 1333 ++++--- src/mod/endpoints/mod_sofia/sofia_presence.c | 456 +-- src/mod/endpoints/mod_sofia/sofia_reg.c | 357 +- src/mod/endpoints/mod_sofia/sofia_sla.c | 104 +- src/mod/endpoints/mod_unicall/mod_unicall.c | 2587 ++++++------- .../event_handlers/mod_cdr_csv/mod_cdr_csv.c | 33 +- .../mod_erlang_event/ei_helpers.c | 104 +- .../mod_erlang_event/handle_msg.c | 259 +- .../mod_erlang_event/mod_erlang_event.c | 470 +-- .../mod_erlang_event/mod_erlang_event.h | 44 +- .../mod_event_multicast/mod_event_multicast.c | 81 +- .../mod_event_socket/mod_event_socket.c | 375 +- .../mod_event_test/mod_event_test.c | 2 +- .../mod_radius_cdr/mod_radius_cdr.c | 30 +- .../formats/mod_file_string/mod_file_string.c | 27 +- .../mod_local_stream/mod_local_stream.c | 85 +- .../formats/mod_native_file/mod_native_file.c | 4 +- .../mod_portaudio_stream.c | 56 +- .../mod_shell_stream/mod_shell_stream.c | 48 +- src/mod/formats/mod_shout/mod_shout.c | 76 +- src/mod/formats/mod_sndfile/mod_sndfile.c | 10 +- .../formats/mod_tone_stream/mod_tone_stream.c | 10 +- src/mod/languages/mod_java/freeswitch_java.h | 26 +- src/mod/languages/mod_java/modjava.c | 347 +- src/mod/languages/mod_lua/freeswitch_lua.h | 62 +- src/mod/languages/mod_lua/mod_lua.cpp | 2 +- src/mod/languages/mod_lua/mod_lua_extra.h | 6 +- src/mod/languages/mod_lua/my_swigable_cpp.h | 207 +- .../mod_managed/freeswitch_managed.h | 135 +- src/mod/languages/mod_perl/freeswitch_perl.h | 62 +- src/mod/languages/mod_perl/mod_perl.c | 4 +- src/mod/languages/mod_perl/mod_perl_extra.h | 6 +- .../languages/mod_python/freeswitch_python.h | 70 +- src/mod/languages/mod_python/mod_python.c | 64 +- .../languages/mod_python/mod_python_extra.c | 24 +- .../languages/mod_python/mod_python_extra.h | 6 +- .../mod_spidermonkey/mod_spidermonkey.c | 65 +- .../mod_spidermonkey/mod_spidermonkey.h | 4 +- .../mod_spidermonkey_core_db.c | 46 +- .../mod_spidermonkey/mod_spidermonkey_curl.c | 6 +- .../mod_spidermonkey/mod_spidermonkey_odbc.c | 14 +- .../mod_spidermonkey/mod_spidermonkey_skel.c | 4 +- .../mod_spidermonkey_socket.c | 2 +- .../mod_spidermonkey_teletone.c | 16 +- src/mod/languages/mod_yaml/mod_yaml.c | 171 +- src/mod/loggers/mod_console/mod_console.c | 35 +- src/mod/loggers/mod_logfile/mod_logfile.c | 8 +- src/mod/loggers/mod_syslog/mod_syslog.c | 62 +- src/mod/say/mod_say_en/mod_say_en.c | 20 +- src/mod/say/mod_say_es/mod_say_es.c | 120 +- src/mod/say/mod_say_hu/mod_say_hu.c | 25 +- src/mod/say/mod_say_it/mod_say_it.c | 111 +- src/mod/say/mod_say_ru/mod_say_ru.c | 365 +- src/mod/say/mod_say_ru/mod_say_ru.h | 110 +- src/mod/say/mod_say_th/mod_say_th.c | 322 +- src/mod/say/mod_say_zh/mod_say_zh.c | 293 +- src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c | 74 +- src/mod/xml_int/mod_xml_curl/mod_xml_curl.c | 109 +- src/mod/xml_int/mod_xml_ldap/lutil_ldap.h | 43 +- src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c | 19 +- src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c | 343 +- src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c | 64 +- src/switch.c | 116 +- src/switch_apr.c | 185 +- src/switch_buffer.c | 2 +- src/switch_caller.c | 48 +- src/switch_channel.c | 262 +- src/switch_config.c | 2 +- src/switch_console.c | 465 +-- src/switch_core.c | 133 +- src/switch_core_asr.c | 8 +- src/switch_core_codec.c | 112 +- src/switch_core_db.c | 15 +- src/switch_core_directory.c | 2 +- src/switch_core_event_hook.c | 2 +- src/switch_core_file.c | 90 +- src/switch_core_hash.c | 4 +- src/switch_core_io.c | 171 +- src/switch_core_media_bug.c | 45 +- src/switch_core_memory.c | 41 +- src/switch_core_port_allocator.c | 11 +- src/switch_core_rwlock.c | 2 +- src/switch_core_session.c | 462 ++- src/switch_core_speech.c | 31 +- src/switch_core_sqldb.c | 389 +- src/switch_core_state_machine.c | 83 +- src/switch_core_timer.c | 2 +- src/switch_cpp.cpp | 2 +- src/switch_dso.c | 36 +- src/switch_event.c | 73 +- src/switch_ivr.c | 239 +- src/switch_ivr_async.c | 294 +- src/switch_ivr_bridge.c | 206 +- src/switch_ivr_menu.c | 110 +- src/switch_ivr_originate.c | 550 ++- src/switch_ivr_play_say.c | 206 +- src/switch_loadable_module.c | 114 +- src/switch_log.c | 74 +- src/switch_mprintf.c | 1314 ++++--- src/switch_nat.c | 171 +- src/switch_odbc.c | 52 +- src/switch_pcm.c | 493 ++- src/switch_regex.c | 17 +- src/switch_resample.c | 26 +- src/switch_rtp.c | 368 +- src/switch_scheduler.c | 4 +- src/switch_stun.c | 18 +- src/switch_swig.c | 2 +- src/switch_time.c | 585 ++- src/switch_utils.c | 558 ++- src/switch_xml.c | 776 ++-- src/switch_xml_config.c | 498 +-- 229 files changed, 20252 insertions(+), 20192 deletions(-) diff --git a/build/indent_options.sh b/build/indent_options.sh index 521377d3a4..9c6d739bd5 100755 --- a/build/indent_options.sh +++ b/build/indent_options.sh @@ -1,5 +1,5 @@ #!/bin/sh echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro -grep typedef `find ./src/include/ -name \*.h` | grep apr_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro -grep typedef `find ./src/include/ -name \*.h` | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro +grep "typedef struct.*_t;" `find ./src/include/ -name \*.h` | grep apr_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro +grep "typedef struct.*_t;" `find ./src/include/ -name \*.h` | grep switch_ | grep -v "\*\|{" | sed -e s/struct// | perl -ne '@l = split; $l[2] =~ s/;//g ; print "-T $l[2] "' >> ./.indent.pro grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro diff --git a/src/g711.c b/src/g711.c index 8a5c58b835..925e424af9 100644 --- a/src/g711.c +++ b/src/g711.c @@ -35,58 +35,58 @@ #include "g711.h" /* Copied from the CCITT G.711 specification */ -static const uint8_t ulaw_to_alaw_table[256] = -{ - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 26, - 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106, - 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 120, - 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 75, 73, 79, 77, - 66, 67, 64, 65, 70, 71, 68, 69, 90, 91, 88, 89, 94, 95, 92, 93, - 82, 82, 83, 83, 80, 80, 81, 81, 86, 86, 87, 87, 84, 84, 85, 85, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154, - 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234, - 232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248, - 254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205, - 194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, - 210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213 +static const uint8_t ulaw_to_alaw_table[256] = { + 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, + 58, 59, 56, 57, 62, 63, 60, 61, 50, 51, 48, 49, 54, 55, 52, 53, + 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 26, + 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, 106, + 104, 105, 110, 111, 108, 109, 98, 99, 96, 97, 102, 103, 100, 101, 122, 120, + 126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117, 75, 73, 79, 77, + 66, 67, 64, 65, 70, 71, 68, 69, 90, 91, 88, 89, 94, 95, 92, 93, + 82, 82, 83, 83, 80, 80, 81, 81, 86, 86, 87, 87, 84, 84, 85, 85, + 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, + 186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181, + 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154, + 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234, + 232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248, + 254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205, + 194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221, + 210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213 }; /* These transcoding tables are copied from the CCITT G.711 specification. To achieve optimal results, do not change them. */ -static const uint8_t alaw_to_ulaw_table[256] = -{ - 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, - 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 47, 48, 53, 54, 51, 52, - 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5, - 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, - 98, 99, 96, 97, 102, 103, 100, 101, 93, 93, 92, 92, 95, 95, 94, 94, - 116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109, - 72, 73, 70, 71, 76, 77, 74, 75, 64, 65, 63, 63, 68, 69, 66, 67, - 86, 87, 84, 85, 90, 91, 88, 89, 79, 79, 78, 78, 82, 83, 80, 81, - 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, - 185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180, - 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133, - 154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, - 226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222, - 244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237, - 200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195, - 214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209 +static const uint8_t alaw_to_ulaw_table[256] = { + 42, 43, 40, 41, 46, 47, 44, 45, 34, 35, 32, 33, 38, 39, 36, 37, + 57, 58, 55, 56, 61, 62, 59, 60, 49, 50, 47, 48, 53, 54, 51, 52, + 10, 11, 8, 9, 14, 15, 12, 13, 2, 3, 0, 1, 6, 7, 4, 5, + 26, 27, 24, 25, 30, 31, 28, 29, 18, 19, 16, 17, 22, 23, 20, 21, + 98, 99, 96, 97, 102, 103, 100, 101, 93, 93, 92, 92, 95, 95, 94, 94, + 116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109, + 72, 73, 70, 71, 76, 77, 74, 75, 64, 65, 63, 63, 68, 69, 66, 67, + 86, 87, 84, 85, 90, 91, 88, 89, 79, 79, 78, 78, 82, 83, 80, 81, + 170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165, + 185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180, + 138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133, + 154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, + 226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222, + 244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237, + 200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195, + 214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209 }; uint8_t alaw_to_ulaw(uint8_t alaw) { - return alaw_to_ulaw_table[alaw]; + return alaw_to_ulaw_table[alaw]; } + /*- End of function --------------------------------------------------------*/ uint8_t ulaw_to_alaw(uint8_t ulaw) { - return ulaw_to_alaw_table[ulaw]; + return ulaw_to_alaw_table[ulaw]; } + /*- End of function --------------------------------------------------------*/ /*- End of file ------------------------------------------------------------*/ diff --git a/src/include/SimpleGlob.h b/src/include/SimpleGlob.h index d395d411b9..ddb334e6c3 100644 --- a/src/include/SimpleGlob.h +++ b/src/include/SimpleGlob.h @@ -302,13 +302,17 @@ template < class SOCHAR > struct SimpleGlobBase { const char *GetFileNameS(char) const { return m_oFindDataA.cFileName; - } const wchar_t *GetFileNameS(wchar_t) const { + } + const wchar_t *GetFileNameS(wchar_t) const { return m_oFindDataW.cFileName; - } bool IsDirS(char) const { + } + bool IsDirS(char) const { return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR; - } bool IsDirS(wchar_t) const { + } + bool IsDirS(wchar_t) const { return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR; - } SG_FileType GetFileTypeS(const char *a_pszPath) { + } + SG_FileType GetFileTypeS(const char *a_pszPath) { return GetFileTypeS(GetFileAttributesA(a_pszPath)); } SG_FileType GetFileTypeS(const wchar_t *a_pszPath) { @@ -390,10 +394,12 @@ template < class SOCHAR > struct SimpleGlobBase { const char *GetFileNameS(char) const { SG_ASSERT(m_uiCurr != (size_t) -1); return m_glob.gl_pathv[m_uiCurr]; - } bool IsDirS(char) const { + } + bool IsDirS(char) const { SG_ASSERT(m_uiCurr != (size_t) -1); return m_bIsDir; - } SG_FileType GetFileTypeS(const char *a_pszPath) const { + } + SG_FileType GetFileTypeS(const char *a_pszPath) const { struct stat sb; if (0 != stat(a_pszPath, &sb)) { return SG_FILETYPE_INVALID; @@ -777,7 +783,7 @@ template < class SOCHAR > int CSimpleGlobTempl < SOCHAR >::fileSortCompare(const // --------------------------------------------------------------------------- typedef CSimpleGlobTempl < char >CSimpleGlobA; /*!< @brief ASCII/MBCS version of CSimpleGlob */ -typedef CSimpleGlobTempl < wchar_t >CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */ +typedef CSimpleGlobTempl < wchar_t > CSimpleGlobW; /*!< @brief wchar_t version of CSimpleGlob */ #if defined(_UNICODE) # define CSimpleGlob CSimpleGlobW /*!< @brief TCHAR version dependent on if _UNICODE is defined */ #else diff --git a/src/include/private/switch_core_pvt.h b/src/include/private/switch_core_pvt.h index 2df7e24a03..5e292d98f3 100644 --- a/src/include/private/switch_core_pvt.h +++ b/src/include/private/switch_core_pvt.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -115,7 +115,7 @@ struct switch_core_session { switch_codec_implementation_t write_impl; switch_codec_implementation_t video_read_impl; switch_codec_implementation_t video_write_impl; - + switch_audio_resampler_t *read_resampler; switch_audio_resampler_t *write_resampler; @@ -130,7 +130,7 @@ struct switch_core_session { void *streams[SWITCH_MAX_STREAMS]; int stream_count; - char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1]; + char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; void *private_info; switch_queue_t *event_queue; switch_queue_t *message_queue; diff --git a/src/include/switch.h b/src/include/switch.h index c87155cb12..7e93646e29 100644 --- a/src/include/switch.h +++ b/src/include/switch.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_apr.h b/src/include/switch_apr.h index e39f9cb15a..b1245ddf41 100644 --- a/src/include/switch_apr.h +++ b/src/include/switch_apr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -40,12 +40,11 @@ #define SWITCH_APR_H SWITCH_BEGIN_EXTERN_C - #ifdef WIN32 -typedef DWORD switch_thread_id_t; +typedef DWORD switch_thread_id_t; #else #include -typedef pthread_t switch_thread_id_t; +typedef pthread_t switch_thread_id_t; #endif SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void); @@ -108,7 +107,7 @@ SWITCH_DECLARE(void) switch_pool_clear(switch_memory_pool_t *p); * @bug We aught to provide an alternative to RTLD_GLOBAL, which * is the only supported method of loading DSOs today. */ -SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, const char *path, switch_memory_pool_t *ctx); +SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx); /** * Close a DSO library. @@ -378,7 +377,7 @@ SWITCH_DECLARE(void) switch_micro_sleep(switch_interval_time_t t); * it will behave as either a nested or an unnested lock. * */ -SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool); /** @@ -420,7 +419,7 @@ SWITCH_DECLARE(switch_status_t) switch_mutex_trylock(switch_mutex_t *lock); /** Opaque structure used for the rwlock */ typedef struct apr_thread_rwlock_t switch_thread_rwlock_t; -SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock); SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock); SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock); @@ -454,7 +453,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_unlock(switch_thread_rwlock * will be stored. * @param pool the pool from which to allocate the mutex. */ -SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool); /** * Put the active calling thread to sleep until signaled to wake up. Each @@ -580,7 +579,7 @@ SWITCH_DECLARE(switch_status_t) switch_md5_string(char digest_str[SWITCH_MD5_DIG * @param queue_capacity maximum size of the queue * @param pool a pool to allocate queue from */ -SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, unsigned int queue_capacity, switch_memory_pool_t *pool); /** * pop/get an object from the queue, blocking if the queue is already empty @@ -774,17 +773,14 @@ SWITCH_DECLARE(switch_status_t) switch_queue_trypush(switch_queue_t *queue, void * @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created, * appropriate default permissions will be used. */ -SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm, +SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t ** newf, const char *fname, int32_t flag, switch_fileperms_t perm, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset); -SWITCH_DECLARE(switch_status_t) switch_file_copy(const char *from_path, - const char *to_path, - switch_fileperms_t perms, - switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_file_copy(const char *from_path, const char *to_path, switch_fileperms_t perms, switch_memory_pool_t *pool); /** * Close the specified file. @@ -844,7 +840,7 @@ SWITCH_DECLARE(switch_status_t) switch_file_read(switch_file_t *thefile, void *b SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes); SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...); -SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t ** thefile, char *templ, int32_t flags, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile); @@ -885,7 +881,7 @@ SWITCH_DECLARE(switch_status_t) switch_dir_make_recursive(const char *path, swit }; typedef struct switch_array_header_t switch_array_header_t; -SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t ** new_dir, const char *dirname, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir); SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len); @@ -920,7 +916,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_priority_increase(switch_threa * @param new_attr The newly created threadattr. * @param pool The pool to use */ -SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool); /** * Set if newly created threads should be created in detached state. @@ -937,7 +933,7 @@ SWITCH_DECLARE(switch_status_t) switch_threadattr_detach_set(switch_threadattr_t * @param data Any data to be passed to the starting function * @param cont The pool to use */ -SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr, +SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t *attr, switch_thread_start_t func, void *data, switch_memory_pool_t *cont); /** @} */ @@ -1006,7 +1002,7 @@ SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_threa * @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP). * @param pool The pool to use */ -SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool); /** * Shutdown either reading, writing, or both sides of a socket. @@ -1055,7 +1051,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_listen(switch_socket_t *sock, int3 * @param sock The socket we are listening on. * @param pool The pool for the new socket. */ -SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock, switch_socket_t *sock, switch_memory_pool_t *pool); /** * Issue a connection request to a socket either on the same machine @@ -1095,7 +1091,7 @@ SWITCH_DECLARE(int) switch_sockaddr_equal(const switch_sockaddr_t *sa1, const sw * * @param pool The pool for the apr_sockaddr_t and associated storage. */ -SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, +SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname, int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool); /** @@ -1124,7 +1120,8 @@ SWITCH_DECLARE(switch_status_t) switch_socket_send(switch_socket_t *sock, const * @param buf The data to send * @param len The length of the data to send */ -SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, switch_size_t *len); +SWITCH_DECLARE(switch_status_t) switch_socket_sendto(switch_socket_t *sock, switch_sockaddr_t *where, int32_t flags, const char *buf, + switch_size_t *len); /** * @param from The apr_sockaddr_t to fill in the recipient info @@ -1219,26 +1216,27 @@ SWITCH_DECLARE(switch_status_t) switch_mcast_hops(switch_socket_t *sock, uint8_t /** @} */ -typedef enum { - SWITCH_NO_DESC, /**< nothing here */ - SWITCH_POLL_SOCKET, /**< descriptor refers to a socket */ - SWITCH_POLL_FILE, /**< descriptor refers to a file */ - SWITCH_POLL_LASTDESC /**< descriptor is the last one in the list */ -} switch_pollset_type_t; + typedef enum { + SWITCH_NO_DESC, /**< nothing here */ + SWITCH_POLL_SOCKET, /**< descriptor refers to a socket */ + SWITCH_POLL_FILE, /**< descriptor refers to a file */ + SWITCH_POLL_LASTDESC /**< descriptor is the last one in the list */ + } switch_pollset_type_t; -typedef union { - switch_file_t *f; /**< file */ - switch_socket_t *s; /**< socket */ -} switch_descriptor_t; + typedef union { + switch_file_t *f; /**< file */ + switch_socket_t *s; /**< socket */ + } switch_descriptor_t; -struct switch_pollfd { - switch_memory_pool_t *p; /**< associated pool */ - switch_pollset_type_t desc_type; /**< descriptor type */ - int16_t reqevents; /**< requested events */ - int16_t rtnevents; /**< returned events */ - switch_descriptor_t desc; /**< @see apr_descriptor */ - void *client_data; /**< allows app to associate context */ -}; + struct switch_pollfd { + switch_memory_pool_t *p; /**< associated pool */ + switch_pollset_type_t desc_type; + /**< descriptor type */ + int16_t reqevents; /**< requested events */ + int16_t rtnevents; /**< returned events */ + switch_descriptor_t desc; /**< @see apr_descriptor */ + void *client_data; /**< allows app to associate context */ + }; @@ -1277,7 +1275,7 @@ struct switch_pollfd { * platforms; the apr_pollset_create() call will fail with * APR_ENOTIMPL on platforms where it is not supported. */ -SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags); +SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t ** pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags); /** * Add a socket or file descriptor to a pollset @@ -1321,10 +1319,10 @@ SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t num \param pool the memory pool to use \return SWITCH_STATUS_SUCCESS when successful */ -SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t **poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_socket_create_pollfd(switch_pollfd_t ** poll, switch_socket_t *sock, int16_t flags, switch_memory_pool_t *pool); -SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p); -SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock); +SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t ** result, switch_memory_pool_t *p); +SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock); /** * Create an anonymous pipe. @@ -1332,7 +1330,7 @@ SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, s * @param out The file descriptor to use as output from the pipe. * @param pool The pool to operate on. */ -SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t **in, switch_file_t **out, switch_memory_pool_t *p); +SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t ** in, switch_file_t ** out, switch_memory_pool_t *p); /** * Get the timeout value for a pipe or manipulate the blocking state. diff --git a/src/include/switch_bitpack.h b/src/include/switch_bitpack.h index c7445091a3..f534ea6bcf 100644 --- a/src/include/switch_bitpack.h +++ b/src/include/switch_bitpack.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_buffer.h b/src/include/switch_buffer.h index f31663989a..322b7415a7 100644 --- a/src/include/switch_buffer.h +++ b/src/include/switch_buffer.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_caller.h b/src/include/switch_caller.h index 7c363f9cac..35a1119d7b 100644 --- a/src/include/switch_caller.h +++ b/src/include/switch_caller.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -147,7 +147,7 @@ struct switch_caller_extension { SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session, _In_z_ const char *extension_name, _In_z_ const char *extension_number); -SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, +SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig, switch_memory_pool_t *pool); /*! @@ -169,8 +169,8 @@ SWITCH_DECLARE(void) switch_caller_extension_add_application(_In_ switch_core_se \param fmt optional argument to the application (printf format string) */ SWITCH_DECLARE(void) switch_caller_extension_add_application_printf(_In_ switch_core_session_t *session, - _In_ switch_caller_extension_t *caller_extension, - _In_z_ const char *application_name, _In_z_ const char *fmt, ...); + _In_ switch_caller_extension_t *caller_extension, + _In_z_ const char *application_name, _In_z_ const char *fmt, ...); /*! diff --git a/src/include/switch_channel.h b/src/include/switch_channel.h index 7e86f71599..5ef0778b70 100644 --- a/src/include/switch_channel.h +++ b/src/include/switch_channel.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -48,6 +48,7 @@ SWITCH_BEGIN_EXTERN_C struct switch_channel_timetable { switch_time_t progress_media; switch_time_t hungup; switch_time_t transferred; + switch_time_t resurrected; struct switch_channel_timetable *next; }; @@ -74,21 +75,20 @@ SWITCH_DECLARE(switch_channel_state_t) switch_channel_get_running_state(switch_c \param channel channel to test \return true if the channel is ready */ -SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t media); +SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media); + +#define switch_channel_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_FALSE) +#define switch_channel_media_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE, SWITCH_TRUE) -#define switch_channel_ready(_channel) switch_channel_test_ready(_channel, SWITCH_FALSE) -#define switch_channel_media_ready(_channel) switch_channel_test_ready(_channel, SWITCH_TRUE) #define switch_channel_up(_channel) (switch_channel_get_state(_channel) < CS_HANGUP) #define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP) #define switch_channel_media_ack(_channel) (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK)) SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state); SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout); -SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, - switch_channel_flag_t want_flag, - switch_bool_t pres, - uint32_t to, - switch_channel_t *super_channel); +SWITCH_DECLARE(switch_status_t) switch_channel_wait_for_flag(switch_channel_t *channel, + switch_channel_flag_t want_flag, + switch_bool_t pres, uint32_t to, switch_channel_t *super_channel); SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel, const char *file, const char *func, int line, switch_channel_state_t state); @@ -142,7 +142,8 @@ SWITCH_DECLARE(switch_channel_timetable_t *) switch_channel_get_timetable(_In_ s \param pool memory_pool to use for allocation \return SWITCH_STATUS_SUCCESS if successful */ -SWITCH_DECLARE(switch_status_t) switch_channel_alloc(_In_ switch_channel_t **channel, _In_ switch_call_direction_t direction, _In_ switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_channel_alloc(_In_ switch_channel_t **channel, _In_ switch_call_direction_t direction, + _In_ switch_memory_pool_t *pool); /*! \brief Connect a newly allocated channel to a session object and setup it's initial state @@ -231,12 +232,12 @@ SWITCH_DECLARE(char *) switch_channel_get_uuid(switch_channel_t *channel); SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val); -SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, +SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check); SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...); SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_name_printf(switch_channel_t *channel, const char *val, const char *fmt, ...); -SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel, +SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel, const char *varname, const char *value, switch_bool_t var_check); SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname); @@ -250,7 +251,9 @@ SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_ \param varname the name of the variable \return the value of the requested variable */ -SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname); +SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup); +#define switch_channel_get_variable(_c, _v) switch_channel_get_variable_dup(_c, _v, SWITCH_TRUE) + SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event); SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel); @@ -300,10 +303,14 @@ SWITCH_DECLARE(uint32_t) switch_channel_test_flag(switch_channel_t *channel, swi \param channel channel on which to set flag \param flag or'd list of flags to set */ -SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flag); +SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value); +#define switch_channel_set_flag(_c, _f) switch_channel_set_flag_value(_c, _f, 1) + SWITCH_DECLARE(void) switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag); -SWITCH_DECLARE(void) switch_channel_set_cap(switch_channel_t *channel, switch_channel_cap_t cap); +SWITCH_DECLARE(void) switch_channel_set_cap_value(switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value); +#define switch_channel_set_cap(_c, _cc) switch_channel_set_cap_value(_c, _cc, 1) + SWITCH_DECLARE(void) switch_channel_clear_cap(switch_channel_t *channel, switch_channel_cap_t cap); SWITCH_DECLARE(uint32_t) switch_channel_test_cap(switch_channel_t *channel, switch_channel_cap_t cap); @@ -338,6 +345,7 @@ SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, sw \param flag flag to clear */ SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag); + SWITCH_DECLARE(void) switch_channel_clear_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag); SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line); @@ -539,7 +547,9 @@ SWITCH_DECLARE(void) switch_channel_clear_app_flag(switch_channel_t *channel, ui SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags); SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel); SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel); -SWITCH_DECLARE(switch_core_session_t*) switch_channel_get_session(switch_channel_t *channel); +SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel); +SWITCH_DECLARE(char *) switch_channel_get_flag_string(switch_channel_t *channel); +SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel); /** @} */ diff --git a/src/include/switch_config.h b/src/include/switch_config.h index d654f9c879..2281a9bbc1 100644 --- a/src/include/switch_config.h +++ b/src/include/switch_config.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_console.h b/src/include/switch_console.h index 06641558e6..31d5ebf8e4 100644 --- a/src/include/switch_console.h +++ b/src/include/switch_console.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -81,12 +81,12 @@ SWITCH_DECLARE(switch_status_t) switch_console_init(switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_console_shutdown(void); SWITCH_DECLARE(switch_status_t) switch_console_add_complete_func(const char *name, switch_console_complete_callback_t cb); SWITCH_DECLARE(switch_status_t) switch_console_del_complete_func(const char *name); -SWITCH_DECLARE(switch_status_t) switch_console_run_complete_func(const char *func, const char *line, +SWITCH_DECLARE(switch_status_t) switch_console_run_complete_func(const char *func, const char *line, const char *last_word, switch_console_callback_match_t **matches); SWITCH_DECLARE(void) switch_console_push_match(switch_console_callback_match_t **matches, const char *new_val); SWITCH_DECLARE(void) switch_console_free_matches(switch_console_callback_match_t **matches); -SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const char *last_word, - FILE *console_out, switch_stream_handle_t *stream, switch_xml_t xml); +SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const char *last_word, + FILE * console_out, switch_stream_handle_t *stream, switch_xml_t xml); SWITCH_DECLARE(void) switch_console_sort_matches(switch_console_callback_match_t *matches); SWITCH_DECLARE(void) switch_console_save_history(void); SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg); diff --git a/src/include/switch_core.h b/src/include/switch_core.h index 8493fe675b..20a465a49d 100644 --- a/src/include/switch_core.h +++ b/src/include/switch_core.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -369,7 +369,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock(_In_ switch_core_s #ifdef SWITCH_DEBUG_RWLOCKS -SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(_In_ switch_core_session_t *session, const char *file, const char *func, int line); +SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(_In_ switch_core_session_t *session, const char *file, const char *func, + int line); #endif /*! @@ -595,6 +596,9 @@ SWITCH_DECLARE(char *) switch_core_vsprintf(switch_memory_pool_t *pool, _In_z_ _ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(_In_ switch_core_session_t *session); ///\} +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_xml(switch_endpoint_interface_t *endpoint_interface, + switch_memory_pool_t **pool, switch_xml_t xml); + ///\defgroup sessm Session Creation / Management ///\ingroup core1 ///\{ @@ -604,7 +608,7 @@ SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(_In_ switch_ \param pool the pool to use for the allocation (a new one will be used if NULL) \return the newly created session */ -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface, +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface, _In_ switch_call_direction_t direction, _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid); #define switch_core_session_request(_ep, _d, _p) switch_core_session_request_uuid(_ep, _d, _p, NULL) @@ -645,9 +649,8 @@ SWITCH_DECLARE(switch_size_t) switch_core_session_id(void); \param pool the pool to use \return the newly created session */ -SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name, - _In_ switch_call_direction_t direction, - _Inout_ switch_memory_pool_t **pool); +SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(_In_z_ const char *endpoint_name, + _In_ switch_call_direction_t direction, _Inout_ switch_memory_pool_t **pool); /*! \brief Launch the session thread (state machine) on a given session @@ -963,7 +966,8 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_outgoing_channel(_In_opt _In_z_ const char *endpoint_name, _In_ switch_caller_profile_t *caller_profile, _Inout_ switch_core_session_t **new_session, - _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); + _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name, _Inout_ switch_core_session_t **new_session, @@ -975,7 +979,7 @@ SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ \param message the message to recieve \return the status returned by the message handler */ -SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, +SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(_In_ switch_core_session_t *session, _In_ switch_core_session_message_t *message, const char *file, const char *func, int line); #define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \ @@ -1013,7 +1017,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_dequeue_event(_In_ switch_co \param priority event has high priority \return the status returned by the message handler */ -SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event, switch_bool_t priority); +SWITCH_DECLARE(switch_status_t) switch_core_session_queue_private_event(_In_ switch_core_session_t *session, _Inout_ switch_event_t **event, + switch_bool_t priority); /*! @@ -1381,10 +1386,10 @@ SWITCH_DECLARE(void) switch_core_session_lock_codec_read(_In_ switch_core_sessio SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session); -SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); -SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); -SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); -SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); +SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp); /*! @@ -1636,8 +1641,7 @@ SWITCH_DECLARE(void) switch_core_speech_float_param_tts(switch_speech_handle_t * \param flags flags in/out for fine tuning \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful */ -SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, - void *data, switch_size_t *datalen, switch_speech_flag_t *flags); +SWITCH_DECLARE(switch_status_t) switch_core_speech_read_tts(switch_speech_handle_t *sh, void *data, switch_size_t *datalen, switch_speech_flag_t *flags); /*! \brief Close an open speech handle \param sh the speech handle to close @@ -1907,7 +1911,7 @@ SWITCH_DECLARE(FILE *) switch_core_get_console(void); /*! \brief Launch a thread */ -SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC *func) (switch_thread_t *, void *), +SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC * func) (switch_thread_t *, void *), void *obj, switch_memory_pool_t *pool); #endif @@ -1970,7 +1974,7 @@ SWITCH_DECLARE(switch_status_t) switch_console_set_alias(const char *string); SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait); SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t); SWITCH_DECLARE(void) switch_cond_next(void); -SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to, +SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint); SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds); @@ -1982,51 +1986,51 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_sessio */ #define CACHE_DB_LEN 256 -typedef enum { - CDF_INUSE = (1 << 0) -} cache_db_flag_t; + typedef enum { + CDF_INUSE = (1 << 0) + } cache_db_flag_t; -typedef enum { - SCDB_TYPE_CORE_DB, - SCDB_TYPE_ODBC -} switch_cache_db_handle_type_t; + typedef enum { + SCDB_TYPE_CORE_DB, + SCDB_TYPE_ODBC + } switch_cache_db_handle_type_t; -typedef union { - switch_core_db_t *core_db_dbh; - switch_odbc_handle_t *odbc_dbh; -} switch_cache_db_native_handle_t; + typedef union { + switch_core_db_t *core_db_dbh; + switch_odbc_handle_t *odbc_dbh; + } switch_cache_db_native_handle_t; -typedef struct { - char *db_path; -} switch_cache_db_core_db_options_t; + typedef struct { + char *db_path; + } switch_cache_db_core_db_options_t; -typedef struct { - char *dsn; - char *user; - char *pass; -} switch_cache_db_odbc_options_t; + typedef struct { + char *dsn; + char *user; + char *pass; + } switch_cache_db_odbc_options_t; -typedef union { - switch_cache_db_core_db_options_t core_db_options; - switch_cache_db_odbc_options_t odbc_options; -} switch_cache_db_connection_options_t; + typedef union { + switch_cache_db_core_db_options_t core_db_options; + switch_cache_db_odbc_options_t odbc_options; + } switch_cache_db_connection_options_t; -typedef struct { - char name[CACHE_DB_LEN]; - switch_cache_db_handle_type_t type; - switch_cache_db_native_handle_t native_handle; - time_t last_used; - switch_mutex_t *mutex; - switch_mutex_t *io_mutex; - switch_memory_pool_t *pool; - int32_t flags; - unsigned long hash; - char creator[CACHE_DB_LEN]; - char last_user[CACHE_DB_LEN]; -} switch_cache_db_handle_t; + typedef struct { + char name[CACHE_DB_LEN]; + switch_cache_db_handle_type_t type; + switch_cache_db_native_handle_t native_handle; + time_t last_used; + switch_mutex_t *mutex; + switch_mutex_t *io_mutex; + switch_memory_pool_t *pool; + int32_t flags; + unsigned long hash; + char creator[CACHE_DB_LEN]; + char last_user[CACHE_DB_LEN]; + } switch_cache_db_handle_t; -static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type) + static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type) { const char *type_str = "INVALID"; @@ -2046,9 +2050,9 @@ static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_ return type_str; } -SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh); -SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t **dbh); -SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_handle_t **dbh, +SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t ** dbh); +SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t ** dbh); +SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_handle_t ** dbh, switch_cache_db_handle_type_t type, switch_cache_db_connection_options_t *connection_options, const char *file, const char *func, int line); @@ -2056,14 +2060,14 @@ SWITCH_DECLARE(switch_status_t) _switch_cache_db_get_db_handle(switch_cache_db_h SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err); SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err); -SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql, +SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err); SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream); -SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line); +SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line); #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__) -SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, +SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db, const char *test_sql, const char *drop_sql, const char *reactive_sql); SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries); SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries); diff --git a/src/include/switch_core_db.h b/src/include/switch_core_db.h index 86403a556d..6be6e8eeda 100644 --- a/src/include/switch_core_db.h +++ b/src/include/switch_core_db.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_core_event_hook.h b/src/include/switch_core_event_hook.h index 6a590cae68..b60246cf24 100644 --- a/src/include/switch_core_event_hook.h +++ b/src/include/switch_core_event_hook.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -47,7 +47,7 @@ typedef struct switch_io_event_hook_recv_dtmf switch_io_event_hook_recv_dtmf_t; typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t; typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t; typedef switch_status_t (*switch_outgoing_channel_hook_t) - (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t); + (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t); typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *); typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *); typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int); diff --git a/src/include/switch_dso.h b/src/include/switch_dso.h index 83498ff87b..052cd5b5d3 100644 --- a/src/include/switch_dso.h +++ b/src/include/switch_dso.h @@ -25,10 +25,10 @@ typedef int (*switch_dso_func_t) (void); #ifdef WIN32 typedef HINSTANCE switch_dso_lib_t; #else -typedef void * switch_dso_lib_t; +typedef void *switch_dso_lib_t; #endif -typedef void * switch_dso_data_t; +typedef void *switch_dso_data_t; SWITCH_DECLARE(void) switch_dso_destroy(switch_dso_lib_t *lib); SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(const char *path, int global, char **err); @@ -48,4 +48,3 @@ SWITCH_DECLARE(void *) switch_dso_data_sym(switch_dso_lib_t lib, const char *sym * For VIM: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 */ - diff --git a/src/include/switch_event.h b/src/include/switch_event.h index eb3bbde785..a935c86a35 100644 --- a/src/include/switch_event.h +++ b/src/include/switch_event.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -237,7 +237,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_t \param node bind handle to later remove the binding. \return SWITCH_STATUS_SUCCESS if the event was binded */ -SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name, +SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name, switch_event_callback_t callback, void *user_data, switch_event_node_t **node); /*! \brief Unbind a bound event consumer @@ -342,15 +342,16 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_pres_in_detailed(_In_z_ char */ #define switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY) -static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id) + static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id) { switch_status_t status = switch_event_create(event, SWITCH_EVENT_CLONE); if (status == SWITCH_STATUS_SUCCESS) { (*event)->event_id = event_id; } - + return status; } + /*! \brief Deliver an event to all of the registered event listeners \param event the event to send (will be nulled) diff --git a/src/include/switch_frame.h b/src/include/switch_frame.h index b00b54aa91..20103a16cb 100644 --- a/src/include/switch_frame.h +++ b/src/include/switch_frame.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -46,7 +46,7 @@ SWITCH_BEGIN_EXTERN_C /*! the originating source of the frame */ const char *source; /*! the raw packet */ - void *packet; + void *packet; /*! the size of the raw packet when applicable */ uint32_t packetlen; /*! the extra frame data */ diff --git a/src/include/switch_ivr.h b/src/include/switch_ivr.h index 506a118934..f4a00addb2 100644 --- a/src/include/switch_ivr.h +++ b/src/include/switch_ivr.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -123,7 +123,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, \param timeout a timeout in milliseconds \return SWITCH_STATUS_SUCCESS to keep the collection moving. */ -SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, uint32_t abs_timeout); +SWITCH_DECLARE(switch_status_t) switch_ivr_collect_digits_callback(switch_core_session_t *session, switch_input_args_t *args, uint32_t digit_timeout, + uint32_t abs_timeout); /*! \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up. @@ -304,7 +305,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_stop_tone_detect_session(switch_core_ */ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, const char *key, const char *tone_spec, - const char *flags, time_t timeout, int hits, + const char *flags, time_t timeout, int hits, const char *app, const char *data, switch_tone_detect_callback_t callback); @@ -321,7 +322,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_sessi SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file, switch_input_args_t *args); -SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits, +SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits, uint32_t listen_hits, uint32_t timeout_ms, const char *file); SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, const char *script, int32_t loops, switch_input_args_t *args); @@ -408,11 +409,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, - switch_caller_profile_t *caller_profile_override, - switch_event_t *ovars, - switch_originate_flag_t flags, - switch_call_cause_t *cancel_cause - ); + switch_caller_profile_t *caller_profile_override, + switch_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_session_t *session, switch_core_session_t **bleg, @@ -422,10 +420,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_sess const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, - switch_caller_profile_t *caller_profile_override, - switch_event_t *ovars, - switch_originate_flag_t flags - ); + switch_caller_profile_t *caller_profile_override, + switch_event_t *ovars, switch_originate_flag_t flags); SWITCH_DECLARE(void) switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session); @@ -571,17 +567,17 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_transfer_variable(switch_core_session /******************************************************************************************************/ -struct switch_ivr_digit_stream_parser; -typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; -struct switch_ivr_digit_stream; -typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; + struct switch_ivr_digit_stream_parser; + typedef struct switch_ivr_digit_stream_parser switch_ivr_digit_stream_parser_t; + struct switch_ivr_digit_stream; + typedef struct switch_ivr_digit_stream switch_ivr_digit_stream_t; /*! \brief Create a digit stream parser object \param pool the pool to use for the new hash \param parser a pointer to the object pointer \return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser); /*! \brief Destroy a digit stream parser object @@ -596,14 +592,14 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_destroy(switch_iv \param stream a pointer to the stream object pointer \return NULL if no match found or consumer data that was associated with a given digit string when matched */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t ** stream); /*! \brief Destroys a digit stream object \param stream a pointer to the stream object \return NULL if no match found or consumer data that was associated with a given digit string when matched */ -SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t **stream); +SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t ** stream); /*! \brief Set a digit string to action mapping @@ -660,25 +656,25 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_set_terminator(sw * @{ */ -typedef enum { - SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), - SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), - SWITCH_IVR_MENU_FLAG_STACK = (1 << 2) -} switch_ivr_menu_flags; + typedef enum { + SWITCH_IVR_MENU_FLAG_FALLTOMAIN = (1 << 0), + SWITCH_IVR_MENU_FLAG_FREEPOOL = (1 << 1), + SWITCH_IVR_MENU_FLAG_STACK = (1 << 2) + } switch_ivr_menu_flags; /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */ -typedef enum { - SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ - SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ - SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ - SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ - SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ - SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ - SWITCH_IVR_ACTION_NOOP /* No operation */ -} switch_ivr_action_t; -struct switch_ivr_menu; -typedef switch_ivr_action_t switch_ivr_menu_action_function_t (struct switch_ivr_menu *, char *, char *, size_t, void *); -typedef struct switch_ivr_menu switch_ivr_menu_t; -typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; + typedef enum { + SWITCH_IVR_ACTION_DIE, /* Exit the menu. */ + SWITCH_IVR_ACTION_EXECMENU, /* Goto another menu in the stack. */ + SWITCH_IVR_ACTION_EXECAPP, /* Execute an application. */ + SWITCH_IVR_ACTION_PLAYSOUND, /* Play a sound. */ + SWITCH_IVR_ACTION_BACK, /* Go back 1 menu. */ + SWITCH_IVR_ACTION_TOMAIN, /* Go back to the top level menu. */ + SWITCH_IVR_ACTION_NOOP /* No operation */ + } switch_ivr_action_t; + struct switch_ivr_menu; + typedef switch_ivr_action_t switch_ivr_menu_action_function_t(struct switch_ivr_menu *, char *, char *, size_t, void *); + typedef struct switch_ivr_menu switch_ivr_menu_t; + typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; /******************************************************************************************************/ /*! @@ -703,7 +699,7 @@ typedef struct switch_ivr_menu_action switch_ivr_menu_action_t; *\return SWITCH_STATUS_SUCCESS if the menu was created. */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu, +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu, switch_ivr_menu_t *main, const char *name, const char *greeting_sound, @@ -715,7 +711,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men const char *tts_engine, const char *tts_voice, int confirm_attempts, - int inter_timeout, int digit_len, int timeout, int max_failures, + int inter_timeout, int digit_len, int timeout, int max_failures, int max_timeouts, switch_memory_pool_t *pool); /*! @@ -726,8 +722,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_men *\param bind KeyStrokes to bind the action to. *\return SWUTCH_STATUS_SUCCESS if the action was binded */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, - const char *bind); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_action(switch_ivr_menu_t *menu, switch_ivr_action_t ivr_action, const char *arg, const char *bind); /*! @@ -762,8 +757,8 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_execute(switch_core_session_t *s */ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack); -struct switch_ivr_menu_xml_ctx; -typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; + struct switch_ivr_menu_xml_ctx; + typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; /*! *\brief Build a menu stack from an xml source *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init @@ -773,7 +768,7 @@ typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t; *\return SWITCH_STATUS_SUCCESS if all is well */ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx, - switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu); + switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu); SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action); @@ -791,7 +786,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_ *\param pool memory pool (NULL to create one) *\return SWITCH_STATUS_SUCCESS if all is well */ -SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t **xml_menu_ctx, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_init(switch_ivr_menu_xml_ctx_t ** xml_menu_ctx, switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang, switch_input_args_t *args); @@ -806,8 +801,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_read(switch_core_session_t *session, uint32_t max_digits, const char *prompt_audio_file, const char *var_name, - char *digit_buffer, - switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators); + char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators); SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key, switch_bind_flag_t bind_flags, const char *app); diff --git a/src/include/switch_loadable_module.h b/src/include/switch_loadable_module.h index c1dac88909..7b9457ea2b 100644 --- a/src/include/switch_loadable_module.h +++ b/src/include/switch_loadable_module.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -268,7 +268,7 @@ SWITCH_DECLARE(switch_status_t) switch_loadable_module_unload_module(char *dir, \param filename the path to the module's dll or so file \return SWITCH_STATUS_SUCCESS on a successful load */ -SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface, char *filename); +SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t ** module_interface, char *filename); SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void); /*! @@ -325,14 +325,15 @@ SWITCH_DECLARE(uint32_t) switch_core_codec_next_id(void); break; \ } -static inline int switch_check_interval(uint32_t rate, uint32_t ptime) + static inline int switch_check_interval(uint32_t rate, uint32_t ptime) { uint32_t max_ms = 0, ptime_div = 0; switch (rate) { case 22050: case 11025: - if (ptime < 120) return 1; + if (ptime < 120) + return 1; break; case 48000: max_ms = 40; @@ -350,13 +351,13 @@ static inline int switch_check_interval(uint32_t rate, uint32_t ptime) case 8000: max_ms = 120; ptime_div = 2; - break; + break; } if (max_ms && ptime_div && (ptime <= max_ms && (ptime % ptime_div) == 0) && ((rate / 1000) * ptime) < SWITCH_RECOMMENDED_BUFFER_SIZE) { return 1; } - + return 0; } @@ -420,7 +421,7 @@ static inline void switch_core_codec_add_implementation(switch_memory_pool_t *po impl->impl_id = switch_core_codec_next_id(); codec_interface->implementations = impl; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u\n", + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u\n", iananame, actual_samples_per_second, microseconds_per_packet / 1000); } } diff --git a/src/include/switch_log.h b/src/include/switch_log.h index 58063b9836..98d9448bac 100644 --- a/src/include/switch_log.h +++ b/src/include/switch_log.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -114,9 +114,8 @@ SWITCH_DECLARE(void) switch_log_printf(_In_ switch_text_channel_t channel, _In_z \see switch_types.h */ SWITCH_DECLARE(void) switch_log_vprintf(_In_ switch_text_channel_t channel, _In_z_ const char *file, - _In_z_ const char *func, _In_ int line, - _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, - const char *fmt, va_list ap); + _In_z_ const char *func, _In_ int line, + _In_opt_z_ const char *userdata, _In_ switch_log_level_t level, const char *fmt, va_list ap); #endif /*! @@ -144,7 +143,7 @@ SWITCH_DECLARE(uint32_t) switch_log_str2mask(_In_z_ const char *str); #define switch_log_check_mask(_mask, _level) (_mask & (1 << _level)) -SWITCH_DECLARE(switch_log_node_t*) switch_log_node_dup(const switch_log_node_t *node); +SWITCH_DECLARE(switch_log_node_t *) switch_log_node_dup(const switch_log_node_t *node); SWITCH_DECLARE(void) switch_log_node_free(switch_log_node_t **pnode); ///\} diff --git a/src/include/switch_module_interfaces.h b/src/include/switch_module_interfaces.h index 7af9f000f2..642d1639f9 100644 --- a/src/include/switch_module_interfaces.h +++ b/src/include/switch_module_interfaces.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -45,7 +45,7 @@ SWITCH_BEGIN_EXTERN_C /*! \brief A table of functions to execute at various states */ -typedef enum { + typedef enum { SWITCH_SHN_ON_INIT, SWITCH_SHN_ON_ROUTING, SWITCH_SHN_ON_EXECUTE, @@ -106,7 +106,27 @@ struct switch_io_event_hooks; typedef switch_call_cause_t (*switch_io_outgoing_channel_t) -(switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t, switch_call_cause_t *); + + + + + + + + + + + + + + + + + + + + (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t **, switch_memory_pool_t **, switch_originate_flag_t, + switch_call_cause_t *); typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int); typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int); typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int); @@ -441,7 +461,7 @@ struct switch_speech_handle { switch_audio_resampler_t *resampler; switch_buffer_t *buffer; switch_byte_t *dbuf; - switch_size_t dbuflen; + switch_size_t dbuflen; /*! the current samplerate */ uint32_t samplerate; /*! the current native samplerate */ @@ -470,7 +490,7 @@ struct switch_chat_interface { /*! the name of the interface */ const char *interface_name; /*! function to open the directory interface */ - switch_status_t (*chat_send) (const char *proto, const char *from, const char *to, + switch_status_t (*chat_send) (const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint); switch_thread_rwlock_t *rwlock; int refs; @@ -680,8 +700,8 @@ struct switch_api_interface { struct switch_api_interface *next; }; -#define PROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_rdlock(_it->parent->rwlock); switch_thread_rwlock_rdlock(_it->rwlock); _it->refs++; _it->parent->refs++; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "+++++++++++LOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); -#define UNPROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_unlock(_it->rwlock); switch_thread_rwlock_unlock(_it->parent->rwlock); _it->refs--; _it->parent->refs--; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "---------UNLOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); +#define PROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_rdlock(_it->parent->rwlock); switch_thread_rwlock_rdlock(_it->rwlock); _it->refs++; _it->parent->refs++; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "+++++++++++LOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); +#define UNPROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_unlock(_it->rwlock); switch_thread_rwlock_unlock(_it->parent->rwlock); _it->refs--; _it->parent->refs--; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "---------UNLOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); SWITCH_END_EXTERN_C diff --git a/src/include/switch_mprintf.h b/src/include/switch_mprintf.h index c0bd4f0f1c..2dd91e0013 100644 --- a/src/include/switch_mprintf.h +++ b/src/include/switch_mprintf.h @@ -14,7 +14,6 @@ #define SWITCH_MPRINTF_H SWITCH_BEGIN_EXTERN_C - /** * This routine is a variant of the "sprintf()" from the * standard C library. The resulting string is written into memory diff --git a/src/include/switch_nat.h b/src/include/switch_nat.h index d4722d3bfb..87ba3190ff 100644 --- a/src/include/switch_nat.h +++ b/src/include/switch_nat.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -38,9 +38,7 @@ #ifndef _SWITCH_NAT_H #define _SWITCH_NAT_H -SWITCH_BEGIN_EXTERN_C - -typedef enum { +SWITCH_BEGIN_EXTERN_C typedef enum { SWITCH_NAT_TYPE_NONE, SWITCH_NAT_TYPE_PMP, SWITCH_NAT_TYPE_UPNP @@ -87,7 +85,8 @@ SWITCH_DECLARE(void) switch_nat_reinit(void); \param external_port [out] Mapped external port \param sticky make the mapping permanent */ -SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port, switch_bool_t sticky); +SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port, + switch_bool_t sticky); /*! \brief Has the NAT subsystem been initialized */ diff --git a/src/include/switch_odbc.h b/src/include/switch_odbc.h index 9e158b459b..81039f113d 100644 --- a/src/include/switch_odbc.h +++ b/src/include/switch_odbc.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -34,10 +34,8 @@ #include -SWITCH_BEGIN_EXTERN_C - -struct switch_odbc_handle; -typedef void * switch_odbc_statement_handle_t; +SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle; +typedef void *switch_odbc_statement_handle_t; typedef enum { SWITCH_ODBC_STATE_INIT, @@ -56,14 +54,11 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_disconnect(switch_odbc_h SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_handle_t *handle); SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep); SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle); -SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, char **err); -SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle, - const char *sql, - char *resbuf, - size_t len, - char **err); +SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, const char *sql, switch_odbc_statement_handle_t *rstmt, + char **err); +SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec_string(switch_odbc_handle_t *handle, const char *sql, char *resbuf, size_t len, char **err); SWITCH_DECLARE(switch_bool_t) switch_odbc_available(void); -SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t * stmt); +SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t *stmt); /*! \brief Execute the sql query and issue a callback for each row returned @@ -78,7 +73,8 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_od \note none */ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(const char *file, const char *func, int line, switch_odbc_handle_t *handle, - const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err); + const char *sql, switch_core_db_callback_func_t callback, void *pdata, + char **err); /*! \brief Execute the sql query and issue a callback for each row returned \param handle the ODBC handle @@ -92,7 +88,7 @@ SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(c switch_odbc_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \ handle, sql, callback, pdata, err) - + SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, switch_odbc_statement_handle_t stmt); SWITCH_END_EXTERN_C #endif diff --git a/src/include/switch_platform.h b/src/include/switch_platform.h index 84d61febfe..bde72d8b8e 100644 --- a/src/include/switch_platform.h +++ b/src/include/switch_platform.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -85,7 +85,7 @@ SWITCH_BEGIN_EXTERN_C #undef inline #define inline __inline #ifndef uint32_t - typedef unsigned __int8 uint8_t; +typedef unsigned __int8 uint8_t; typedef unsigned __int16 uint16_t; typedef unsigned __int32 uint32_t; typedef unsigned __int64 uint64_t; diff --git a/src/include/switch_regex.h b/src/include/switch_regex.h index df323a69fb..4ee1fd582a 100644 --- a/src/include/switch_regex.h +++ b/src/include/switch_regex.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -68,7 +68,7 @@ SWITCH_DECLARE(switch_status_t) switch_regex_match(const char *target, const cha \param partial If non-zero returns SUCCESS if the target is a partial match, on successful return, this is set to non-zero if the match was partial and zero if it was a full match \return Boolean if a match was found or not */ -SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int * partial_match); +SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int *partial_match); #define switch_regex_safe_free(re) if (re) {\ diff --git a/src/include/switch_resample.h b/src/include/switch_resample.h index f19ff9893a..55f1740bff 100644 --- a/src/include/switch_resample.h +++ b/src/include/switch_resample.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -51,7 +51,7 @@ SWITCH_BEGIN_EXTERN_C \{ */ /*! \brief An audio resampling handle */ -typedef struct { + typedef struct { /*! a pointer to store the resampler object */ void *resampler; /*! the rate to resample from in hz */ @@ -61,11 +61,11 @@ typedef struct { /*! the factor to resample by (from / to) */ double factor; double rfactor; - int16_t *to; - /*! the size of the to buffer used */ - uint32_t to_len; - /*! the total size of the to buffer */ - uint32_t to_size; + int16_t *to; + /*! the size of the to buffer used */ + uint32_t to_len; + /*! the total size of the to buffer */ + uint32_t to_size; } switch_audio_resampler_t; @@ -79,9 +79,7 @@ typedef struct { */ SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler, uint32_t from_rate, uint32_t to_rate, uint32_t to_size, - int quality, - uint32_t channels, - const char *file, const char *func, int line); + int quality, uint32_t channels, const char *file, const char *func, int line); #define switch_resample_create(_n, _fr, _tr, _ts, _q, _c) switch_resample_perform_create(_n, _fr, _tr, _ts, _q, _c, __FILE__, __SWITCH_FUNC__, __LINE__) diff --git a/src/include/switch_rtp.h b/src/include/switch_rtp.h index 1a6b586657..d2235c7414 100644 --- a/src/include/switch_rtp.h +++ b/src/include/switch_rtp.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -45,8 +45,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_RTP_KEY_LEN 30 #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32" #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80" - -typedef enum { + typedef enum { SWITCH_RTP_CRYPTO_SEND, SWITCH_RTP_CRYPTO_RECV, SWITCH_RTP_CRYPTO_MAX @@ -54,7 +53,7 @@ typedef enum { typedef enum { NO_CRYPTO, - AES_CM_128_HMAC_SHA1_80, + AES_CM_128_HMAC_SHA1_80, AES_CM_128_HMAC_SHA1_32, AES_CM_128_NULL_AUTH } switch_rtp_crypto_key_type_t; @@ -97,6 +96,8 @@ SWITCH_DECLARE(void) switch_rtp_shutdown(void); */ SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port); +SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc); + /*! \brief Set/Get RTP end port \param port new value (if > 0) @@ -166,7 +167,7 @@ SWITCH_DECLARE(switch_rtp_t *) switch_rtp_new(const char *rx_host, \param port the remote port \param err pointer for error messages */ -SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, +SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, switch_bool_t change_adv_addr, const char **err); SWITCH_DECLARE(char *) switch_rtp_get_remote_host(switch_rtp_t *rtp_session); @@ -183,8 +184,7 @@ SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session \param err pointer for error messages \note this call also binds the RTP session's socket to the new address */ -SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, - switch_port_t port, const char **err); +SWITCH_DECLARE(switch_status_t) switch_rtp_set_local_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port, const char **err); /*! \brief Kill the socket on an existing RTP session diff --git a/src/include/switch_scheduler.h b/src/include/switch_scheduler.h index 3560463fce..d9fa5655d7 100644 --- a/src/include/switch_scheduler.h +++ b/src/include/switch_scheduler.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * diff --git a/src/include/switch_stun.h b/src/include/switch_stun.h index d37af0491d..75bc646933 100644 --- a/src/include/switch_stun.h +++ b/src/include/switch_stun.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -41,8 +41,7 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_STUN_DEFAULT_PORT 3478 #define SWITCH_STUN_PACKET_MIN_LEN 20 #define SWITCH_STUN_ATTRIBUTE_MIN_LEN 8 - -typedef enum { + typedef enum { SWITCH_STUN_BINDING_REQUEST = 0x0001, SWITCH_STUN_BINDING_RESPONSE = 0x0101, SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111, diff --git a/src/include/switch_types.h b/src/include/switch_types.h index 2b4815837f..2393607f3e 100644 --- a/src/include/switch_types.h +++ b/src/include/switch_types.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -181,7 +181,6 @@ SWITCH_BEGIN_EXTERN_C #define SWITCH_BITS_PER_BYTE 8 #define SWITCH_DEFAULT_FILE_BUFFER_LEN 65536 #define SWITCH_DTMF_LOG_LEN 1000 - typedef uint8_t switch_byte_t; typedef struct { @@ -394,7 +393,7 @@ SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs; #define SWITCH_INTERVAL_PAD 10 /* A little extra buffer space to be safe */ #define SWITCH_MAX_SAMPLE_LEN 48 #define SWITCH_BYTES_PER_SAMPLE 2 /* slin is 2 bytes per sample */ -#define SWITCH_RECOMMENDED_BUFFER_SIZE 4096 /* worst case of 32khz @60ms we only do 48khz @10ms which is 960 */ +#define SWITCH_RECOMMENDED_BUFFER_SIZE 4096 /* worst case of 32khz @60ms we only do 48khz @10ms which is 960 */ #define SWITCH_MAX_CODECS 50 #define SWITCH_MAX_STATE_HANDLERS 30 #define SWITCH_CORE_QUEUE_LEN 100000 @@ -425,7 +424,7 @@ typedef enum { SWITCH_XML_SECTION_DIRECTORY = (1 << 1), SWITCH_XML_SECTION_DIALPLAN = (1 << 2), SWITCH_XML_SECTION_PHRASES = (1 << 3), - + /* Nothing after this line */ SWITCH_XML_SECTION_MAX = (1 << 4) } switch_xml_section_enum_t; @@ -530,36 +529,35 @@ typedef enum { typedef uint32_t switch_rtp_flag_t; typedef enum { - RTP_BUG_NONE = 0, /* won't be using this one much ;) */ + RTP_BUG_NONE = 0, /* won't be using this one much ;) */ RTP_BUG_CISCO_SKIP_MARK_BIT_2833 = (1 << 0), /* Some Cisco devices get mad when you send the mark bit on new 2833 because it makes them flush their jitterbuffer and the dtmf along with it. This flag will disable the sending of the mark bit on the first DTMF packet. - */ + */ RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833 = (1 << 1) - /* - Sonus wrongly expects that, when sending a multi-packet 2833 DTMF event, The sender - should increment the RTP timestamp in each packet when, in reality, the sender should - send the same exact timestamp and increment the duration field in the 2833 payload. - This allows a reconstruction of the duration if any of the packets are lost. + /* + Sonus wrongly expects that, when sending a multi-packet 2833 DTMF event, The sender + should increment the RTP timestamp in each packet when, in reality, the sender should + send the same exact timestamp and increment the duration field in the 2833 payload. + This allows a reconstruction of the duration if any of the packets are lost. - final_duration - initial_timestamp = total_samples + final_duration - initial_timestamp = total_samples - However, if the duration value exceeds the space allocated (16 bits), The sender should increment - the timestamp one unit and reset the duration to 0. - - Always sending a duration of 0 with a new timestamp should be tolerated but is rarely intentional - and is mistakenly done by many devices. - The issue is that the Sonus expects everyone to do it this way instead of tolerating either way. - Sonus will actually ignore every packet with the same timestamp before concluding if it's DTMF. - - This flag will cause each packet to have a new timestamp. - */ + However, if the duration value exceeds the space allocated (16 bits), The sender should increment + the timestamp one unit and reset the duration to 0. + Always sending a duration of 0 with a new timestamp should be tolerated but is rarely intentional + and is mistakenly done by many devices. + The issue is that the Sonus expects everyone to do it this way instead of tolerating either way. + Sonus will actually ignore every packet with the same timestamp before concluding if it's DTMF. + + This flag will cause each packet to have a new timestamp. + */ } switch_rtp_bug_flag_t; #ifdef _MSC_VER @@ -680,6 +678,8 @@ typedef enum { SWITCH_MESSAGE_INDICATE_SIMPLIFY, SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO, SWITCH_MESSAGE_INDICATE_PROXY_MEDIA, + SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC, + SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; @@ -1545,7 +1545,7 @@ typedef void (*switch_application_function_t) (switch_core_session_t *, const ch typedef void (*switch_event_callback_t) (switch_event_t *); typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *); -#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t * name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) +#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t *name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile) typedef struct switch_scheduler_task switch_scheduler_task_t; @@ -1579,9 +1579,9 @@ typedef switch_status_t (*switch_say_callback_t) (switch_core_session_t *session char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args); typedef struct switch_xml *switch_xml_t; typedef struct switch_core_time_duration switch_core_time_duration_t; -typedef switch_xml_t (*switch_xml_search_function_t) (const char *section, - const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, - void *user_data); +typedef switch_xml_t(*switch_xml_search_function_t) (const char *section, + const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, + void *user_data); typedef struct switch_hash switch_hash_t; struct HashElem; diff --git a/src/include/switch_utils.h b/src/include/switch_utils.h index e5790e5fc4..91027d59f6 100644 --- a/src/include/switch_utils.h +++ b/src/include/switch_utils.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -40,9 +40,7 @@ #include -SWITCH_BEGIN_EXTERN_C - -SWITCH_DECLARE(int) switch_toupper(int c); +SWITCH_BEGIN_EXTERN_C SWITCH_DECLARE(int) switch_toupper(int c); SWITCH_DECLARE(int) switch_tolower(int c); SWITCH_DECLARE(int) switch_isalnum(int c); SWITCH_DECLARE(int) switch_isalpha(int c); @@ -74,7 +72,8 @@ SWITCH_DECLARE(int) switch_isxdigit(int c); \param s the string to test \return true value if the string is NULL or zero length */ -static inline int zstr(const char *s) { + static inline int zstr(const char *s) +{ return !s || *s == '\0'; } @@ -106,7 +105,7 @@ static inline int switch_string_has_escaped_data(const char *in) } i = strchr(i, '\\'); } - + return 0; } @@ -208,11 +207,11 @@ SWITCH_DECLARE(unsigned short) get_port(struct sockaddr *sa); /*! \brief flags to be used with switch_build_uri() */ -enum switch_uri_flags { - SWITCH_URI_NUMERIC_HOST = 1, - SWITCH_URI_NUMERIC_PORT = 2, - SWITCH_URI_NO_SCOPE = 4 -}; + enum switch_uri_flags { + SWITCH_URI_NUMERIC_HOST = 1, + SWITCH_URI_NUMERIC_PORT = 2, + SWITCH_URI_NO_SCOPE = 4 + }; /*! \brief build a URI string from components @@ -224,12 +223,7 @@ enum switch_uri_flags { \param flags logical OR-ed combination of flags from \ref switch_uri_flags \return number of characters printed (not including the trailing null) */ -SWITCH_DECLARE(int) switch_build_uri(char *uri, - switch_size_t size, - const char *scheme, - const char *user, - const switch_sockaddr_t *sa, - int flags); +SWITCH_DECLARE(int) switch_build_uri(char *uri, switch_size_t size, const char *scheme, const char *user, const switch_sockaddr_t *sa, int flags); #define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35) @@ -313,7 +307,7 @@ switch_mutex_unlock(obj->flag_mutex); #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst)) -static inline char *switch_sanitize_number(char *number) + static inline char *switch_sanitize_number(char *number) { char *p = number, *q; char warp[] = "/:"; @@ -323,10 +317,12 @@ static inline char *switch_sanitize_number(char *number) return number; } - while((q = strrchr(p, '@'))) *q = '\0'; - - for(i = 0; i < (int)strlen(warp); i++) { - while(p && (q = strchr(p, warp[i]))) p = q + 1; + while ((q = strrchr(p, '@'))) + *q = '\0'; + + for (i = 0; i < (int) strlen(warp); i++) { + while (p && (q = strchr(p, warp[i]))) + p = q + 1; } return p; @@ -334,46 +330,46 @@ static inline char *switch_sanitize_number(char *number) static inline switch_bool_t switch_string_var_check(char *s, switch_bool_t disable) { - char *p; + char *p; char *dol = NULL; - for (p = s; p && *p; p++) { - if (*p == '$') { - dol = p; - } else if (dol) { - if (*p == '{') { + for (p = s; p && *p; p++) { + if (*p == '$') { + dol = p; + } else if (dol) { + if (*p == '{') { if (disable) { *dol = '%'; dol = NULL; } else { return SWITCH_TRUE; } - } else if (*p != '\\') { - dol = NULL; - } - } - } - return SWITCH_FALSE; + } else if (*p != '\\') { + dol = NULL; + } + } + } + return SWITCH_FALSE; } static inline switch_bool_t switch_string_var_check_const(const char *s) { - const char *p; + const char *p; int dol = 0; - for (p = s; p && *p; p++) { - if (*p == '$') { - dol = 1; - } else if (dol) { - if (*p == '{') { - return SWITCH_TRUE; - } else if (*p != '\\') { - dol = 0; - } - } - } - return SWITCH_FALSE; + for (p = s; p && *p; p++) { + if (*p == '$') { + dol = 1; + } else if (dol) { + if (*p == '{') { + return SWITCH_TRUE; + } else if (*p != '\\') { + dol = 0; + } + } + } + return SWITCH_FALSE; } static inline char *switch_var_clean_string(char *s) @@ -386,7 +382,7 @@ static inline char *switch_clean_string(char *s) { char *p; for (p = s; p && *p; p++) { - uint8_t x = (uint8_t) *p; + uint8_t x = (uint8_t) * p; if ((x < 32) && x != '\n' && x != '\r') { *p = ' '; } @@ -403,7 +399,7 @@ static inline char *switch_clean_string(char *s) */ #define switch_safe_free(it) if (it) {free(it);it=NULL;} -static inline char *switch_safe_strdup(const char *it) +static inline char *switch_safe_strdup(const char *it) { if (it) { return strdup(it); @@ -413,14 +409,14 @@ static inline char *switch_safe_strdup(const char *it) } -static inline char *switch_lc_strdup(const char *it) +static inline char *switch_lc_strdup(const char *it) { char *dup; char *p; if (it) { dup = strdup(it); - for(p = dup; p && *p; p++) { + for (p = dup; p && *p; p++) { *p = (char) switch_tolower(*p); } return dup; @@ -430,14 +426,14 @@ static inline char *switch_lc_strdup(const char *it) } -static inline char *switch_uc_strdup(const char *it) +static inline char *switch_uc_strdup(const char *it) { char *dup; char *p; if (it) { dup = strdup(it); - for(p = dup; p && *p; p++) { + for (p = dup; p && *p; p++) { *p = (char) switch_toupper(*p); } return dup; @@ -562,7 +558,7 @@ SWITCH_DECLARE(switch_bool_t) switch_ast2regex(const char *pat, char *rbuf, size SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, const char *delim, char esc); SWITCH_DECLARE(char *) switch_escape_string(const char *in, char *out, switch_size_t outlen); -SWITCH_DECLARE(char*) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool); +SWITCH_DECLARE(char *) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool); /*! \brief Wait for a socket @@ -591,17 +587,14 @@ SWITCH_DECLARE(char *) switch_util_quote_shell_arg(const char *string); #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK) SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len); SWITCH_DECLARE(char *) switch_url_decode(char *s); -SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, - const char *from, - const char *headers, - const char *body, - const char *file, - const char *convert_cmd, - const char *convert_ext); +SWITCH_DECLARE(switch_bool_t) switch_simple_email(const char *to, + const char *from, + const char *headers, + const char *body, const char *file, const char *convert_cmd, const char *convert_ext); SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char close); -static inline switch_bool_t switch_is_file_path(const char *file) + static inline switch_bool_t switch_is_file_path(const char *file) { const char *e; int r; @@ -611,21 +604,21 @@ static inline switch_bool_t switch_is_file_path(const char *file) file = e + 1; } } - #ifdef WIN32 - r = (file && (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))); + r = (file && (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR))); #else r = (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR))); #endif return r ? SWITCH_TRUE : SWITCH_FALSE; - + } SWITCH_DECLARE(int) switch_parse_cidr(const char *string, uint32_t *ip, uint32_t *mask, uint32_t *bitp); -SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type, switch_memory_pool_t *pool); +SWITCH_DECLARE(switch_status_t) switch_network_list_create(switch_network_list_t **list, const char *name, switch_bool_t default_type, + switch_memory_pool_t *pool); SWITCH_DECLARE(switch_status_t) switch_network_list_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token); #define switch_network_list_add_cidr(_list, _cidr_str, _ok) switch_network_list_add_cidr_token(_list, _cidr_str, _ok, NULL) diff --git a/src/include/switch_xml.h b/src/include/switch_xml.h index 1187b89d4f..3995532af3 100644 --- a/src/include/switch_xml.h +++ b/src/include/switch_xml.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -103,7 +103,7 @@ struct switch_xml { * \param s The string to parse * \param dup true if you want the string to be strdup()'d automatically * \return the switch_xml_t or NULL if an error occured - */ + */ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup); /*! @@ -156,7 +156,8 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_child(_In_ switch_xml_t xml, _In_z_ cons ///\param attrname the attribute name ///\param value the value ///\return an xml node or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname, _In_opt_z_ const char *value); +SWITCH_DECLARE(switch_xml_t) switch_xml_find_child(_In_ switch_xml_t node, _In_z_ const char *childname, _In_opt_z_ const char *attrname, + _In_opt_z_ const char *value); SWITCH_DECLARE(switch_xml_t) switch_xml_find_child_multi(_In_ switch_xml_t node, _In_z_ const char *childname, ...); ///\brief returns the next tag of the same name in the same section and depth or NULL @@ -202,7 +203,7 @@ SWITCH_DECLARE(const char *) switch_xml_attr_soft(_In_ switch_xml_t xml, _In_z_ ///\ Returns NULL if not found. ///\param xml the xml node ///\return an xml node or NULL -SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml, ...); +SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml,...); ///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that ///\ must be freed. @@ -218,7 +219,8 @@ SWITCH_DECLARE(char *) switch_xml_toxml(_In_ switch_xml_t xml, _In_ switch_bool_ ///\param offset offset to start at ///\param prn_header add header too ///\return the xml text string -SWITCH_DECLARE(char *) switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset, _In_ switch_bool_t prn_header); +SWITCH_DECLARE(char *) switch_xml_toxml_buf(_In_ switch_xml_t xml, _In_z_ char *buf, _In_ switch_size_t buflen, _In_ switch_size_t offset, + _In_ switch_bool_t prn_header); ///\brief returns a NULL terminated array of processing instructions for the given ///\ target @@ -346,30 +348,28 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_root(void); ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned SWITCH_DECLARE(switch_status_t) switch_xml_locate(_In_z_ const char *section, _In_opt_z_ const char *tag_name, - _In_opt_z_ const char *key_name, - _In_opt_z_ const char *key_value, - _Out_ switch_xml_t *root, - _Out_ switch_xml_t *node, - _In_opt_ switch_event_t *params, - _In_ switch_bool_t clone); + _In_opt_z_ const char *key_name, + _In_opt_z_ const char *key_value, + _Out_ switch_xml_t *root, + _Out_ switch_xml_t *node, _In_opt_ switch_event_t *params, _In_ switch_bool_t clone); -SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain); +SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(_In_z_ const char *domain_name, _In_opt_ switch_event_t *params, _Out_ switch_xml_t *root, + _Out_ switch_xml_t *domain); SWITCH_DECLARE(switch_status_t) switch_xml_locate_group(_In_z_ const char *group_name, - _In_z_ const char *domain_name, + _In_z_ const char *domain_name, _Out_ switch_xml_t *root, - _Out_ switch_xml_t *domain, - _Out_ switch_xml_t *group, - _In_opt_ switch_event_t *params); + _Out_ switch_xml_t *domain, _Out_ switch_xml_t *group, _In_opt_ switch_event_t *params); SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(_In_z_ const char *key, _In_z_ const char *user_name, _In_z_ const char *domain_name, _In_opt_z_ const char *ip, - _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup, - _In_opt_ switch_event_t *params); + _Out_ switch_xml_t *root, _Out_ switch_xml_t *domain, _Out_ switch_xml_t *user, + _Out_opt_ switch_xml_t *ingroup, _In_opt_ switch_event_t *params); -SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(_In_z_ const char *user_name, _In_ switch_xml_t domain, _Out_ switch_xml_t *user, _Out_opt_ switch_xml_t *ingroup); +SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(_In_z_ const char *user_name, _In_ switch_xml_t domain, _Out_ switch_xml_t *user, + _Out_opt_ switch_xml_t *ingroup); ///\brief open a config in the core registry ///\param file_path the name of the config section e.g. modules.conf @@ -390,7 +390,8 @@ SWITCH_DECLARE(void) switch_xml_set_binding_user_data(_In_ switch_xml_binding_t SWITCH_DECLARE(switch_xml_section_t) switch_xml_get_binding_sections(_In_ switch_xml_binding_t *binding); SWITCH_DECLARE(void *) switch_xml_get_binding_user_data(_In_ switch_xml_binding_t *binding); -SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_ret(_In_ switch_xml_search_function_t function, _In_ switch_xml_section_t sections, _In_opt_ void *user_data, switch_xml_binding_t **ret_binding); +SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_ret(_In_ switch_xml_search_function_t function, _In_ switch_xml_section_t sections, + _In_opt_ void *user_data, switch_xml_binding_t **ret_binding); #define switch_xml_bind_search_function(_f, _s, _u) switch_xml_bind_search_function_ret(_f, _s, _u, NULL) diff --git a/src/include/switch_xml_config.h b/src/include/switch_xml_config.h index 5a4857bd93..3e78f5f46f 100644 --- a/src/include/switch_xml_config.h +++ b/src/include/switch_xml_config.h @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -36,38 +36,37 @@ #include SWITCH_BEGIN_EXTERN_C - /*! \brief Type of value to parse */ -typedef enum { - SWITCH_CONFIG_INT, /*< (ptr=int* default=int data=NULL) Integer */ - SWITCH_CONFIG_STRING, /*< (ptr=[char* or char ** (for alloc)] default=char* data=switch_xml_config_string_options_t*) Zero-terminated C-string */ - SWITCH_CONFIG_BOOL, /*< (ptr=switch_bool_t* default=switch_bool_t data=NULL) Yes and no */ - SWITCH_CONFIG_CUSTOM, /*< (ptr= default= data=switch_xml_config_callback_t) Custom, get value through function pointer */ - SWITCH_CONFIG_ENUM, /*< (ptr=int* default=int data=switch_xml_config_enum_item_t*) */ - SWITCH_CONFIG_FLAG, /*< (ptr=int32_t* default=switch_bool_t data=int (flag index) */ - SWITCH_CONFIG_FLAGARRAY, /*< (ptr=int8_t* default=switch_bool_t data=int (flag index) */ - + typedef enum { + SWITCH_CONFIG_INT, /*< (ptr=int* default=int data=NULL) Integer */ + SWITCH_CONFIG_STRING, /*< (ptr=[char* or char ** (for alloc)] default=char* data=switch_xml_config_string_options_t*) Zero-terminated C-string */ + SWITCH_CONFIG_BOOL, /*< (ptr=switch_bool_t* default=switch_bool_t data=NULL) Yes and no */ + SWITCH_CONFIG_CUSTOM, /*< (ptr= default= data=switch_xml_config_callback_t) Custom, get value through function pointer */ + SWITCH_CONFIG_ENUM, /*< (ptr=int* default=int data=switch_xml_config_enum_item_t*) */ + SWITCH_CONFIG_FLAG, /*< (ptr=int32_t* default=switch_bool_t data=int (flag index) */ + SWITCH_CONFIG_FLAGARRAY, /*< (ptr=int8_t* default=switch_bool_t data=int (flag index) */ + /* No more past that line */ SWITCH_CONFIG_LAST } switch_xml_config_type_t; -typedef struct { - char *key; /*< The item's key or NULL if this is the last one in the list */ - int value; /*< The item's value */ +typedef struct { + char *key; /*< The item's key or NULL if this is the last one in the list */ + int value; /*< The item's value */ } switch_xml_config_enum_item_t; typedef struct { - switch_memory_pool_t *pool; /*< If set, the string will be allocated on the pool (unless the length param is > 0, then you misread this file)*/ - switch_size_t length; /*< Length of the char array, or 0 if memory has to be allocated dynamically*/ - char *validation_regex; /*< Enforce validation using this regular expression */ + switch_memory_pool_t *pool; /*< If set, the string will be allocated on the pool (unless the length param is > 0, then you misread this file) */ + switch_size_t length; /*< Length of the char array, or 0 if memory has to be allocated dynamically */ + char *validation_regex; /*< Enforce validation using this regular expression */ } switch_xml_config_string_options_t; -SWITCH_DECLARE_DATA extern switch_xml_config_string_options_t switch_config_string_strdup; /*< String options structure for strdup, no validation */ +SWITCH_DECLARE_DATA extern switch_xml_config_string_options_t switch_config_string_strdup; /*< String options structure for strdup, no validation */ typedef struct { switch_bool_t enforce_min; int min; - switch_bool_t enforce_max; + switch_bool_t enforce_max; int max; } switch_xml_config_int_options_t; @@ -85,21 +84,22 @@ typedef enum { CONFIG_REQUIRED = (1 << 1) } switch_config_flags_t; -typedef switch_status_t (*switch_xml_config_callback_t)(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed); +typedef switch_status_t (*switch_xml_config_callback_t) (switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, + switch_bool_t changed); /*! * \brief A configuration instruction read by switch_xml_config_parse */ struct switch_xml_config_item { - const char *key; /*< The key of the element, or NULL to indicate the end of the list */ - switch_xml_config_type_t type; /*< The type of variable */ - int flags; /*< True if the var can be changed on reload */ - void *ptr; /*< Ptr to the var to be changed */ - const void *defaultvalue; /*< Default value */ - void *data; /*< Custom data (depending on the type) */ + const char *key; /*< The key of the element, or NULL to indicate the end of the list */ + switch_xml_config_type_t type; /*< The type of variable */ + int flags; /*< True if the var can be changed on reload */ + void *ptr; /*< Ptr to the var to be changed */ + const void *defaultvalue; /*< Default value */ + void *data; /*< Custom data (depending on the type) */ switch_xml_config_callback_t function; /*< Callback to be called after the var is parsed */ - const char *syntax; /*< Optional syntax documentation for this setting */ - const char *helptext; /*< Optional documentation text for this setting */ + const char *syntax; /*< Optional syntax documentation for this setting */ + const char *helptext; /*< Optional documentation text for this setting */ }; #define SWITCH_CONFIG_ITEM(_key, _type, _flags, _ptr, _defaultvalue, _data, _syntax, _helptext) { _key, _type, _flags, _ptr, (void*)_defaultvalue, (void*)_data, NULL, _syntax, _helptext } @@ -110,9 +110,10 @@ struct switch_xml_config_item { #define SWITCH_CONFIG_SET_ITEM(_item, _key, _type, _flags, _ptr, _defaultvalue, _data, _syntax, _helptext) switch_config_perform_set_item(&(_item), _key, _type, _flags, _ptr, (void*)(_defaultvalue), _data, NULL, _syntax, _helptext) #define SWITCH_CONFIG_SET_ITEM_CALLBACK(_item, _key, _type, _flags, _ptr, _defaultvalue, _data, _function, _syntax, _helptext) switch_config_perform_set_item(&(_item), _key, _type, _flags, _ptr, (void*)(_defaultvalue), _data, _function, _syntax, _helptext) -SWITCH_DECLARE(void) switch_config_perform_set_item(switch_xml_config_item_t *item, const char *key, switch_xml_config_type_t type, int flags, void *ptr, - const void* defaultvalue, void *data, switch_xml_config_callback_t function, const char *syntax, const char *helptext); - +SWITCH_DECLARE(void) switch_config_perform_set_item(switch_xml_config_item_t *item, const char *key, switch_xml_config_type_t type, int flags, void *ptr, + const void *defaultvalue, void *data, switch_xml_config_callback_t function, const char *syntax, + const char *helptext); + /*! * \brief Gets the int representation of an enum * \param enum_options the switch_xml_config_enum_item_t array for this enum @@ -125,7 +126,7 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_enum_str2int(switch_xml_config * \param enum_options the switch_xml_config_enum_item_t array for this enum * \param value int value to search */ -SWITCH_DECLARE(const char*) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value); +SWITCH_DECLARE(const char *) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value); /*! * \brief Prints out an item's documentation on the console @@ -158,7 +159,8 @@ SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_module_settings(const ch * \param instructions instrutions on how to parse the elements * \see switch_xml_config_item_t */ -SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *event, int count, switch_bool_t reload, switch_xml_config_item_t *instructions); +SWITCH_DECLARE(switch_status_t) switch_xml_config_parse_event(switch_event_t *event, int count, switch_bool_t reload, + switch_xml_config_item_t *instructions); /*! * \brief Parses a list of xml elements into an event @@ -176,9 +178,7 @@ SWITCH_DECLARE(switch_size_t) switch_event_import_xml(switch_xml_t xml, const ch SWITCH_DECLARE(void) switch_xml_config_cleanup(switch_xml_config_item_t *instructions); SWITCH_END_EXTERN_C - #endif /* !defined(SWITCH_XML_CONFIG_H) */ - /* For Emacs: * Local Variables: * mode:c diff --git a/src/inet_pton.c b/src/inet_pton.c index 0410dfae50..a38030f188 100644 --- a/src/inet_pton.c +++ b/src/inet_pton.c @@ -52,9 +52,9 @@ * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. */ -static int inet_pton4(const char *src, unsigned char *dst); +static int inet_pton4(const char *src, unsigned char *dst); #ifdef ENABLE_IPV6 -static int inet_pton6(const char *src, unsigned char *dst); +static int inet_pton6(const char *src, unsigned char *dst); #endif /* int @@ -68,24 +68,23 @@ static int inet_pton6(const char *src, unsigned char *dst); * author: * Paul Vixie, 1996. */ -SWITCH_DECLARE(int) -switch_inet_pton(int af, const char *src, void *dst) +SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst) { - switch (af) { - case AF_INET: - return (inet_pton4(src, (unsigned char *)dst)); + switch (af) { + case AF_INET: + return (inet_pton4(src, (unsigned char *) dst)); #ifdef ENABLE_IPV6 #ifndef AF_INET6 -#define AF_INET6 (AF_MAX+1) /* just to let this compile */ +#define AF_INET6 (AF_MAX+1) /* just to let this compile */ #endif - case AF_INET6: - return (inet_pton6(src, (unsigned char *)dst)); + case AF_INET6: + return (inet_pton6(src, (unsigned char *) dst)); #endif - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ + default: + errno = EAFNOSUPPORT; + return (-1); + } + /* NOTREACHED */ } /* int @@ -98,44 +97,43 @@ switch_inet_pton(int af, const char *src, void *dst) * author: * Paul Vixie, 1996. */ -static int -inet_pton4(const char *src, unsigned char *dst) +static int inet_pton4(const char *src, unsigned char *dst) { - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[INADDRSZ], *tp; + static const char digits[] = "0123456789"; + int saw_digit, octets, ch; + unsigned char tmp[INADDRSZ], *tp; - saw_digit = 0; - octets = 0; - tp = tmp; - *tp = 0; - while ((ch = *src++) != '\0') { - const char *pch; + saw_digit = 0; + octets = 0; + tp = tmp; + *tp = 0; + while ((ch = *src++) != '\0') { + const char *pch; - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int val = *tp * 10 + (unsigned int)(pch - digits); + if ((pch = strchr(digits, ch)) != NULL) { + unsigned int val = *tp * 10 + (unsigned int) (pch - digits); - if (val > 255) - return (0); - *tp = (unsigned char)val; - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - /* bcopy(tmp, dst, INADDRSZ); */ - memcpy(dst, tmp, INADDRSZ); - return (1); + if (val > 255) + return (0); + *tp = (unsigned char) val; + if (!saw_digit) { + if (++octets > 4) + return (0); + saw_digit = 1; + } + } else if (ch == '.' && saw_digit) { + if (octets == 4) + return (0); + *++tp = 0; + saw_digit = 0; + } else + return (0); + } + if (octets < 4) + return (0); + /* bcopy(tmp, dst, INADDRSZ); */ + memcpy(dst, tmp, INADDRSZ); + return (1); } #ifdef ENABLE_IPV6 @@ -152,88 +150,85 @@ inet_pton4(const char *src, unsigned char *dst) * author: * Paul Vixie, 1996. */ -static int -inet_pton6(const char *src, unsigned char *dst) +static int inet_pton6(const char *src, unsigned char *dst) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - unsigned int val; + static const char xdigits_l[] = "0123456789abcdef", xdigits_u[] = "0123456789ABCDEF"; + unsigned char tmp[IN6ADDRSZ], *tp, *endp, *colonp; + const char *xdigits, *curtok; + int ch, saw_xdigit; + unsigned int val; - memset((tp = tmp), 0, IN6ADDRSZ); - endp = tp + IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; + memset((tp = tmp), 0, IN6ADDRSZ); + endp = tp + IN6ADDRSZ; + colonp = NULL; + /* Leading :: requires some special handling. */ + if (*src == ':') + if (*++src != ':') + return (0); + curtok = src; + saw_xdigit = 0; + val = 0; + while ((ch = *src++) != '\0') { + const char *pch; - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + INADDRSZ) <= endp) && - inet_pton4(curtok, tp) > 0) { - tp += INADDRSZ; - saw_xdigit = 0; - break; /* '\0' was seen by inet_pton4(). */ - } - return (0); - } - if (saw_xdigit) { - if (tp + INT16SZ > endp) - return (0); - *tp++ = (unsigned char) (val >> 8) & 0xff; - *tp++ = (unsigned char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const int n = tp - colonp; - int i; + if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) + pch = strchr((xdigits = xdigits_u), ch); + if (pch != NULL) { + val <<= 4; + val |= (pch - xdigits); + if (val > 0xffff) + return (0); + saw_xdigit = 1; + continue; + } + if (ch == ':') { + curtok = src; + if (!saw_xdigit) { + if (colonp) + return (0); + colonp = tp; + continue; + } + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + saw_xdigit = 0; + val = 0; + continue; + } + if (ch == '.' && ((tp + INADDRSZ) <= endp) && inet_pton4(curtok, tp) > 0) { + tp += INADDRSZ; + saw_xdigit = 0; + break; /* '\0' was seen by inet_pton4(). */ + } + return (0); + } + if (saw_xdigit) { + if (tp + INT16SZ > endp) + return (0); + *tp++ = (unsigned char) (val >> 8) & 0xff; + *tp++ = (unsigned char) val & 0xff; + } + if (colonp != NULL) { + /* + * Since some memmove()'s erroneously fail to handle + * overlapping regions, we'll do the shift by hand. + */ + const int n = tp - colonp; + int i; - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - /* bcopy(tmp, dst, IN6ADDRSZ); */ - memcpy(dst, tmp, IN6ADDRSZ); - return (1); + for (i = 1; i <= n; i++) { + endp[-i] = colonp[n - i]; + colonp[n - i] = 0; + } + tp = endp; + } + if (tp != endp) + return (0); + /* bcopy(tmp, dst, IN6ADDRSZ); */ + memcpy(dst, tmp, IN6ADDRSZ); + return (1); } #endif /* ENABLE_IPV6 */ diff --git a/src/mod/applications/mod_cidlookup/mod_cidlookup.c b/src/mod/applications/mod_cidlookup/mod_cidlookup.c index 5a3cf7286a..c56e6cf7e6 100755 --- a/src/mod/applications/mod_cidlookup/mod_cidlookup.c +++ b/src/mod/applications/mod_cidlookup/mod_cidlookup.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,7 +28,7 @@ * mod_cidlookup.c -- API for querying cid->name services * */ - + #include #include @@ -50,12 +50,12 @@ static struct { char *url; int curl_timeout; int curl_warnduration; - + char *whitepages_apikey; switch_bool_t cache; int cache_expire; - + char *odbc_dsn; char *odbc_user; char *odbc_pass; @@ -92,22 +92,24 @@ static switch_cache_db_handle_t *cidlookup_get_db_handle(void) { switch_cache_db_connection_options_t options = { {0} }; switch_cache_db_handle_t *dbh = NULL; - + if (!zstr(globals.odbc_dsn)) { options.odbc_options.dsn = globals.odbc_dsn; options.odbc_options.user = globals.odbc_user; options.odbc_options.pass = globals.odbc_pass; - if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL; + if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) + dbh = NULL; } return dbh; } -static switch_status_t config_callback_dsn(switch_xml_config_item_t *data, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed) +static switch_status_t config_callback_dsn(switch_xml_config_item_t *data, const char *newvalue, switch_config_callback_type_t callback_type, + switch_bool_t changed) { switch_status_t status = SWITCH_STATUS_SUCCESS; - + switch_cache_db_handle_t *dbh = NULL; if (!switch_odbc_available()) { @@ -139,25 +141,31 @@ static switch_status_t config_callback_dsn(switch_xml_config_item_t *data, const } switch_goto_status(SWITCH_STATUS_SUCCESS, done); - -done: + + done: switch_cache_db_release_db_handle(&dbh); return status; } -static switch_xml_config_string_options_t config_opt_dsn = {NULL, 0, NULL}; /* anything is ok here */ +static switch_xml_config_string_options_t config_opt_dsn = { NULL, 0, NULL }; /* anything is ok here */ static switch_xml_config_item_t instructions[] = { /* parameter name type reloadable pointer default value options structure */ - SWITCH_CONFIG_ITEM_STRING_STRDUP("url", CONFIG_RELOAD, &globals.url, NULL, "http://server.example.com/app?number=${caller_id_number}", "URL for the CID lookup service"), - SWITCH_CONFIG_ITEM_STRING_STRDUP("whitepages-apikey", CONFIG_RELOAD, &globals.whitepages_apikey, NULL, "api key for whitepages.com", "api key for whitepages.com"), + SWITCH_CONFIG_ITEM_STRING_STRDUP("url", CONFIG_RELOAD, &globals.url, NULL, "http://server.example.com/app?number=${caller_id_number}", + "URL for the CID lookup service"), + SWITCH_CONFIG_ITEM_STRING_STRDUP("whitepages-apikey", CONFIG_RELOAD, &globals.whitepages_apikey, NULL, "api key for whitepages.com", + "api key for whitepages.com"), SWITCH_CONFIG_ITEM("cache", SWITCH_CONFIG_BOOL, CONFIG_RELOAD, &globals.cache, SWITCH_FALSE, NULL, "true|false", "whether to cache via cidlookup"), - SWITCH_CONFIG_ITEM("cache-expire", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.cache_expire, (void *)300, NULL, "expire", "seconds to preserve num->name cache"), - SWITCH_CONFIG_ITEM("curl-timeout", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.curl_timeout, (void *)2000, NULL, "timeout for curl", "milliseconds to timeout"), - SWITCH_CONFIG_ITEM("curl-warning-duration", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.curl_warnduration, (void *)1000, NULL, "warning when curl queries are longer than specified time", "milliseconds"), + SWITCH_CONFIG_ITEM("cache-expire", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.cache_expire, (void *) 300, NULL, "expire", + "seconds to preserve num->name cache"), + SWITCH_CONFIG_ITEM("curl-timeout", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.curl_timeout, (void *) 2000, NULL, "timeout for curl", + "milliseconds to timeout"), + SWITCH_CONFIG_ITEM("curl-warning-duration", SWITCH_CONFIG_INT, CONFIG_RELOAD, &globals.curl_warnduration, (void *) 1000, NULL, + "warning when curl queries are longer than specified time", "milliseconds"), SWITCH_CONFIG_ITEM_STRING_STRDUP("sql", CONFIG_RELOAD, &globals.sql, NULL, "sql whre number=${caller_id_number}", "SQL to run if overriding CID"), - SWITCH_CONFIG_ITEM_STRING_STRDUP("citystate-sql", CONFIG_RELOAD, &globals.citystate_sql, NULL, "sql to look up city/state info", "SQL to run if overriding CID"), + SWITCH_CONFIG_ITEM_STRING_STRDUP("citystate-sql", CONFIG_RELOAD, &globals.citystate_sql, NULL, "sql to look up city/state info", + "SQL to run if overriding CID"), SWITCH_CONFIG_ITEM_CALLBACK("odbc-dsn", SWITCH_CONFIG_STRING, CONFIG_RELOAD, &globals.odbc_dsn, "", config_callback_dsn, &config_opt_dsn, - "db:user:passwd", "Database to use."), + "db:user:passwd", "Database to use."), SWITCH_CONFIG_ITEM_END() }; @@ -166,7 +174,7 @@ static switch_status_t do_config(switch_bool_t reload) if (switch_xml_config_parse_module_settings("cidlookup.conf", reload, instructions) != SWITCH_STATUS_SUCCESS) { return SWITCH_STATUS_GENERR; } - + return SWITCH_STATUS_SUCCESS; } @@ -179,10 +187,10 @@ static switch_bool_t cidlookup_execute_sql_callback(char *sql, switch_core_db_ca { switch_bool_t retval = SWITCH_FALSE; switch_cache_db_handle_t *dbh = NULL; - + if (globals.odbc_dsn && (dbh = cidlookup_get_db_handle())) { - if (switch_cache_db_execute_sql_callback(dbh, sql, callback, (void *)cbt, err) - == SWITCH_ODBC_FAIL) { + if (switch_cache_db_execute_sql_callback(dbh, sql, callback, (void *) cbt, err) + == SWITCH_ODBC_FAIL) { retval = SWITCH_FALSE; } else { retval = SWITCH_TRUE; @@ -190,7 +198,7 @@ static switch_bool_t cidlookup_execute_sql_callback(char *sql, switch_core_db_ca } else { *err = switch_core_sprintf(cbt->pool, "Unable to get ODBC handle. dsn: %s, dbh is %s\n", globals.odbc_dsn, dbh ? "not null" : "null"); } - + switch_cache_db_release_db_handle(&dbh); return retval; } @@ -199,33 +207,31 @@ static int cidlookup_callback(void *pArg, int argc, char **argv, char **columnNa { callback_t *cbt = (callback_t *) pArg; switch_memory_pool_t *pool = cbt->pool; - + if (argc < 1) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Unexpected number of columns returned for SQL. Returned column count: %d. ", - argc); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unexpected number of columns returned for SQL. Returned column count: %d. ", argc); return SWITCH_STATUS_GENERR; } cbt->name = switch_core_strdup(pool, switch_str_nil(argv[0])); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Name: %s\n", cbt->name); - + return SWITCH_STATUS_SUCCESS; } /* make a new string with digits only */ -static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) +static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) { char *p, *np, *newstr; size_t len; - p = (char *)str; + p = (char *) str; len = strlen(str); - newstr = switch_core_alloc(pool, len+1); + newstr = switch_core_alloc(pool, len + 1); switch_assert(newstr); np = newstr; - - while(*p) { + + while (*p) { if (switch_isdigit(*p)) { *np = *p; np++; @@ -237,16 +243,17 @@ static char *string_digitsonly(switch_memory_pool_t *pool, const char *str) return newstr; } -static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number) { +static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number) +{ char *cmd; char *name = NULL; char *area = NULL; char *src = NULL; cid_data_t *cid = NULL; switch_stream_handle_t stream = { 0 }; - + SWITCH_STANDARD_STREAM(stream); - + cmd = switch_core_sprintf(pool, "get fs:cidlookup:name:%s", number); if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) { if (strncmp("-ERR", stream.data, 4)) { @@ -275,7 +282,7 @@ static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number) { src = NULL; } } - + if (name || area || src) { cid = switch_core_alloc(pool, sizeof(cid_data_t)); switch_assert(cid); @@ -283,24 +290,21 @@ static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number) { cid->area = area; cid->src = src; } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "memcache: k:'%s', vn:'%s', va:'%s', vs:'%s'\n", - cmd, - (name) ? name : "(null)", - (area) ? area : "(null)", - (src) ? src : "(null)" - ); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "memcache: k:'%s', vn:'%s', va:'%s', vs:'%s'\n", + cmd, (name) ? name : "(null)", (area) ? area : "(null)", (src) ? src : "(null)"); switch_safe_free(stream.data); return cid; } -switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *cid) { +switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *cid) +{ char *cmd; switch_bool_t success = SWITCH_TRUE; switch_stream_handle_t stream = { 0 }; - + SWITCH_STANDARD_STREAM(stream); - + cmd = switch_core_sprintf(pool, "set fs:cidlookup:name:%s '%s' %d", number, cid->name, globals.cache_expire); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "memcache: %s\n", cmd); if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) { @@ -334,7 +338,7 @@ switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *ci } } -done: + done: switch_safe_free(stream.data); return success; } @@ -347,17 +351,18 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data) http_data->bytes += realsize; if (http_data->bytes > http_data->max_bytes) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)http_data->bytes); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) http_data->bytes); http_data->err = 1; return 0; } - http_data->stream.write_function( - &http_data->stream, "%.*s", realsize, ptr); + http_data->stream.write_function(&http_data->stream, "%.*s", realsize, ptr); return realsize; } -static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, struct curl_httppost *post, struct curl_slist *headers, int timeout) { +static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, char **response, const char *query, struct curl_httppost *post, + struct curl_slist *headers, int timeout) +{ switch_time_t start_time = switch_micro_time_now(); switch_time_t time_diff = 0; CURL *curl_handle = NULL; @@ -365,20 +370,20 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha char hostname[256] = ""; struct http_data http_data; - + memset(&http_data, 0, sizeof(http_data)); - + http_data.max_bytes = 10240; SWITCH_STANDARD_STREAM(http_data.stream); gethostname(hostname, sizeof(hostname)); - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "url: %s\n", query); curl_handle = curl_easy_init(); - + curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 0); curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1); - + if (!strncasecmp(query, "https", 5)) { curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); @@ -394,7 +399,7 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10); /* - TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree + TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree */ #ifdef CURLOPT_TIMEOUT_MS if (timeout > 0) { @@ -406,7 +411,7 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha if (timeout > 0) { curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout); } else { - curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.curl_timeout/1000); + curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.curl_timeout / 1000); } #endif curl_easy_setopt(curl_handle, CURLOPT_URL, query); @@ -417,34 +422,24 @@ static long do_lookup_url(switch_memory_pool_t *pool, switch_event_t *event, cha curl_easy_perform(curl_handle); curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes); curl_easy_cleanup(curl_handle); - - if ( http_data.stream.data && - !zstr((char *)http_data.stream.data) && - strcmp(" ", http_data.stream.data) ) { - + + if (http_data.stream.data && !zstr((char *) http_data.stream.data) && strcmp(" ", http_data.stream.data)) { + /* don't return UNKNOWN */ - if (strcmp("UNKNOWN", http_data.stream.data) || - strcmp("UNAVAILABLE", http_data.stream.data)) { + if (strcmp("UNKNOWN", http_data.stream.data) || strcmp("UNAVAILABLE", http_data.stream.data)) { *response = switch_core_strdup(pool, http_data.stream.data); } } - - time_diff = (switch_micro_time_now() - start_time); /* convert to milli from micro */ - - if ((time_diff/1000) >= globals.curl_warnduration) { + + time_diff = (switch_micro_time_now() - start_time); /* convert to milli from micro */ + + if ((time_diff / 1000) >= globals.curl_warnduration) { switch_core_time_duration_t duration; switch_core_measure_time(time_diff, &duration); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SLOW LOOKUP (" - "%um, " - "%us, " - "%ums" - "): url: %s\n", - duration.min, - duration.sec, - duration.ms, - query); + "%um, " "%us, " "%ums" "): url: %s\n", duration.min, duration.sec, duration.ms, query); } - + switch_safe_free(http_data.stream.data); return httpRes; } @@ -463,19 +458,19 @@ static cid_data_t *do_whitepages_lookup(switch_memory_pool_t *pool, switch_event /* NANPA check */ if (strlen(num) == 11 && num[0] == '1') { - num++; /* skip past leading 1 */ + num++; /* skip past leading 1 */ } else { goto done; } - + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-cid", num); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-api-key", globals.whitepages_apikey); - + query = switch_event_expand_headers(event, "http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}"); do_lookup_url(pool, event, &xml_s, query, NULL, NULL, 0); - + xml = switch_xml_parse_str_dup(xml_s); - + if (!xml) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", xml_s); goto done; @@ -487,14 +482,14 @@ static cid_data_t *do_whitepages_lookup(switch_memory_pool_t *pool, switch_event name = switch_core_strdup(pool, switch_xml_txt(node)); goto area; } - + node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:displayname", -1); if (node) { name = switch_core_strdup(pool, switch_xml_txt(node)); } -area: - + area: + node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:address", 0, "wp:city", -1); if (node) { city = switch_xml_txt(node); @@ -504,12 +499,12 @@ area: if (node) { state = switch_xml_txt(node); } - + if (city || state) { area = switch_core_sprintf(pool, "%s %s", city ? city : "", state ? state : ""); } -done: + done: if (query) { switch_safe_free(query); @@ -519,23 +514,24 @@ done: } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "whitepages XML: %s\n", xml_s); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "whitepages name: %s, area: %s\n", name ? name : "(null)", area ? area : "(null)"); - + cid = switch_core_alloc(pool, sizeof(cid_data_t)); switch_assert(cid); - + cid->name = name; cid->area = area; cid->src = "whitepages"; return cid; } -static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, const char *sql) { +static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, const char *sql) +{ char *name = NULL; char *newsql = NULL; char *err = NULL; callback_t cbt = { 0 }; cbt.pool = pool; - + if (globals.odbc_dsn) { newsql = switch_event_expand_headers(event, sql); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL: %s\n", newsql); @@ -551,13 +547,14 @@ static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, con return name; } -static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, switch_bool_t skipurl, switch_bool_t skipcitystate) { +static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, switch_bool_t skipurl, switch_bool_t skipcitystate) +{ char *number = NULL; char *name = NULL; char *url_query = NULL; cid_data_t *cid = NULL; switch_bool_t save_cache = SWITCH_FALSE; - + cid = switch_core_alloc(pool, sizeof(cid_data_t)); switch_assert(cid); @@ -581,40 +578,37 @@ static cid_data_t *do_lookup(switch_memory_pool_t *pool, switch_event_t *event, goto done; } } - + if (!skipurl && globals.whitepages_apikey) { cid = do_whitepages_lookup(pool, event, number); - if (cid && cid->name) { /* only cache if we have a name */ + if (cid && cid->name) { /* only cache if we have a name */ save_cache = SWITCH_TRUE; goto done; } } - + if (!skipurl && globals.url) { url_query = switch_event_expand_headers(event, globals.url); do_lookup_url(pool, event, &name, url_query, NULL, NULL, 0); if (name) { cid->name = name; cid->src = "url"; - + save_cache = SWITCH_TRUE; } if (url_query != globals.url) { switch_safe_free(url_query); } } - -done: + + done: if (!cid) { cid = switch_core_alloc(pool, sizeof(cid_data_t)); switch_assert(cid); } /* append area if we can */ - if (!cid->area && - !skipcitystate && - strlen(number) == 11 && number[0] == '1' && - switch_odbc_available() && globals.odbc_dsn && globals.citystate_sql) { - + if (!cid->area && !skipcitystate && strlen(number) == 11 && number[0] == '1' && switch_odbc_available() && globals.odbc_dsn && globals.citystate_sql) { + /* yes, this is really area */ name = do_db_lookup(pool, event, number, globals.citystate_sql); if (name) { @@ -626,7 +620,7 @@ done: } } } - + if (!cid->area) { cid->area = "UNKNOWN"; } @@ -636,11 +630,11 @@ done: if (!cid->src) { cid->src = "UNKNOWN"; } - + if (globals.cache && save_cache) { set_cache(pool, number, cid); } - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cidlookup source: %s\n", cid->src); return cid; @@ -649,7 +643,7 @@ done: SWITCH_STANDARD_APP(cidlookup_app_function) { switch_status_t status = SWITCH_STATUS_SUCCESS; - + char *argv[4] = { 0 }; int argc; char *mydata = NULL; @@ -663,7 +657,7 @@ SWITCH_STANDARD_APP(cidlookup_app_function) const char *number = NULL; switch_bool_t skipurl = SWITCH_FALSE; switch_bool_t skipcitystate = SWITCH_FALSE; - + if (session) { pool = switch_core_session_get_pool(session); } else { @@ -674,7 +668,7 @@ SWITCH_STANDARD_APP(cidlookup_app_function) if (!(mydata = switch_core_session_strdup(session, data))) { return; } - + if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc > 0) { number = switch_core_session_strdup(session, argv[0]); @@ -687,20 +681,20 @@ SWITCH_STANDARD_APP(cidlookup_app_function) } } } - + if (!number && profile) { number = switch_caller_get_field_by_name(profile, "caller_id_number"); } - + if (number) { cid = do_lookup(pool, event, number, skipurl, skipcitystate); } - + if (switch_string_var_check_const(cid->name)) { - switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name); + switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name); switch_goto_status(SWITCH_STATUS_GENERR, done); } - + if (cid && channel) { switch_channel_set_variable(channel, "original_caller_id_name", switch_core_strdup(pool, profile->caller_id_name)); if (!zstr(cid->src)) { @@ -711,10 +705,10 @@ SWITCH_STANDARD_APP(cidlookup_app_function) } profile->caller_id_name = switch_core_strdup(profile->pool, cid->name);; } - + switch_goto_status(SWITCH_STATUS_SUCCESS, done); - -done: + + done: if (event) { switch_event_destroy(&event); } @@ -722,6 +716,7 @@ done: switch_core_destroy_memory_pool(&pool); } } + SWITCH_STANDARD_API(cidlookup_function) { switch_status_t status; @@ -736,7 +731,7 @@ SWITCH_STANDARD_API(cidlookup_function) switch_bool_t skipurl = SWITCH_FALSE; switch_bool_t skipcitystate = SWITCH_FALSE; switch_bool_t verbose = SWITCH_FALSE; - + if (zstr(cmd)) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } @@ -753,22 +748,18 @@ SWITCH_STANDARD_API(cidlookup_function) if (argc < 1) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } - + if (!strcmp("status", argv[0])) { - stream->write_function(stream, "+OK\n url: %s\n cache: %s\n cache-expire: %d\n", - globals.url ? globals.url : "(null)", - (globals.cache) ? "true" : "false", - globals.cache_expire); - stream->write_function(stream, " curl-timeout: %" SWITCH_TIME_T_FMT "\n curl-warn-duration: %" SWITCH_TIME_T_FMT "\n", - globals.curl_timeout, - globals.curl_warnduration); - - stream->write_function(stream, " odbc-dsn: %s\n sql: %s\n citystate-sql: %s\n", - globals.odbc_dsn ? globals.odbc_dsn : "(null)", - globals.sql ? globals.sql : "(null)", - globals.citystate_sql ? globals.citystate_sql : "(null)"); - stream->write_function(stream, " ODBC Compiled: %s\n", switch_odbc_available() ? "true" : "false"); - + stream->write_function(stream, "+OK\n url: %s\n cache: %s\n cache-expire: %d\n", + globals.url ? globals.url : "(null)", (globals.cache) ? "true" : "false", globals.cache_expire); + stream->write_function(stream, " curl-timeout: %" SWITCH_TIME_T_FMT "\n curl-warn-duration: %" SWITCH_TIME_T_FMT "\n", + globals.curl_timeout, globals.curl_warnduration); + + stream->write_function(stream, " odbc-dsn: %s\n sql: %s\n citystate-sql: %s\n", + globals.odbc_dsn ? globals.odbc_dsn : "(null)", + globals.sql ? globals.sql : "(null)", globals.citystate_sql ? globals.citystate_sql : "(null)"); + stream->write_function(stream, " ODBC Compiled: %s\n", switch_odbc_available()? "true" : "false"); + switch_goto_status(SWITCH_STATUS_SUCCESS, done); } for (i = 1; i < argc; i++) { @@ -784,7 +775,7 @@ SWITCH_STANDARD_API(cidlookup_function) cid = do_lookup(pool, event, argv[0], skipurl, skipcitystate); if (cid) { if (switch_string_var_check_const(cid->name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name); stream->write_function(stream, "-ERR Invalid CID data {%s} contains a variable\n", cid->name); switch_goto_status(SWITCH_STATUS_SUCCESS, done); } @@ -798,11 +789,11 @@ SWITCH_STANDARD_API(cidlookup_function) } switch_goto_status(SWITCH_STATUS_SUCCESS, done); -usage: + usage: stream->write_function(stream, "-ERR\n%s\n", SYNTAX); switch_goto_status(status, done); - -done: + + done: switch_safe_free(mydata); if (event) { switch_event_destroy(&event); @@ -822,16 +813,16 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cidlookup_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); memset(&globals, 0, sizeof(globals)); - + globals.pool = pool; do_config(SWITCH_FALSE); - + if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &reload_xml_event) != SWITCH_STATUS_SUCCESS)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event!\n"); return SWITCH_STATUS_TERM; } - + SWITCH_ADD_API(api_interface, "cidlookup", "cidlookup API", cidlookup_function, SYNTAX); SWITCH_ADD_APP(app_interface, "cidlookup", "Perform a CID lookup", "Perform a CID lookup", cidlookup_app_function, "[number [skipurl]]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); diff --git a/src/mod/applications/mod_cluechoo/mod_cluechoo.c b/src/mod/applications/mod_cluechoo/mod_cluechoo.c index d36948ba7f..ab14b757aa 100644 --- a/src/mod/applications/mod_cluechoo/mod_cluechoo.c +++ b/src/mod/applications/mod_cluechoo/mod_cluechoo.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -52,11 +52,11 @@ int vgo(int i, switch_core_session_t *session); SWITCH_STANDARD_APP(cluechoo_app) { switch_channel_t *channel = switch_core_session_get_channel(session); - + switch_channel_answer(channel); switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL); - while(switch_channel_ready(channel)) { + while (switch_channel_ready(channel)) { if (vgo(0, session) < 0) { break; } @@ -66,7 +66,7 @@ SWITCH_STANDARD_APP(cluechoo_app) SWITCH_STANDARD_API(cluechoo_function) { //stream->write_function(stream, "+OK Reloading\n"); - + go(0); return SWITCH_STATUS_SUCCESS; } @@ -81,7 +81,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_cluechoo_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n"); - + SWITCH_ADD_API(api_interface, "cluechoo", "Cluechoo API", cluechoo_function, "syntax"); SWITCH_ADD_APP(app_interface, "cluechoo", "cluechoo", "cluechoo", cluechoo_app, "", SAF_NONE); @@ -134,36 +134,45 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cluechoo_shutdown) #include #include "sl.h" -int ACCIDENT = 0; -int LOGO = 0; -int FLY = 0; +int ACCIDENT = 0; +int LOGO = 0; +int FLY = 0; int my_mvaddstr(int y, int x, char *str) { - for ( ; x < 0; ++x, ++str) - if (*str == '\0') return ERR; - for ( ; *str != '\0'; ++str, ++x) - if (mvaddch(y, x, *str) == ERR) return ERR; - return OK; + for (; x < 0; ++x, ++str) + if (*str == '\0') + return ERR; + for (; *str != '\0'; ++str, ++x) + if (mvaddch(y, x, *str) == ERR) + return ERR; + return OK; } void option(char *str) { - extern int ACCIDENT, FLY; + extern int ACCIDENT, FLY; - while (*str != '\0') { + while (*str != '\0') { switch (*str++) { - case 'a': ACCIDENT = 1; break; - case 'F': FLY = 1; break; - case 'l': LOGO = 1; break; - default: break; + case 'a': + ACCIDENT = 1; + break; + case 'F': + FLY = 1; + break; + case 'l': + LOGO = 1; + break; + default: + break; } - } + } } int go(int i) { - int x; + int x; int sleep_len = 40000; if (i > 0) { @@ -171,23 +180,25 @@ int go(int i) } /* - for (i = 1; i < argc; ++i) { - if (*argv[i] == '-') { - option(argv[i] + 1); - } - } - */ - initscr(); - signal(SIGINT, SIG_IGN); - noecho(); - leaveok(stdscr, TRUE); - scrollok(stdscr, FALSE); + for (i = 1; i < argc; ++i) { + if (*argv[i] == '-') { + option(argv[i] + 1); + } + } + */ + initscr(); + signal(SIGINT, SIG_IGN); + noecho(); + leaveok(stdscr, TRUE); + scrollok(stdscr, FALSE); - for (x = COLS - 1; ; --x) { + for (x = COLS - 1;; --x) { if (LOGO == 0) { - if (add_D51(x) == ERR) break; + if (add_D51(x) == ERR) + break; } else { - if (add_sl(x) == ERR) break; + if (add_sl(x) == ERR) + break; } refresh(); if (x == COLS / 4) { @@ -195,9 +206,9 @@ int go(int i) } else { usleep(sleep_len); } - } - mvcur(0, COLS - 1, LINES - 1, 0); - endwin(); + } + mvcur(0, COLS - 1, LINES - 1, 0); + endwin(); return 0; } @@ -205,20 +216,20 @@ int go(int i) int vgo(int i, switch_core_session_t *session) { - int x; + int x; int sleep_len = 40000; switch_channel_t *channel = switch_core_session_get_channel(session); switch_frame_t *read_frame; switch_status_t status; - switch_codec_implementation_t read_impl = {0}; - switch_codec_t codec = {0}; + switch_codec_implementation_t read_impl = { 0 }; + switch_codec_t codec = { 0 }; int hangover_hits = 0, hangunder_hits = 0; int diff_level = 400; int hangover = 40, hangunder = 15; int talking = 0; int energy_level = 500; int done = 0; - switch_core_session_get_read_impl(session, &read_impl); + switch_core_session_get_read_impl(session, &read_impl); printf("%s", SWITCH_SEQ_CLEARSCR); @@ -226,16 +237,16 @@ int vgo(int i, switch_core_session_t *session) sleep_len = i; } - initscr(); - signal(SIGINT, SIG_IGN); - noecho(); - leaveok(stdscr, TRUE); - scrollok(stdscr, FALSE); + initscr(); + signal(SIGINT, SIG_IGN); + noecho(); + leaveok(stdscr, TRUE); + scrollok(stdscr, FALSE); if (switch_core_codec_init(&codec, "L16", - NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000, + NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) { return -1; @@ -243,28 +254,27 @@ int vgo(int i, switch_core_session_t *session) switch_core_session_set_read_codec(session, &codec); - for (x = COLS - 1; ; --x) { + for (x = COLS - 1;; --x) { if (!done && !switch_channel_ready(channel)) { done = 1; } - + if (!done) { status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0); if (!SWITCH_READ_ACCEPTABLE(status)) { done = 1; } } - - if (!done) - { + + if (!done) { int16_t *fdata = (int16_t *) read_frame->data; uint32_t samples = read_frame->datalen / sizeof(*fdata); uint32_t score, count = 0, j = 0; double energy = 0; int divisor = 0; - + for (count = 0; count < samples; count++) { energy += abs(fdata[j]); j += read_impl.number_of_channels; @@ -275,7 +285,7 @@ int vgo(int i, switch_core_session_t *session) } score = (uint32_t) (energy / (samples / divisor)); - + if (score > energy_level) { uint32_t diff = score - energy_level; if (hangover_hits) { @@ -284,7 +294,7 @@ int vgo(int i, switch_core_session_t *session) if (diff >= diff_level || ++hangunder_hits >= hangunder) { hangover_hits = hangunder_hits = 0; - + if (!talking) { talking = 1; } @@ -310,22 +320,24 @@ int vgo(int i, switch_core_session_t *session) } if (LOGO == 0) { - if (add_D51(x) == ERR) break; + if (add_D51(x) == ERR) + break; } else { - if (add_sl(x) == ERR) break; + if (add_sl(x) == ERR) + break; } refresh(); /* - if (x == COLS / 4) { - sleep(2); - } else { - usleep(sleep_len); - } - */ - } - mvcur(0, COLS - 1, LINES - 1, 0); - endwin(); + if (x == COLS / 4) { + sleep(2); + } else { + usleep(sleep_len); + } + */ + } + mvcur(0, COLS - 1, LINES - 1, 0); + endwin(); switch_core_session_set_read_codec(session, NULL); switch_core_codec_destroy(&codec); @@ -335,103 +347,114 @@ int vgo(int i, switch_core_session_t *session) int add_sl(int x) { - static char *sl[LOGOPATTERNS][LOGOHIGHT + 1] - = {{LOGO1, LOGO2, LOGO3, LOGO4, LWHL11, LWHL12, DELLN}, - {LOGO1, LOGO2, LOGO3, LOGO4, LWHL21, LWHL22, DELLN}, - {LOGO1, LOGO2, LOGO3, LOGO4, LWHL31, LWHL32, DELLN}, - {LOGO1, LOGO2, LOGO3, LOGO4, LWHL41, LWHL42, DELLN}, - {LOGO1, LOGO2, LOGO3, LOGO4, LWHL51, LWHL52, DELLN}, - {LOGO1, LOGO2, LOGO3, LOGO4, LWHL61, LWHL62, DELLN}}; + static char *sl[LOGOPATTERNS][LOGOHIGHT + 1] + = { {LOGO1, LOGO2, LOGO3, LOGO4, LWHL11, LWHL12, DELLN}, + {LOGO1, LOGO2, LOGO3, LOGO4, LWHL21, LWHL22, DELLN}, + {LOGO1, LOGO2, LOGO3, LOGO4, LWHL31, LWHL32, DELLN}, + {LOGO1, LOGO2, LOGO3, LOGO4, LWHL41, LWHL42, DELLN}, + {LOGO1, LOGO2, LOGO3, LOGO4, LWHL51, LWHL52, DELLN}, + {LOGO1, LOGO2, LOGO3, LOGO4, LWHL61, LWHL62, DELLN} + }; - static char *coal[LOGOHIGHT + 1] - = {LCOAL1, LCOAL2, LCOAL3, LCOAL4, LCOAL5, LCOAL6, DELLN}; + static char *coal[LOGOHIGHT + 1] + = { LCOAL1, LCOAL2, LCOAL3, LCOAL4, LCOAL5, LCOAL6, DELLN }; - static char *car[LOGOHIGHT + 1] - = {LCAR1, LCAR2, LCAR3, LCAR4, LCAR5, LCAR6, DELLN}; + static char *car[LOGOHIGHT + 1] + = { LCAR1, LCAR2, LCAR3, LCAR4, LCAR5, LCAR6, DELLN }; - int i, y, py1 = 0, py2 = 0, py3 = 0; - - if (x < - LOGOLENGTH) return ERR; - y = LINES / 2 - 3; + int i, y, py1 = 0, py2 = 0, py3 = 0; - if (FLY == 1) { + if (x < -LOGOLENGTH) + return ERR; + y = LINES / 2 - 3; + + if (FLY == 1) { y = (x / 6) + LINES - (COLS / 6) - LOGOHIGHT; - py1 = 2; py2 = 4; py3 = 6; - } + py1 = 2; + py2 = 4; + py3 = 6; + } - for (i = 0; i <= LOGOHIGHT; ++i) { + for (i = 0; i <= LOGOHIGHT; ++i) { my_mvaddstr(y + i, x, sl[(LOGOLENGTH + x) / 3 % LOGOPATTERNS][i]); my_mvaddstr(y + i + py1, x + 21, coal[i]); my_mvaddstr(y + i + py2, x + 42, car[i]); my_mvaddstr(y + i + py3, x + 63, car[i]); - } - if (ACCIDENT == 1) { + } + if (ACCIDENT == 1) { add_man(y + 1, x + 14); - add_man(y + 1 + py2, x + 45); add_man(y + 1 + py2, x + 53); - add_man(y + 1 + py3, x + 66); add_man(y + 1 + py3, x + 74); - } - add_smoke(y - 1, x + LOGOFUNNEL); - return OK; + add_man(y + 1 + py2, x + 45); + add_man(y + 1 + py2, x + 53); + add_man(y + 1 + py3, x + 66); + add_man(y + 1 + py3, x + 74); + } + add_smoke(y - 1, x + LOGOFUNNEL); + return OK; } static int loops = 0; int add_D51(int x) { - static char *d51[D51PATTERNS][D51HIGHT + 1] - = {{D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL11, D51WHL12, D51WHL13, D51DEL}, - {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL21, D51WHL22, D51WHL23, D51DEL}, - {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL31, D51WHL32, D51WHL33, D51DEL}, - {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL41, D51WHL42, D51WHL43, D51DEL}, - {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL51, D51WHL52, D51WHL53, D51DEL}, - {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, - D51WHL61, D51WHL62, D51WHL63, D51DEL}}; - static char *coal[D51HIGHT + 1] - = {COAL01, COAL02, COAL03, COAL04, COAL05, - COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL}; + static char *d51[D51PATTERNS][D51HIGHT + 1] + = { {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL11, D51WHL12, D51WHL13, D51DEL}, + {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL21, D51WHL22, D51WHL23, D51DEL}, + {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL31, D51WHL32, D51WHL33, D51DEL}, + {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL41, D51WHL42, D51WHL43, D51DEL}, + {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL51, D51WHL52, D51WHL53, D51DEL}, + {D51STR1, D51STR2, D51STR3, D51STR4, D51STR5, D51STR6, D51STR7, + D51WHL61, D51WHL62, D51WHL63, D51DEL} + }; + static char *coal[D51HIGHT + 1] + = { COAL01, COAL02, COAL03, COAL04, COAL05, + COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL + }; - static char *acoal[D51HIGHT + 1] - = {COAL01, COAL02, COAL03, COAL04, COAL5A, - COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL}; + static char *acoal[D51HIGHT + 1] + = { COAL01, COAL02, COAL03, COAL04, COAL5A, + COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL + }; - int y, i, dy = 0; + int y, i, dy = 0; - if (x < - D51LENGTH) return ERR; - y = LINES / 2 - 5; + if (x < -D51LENGTH) + return ERR; + y = LINES / 2 - 5; - if (FLY == 1) { + if (FLY == 1) { y = (x / 7) + LINES - (COLS / 7) - D51HIGHT; dy = 1; - } + } - for (i = 0; i <= D51HIGHT; ++i) { + for (i = 0; i <= D51HIGHT; ++i) { my_mvaddstr(y + i, x, d51[(D51LENGTH + x) % D51PATTERNS][i]); my_mvaddstr(y + i + dy, x + 53, loops > 60 ? coal[i] : acoal[i]); loops++; - if (loops == 500) loops = -100; - } - if (ACCIDENT == 1) { + if (loops == 500) + loops = -100; + } + if (ACCIDENT == 1) { add_man(y + 2, x + 43); add_man(y + 2, x + 47); - } - add_smoke(y - 1, x + D51FUNNEL); - return OK; + } + add_smoke(y - 1, x + D51FUNNEL); + return OK; } int add_man(int y, int x) { - static char *man[2][2] = {{"", "(O)"}, {"Help!", "\\O/"}}; - int i; + static char *man[2][2] = { {"", "(O)"}, {"Help!", "\\O/"} }; + int i; - for (i = 0; i < 2; ++i) { + for (i = 0; i < 2; ++i) { my_mvaddstr(y + i, x, man[(LOGOLENGTH + x) / 12 % 2][i]); - } + } return 0; } @@ -440,45 +463,51 @@ int add_man(int y, int x) int add_smoke(int y, int x) #define SMOKEPTNS 16 { - static struct smokes { + static struct smokes { int y, x; int ptrn, kind; - } S[1000]; - static int sum = 0; - static char *Smoke[2][SMOKEPTNS] - = {{"( )", "( )", "( )", "( )", "( )", - "( )" , "( )" , "( )" , "()" , "()" , - "O" , "O" , "O" , "O" , "O" , - " " }, - {"(@@@)", "(@@@@)", "(@@@@)", "(@@@)", "(@@)", - "(@@)" , "(@)" , "(@)" , "@@" , "@@" , - "@" , "@" , "@" , "@" , "@" , - " " }}; - static char *Eraser[SMOKEPTNS] - = {" ", " ", " ", " ", " ", - " " , " " , " " , " " , " " , - " " , " " , " " , " " , " " , - " " }; - static int dy[SMOKEPTNS] = { 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0 }; - static int dx[SMOKEPTNS] = {-2, -1, 0, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 3, 3, 3 }; - int i; + } S[1000]; + static int sum = 0; + static char *Smoke[2][SMOKEPTNS] + = { {"( )", "( )", "( )", "( )", "( )", + "( )", "( )", "( )", "()", "()", + "O", "O", "O", "O", "O", + " "}, + {"(@@@)", "(@@@@)", "(@@@@)", "(@@@)", "(@@)", + "(@@)", "(@)", "(@)", "@@", "@@", + "@", "@", "@", "@", "@", + " "} + }; + static char *Eraser[SMOKEPTNS] + = { " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " ", " ", " ", " ", " ", + " " + }; + static int dy[SMOKEPTNS] = { 2, 1, 1, 1, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0 + }; + static int dx[SMOKEPTNS] = { -2, -1, 0, 1, 1, 1, 1, 1, 2, 2, + 2, 2, 2, 3, 3, 3 + }; + int i; - if (x % 4 == 0) { + if (x % 4 == 0) { for (i = 0; i < sum; ++i) { my_mvaddstr(S[i].y, S[i].x, Eraser[S[i].ptrn]); - S[i].y -= dy[S[i].ptrn]; - S[i].x += dx[S[i].ptrn]; + S[i].y -= dy[S[i].ptrn]; + S[i].x += dx[S[i].ptrn]; S[i].ptrn += (S[i].ptrn < SMOKEPTNS - 1) ? 1 : 0; my_mvaddstr(S[i].y, S[i].x, Smoke[S[i].kind][S[i].ptrn]); } my_mvaddstr(y, x, Smoke[sum % 2][0]); - S[sum].y = y; S[sum].x = x; - S[sum].ptrn = 0; S[sum].kind = sum % 2; - sum ++; - } - + S[sum].y = y; + S[sum].x = x; + S[sum].ptrn = 0; + S[sum].kind = sum % 2; + sum++; + } + return 0; } diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 5c192213fd..e9b4001356 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -53,7 +53,7 @@ SWITCH_STANDARD_API(banner_function) SWITCH_STANDARD_API(hostname_api_function) { - char hostname[256]=""; + char hostname[256] = ""; gethostname(hostname, sizeof(hostname)); stream->write_function(stream, "%s", hostname); return SWITCH_STATUS_SUCCESS; @@ -77,14 +77,15 @@ SWITCH_STANDARD_API(version_function) return SWITCH_STATUS_SUCCESS; } -SWITCH_STANDARD_API(db_cache_function) { +SWITCH_STANDARD_API(db_cache_function) +{ int argc; char *mydata = NULL, *argv[2]; if (zstr(cmd)) { goto error; } - + mydata = strdup(cmd); switch_assert(mydata); @@ -99,12 +100,12 @@ SWITCH_STANDARD_API(db_cache_function) { } else { goto error; } - -error: - stream->write_function(stream, "%s", "parameter missing\n"); -ok: - switch_safe_free(mydata); - return SWITCH_STATUS_SUCCESS; + + error: + stream->write_function(stream, "%s", "parameter missing\n"); + ok: + switch_safe_free(mydata); + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(host_lookup_function) @@ -136,7 +137,7 @@ SWITCH_STANDARD_API(nat_map_function) if (!cmd) { goto error; } - + if (!switch_nat_is_initialized()) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "nat_map API called while NAT not initialized\n"); goto error; @@ -166,7 +167,7 @@ SWITCH_STANDARD_API(nat_map_function) switch_safe_free(tmp); goto ok; } - + if (argc < 3) { goto error; } @@ -176,18 +177,18 @@ SWITCH_STANDARD_API(nat_map_function) } else if (argv[2] && switch_stristr("udp", argv[2])) { proto = SWITCH_NAT_UDP; } - + if (argv[3] && switch_stristr("sticky", argv[3])) { sticky = SWITCH_TRUE; } if (argv[0] && switch_stristr("add", argv[0])) { - if (switch_nat_add_mapping((switch_port_t)atoi(argv[1]), proto, &external_port, sticky) == SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "true"); /* still return true */ + if (switch_nat_add_mapping((switch_port_t) atoi(argv[1]), proto, &external_port, sticky) == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "true"); /* still return true */ goto ok; } } else if (argv[0] && switch_stristr("del", argv[0])) { - if (switch_nat_del_mapping((switch_port_t)atoi(argv[1]), proto) == SWITCH_STATUS_SUCCESS) { + if (switch_nat_del_mapping((switch_port_t) atoi(argv[1]), proto) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "true"); goto ok; } @@ -213,7 +214,7 @@ SWITCH_STANDARD_API(time_test_function) int diff; int max = 10, a = 0; char *p; - if (zstr(cmd)){ + if (zstr(cmd)) { stream->write_function(stream, "parameter missing\n"); return SWITCH_STATUS_SUCCESS; } @@ -225,7 +226,7 @@ SWITCH_STANDARD_API(time_test_function) } if ((p = strchr(cmd, ' '))) { - if ((a = atoi(p+1)) > 0) { + if ((a = atoi(p + 1)) > 0) { max = a; if (max > 100) { max = 100; @@ -262,7 +263,7 @@ SWITCH_STANDARD_API(timer_test_function) const char *timer_name = "soft"; switch_memory_pool_t *pool; char *mycmd = NULL; - + switch_core_new_memory_pool(&pool); if (zstr(cmd)) { @@ -272,7 +273,7 @@ SWITCH_STANDARD_API(timer_test_function) } argc = switch_split(mycmd, ' ', argv); - + if (argc > 0) { mss = atoi(argv[0]); } @@ -292,14 +293,12 @@ SWITCH_STANDARD_API(timer_test_function) stream->write_function(stream, "parameter missing: %s\n", TIMER_TEST_SYNTAX); goto end; } - - if (switch_core_timer_init(&timer, - timer_name, mss, - 1, pool) != SWITCH_STATUS_SUCCESS) { + + if (switch_core_timer_init(&timer, timer_name, mss, 1, pool) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "Timer Error!\n"); goto end; } - + start = switch_time_now(); for (x = 1; x <= max; x++) { then = switch_time_now(); @@ -311,15 +310,16 @@ SWITCH_STANDARD_API(timer_test_function) total += diff; } end = switch_time_now(); - + switch_yield(250000); - stream->write_function(stream, "Avg: %0.3fms Total Time: %0.3fms\n", (float)((float)(total / (x > 1 ? x - 1 : 1)) / 1000), (float)((float)(end - start)/1000)); + stream->write_function(stream, "Avg: %0.3fms Total Time: %0.3fms\n", (float) ((float) (total / (x > 1 ? x - 1 : 1)) / 1000), + (float) ((float) (end - start) / 1000)); + + end: - end: - switch_core_destroy_memory_pool(&pool); - + return SWITCH_STATUS_SUCCESS; } @@ -348,7 +348,7 @@ SWITCH_STANDARD_API(group_call_function) if ((flags = strchr(group_name, '+'))) { *flags++ = '\0'; for (fp = flags; fp && *fp; fp++) { - switch(*fp) { + switch (*fp) { case 'F': call_delim = "|"; break; @@ -363,15 +363,15 @@ SWITCH_STANDARD_API(group_call_function) } } } - + domain = strchr(group_name, '@'); - + if (domain) { *domain++ = '\0'; } else { domain = switch_core_get_variable("domain"); } - + if (!zstr(domain)) { switch_xml_t xml, x_domain, x_group; switch_event_t *params; @@ -383,14 +383,14 @@ SWITCH_STANDARD_API(group_call_function) switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "group", group_name); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "group_call"); - + if (switch_xml_locate_group(group_name, domain, &xml, &x_domain, &x_group, params) == SWITCH_STATUS_SUCCESS) { switch_xml_t x_user, x_users, x_param, x_params, my_x_user; - + if ((x_users = switch_xml_child(x_group, "users"))) { ok++; - - for(x_user = switch_xml_child(x_users, "user"); x_user; x_user = x_user->next) { + + for (x_user = switch_xml_child(x_users, "user"); x_user; x_user = x_user->next) { const char *id = switch_xml_attr_soft(x_user, "id"); const char *x_user_type = switch_xml_attr_soft(x_user, "type"); const char *dest = NULL; @@ -399,17 +399,16 @@ SWITCH_STANDARD_API(group_call_function) my_x_user = x_user; - if (!strcmp(x_user_type,"pointer")) { + if (!strcmp(x_user_type, "pointer")) { if (switch_xml_locate_user("id", id, domain, NULL, &xml_for_pointer, &x_domain_for_pointer, - &x_user_for_pointer, &x_group_for_pointer, - params) != SWITCH_STATUS_SUCCESS) { + &x_user_for_pointer, &x_group_for_pointer, params) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", id, domain); goto done_x_user; } my_x_user = x_user_for_pointer; } - + if ((x_params = switch_xml_child(x_domain, "params"))) { for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) { const char *var = switch_xml_attr(x_param, "name"); @@ -446,7 +445,7 @@ SWITCH_STANDARD_API(group_call_function) for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) { const char *var = switch_xml_attr(x_param, "name"); const char *val = switch_xml_attr(x_param, "value"); - + if (!strcasecmp(var, "group-dial-string")) { dest = val; break; @@ -457,7 +456,7 @@ SWITCH_STANDARD_API(group_call_function) } } } - + if (dest) { if (channel) { switch_channel_set_variable(channel, "dialed_group", group_name); @@ -476,7 +475,7 @@ SWITCH_STANDARD_API(group_call_function) } else { d_dest = switch_mprintf("user/%s@%s", id, domain); } - + if (d_dest) { dstream.write_function(&dstream, "%s%s", d_dest, call_delim); @@ -485,9 +484,9 @@ SWITCH_STANDARD_API(group_call_function) } } - done_x_user: + done_x_user: if (xml_for_pointer) { - switch_xml_free(xml_for_pointer); + switch_xml_free(xml_for_pointer); xml_for_pointer = NULL; } } @@ -514,17 +513,17 @@ SWITCH_STANDARD_API(group_call_function) } else { ok = 0; } - + } } switch_xml_free(xml); switch_event_destroy(¶ms); } - end: + end: switch_safe_free(group_name); - + if (!ok) { stream->write_function(stream, "error/NO_ROUTE_DESTINATION"); } @@ -542,7 +541,7 @@ SWITCH_STANDARD_API(in_group_function) switch_event_t *params = NULL; const char *rval = "false"; char *group; - + if (zstr(cmd) || !(mydata = strdup(cmd))) { goto end; } @@ -574,9 +573,9 @@ SWITCH_STANDARD_API(in_group_function) } end: - + stream->write_function(stream, "%s", rval); - + switch_xml_free(xml); switch_safe_free(mydata); switch_event_destroy(¶ms); @@ -612,7 +611,7 @@ SWITCH_STANDARD_API(user_data_function) domain = "cluecon.com"; } } - + switch_event_create(¶ms, SWITCH_EVENT_REQUEST_PARAMS); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "user", user); switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain); @@ -642,7 +641,7 @@ SWITCH_STANDARD_API(user_data_function) } } - + if ((x_params = switch_xml_child(x_domain, container))) { for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) { const char *var = switch_xml_attr(x_param, "name"); @@ -733,9 +732,9 @@ static switch_status_t _find_user(const char *cmd, switch_core_session_t *sessio free(xmlstr); } } - + switch_xml_free(xml); - + switch_safe_free(mydata); return SWITCH_STATUS_SUCCESS; } @@ -753,7 +752,7 @@ SWITCH_STANDARD_API(md5_function) stream->write_function(stream, "%s", digest); } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(url_decode_function) @@ -766,11 +765,11 @@ SWITCH_STANDARD_API(url_decode_function) switch_url_decode(data); reply = data; } - + stream->write_function(stream, "%s", reply); switch_safe_free(data); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(echo_function) @@ -782,7 +781,7 @@ SWITCH_STANDARD_API(echo_function) SWITCH_STANDARD_API(stun_function) { char *stun_ip = NULL; - switch_port_t stun_port = (switch_port_t)SWITCH_STUN_DEFAULT_PORT; + switch_port_t stun_port = (switch_port_t) SWITCH_STUN_DEFAULT_PORT; char *p; char ip_buf[256] = ""; char *ip = NULL; @@ -849,7 +848,7 @@ SWITCH_STANDARD_API(expand_function) const char *p; switch_core_session_t *xsession; char uuid[80] = ""; - + if (zstr(cmd)) { stream->write_function(stream, "-ERR, no input\n"); return SWITCH_STATUS_SUCCESS; @@ -864,7 +863,7 @@ SWITCH_STANDARD_API(expand_function) switch_copy_string(uuid, p, mycmd - p); } } - + if (zstr(mycmd)) { stream->write_function(stream, "-ERR, no input\n"); return SWITCH_STATUS_SUCCESS; @@ -905,7 +904,7 @@ SWITCH_STANDARD_API(console_complete_function) if (zstr(cmd)) { cmd = " "; } - + if ((p = strstr(cmd, "c="))) { p += 2; c = atoi(p); @@ -929,7 +928,7 @@ SWITCH_STANDARD_API(console_complete_xml_function) if (zstr(cmd)) { cmd = " "; } - + if ((p = strstr(cmd, "c="))) { p += 2; c = atoi(p); @@ -940,13 +939,13 @@ SWITCH_STANDARD_API(console_complete_xml_function) } switch_console_complete(cmd, cursor, NULL, NULL, xml); - + sxml = switch_xml_toxml(xml, SWITCH_TRUE); stream->write_function(stream, "%s", sxml); free(sxml); - + switch_xml_free(xml); - + return SWITCH_STATUS_SUCCESS; } @@ -961,20 +960,20 @@ SWITCH_STANDARD_API(eval_function) stream->write_function(stream, "%s", ""); return SWITCH_STATUS_SUCCESS; } - + if (!strncasecmp(cmd, "uuid:", 5)) { p = cmd + 5; if ((input = strchr(p, ' ')) && *input++) { switch_copy_string(uuid, p, input - p); } } - + if (zstr(input)) { stream->write_function(stream, "%s", ""); return SWITCH_STATUS_SUCCESS; } - + switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA); if (*uuid) { if ((session = switch_core_session_locate(uuid))) { @@ -984,14 +983,14 @@ SWITCH_STANDARD_API(eval_function) } expanded = switch_event_expand_headers(event, input); - + stream->write_function(stream, "%s", expanded); if (expanded != input) { free(expanded); } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(module_exists_function) @@ -1001,25 +1000,25 @@ SWITCH_STANDARD_API(module_exists_function) stream->write_function(stream, "true"); } else { stream->write_function(stream, "false"); - } + } } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(domain_exists_function) { switch_xml_t root = NULL, domain = NULL; - - if (!zstr(cmd)) { + + if (!zstr(cmd)) { if (switch_xml_locate_domain(cmd, NULL, &root, &domain) == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "true"); - switch_xml_free(root); + switch_xml_free(root); } else { stream->write_function(stream, "false"); } } - + return SWITCH_STATUS_SUCCESS; } @@ -1027,7 +1026,7 @@ SWITCH_STANDARD_API(url_encode_function) { char *reply = ""; char *data = NULL; - int len = 0 ; + int len = 0; if (!zstr(cmd)) { len = (strlen(cmd) * 3) + 1; @@ -1039,7 +1038,7 @@ SWITCH_STANDARD_API(url_encode_function) stream->write_function(stream, "%s", reply); switch_safe_free(data); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } @@ -1213,7 +1212,7 @@ SWITCH_STANDARD_API(regex_function) mydata = strdup(cmd); switch_assert(mydata); - + d = mydata; if (*d == 'm' && *(d + 1) == ':' && *(d + 2)) { @@ -1230,7 +1229,7 @@ SWITCH_STANDARD_API(regex_function) break; } } - + argc = switch_separate_string(d, delim, argv, (sizeof(argv) / sizeof(argv[0]))); @@ -1645,10 +1644,10 @@ SWITCH_STANDARD_API(unload_function) if (*p == '-') { p++; - while(p && *p) { + while (p && *p) { switch (*p) { case ' ': - cmd = p+1; + cmd = p + 1; goto end; case 'f': force = SWITCH_TRUE; @@ -1659,7 +1658,7 @@ SWITCH_STANDARD_API(unload_function) p++; } } - end: + end: if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); @@ -1688,10 +1687,10 @@ SWITCH_STANDARD_API(reload_function) if (*p == '-') { p++; - while(p && *p) { + while (p && *p) { switch (*p) { case ' ': - cmd = p+1; + cmd = p + 1; goto end; case 'f': force = SWITCH_TRUE; @@ -1702,7 +1701,7 @@ SWITCH_STANDARD_API(reload_function) p++; } } - end: + end: if (zstr(cmd)) { stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX); @@ -1759,9 +1758,9 @@ SWITCH_STANDARD_API(kill_function) stream->write_function(stream, "-ERR No Such Channel!\n"); } else { switch_channel_t *channel = switch_core_session_get_channel(ksession); - if (!zstr(kcause)){ + if (!zstr(kcause)) { cause = switch_channel_str2cause(kcause); - } + } switch_channel_hangup(channel, cause); switch_core_session_rwunlock(ksession); stream->write_function(stream, "+OK\n"); @@ -1792,16 +1791,16 @@ SWITCH_STANDARD_API(preprocess_function) stream->write_function(stream, "-ERR No Such Channel!\n"); goto done; } else { - switch_ivr_preprocess_session(ksession, (char *)argv[1]); + switch_ivr_preprocess_session(ksession, (char *) argv[1]); switch_core_session_rwunlock(ksession); stream->write_function(stream, "+OK\n"); goto done; } - usage: + usage: stream->write_function(stream, "-USAGE: %s\n", PREPROCESS_SYNTAX); - done: + done: switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; } @@ -2349,7 +2348,7 @@ SWITCH_STANDARD_API(uuid_debug_audio_function) } else { switch_core_session_message_t msg = { 0 }; switch_core_session_t *lsession = NULL; - + msg.message_id = SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO; msg.string_array_arg[0] = argv[1]; msg.string_array_arg[1] = argv[2]; @@ -2366,8 +2365,8 @@ SWITCH_STANDARD_API(uuid_debug_audio_function) } else { stream->write_function(stream, "-ERR Operation Failed\n"); } - - done: + + done: switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; @@ -2446,8 +2445,8 @@ SWITCH_STANDARD_API(session_record_function) } if (!strcasecmp(action, "start")) { - if (switch_ivr_record_session(rsession, path, limit, NULL)!= SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "-ERR Cannot record session!\n"); + if (switch_ivr_record_session(rsession, path, limit, NULL) != SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "-ERR Cannot record session!\n"); } else { stream->write_function(stream, "+OK Success\n"); } @@ -2518,7 +2517,7 @@ SWITCH_STANDARD_API(session_displace_function) if (switch_ivr_stop_displace_session(rsession, path) != SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "-ERR Cannot stop displace session!\n"); } else { - stream->write_function(stream, "+OK Success\n"); + stream->write_function(stream, "+OK Success\n"); } } else { goto usage; @@ -2550,32 +2549,35 @@ SWITCH_STANDARD_API(session_audio_function) int level; if (zstr(cmd)) { - fail++; goto done; + fail++; + goto done; } mycmd = strdup(cmd); argc = switch_split(mycmd, ' ', argv); - + if (argc < 2) { - fail++; goto done; + fail++; + goto done; } - + if (!(u_session = switch_core_session_locate(argv[0]))) { stream->write_function(stream, "-ERR No Such Channel!\n"); goto done; } - + if (!strcasecmp(argv[1], "stop")) { switch_ivr_stop_session_audio(u_session); goto done; - } + } if (strcasecmp(argv[1], "start") || argc < 5 || (strcasecmp(argv[2], "read") && strcasecmp(argv[2], "write"))) { - fail++; goto done; + fail++; + goto done; } level = atoi(argv[4]); - + if (!strcasecmp(argv[3], "mute")) { switch_ivr_session_audio(u_session, "mute", argv[2], level); } else if (!strcasecmp(argv[3], "level")) { @@ -2584,7 +2586,7 @@ SWITCH_STANDARD_API(session_audio_function) fail++; } - done: + done: if (u_session) { switch_core_session_rwunlock(u_session); @@ -2637,7 +2639,7 @@ SWITCH_STANDARD_API(break_function) switch_channel_set_flag(channel, CF_BREAK); } - done: + done: if (psession) { switch_core_session_rwunlock(psession); } @@ -2895,7 +2897,7 @@ static void sch_api_callback(switch_scheduler_task_t *task) SWITCH_STANDARD_API(unsched_api_function) { uint32_t id; - + if (!cmd) { stream->write_function(stream, "-ERR Invalid syntax. USAGE: %s\n", UNSCHED_SYNTAX); return SWITCH_STATUS_SUCCESS; @@ -2955,7 +2957,7 @@ SWITCH_STANDARD_API(sched_api_function) } } - bad: + bad: stream->write_function(stream, "-ERR Invalid syntax. USAGE: %s\n", SCHED_SYNTAX); @@ -3085,12 +3087,12 @@ static int show_as_xml_callback(void *pArg, int argc, char **argv, char **column return -1; } } - + if (holder->justcount) { - holder->count++; - return 0; + holder->count++; + return 0; } - + if (!(row = switch_xml_add_child_d(holder->xml, "row", holder->rows++))) { return -1; } @@ -3123,12 +3125,12 @@ static int show_callback(void *pArg, int argc, char **argv, char **columnNames) { struct holder *holder = (struct holder *) pArg; int x; - + if (holder->justcount) { - holder->count++; - return 0; + holder->count++; + return 0; } - + if (holder->print_title && holder->count == 0) { if (holder->http) { holder->stream->write_function(holder->stream, "\n"); @@ -3215,22 +3217,22 @@ SWITCH_STANDARD_API(show_function) switch_status_t status = SWITCH_STATUS_SUCCESS; switch_core_db_handle(&db); - + holder.justcount = 0; - + if (cmd && (mydata = strdup(cmd))) { argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); command = argv[0]; if (argv[2] && !strcasecmp(argv[1], "as")) { as = argv[2]; } - + } if (stream->param_event) { const char *var; holder.http = switch_event_get_header(stream->param_event, "http-host"); - + if ((var = switch_event_get_header(stream->param_event, "content-type"))) { if (!strcasecmp(var, "text/plain")) { holder.http = NULL; @@ -3253,14 +3255,12 @@ SWITCH_STANDARD_API(show_function) if (!command) { stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX); goto end; - } else if (!strncasecmp(command, "codec", 5) || - !strncasecmp(command, "dialplan", 8) || - !strncasecmp(command, "file", 4) || - !strncasecmp(command, "timer", 5) || - !strncasecmp(command, "chat", 4) || - !strncasecmp(command, "say", 3) || - !strncasecmp(command, "management", 10) || - !strncasecmp(command, "endpoint", 8)) { + } else if (!strncasecmp(command, "codec", 5) || + !strncasecmp(command, "dialplan", 8) || + !strncasecmp(command, "file", 4) || + !strncasecmp(command, "timer", 5) || + !strncasecmp(command, "chat", 4) || + !strncasecmp(command, "say", 3) || !strncasecmp(command, "management", 10) || !strncasecmp(command, "endpoint", 8)) { if (end_of(command) == 's') { end_of(command) = '\0'; } @@ -3279,17 +3279,19 @@ SWITCH_STANDARD_API(show_function) sprintf(sql, "select * from %s", command); } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) { if (argv[1] && strcasecmp(argv[1], "as")) { - sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", command, argv[1]); + sprintf(sql, + "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", + command, argv[1]); } else { sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' order by type,name", command); } } else if (!strcasecmp(command, "calls")) { sprintf(sql, "select * from calls order by call_created_epoch"); - if (argv[1] && !strcasecmp(argv[1],"count")) { - holder.justcount = 1; - if (argv[3] && !strcasecmp(argv[2], "as")) { - as = argv[3]; - } + if (argv[1] && !strcasecmp(argv[1], "count")) { + holder.justcount = 1; + if (argv[3] && !strcasecmp(argv[2], "as")) { + as = argv[3]; + } } } else if (!strcasecmp(command, "channels") && argv[1] && !strcasecmp(argv[1], "like")) { if (argv[2]) { @@ -3300,27 +3302,29 @@ SWITCH_STANDARD_API(show_function) } } if (strchr(argv[2], '%')) { - sprintf(sql, "select * from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch", + sprintf(sql, + "select * from channels where uuid like '%s' or name like '%s' or cid_name like '%s' or cid_num like '%s' order by created_epoch", argv[2], argv[2], argv[2], argv[2]); } else { - sprintf(sql, "select * from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch", + sprintf(sql, + "select * from channels where uuid like '%%%s%%' or name like '%%%s%%' or cid_name like '%%%s%%' or cid_num like '%%%s%%' order by created_epoch", argv[2], argv[2], argv[2], argv[2]); } - - if (argv[4] && !strcasecmp(argv[3], "as")) { + + if (argv[4] && !strcasecmp(argv[3], "as")) { as = argv[4]; - } + } } else { sprintf(sql, "select * from channels order by created_epoch"); } } else if (!strcasecmp(command, "channels")) { sprintf(sql, "select * from channels order by created_epoch"); - if (argv[1] && !strcasecmp(argv[1],"count")) { - holder.justcount = 1; - if (argv[3] && !strcasecmp(argv[2], "as")) { + if (argv[1] && !strcasecmp(argv[1], "count")) { + holder.justcount = 1; + if (argv[3] && !strcasecmp(argv[2], "as")) { as = argv[3]; - } + } } } else if (!strcasecmp(command, "distinct_channels")) { sprintf(sql, "select * from channels left join calls on " @@ -3339,23 +3343,18 @@ SWITCH_STANDARD_API(show_function) holder.print_title = 0; if ((cmdname = strchr(command, ' ')) && strcasecmp(cmdname, "as")) { *cmdname++ = '\0'; - switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name", - cmdname); + switch_snprintf(sql, sizeof(sql) - 1, + "select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name", cmdname); } else { switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' order by name"); } } else if (!strcasecmp(command, "nat_map")) { - switch_snprintf(sql, sizeof(sql) - 1, - "SELECT port, " - " CASE proto " - " WHEN 0 THEN 'udp' " - " WHEN 1 THEN 'tcp' " - " ELSE 'unknown' " - " END AS proto, " - " proto AS proto_num, " - " sticky " - " FROM nat ORDER BY port, proto" - ); + switch_snprintf(sql, sizeof(sql) - 1, + "SELECT port, " + " CASE proto " + " WHEN 0 THEN 'udp' " + " WHEN 1 THEN 'tcp' " + " ELSE 'unknown' " " END AS proto, " " proto AS proto_num, " " sticky " " FROM nat ORDER BY port, proto"); } else { stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX); goto end; @@ -3374,7 +3373,7 @@ SWITCH_STANDARD_API(show_function) } /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SQL: %s.\n", sql); */ - + if (!strcasecmp(as, "delim") || !strcasecmp(as, "csv")) { if (zstr(holder.delim)) { if (!(holder.delim = argv[3])) { @@ -3427,7 +3426,7 @@ SWITCH_STANDARD_API(show_function) holder.stream->write_function(holder.stream, "-ERR Cannot find format %s\n", as); } - end: + end: switch_safe_free(mydata); @@ -3476,12 +3475,12 @@ SWITCH_STANDARD_API(uuid_session_heartbeat_function) if (argc < 2 || !argv[0]) { goto error; } - + if (!(l_session = switch_core_session_locate(argv[0]))) { stream->write_function(stream, "-ERR Usage: cannot locate session.\n"); return SWITCH_STATUS_SUCCESS; } - + if (!strcasecmp(argv[1], "sched")) { x = 2; sched++; @@ -3497,7 +3496,7 @@ SWITCH_STANDARD_API(uuid_session_heartbeat_function) } else if (!switch_true(argv[x])) { seconds = 0; } - + if (seconds) { if (sched) { switch_core_session_sched_heartbeat(l_session, seconds); @@ -3508,14 +3507,14 @@ SWITCH_STANDARD_API(uuid_session_heartbeat_function) } else { switch_core_session_disable_heartbeat(l_session); } - + switch_core_session_rwunlock(l_session); - - switch_safe_free(mycmd); + + switch_safe_free(mycmd); stream->write_function(stream, "+OK\n"); return SWITCH_STATUS_SUCCESS; - - error: + + error: switch_safe_free(mycmd); stream->write_function(stream, "-ERR Usage: uuid_session_heartbeat %s", HEARTBEAT_SYNTAX); return SWITCH_STATUS_SUCCESS; @@ -3551,7 +3550,7 @@ SWITCH_STANDARD_API(uuid_setvar_function) char *var_value = NULL; if (argc == 3) { - var_value = argv[2]; + var_value = argv[2]; } if ((psession = switch_core_session_locate(uuid))) { @@ -3600,10 +3599,10 @@ SWITCH_STANDARD_API(uuid_setvar_multi_function) if ((psession = switch_core_session_locate(uuid))) { switch_channel_t *channel = switch_core_session_get_channel(psession); - int x, y = 0; + int x, y = 0; argc = switch_separate_string(vars, ';', argv, (sizeof(argv) / sizeof(argv[0]))); - for (x = 0 ; x < argc; x++) { + for (x = 0; x < argc; x++) { var_name = argv[x]; if (var_name && (var_value = strchr(var_name, '='))) { *var_value++ = '\0'; @@ -3616,7 +3615,7 @@ SWITCH_STANDARD_API(uuid_setvar_multi_function) y++; } } - + switch_core_session_rwunlock(psession); if (y) { stream->write_function(stream, "+OK\n"); @@ -3626,7 +3625,7 @@ SWITCH_STANDARD_API(uuid_setvar_multi_function) stream->write_function(stream, "-ERR No Such Channel!\n"); } } - + stream->write_function(stream, "-USAGE: %s\n", SETVAR_MULTI_SYNTAX); done: @@ -3729,10 +3728,10 @@ SWITCH_STANDARD_API(uuid_send_dtmf_function) switch_core_session_send_dtmf_string(psession, (const char *) dtmf_data); goto done; -usage: + usage: stream->write_function(stream, "-USAGE: %s\n", UUID_SEND_DTMF_SYNTAX); -done: + done: if (psession) { switch_core_session_rwunlock(psession); } @@ -3777,10 +3776,10 @@ SWITCH_STANDARD_API(uuid_recv_dtmf_function) switch_channel_queue_dtmf_string(switch_core_session_get_channel(psession), dtmf_data); goto done; -usage: + usage: stream->write_function(stream, "-USAGE: %s\n", UUID_RECV_DTMF_SYNTAX); -done: + done: if (psession) { switch_core_session_rwunlock(psession); } @@ -3896,34 +3895,34 @@ SWITCH_STANDARD_API(global_getvar_function) #define SYSTEM_SYNTAX "" SWITCH_STANDARD_API(system_function) { - if (zstr(cmd)) { - stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); - return SWITCH_STATUS_SUCCESS; - } + if (zstr(cmd)) { + stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); + return SWITCH_STATUS_SUCCESS; + } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", cmd); - if (switch_system(cmd, SWITCH_TRUE) < 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", cmd); - } - stream->write_function(stream, "+OK\n"); - return SWITCH_STATUS_SUCCESS; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", cmd); + if (switch_system(cmd, SWITCH_TRUE) < 0) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", cmd); + } + stream->write_function(stream, "+OK\n"); + return SWITCH_STATUS_SUCCESS; } #define SYSTEM_SYNTAX "" SWITCH_STANDARD_API(bg_system_function) { - if (zstr(cmd)) { - stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); - return SWITCH_STATUS_SUCCESS; - } + if (zstr(cmd)) { + stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX); + return SWITCH_STATUS_SUCCESS; + } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", cmd); - if (switch_system(cmd, SWITCH_FALSE) < 0) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", cmd); - } - stream->write_function(stream, "+OK\n"); - return SWITCH_STATUS_SUCCESS; + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Executing command: %s\n", cmd); + if (switch_system(cmd, SWITCH_FALSE) < 0) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Failed to execute command: %s\n", cmd); + } + stream->write_function(stream, "+OK\n"); + return SWITCH_STATUS_SUCCESS; } SWITCH_STANDARD_API(strftime_tz_api_function) @@ -3939,13 +3938,13 @@ SWITCH_STANDARD_API(strftime_tz_api_function) *format++ = '\0'; } } - - if (switch_strftime_tz(tz_name, format, date, sizeof(date), 0) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */ + + if (switch_strftime_tz(tz_name, format, date, sizeof(date), 0) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */ stream->write_function(stream, "%s", date); } else { stream->write_function(stream, "-ERR Invalid Timezone\n"); } - + return SWITCH_STATUS_SUCCESS; } @@ -3976,13 +3975,13 @@ SWITCH_STANDARD_API(hupall_api_function) } else { switch_core_session_hupall_matching_var(var, val, cause); } - + if (zstr(var)) { stream->write_function(stream, "+OK hangup all channels with cause %s\n", switch_channel_cause2str(cause)); } else { stream->write_function(stream, "+OK hangup all channels matching [%s]=[%s] with cause: %s\n", var, val, switch_channel_cause2str(cause)); } - + switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; } @@ -3991,16 +3990,16 @@ SWITCH_STANDARD_API(escape_function) { int len; char *mycmd; - + if (zstr(cmd)) { return SWITCH_STATUS_SUCCESS; } - - len = strlen(cmd)*2; + + len = strlen(cmd) * 2; mycmd = malloc(len); - + stream->write_function(stream, "%s", switch_escape_string(cmd, mycmd, len)); - + switch_safe_free(mycmd); return SWITCH_STATUS_SUCCESS; } @@ -4024,14 +4023,12 @@ SWITCH_STANDARD_API(uuid_loglevel) if (level == SWITCH_LOG_INVALID) { stream->write_function(stream, "-ERR Invalid log level!\n"); - } - else if ((tsession = switch_core_session_locate(uuid))) { + } else if ((tsession = switch_core_session_locate(uuid))) { switch_core_session_set_loglevel(tsession, level); stream->write_function(stream, "+OK\n"); switch_core_session_rwunlock(tsession); - } - else { + } else { stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid); } } @@ -4123,7 +4120,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) SWITCH_ADD_API(commands_api_interface, "reload", "Reload Module", reload_function, UNLOAD_SYNTAX); SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_xml_function, ""); SWITCH_ADD_API(commands_api_interface, "sched_api", "Schedule an api command", sched_api_function, SCHED_SYNTAX); - SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function, SCHED_BROADCAST_SYNTAX); + SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function, + SCHED_BROADCAST_SYNTAX); SWITCH_ADD_API(commands_api_interface, "sched_del", "Delete a Scheduled task", sched_del_function, "|"); SWITCH_ADD_API(commands_api_interface, "sched_hangup", "Schedule a running call to hangup", sched_hangup_function, SCHED_HANGUP_SYNTAX); SWITCH_ADD_API(commands_api_interface, "sched_transfer", "Schedule a transfer for a running call", sched_transfer_function, SCHED_TRANSFER_SYNTAX); @@ -4204,8 +4202,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_commands_load) switch_console_set_complete("add fsctl shutdown restart asap"); switch_console_set_complete("add fsctl shutdown restart elegant"); switch_console_set_complete("add fsctl sps"); - switch_console_set_complete("add fsctl sync_clock"); - switch_console_set_complete("add fsctl flush_db_handles"); + switch_console_set_complete("add fsctl sync_clock"); + switch_console_set_complete("add fsctl flush_db_handles"); switch_console_set_complete("add nat_map reinit"); switch_console_set_complete("add nat_map republish"); switch_console_set_complete("add nat_map status"); diff --git a/src/mod/applications/mod_conference/mod_conference.c b/src/mod/applications/mod_conference/mod_conference.c index 379aefe2db..c42338a2ab 100644 --- a/src/mod/applications/mod_conference/mod_conference.c +++ b/src/mod/applications/mod_conference/mod_conference.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -42,7 +42,7 @@ SWITCH_MODULE_DEFINITION(mod_conference, mod_conference_load, mod_conference_shu static const char global_app_name[] = "conference"; static char *global_cf_name = "conference.conf"; -static char *cf_pin_url_param_name ="X-ConfPin="; +static char *cf_pin_url_param_name = "X-ConfPin="; static char *api_syntax; static int EC = 0; @@ -406,12 +406,13 @@ SWITCH_STANDARD_APP(conference_function); static void launch_conference_thread(conference_obj_t *conference); static void launch_conference_video_thread(conference_obj_t *conference); static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj); -static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf, uint32_t buflen); +static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf, + uint32_t buflen); static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin); static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin); static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop); static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool); -static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, +static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint); static void launch_conference_record_thread(conference_obj_t *conference, char *path); @@ -459,13 +460,13 @@ static switch_status_t conference_add_event_member_data(conference_member_t *mem if (member->session) { switch_channel_t *channel = switch_core_session_get_channel(member->session); - + if (member->verbose_events) { switch_channel_event_set_data(channel, event); } else { switch_channel_event_set_basic_data(channel, event); } - + } switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id); @@ -678,7 +679,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe conference_stop_file(conference, FILE_STOP_ASYNC); } if (conference->enter_sound) { - conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), + conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), switch_test_flag(conference, CFLAG_WAIT_MOD) ? 0 : 1); } } @@ -701,7 +702,8 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe if (!switch_test_flag(conference, CFLAG_BRIDGE_TO)) { if (conference->alone_sound) { conference_stop_file(conference, FILE_STOP_ASYNC); - conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 1); + conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, + switch_core_session_get_channel(member->session), 1); } else { switch_snprintf(msg, sizeof(msg), "You are currently the only person in this conference."); conference_member_say(member, msg, CONF_DEFAULT_LEADIN); @@ -911,7 +913,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr req_iframe = 0; goto do_continue; } - + if (conference->floor_holder->id != last_member) { int iframe = 0; #if 0 @@ -929,13 +931,13 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr if (vid_frame->codec->implementation->ianacode == 34) { /* h.263 */ //iframe = (*((int16_t *) vid_frame->data) >> 12 == 6); - iframe = 1; + iframe = 1; } else if (vid_frame->codec->implementation->ianacode == 115) { /* h.263-1998 */ int y = *((int8_t *) vid_frame->data + 2) & 0xfe; iframe = (y == 0x80 || y == 0x82); } else if (vid_frame->codec->implementation->ianacode == 99) { /* h.264 */ iframe = (*((int16_t *) vid_frame->data) >> 5 == 0x11); - } else { /* we need more defs */ + } else { /* we need more defs */ iframe = 1; } @@ -943,7 +945,7 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr goto do_continue; } - req_iframe = 0; + req_iframe = 0; } last_member = conference->floor_holder->id; @@ -958,8 +960,8 @@ static void *SWITCH_THREAD_FUNC conference_video_thread_run(switch_thread_t *thr } } - do_continue: - + do_continue: + switch_mutex_unlock(conference->member_mutex); } @@ -1000,13 +1002,13 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_mutex_unlock(globals.hash_mutex); conference->is_recording = 0; - + while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) { switch_size_t file_sample_len = samples; switch_size_t file_data_len = samples * 2; int has_file_data = 0, members_with_video = 0; - if (conference->perpetual_sound && !conference->async_fnode) { + if (conference->perpetual_sound && !conference->async_fnode) { conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1); } else if (conference->moh_sound && (conference->count == 1 || switch_test_flag(conference, CFLAG_WAIT_MOD)) && !conference->async_fnode) { conference_play_file(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1); @@ -1044,12 +1046,12 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } /* Start recording if there's more than one participant. */ - if (ready > 1 && conference->auto_record && !conference->is_recording){ + if (ready > 1 && conference->auto_record && !conference->is_recording) { conference->is_recording = 1; imember = conference->members; if (imember) { switch_channel_t *channel = switch_core_session_get_channel(imember->session); - char *rfile = switch_channel_expand_variables(channel, conference->auto_record); + char *rfile = switch_channel_expand_variables(channel, conference->auto_record); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto recording file: %s\n", rfile); launch_conference_record_thread(conference, rfile); if (rfile != conference->auto_record) { @@ -1186,7 +1188,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v check if our audio is involved and if so, subtract it from the sample so we don't hear ourselves. Since main frame was 32 bit int, we did not lose any detail, now that we have to convert to 16 bit we can cut it off at the min and max range if need be and write the frame to the output buffer. - */ + */ for (omember = conference->members; omember; omember = omember->next) { switch_size_t ok = 1; @@ -1194,7 +1196,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v continue; } - if (!switch_test_flag(omember, MFLAG_CAN_HEAR) && !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH) + if (!switch_test_flag(omember, MFLAG_CAN_HEAR) && !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH) && !switch_test_flag(conference, CFLAG_WASTE_BANDWIDTH)) { continue; } @@ -1206,10 +1208,10 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v if (switch_test_flag(omember, MFLAG_HAS_AUDIO) && x <= omember->read / 2) { z -= (int32_t) bptr[x]; } - + /* when there are relationships, we have to do more work by scouring all the members to see if there are any reasons why we should not be hearing a paticular member, and if not, delete their samples as well. - */ + */ if (conference->relationship_total) { for (imember = conference->members; imember; imember = imember->next) { conference_relationship_t *rel; @@ -1228,15 +1230,15 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v } } - /* Now we can convert to 16 bit.*/ + /* Now we can convert to 16 bit. */ switch_normalize_to_16bit(z); write_frame[x] = (int16_t) z; } - + switch_mutex_lock(omember->audio_out_mutex); ok = switch_buffer_write(omember->mux_buffer, write_frame, bytes); switch_mutex_unlock(omember->audio_out_mutex); - + if (!ok) { goto end; } @@ -1270,7 +1272,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v switch_mutex_unlock(conference->mutex); } /* Rinse ... Repeat */ - end: + end: if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) { switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO); @@ -1427,7 +1429,7 @@ static void conference_loop_fn_lock_toggle(conference_member_t *member, caller_c } switch_set_flag_locked(member->conference, CFLAG_LOCKED); - if (test_eflag(member->conference, EFLAG_LOCK) && + if (test_eflag(member->conference, EFLAG_LOCK) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_data(member->conference, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "lock"); @@ -1439,7 +1441,7 @@ static void conference_loop_fn_lock_toggle(conference_member_t *member, caller_c } switch_clear_flag_locked(member->conference, CFLAG_LOCKED); - if (test_eflag(member->conference, EFLAG_UNLOCK) && + if (test_eflag(member->conference, EFLAG_UNLOCK) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_data(member->conference, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "unlock"); @@ -1715,7 +1717,7 @@ static void conference_loop_fn_transfer(conference_member_t *member, caller_cont int argc; char *mydata = NULL; switch_event_t *event; - + if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "transfer"); @@ -1723,7 +1725,7 @@ static void conference_loop_fn_transfer(conference_member_t *member, caller_cont switch_event_fire(&event); } switch_clear_flag_locked(member, MFLAG_RUNNING); - + if ((mydata = switch_core_session_strdup(member->session, action->data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc > 0) { @@ -1735,7 +1737,7 @@ static void conference_loop_fn_transfer(conference_member_t *member, caller_cont if (argc > 2) { context = argv[2]; } - + } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty transfer string [%s]\n", (char *) action->data); goto done; @@ -1745,11 +1747,10 @@ static void conference_loop_fn_transfer(conference_member_t *member, caller_cont goto done; } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Transfering to: %s, %s, %s\n", exten, dialplan, context); - - switch_ivr_session_transfer(member->session, - exten, dialplan, context); - -done: + + switch_ivr_session_transfer(member->session, exten, dialplan, context); + + done: return; } @@ -1763,14 +1764,14 @@ static void conference_loop_fn_exec_app(conference_member_t *member, caller_cont char *mydata = NULL; switch_event_t *event = NULL; switch_channel_t *channel = NULL; - + if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "execute_app"); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", action->data); switch_event_fire(&event); } - + if ((mydata = switch_core_session_strdup(member->session, action->data))) { if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc > 0) { @@ -1779,7 +1780,7 @@ static void conference_loop_fn_exec_app(conference_member_t *member, caller_cont if (argc > 1) { arg = argv[1]; } - + } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty execute app string [%s]\n", (char *) action->data); goto done; @@ -1796,13 +1797,13 @@ static void conference_loop_fn_exec_app(conference_member_t *member, caller_cont switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Execute app: %s, %s\n", app, arg); channel = switch_core_session_get_channel(member->session); - + switch_channel_set_app_flag(channel, CF_APP_TAGGED); switch_core_session_set_read_codec(member->session, NULL); switch_core_session_execute_application(member->session, app, arg); - switch_core_session_set_read_codec(member->session, &member->read_codec); - switch_channel_clear_app_flag(channel, CF_APP_TAGGED); -done: + switch_core_session_set_read_codec(member->session, &member->read_codec); + switch_channel_clear_app_flag(channel, CF_APP_TAGGED); + done: return; } @@ -1819,7 +1820,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v switch_status_t status; switch_frame_t *read_frame = NULL; uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400; - switch_codec_implementation_t read_impl = {0}; + switch_codec_implementation_t read_impl = { 0 }; switch_core_session_t *session = member->session; switch_assert(member != NULL); @@ -1868,7 +1869,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } } } - + goto do_continue; } @@ -1897,7 +1898,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v member->score = energy / (samples / divisor); } - member->score_iir = (int)(((1.0 - SCORE_DECAY) * (float)member->score) + (SCORE_DECAY * (float)member->score_iir)); + member->score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member->score) + (SCORE_DECAY * (float) member->score_iir)); if (member->score_iir > SCORE_MAX_IIR) { member->score_iir = SCORE_MAX_IIR; @@ -1933,14 +1934,14 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v member->conference->floor_holder = member; } switch_mutex_unlock(member->conference->member_mutex); - + if (test_eflag(member->conference, EFLAG_START_TALKING) && switch_test_flag(member, MFLAG_CAN_SPEAK) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_member_data(member, event); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "start-talking"); switch_event_fire(&event); } - + if (switch_test_flag(member, MFLAG_MUTE_DETECT) && !switch_test_flag(member, MFLAG_CAN_SPEAK)) { if (!zstr(member->conference->mute_detect_sound)) { @@ -1955,7 +1956,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } } - + } } } else { @@ -1980,12 +1981,12 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } /* skip frames that are not actual media or when we are muted or silent */ - if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && + if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) && !switch_test_flag(member->conference, CFLAG_WAIT_MOD)) { switch_audio_resampler_t *read_resampler = member->read_resampler; void *data; uint32_t datalen; - + if (read_resampler) { int16_t *bptr = (int16_t *) read_frame->data; int len = (int) read_frame->datalen; @@ -2019,7 +2020,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v } } - do_continue: + do_continue: switch_mutex_unlock(member->read_mutex); } @@ -2035,7 +2036,7 @@ static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, v static void member_add_file_data(conference_member_t *member, int16_t *data, switch_size_t file_data_len) { switch_size_t file_sample_len = file_data_len / 2; - int16_t file_frame[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = {0}; + int16_t file_frame[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 }; if (!member->fnode) { return; @@ -2063,7 +2064,7 @@ static void member_add_file_data(conference_member_t *member, int16_t *data, swi } else { if (member->fnode->type == NODE_TYPE_SPEECH) { switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING; - + if (switch_core_speech_read_tts(member->fnode->sh, file_frame, &file_data_len, &flags) == SWITCH_STATUS_SUCCESS) { file_sample_len = file_data_len / 2; } else { @@ -2077,7 +2078,7 @@ static void member_add_file_data(conference_member_t *member, int16_t *data, swi if (file_sample_len <= 0) { switch_event_t *event; member->fnode->done++; - + if (test_eflag(member->conference, EFLAG_PLAY_FILE) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) { conference_add_event_data(member->conference, event); @@ -2086,20 +2087,20 @@ static void member_add_file_data(conference_member_t *member, int16_t *data, swi switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", member->fnode->file); switch_event_fire(&event); } - } else { /* there is file node data to mix into the frame */ + } else { /* there is file node data to mix into the frame */ int32_t i, sample; - + /* Check for output volume adjustments */ if (member->volume_out_level) { switch_change_sln_volume(file_frame, file_sample_len, member->volume_out_level); } - - for(i = 0; i < file_sample_len; i++) { + + for (i = 0; i < file_sample_len; i++) { sample = data[i] + file_frame[i]; switch_normalize_to_16bit(sample); data[i] = sample; } - + } } } @@ -2162,14 +2163,14 @@ static void conference_loop_output(conference_member_t *member) uint32_t low_count, bytes; call_list_t *call_list, *cp; int restarting = -1; - switch_codec_implementation_t read_impl = {0}; - - top: + switch_codec_implementation_t read_impl = { 0 }; + + top: switch_core_session_get_read_impl(member->session, &read_impl); restarting++; - + if (switch_test_flag(member, MFLAG_RESTART)) { switch_clear_flag(member, MFLAG_RESTART); switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER); @@ -2215,11 +2216,12 @@ static void conference_loop_output(conference_member_t *member) if (!restarting) { /* Start the input thread */ launch_conference_loop_input(member, switch_core_session_get_pool(member->session)); - + /* build a digit stream object */ if (member->conference->dtmf_parser != NULL && switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Danger Will Robinson, there is no digit parser stream object\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, + "Danger Will Robinson, there is no digit parser stream object\n"); } if ((call_list = switch_channel_get_private(channel, "_conference_autocall_list_"))) { @@ -2230,7 +2232,7 @@ static void conference_loop_output(conference_member_t *member) const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce"); const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix"); int to = 60; - + if (ann) { member->conference->special_announce = switch_core_strdup(member->conference->pool, ann); } @@ -2311,7 +2313,8 @@ static void conference_loop_output(conference_member_t *member) if (switch_channel_test_flag(channel, CF_OUTBOUND)) { /* test to see if outbound channel has answered */ if (switch_channel_test_flag(channel, CF_ANSWERED) && !switch_test_flag(member->conference, CFLAG_ANSWERED)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Outbound conference channel answered, setting CFLAG_ANSWERED\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, + "Outbound conference channel answered, setting CFLAG_ANSWERED\n"); switch_set_flag(member->conference, CFLAG_ANSWERED); } } else { @@ -2351,8 +2354,7 @@ static void conference_loop_output(conference_member_t *member) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_INFO, "executing caller control '%s' param '%s' on call '%u, %s\n", - caller_action->fndesc->key, - param ? param : "none", member->id, switch_channel_get_name(channel)); + caller_action->fndesc->key, param ? param : "none", member->id, switch_channel_get_name(channel)); #endif caller_action->fndesc->handler(member, caller_action); @@ -2361,7 +2363,7 @@ static void conference_loop_output(conference_member_t *member) caller_action = NULL; } - + use_buffer = NULL; mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer); @@ -2376,10 +2378,10 @@ static void conference_loop_output(conference_member_t *member) switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER); } } - + use_timer = 1; - + if (mux_used) { /* Flush the output buffer and write all the data (presumably muxed) back to the channel */ switch_mutex_lock(member->audio_out_mutex); @@ -2412,7 +2414,7 @@ static void conference_loop_output(conference_member_t *member) } else if (!switch_test_flag(member->conference, CFLAG_WASTE_BANDWIDTH)) { if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) { if (member->conference->comfort_noise_level) { - switch_generate_sln_silence(write_frame.data, samples, member->conference->comfort_noise_level); + switch_generate_sln_silence(write_frame.data, samples, member->conference->comfort_noise_level); } else { memset(write_frame.data, 255, bytes); } @@ -2420,7 +2422,7 @@ static void conference_loop_output(conference_member_t *member) write_frame.datalen = bytes; write_frame.samples = samples; write_frame.timestamp = timer.samplecount; - + switch_core_session_write_frame(member->session, &write_frame, SWITCH_IO_FLAG_NONE, 0); } } @@ -2433,7 +2435,7 @@ static void conference_loop_output(conference_member_t *member) } switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER); } - + switch_mutex_unlock(member->write_mutex); @@ -2446,14 +2448,14 @@ static void conference_loop_output(conference_member_t *member) } else { switch_ivr_parse_all_messages(member->session); } - + if (use_timer) { switch_core_timer_next(&timer); } else { switch_cond_next(); } - } /* Rinse ... Repeat */ + } /* Rinse ... Repeat */ if (member->digit_stream != NULL) { @@ -2544,7 +2546,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Joining Conference\n"); goto end; } - + fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN; if (switch_core_file_open(&fh, @@ -2572,7 +2574,7 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) { switch_size_t len = 0; mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer); - + if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) { if (mux_used) { switch_mutex_lock(member->audio_out_mutex); @@ -2595,13 +2597,13 @@ static void *SWITCH_THREAD_FUNC conference_record_thread_run(switch_thread_t *th len = (switch_size_t) rlen / sizeof(int16_t); } switch_mutex_unlock(member->audio_out_mutex); - } - + } + if (len < (switch_size_t) samples) { - memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t)samples - len) * sizeof(int16_t)); + memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t) samples - len) * sizeof(int16_t)); len = (switch_size_t) samples; } - + if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n"); switch_clear_flag_locked(member, MFLAG_RUNNING); @@ -2712,12 +2714,12 @@ static void conference_send_all_dtmf(conference_member_t *member, conference_obj for (imember = conference->members; imember; imember = imember->next) { /* don't send to self */ if (imember->id == member->id) { - continue; + continue; } if (imember->session) { const char *p; for (p = dtmf; p && *p; p++) { - switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION}; + switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION }; lock_member(imember); switch_core_session_kill_channel(imember->session, SWITCH_SIG_BREAK); switch_core_session_send_dtmf(imember->session, &digit); @@ -3480,9 +3482,7 @@ static switch_status_t conf_api_sub_list(conference_obj_t *conference, switch_st stream->write_function(stream, "Conference %s (%u member%s rate: %u%s)\n", conference->name, conference->count, - conference->count == 1 ? "" : "s", - conference->rate, - switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""); + conference->count == 1 ? "" : "s", conference->rate, switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : ""); count++; if (!summary) { if (pretty) { @@ -3520,7 +3520,7 @@ static void add_x_tag(switch_xml_t x_member, const char *name, const char *value x_tag = switch_xml_add_child_d(x_member, name, off); switch_assert(x_tag); - + switch_zmalloc(data, dlen); switch_url_encode(value, data, dlen); @@ -3537,7 +3537,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer char *ival = i; switch_assert(conference != NULL); switch_assert(x_conference != NULL); - + switch_xml_set_attr_d(x_conference, "name", conference->name); switch_snprintf(i, sizeof(i), "%d", conference->count); switch_xml_set_attr_d(x_conference, "member-count", ival); @@ -3547,7 +3547,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer if (switch_test_flag(conference, CFLAG_LOCKED)) { switch_xml_set_attr_d(x_conference, "locked", "true"); } - + if (switch_test_flag(conference, CFLAG_DESTRUCT)) { switch_xml_set_attr_d(x_conference, "destruct", "true"); } @@ -3578,7 +3578,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer x_members = switch_xml_add_child_d(x_conference, "members", 0); switch_assert(x_members); - + switch_mutex_lock(conference->member_mutex); for (member = conference->members; member; member = member->next) { @@ -3589,7 +3589,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer uint32_t count = 0; switch_xml_t x_tag; int toff = 0; - + if (switch_test_flag(member, MFLAG_NOCHANNEL)) { continue; } @@ -3599,7 +3599,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer profile = switch_channel_get_caller_profile(channel); name = switch_channel_get_name(channel); - + x_member = switch_xml_add_child_d(x_members, "member", moff++); switch_assert(x_member); @@ -3609,7 +3609,7 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer add_x_tag(x_member, "uuid", uuid, toff++); add_x_tag(x_member, "caller_id_name", profile->caller_id_name, toff++); add_x_tag(x_member, "caller_id_number", profile->caller_id_number, toff++); - + x_flags = switch_xml_add_child_d(x_member, "flags", count++); switch_assert(x_flags); @@ -3625,16 +3625,16 @@ static void conference_xlist(conference_obj_t *conference, switch_xml_t x_confer x_tag = switch_xml_add_child_d(x_flags, "has_video", count++); switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member->session), CF_VIDEO) ? "true" : "false"); - + x_tag = switch_xml_add_child_d(x_flags, "has_floor", count++); switch_xml_set_txt_d(x_tag, (member == member->conference->floor_holder) ? "true" : "false"); - + x_tag = switch_xml_add_child_d(x_flags, "is_moderator", count++); switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_MOD) ? "true" : "false"); - + x_tag = switch_xml_add_child_d(x_flags, "end_conference", count++); switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_ENDCONF) ? "true" : "false"); - + } switch_mutex_unlock(conference->member_mutex); @@ -3650,13 +3650,13 @@ static switch_status_t conf_api_sub_xml_list(conference_obj_t *conference, switc x_conferences = switch_xml_new("conferences"); switch_assert(x_conferences); - + if (conference == NULL) { switch_mutex_lock(globals.hash_mutex); for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); conference = (conference_obj_t *) val; - + x_conference = switch_xml_add_child_d(x_conferences, "conference", off++); switch_assert(conference); @@ -4009,7 +4009,7 @@ static switch_status_t conf_api_sub_bgdial(conference_obj_t *conference, switch_ switch_uuid_get(&uuid); switch_uuid_format(uuid_str, &uuid); - + if (conference) { conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str); } else { @@ -4049,7 +4049,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc switch_channel_t *channel; switch_event_t *event; switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL; - + if (!id || !(member = conference_member_get(conference, id))) { stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name); continue; @@ -4154,7 +4154,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc } unlock_member(member); - + stream->write_function(stream, "OK Member '%d' sent to conference %s.\n", member->id, argv[2]); /* tell them what happened */ @@ -4177,7 +4177,7 @@ static switch_status_t conf_api_sub_transfer(conference_obj_t *conference, switc } done: - + if (locked) { switch_mutex_unlock(globals.setup_mutex); locked = 0; @@ -4269,43 +4269,43 @@ typedef enum { /* API Interface Function sub-commands */ /* Entries in this list should be kept in sync with the enum above */ static api_command_t conf_api_sub_commands[] = { - {"list", (void_fn_t) &conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, " list [delim ]"}, - {"xml_list", (void_fn_t) &conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, " xml_list"}, - {"energy", (void_fn_t) &conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, + {"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, " list [delim ]"}, + {"xml_list", (void_fn_t) & conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, " xml_list"}, + {"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET, " energy []"}, - {"volume_in", (void_fn_t) &conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, + {"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET, " volume_in []"}, - {"volume_out", (void_fn_t) &conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, + {"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET, " volume_out []"}, - {"play", (void_fn_t) &conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, " play [async|]"}, - {"say", (void_fn_t) &conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, " say "}, - {"saymember", (void_fn_t) &conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, + {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, " play [async|]"}, + {"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, " say "}, + {"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE, " saymember "}, - {"stop", (void_fn_t) &conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT, + {"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT, " stop <[current|all|async|last]> []"}, - {"dtmf", (void_fn_t) &conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET, + {"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET, " dtmf <[member_id|all|last]> "}, - {"kick", (void_fn_t) &conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, " kick <[member_id|all|last]>"}, - {"mute", (void_fn_t) &conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, " mute <[member_id|all]|last>"}, - {"unmute", (void_fn_t) &conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, + {"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, " kick <[member_id|all|last]>"}, + {"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, " mute <[member_id|all]|last>"}, + {"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET, " unmute <[member_id|all]|last>"}, - {"deaf", (void_fn_t) &conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, " deaf <[member_id|all]|last>"}, - {"undeaf", (void_fn_t) &conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, + {"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, " deaf <[member_id|all]|last>"}, + {"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET, " undeaf <[member_id|all]|last>"}, - {"relate", (void_fn_t) &conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, + {"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT, " relate [nospeak|nohear|clear]"}, - {"lock", (void_fn_t) &conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, " lock"}, - {"unlock", (void_fn_t) &conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, " unlock"}, - {"dial", (void_fn_t) &conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, + {"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, " lock"}, + {"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, " unlock"}, + {"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT, " dial / "}, - {"bgdial", (void_fn_t) &conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT, + {"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT, " bgdial / "}, - {"transfer", (void_fn_t) &conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, + {"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT, " transfer [...]"}, - {"record", (void_fn_t) &conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, " record "}, - {"norecord", (void_fn_t) &conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, " norecord <[filename|all]>"}, - {"pin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " pin "}, - {"nopin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " nopin"}, + {"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, " record "}, + {"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, " norecord <[filename|all]>"}, + {"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " pin "}, + {"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, " nopin"}, }; #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0])) @@ -4553,8 +4553,10 @@ static switch_status_t conference_outcall(conference_obj_t *conference, /* establish an outbound call leg */ - if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", switch_channel_cause2str(*cause)); + if (switch_ivr_originate(session, &peer_session, cause, bridgeto, timeout, NULL, cid_name, cid_num, NULL, NULL, SOF_NONE, NULL) != + SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel, cause: %s\n", + switch_channel_cause2str(*cause)); if (caller_channel) { switch_channel_hangup(caller_channel, *cause); } @@ -4639,7 +4641,7 @@ static void *SWITCH_THREAD_FUNC conference_outcall_run(switch_thread_t *thread, if (call) { switch_call_cause_t cause; switch_event_t *event; - + conference_outcall(call->conference, call->conference_name, call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause); @@ -4707,7 +4709,7 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference, if (conference_name) { call->conference_name = strdup(conference_name); } - + if (call_uuid) { call->uuid = strdup(call_uuid); } @@ -4722,7 +4724,8 @@ static switch_status_t conference_outcall_bg(conference_obj_t *conference, } /* Play a file */ -static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf, uint32_t buflen) +static switch_status_t conference_local_play_file(conference_obj_t *conference, switch_core_session_t *session, char *path, uint32_t leadin, void *buf, + uint32_t buflen) { uint32_t x = 0; switch_status_t status = SWITCH_STATUS_SUCCESS; @@ -4792,7 +4795,7 @@ static void set_mflags(const char *flags, member_flag_t *f) char *argv[10] = { 0 }; int i, argc = 0; - for(p = dup; p && *p; p++) { + for (p = dup; p && *p; p++) { if (*p == ',') { *p = '|'; } @@ -4800,7 +4803,7 @@ static void set_mflags(const char *flags, member_flag_t *f) argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0]))); - for(i = 0; i < argc && argv[i]; i++) { + for (i = 0; i < argc && argv[i]; i++) { if (!strcasecmp(argv[i], "mute")) { *f &= ~MFLAG_CAN_SPEAK; } else if (!strcasecmp(argv[i], "deaf")) { @@ -4834,7 +4837,7 @@ static void set_cflags(const char *flags, uint32_t *f) char *argv[10] = { 0 }; int i, argc = 0; - for(p = dup; p && *p; p++) { + for (p = dup; p && *p; p++) { if (*p == ',') { *p = '|'; } @@ -4842,7 +4845,7 @@ static void set_cflags(const char *flags, uint32_t *f) argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0]))); - for(i = 0; i < argc && argv[i]; i++) { + for (i = 0; i < argc && argv[i]; i++) { if (!strcasecmp(argv[i], "wait-mod")) { *f |= CFLAG_WAIT_MOD; } else if (!strcasecmp(argv[i], "video-floor-only")) { @@ -4957,7 +4960,7 @@ SWITCH_STANDARD_APP(conference_auto_function) static int setup_media(conference_member_t *member, conference_obj_t *conference) { - switch_codec_implementation_t read_impl = {0}; + switch_codec_implementation_t read_impl = { 0 }; switch_core_session_get_read_impl(member->session, &read_impl); switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE); @@ -5025,8 +5028,7 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference read_impl.microseconds_per_packet / 1000, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member->pool) == SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, - "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", - conference->rate, read_impl.microseconds_per_packet / 1000); + "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", conference->rate, read_impl.microseconds_per_packet / 1000); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n", conference->rate, read_impl.microseconds_per_packet / 1000); @@ -5047,14 +5049,14 @@ static int setup_media(conference_member_t *member, conference_obj_t *conference return 0; - codec_done1: + codec_done1: switch_core_codec_destroy(&member->read_codec); - codec_done2: + codec_done2: switch_core_codec_destroy(&member->write_codec); - done: + done: return -1; - + } @@ -5104,7 +5106,7 @@ SWITCH_STANDARD_APP(conference_function) if ((flags_str = strstr(mydata, flags_prefix))) { char *p; - *((char *)flags_str) = '\0'; + *((char *) flags_str) = '\0'; flags_str += strlen(flags_prefix); if ((p = strchr(flags_str, '}'))) { *p = '\0'; @@ -5143,7 +5145,7 @@ SWITCH_STANDARD_APP(conference_function) } else { profile_name = "default"; } - + #if 0 if (0) { member.dtmf_parser = conference->dtmf_parser; @@ -5234,7 +5236,7 @@ SWITCH_STANDARD_APP(conference_function) if (!conference) { /* couldn't find the conference, create one */ conference = conference_new(conf_name, xml_cfg, NULL); - + if (!conference) { goto done; } @@ -5254,7 +5256,7 @@ SWITCH_STANDARD_APP(conference_function) if (zstr(conference->perpetual_sound)) { conference->perpetual_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_perpetual_sound")); } - + /* Set the minimum number of members (once you go above it you cannot go below it) */ conference->min = 1; @@ -5263,7 +5265,7 @@ SWITCH_STANDARD_APP(conference_function) /* Start the conference thread for this conference */ launch_conference_thread(conference); - } else { /* setup user variable */ + } else { /* setup user variable */ switch_channel_set_variable(channel, "conference_name", conference->name); } @@ -5290,23 +5292,23 @@ SWITCH_STANDARD_APP(conference_function) /* Answer the channel */ switch_channel_answer(channel); - - /* look for PIN in channel variable first. If not present or invalid revert to prompting user */ + + /* look for PIN in channel variable first. If not present or invalid revert to prompting user */ supplied_pin_value = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "supplied_pin")); - if (!zstr(supplied_pin_value)){ + if (!zstr(supplied_pin_value)) { char *supplied_pin_value_start; int i = 0; - if ((supplied_pin_value_start = (char *)switch_stristr(cf_pin_url_param_name, supplied_pin_value))){ + if ((supplied_pin_value_start = (char *) switch_stristr(cf_pin_url_param_name, supplied_pin_value))) { /* pin supplied as a URL parameter, move pointer to start of actual pin value */ supplied_pin_value = supplied_pin_value_start + strlen(cf_pin_url_param_name); } - while (*supplied_pin_value != 0 && *supplied_pin_value != ';'){ + while (*supplied_pin_value != 0 && *supplied_pin_value != ';') { pin_buf[i++] = *supplied_pin_value++; } pin_valid = (strcmp(pin_buf, dpin) == 0); memset(pin_buf, 0, sizeof(pin_buf)); } - + if (!conference->pin_sound) { conference->pin_sound = switch_core_strdup(conference->pool, "conference/conf-pin.wav"); } @@ -5317,16 +5319,17 @@ SWITCH_STANDARD_APP(conference_function) while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) { switch_status_t pstatus = SWITCH_STATUS_FALSE; - + /* be friendly */ if (conference->pin_sound) { pstatus = conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf)); } else if (conference->tts_engine && conference->tts_voice) { - pstatus = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL); + pstatus = + switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL); } else { pstatus = switch_ivr_speak_text(session, "flite", "slt", "please enter the conference pin number", NULL); } - + if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call"); switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER); @@ -5336,11 +5339,10 @@ SWITCH_STANDARD_APP(conference_function) if (strlen(pin_buf) < strlen(dpin)) { char *buf = pin_buf + strlen(pin_buf); char term = '\0'; - + status = switch_ivr_collect_digits_count(session, buf, - sizeof(pin_buf) - strlen(pin_buf), - strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0); + sizeof(pin_buf) - strlen(pin_buf), strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0); if (status == SWITCH_STATUS_TIMEOUT) { status = SWITCH_STATUS_SUCCESS; } @@ -5441,7 +5443,7 @@ SWITCH_STANDARD_APP(conference_function) if (mflags & MFLAG_MINTWO) { conference->min = 2; } - + /* Add the caller to the conference */ if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) { switch_core_codec_destroy(&member.read_codec); @@ -5626,20 +5628,10 @@ static switch_status_t chat_send(const char *proto, const char *from, const char } else { return SWITCH_STATUS_SUCCESS; } -#if 0 - else { - if (strcasecmp(argv[0], "help") == 0 || strcasecmp(argv[0], "commands") == 0) { - stream.write_function(&stream, "%s\n", api_syntax); - /* find a normal command */ - } else { - conf_api_dispatch(conference, &stream, argc, argv, (const char *) body, 0); - } - } -#endif } switch_safe_free(lbuf); - + switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL); switch_safe_free(stream.data); @@ -5792,126 +5784,126 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m /* parse the profile tree for param values */ if (cfg.profile) - for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) { - char *var = (char *) switch_xml_attr_soft(xml_kvp, "name"); - char *val = (char *) switch_xml_attr_soft(xml_kvp, "value"); - char buf[128] = ""; - char *p; + for (xml_kvp = switch_xml_child(cfg.profile, "param"); xml_kvp; xml_kvp = xml_kvp->next) { + char *var = (char *) switch_xml_attr_soft(xml_kvp, "name"); + char *val = (char *) switch_xml_attr_soft(xml_kvp, "value"); + char buf[128] = ""; + char *p; - if ((p = strchr(var, '_'))) { - switch_copy_string(buf, var, sizeof(buf)); - for (p = buf; *p; p++) { - if (*p == '_') { - *p = '-'; + if ((p = strchr(var, '_'))) { + switch_copy_string(buf, var, sizeof(buf)); + for (p = buf; *p; p++) { + if (*p == '_') { + *p = '-'; + } } + var = buf; } - var = buf; - } - if (!strcasecmp(var, "rate") && !zstr(val)) { - uint32_t tmp = atoi(val); - if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) { - rate = tmp; + if (!strcasecmp(var, "rate") && !zstr(val)) { + uint32_t tmp = atoi(val); + if (tmp == 8000 || tmp == 12000 || tmp == 16000 || tmp == 24000 || tmp == 32000 || tmp == 48000) { + rate = tmp; + } + } else if (!strcasecmp(var, "domain") && !zstr(val)) { + domain = val; + } else if (!strcasecmp(var, "interval") && !zstr(val)) { + uint32_t tmp = atoi(val); + if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) { + interval = tmp; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); + } + } else if (!strcasecmp(var, "timer-name") && !zstr(val)) { + timer_name = val; + } else if (!strcasecmp(var, "tts-engine") && !zstr(val)) { + tts_engine = val; + } else if (!strcasecmp(var, "tts-voice") && !zstr(val)) { + tts_voice = val; + } else if (!strcasecmp(var, "enter-sound") && !zstr(val)) { + enter_sound = val; + } else if (!strcasecmp(var, "exit-sound") && !zstr(val)) { + exit_sound = val; + } else if (!strcasecmp(var, "alone-sound") && !zstr(val)) { + alone_sound = val; + } else if (!strcasecmp(var, "perpetual-sound") && !zstr(val)) { + perpetual_sound = val; + } else if (!strcasecmp(var, "moh-sound") && !zstr(val)) { + moh_sound = val; + } else if (!strcasecmp(var, "ack-sound") && !zstr(val)) { + ack_sound = val; + } else if (!strcasecmp(var, "nack-sound") && !zstr(val)) { + nack_sound = val; + } else if (!strcasecmp(var, "muted-sound") && !zstr(val)) { + muted_sound = val; + } else if (!strcasecmp(var, "mute-detect-sound") && !zstr(val)) { + mute_detect_sound = val; + } else if (!strcasecmp(var, "unmuted-sound") && !zstr(val)) { + unmuted_sound = val; + } else if (!strcasecmp(var, "locked-sound") && !zstr(val)) { + locked_sound = val; + } else if (!strcasecmp(var, "is-locked-sound") && !zstr(val)) { + is_locked_sound = val; + } else if (!strcasecmp(var, "is-unlocked-sound") && !zstr(val)) { + is_unlocked_sound = val; + } else if (!strcasecmp(var, "member-flags") && !zstr(val)) { + member_flags = val; + } else if (!strcasecmp(var, "conference-flags") && !zstr(val)) { + conference_flags = val; + } else if (!strcasecmp(var, "kicked-sound") && !zstr(val)) { + kicked_sound = val; + } else if (!strcasecmp(var, "pin") && !zstr(val)) { + pin = val; + } else if (!strcasecmp(var, "pin-sound") && !zstr(val)) { + pin_sound = val; + } else if (!strcasecmp(var, "bad-pin-sound") && !zstr(val)) { + bad_pin_sound = val; + } else if (!strcasecmp(var, "energy-level") && !zstr(val)) { + energy_level = val; + } else if (!strcasecmp(var, "caller-id-name") && !zstr(val)) { + caller_id_name = val; + } else if (!strcasecmp(var, "caller-id-number") && !zstr(val)) { + caller_id_number = val; + } else if (!strcasecmp(var, "caller-controls") && !zstr(val)) { + caller_controls = val; + } else if (!strcasecmp(var, "comfort-noise") && !zstr(val)) { + int tmp; + tmp = atoi(val); + if (tmp > 1 && tmp < 10000) { + comfort_noise_level = tmp; + } else if (switch_true(val)) { + comfort_noise_level = 1400; + } + } else if (!strcasecmp(var, "sound-prefix") && !zstr(val)) { + sound_prefix = val; + } else if (!strcasecmp(var, "max-members") && !zstr(val)) { + errno = 0; /* sanity first */ + max_members = strtol(val, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */ + if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) { + /* a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound + * stuff is added, see comments above + */ + max_members = 0; /* set to 0 to disable max counts */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val); + } + } else if (!strcasecmp(var, "max-members-sound") && !zstr(val)) { + maxmember_sound = val; + } else if (!strcasecmp(var, "announce-count") && !zstr(val)) { + errno = 0; /* safety first */ + announce_count = strtol(val, NULL, 0); + if (errno == ERANGE || errno == EINVAL) { + announce_count = 0; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "announce-count is invalid, not anouncing member counts\n"); + } + } else if (!strcasecmp(var, "suppress-events") && !zstr(val)) { + suppress_events = val; + } else if (!strcasecmp(var, "verbose-events") && !zstr(val)) { + verbose_events = val; + } else if (!strcasecmp(var, "auto-record") && !zstr(val)) { + auto_record = val; } - } else if (!strcasecmp(var, "domain") && !zstr(val)) { - domain = val; - } else if (!strcasecmp(var, "interval") && !zstr(val)) { - uint32_t tmp = atoi(val); - if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) { - interval = tmp; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, - "Interval must be multipe of 10 and less than %d, Using default of 20\n", SWITCH_MAX_INTERVAL); - } - } else if (!strcasecmp(var, "timer-name") && !zstr(val)) { - timer_name = val; - } else if (!strcasecmp(var, "tts-engine") && !zstr(val)) { - tts_engine = val; - } else if (!strcasecmp(var, "tts-voice") && !zstr(val)) { - tts_voice = val; - } else if (!strcasecmp(var, "enter-sound") && !zstr(val)) { - enter_sound = val; - } else if (!strcasecmp(var, "exit-sound") && !zstr(val)) { - exit_sound = val; - } else if (!strcasecmp(var, "alone-sound") && !zstr(val)) { - alone_sound = val; - } else if (!strcasecmp(var, "perpetual-sound") && !zstr(val)) { - perpetual_sound = val; - } else if (!strcasecmp(var, "moh-sound") && !zstr(val)) { - moh_sound = val; - } else if (!strcasecmp(var, "ack-sound") && !zstr(val)) { - ack_sound = val; - } else if (!strcasecmp(var, "nack-sound") && !zstr(val)) { - nack_sound = val; - } else if (!strcasecmp(var, "muted-sound") && !zstr(val)) { - muted_sound = val; - } else if (!strcasecmp(var, "mute-detect-sound") && !zstr(val)) { - mute_detect_sound = val; - } else if (!strcasecmp(var, "unmuted-sound") && !zstr(val)) { - unmuted_sound = val; - } else if (!strcasecmp(var, "locked-sound") && !zstr(val)) { - locked_sound = val; - } else if (!strcasecmp(var, "is-locked-sound") && !zstr(val)) { - is_locked_sound = val; - } else if (!strcasecmp(var, "is-unlocked-sound") && !zstr(val)) { - is_unlocked_sound = val; - } else if (!strcasecmp(var, "member-flags") && !zstr(val)) { - member_flags = val; - } else if (!strcasecmp(var, "conference-flags") && !zstr(val)) { - conference_flags = val; - } else if (!strcasecmp(var, "kicked-sound") && !zstr(val)) { - kicked_sound = val; - } else if (!strcasecmp(var, "pin") && !zstr(val)) { - pin = val; - } else if (!strcasecmp(var, "pin-sound") && !zstr(val)) { - pin_sound = val; - } else if (!strcasecmp(var, "bad-pin-sound") && !zstr(val)) { - bad_pin_sound = val; - } else if (!strcasecmp(var, "energy-level") && !zstr(val)) { - energy_level = val; - } else if (!strcasecmp(var, "caller-id-name") && !zstr(val)) { - caller_id_name = val; - } else if (!strcasecmp(var, "caller-id-number") && !zstr(val)) { - caller_id_number = val; - } else if (!strcasecmp(var, "caller-controls") && !zstr(val)) { - caller_controls = val; - } else if (!strcasecmp(var, "comfort-noise") && !zstr(val)) { - int tmp; - tmp = atoi(val); - if (tmp > 1 && tmp < 10000) { - comfort_noise_level = tmp; - } else if (switch_true(val)) { - comfort_noise_level = 1400; - } - } else if (!strcasecmp(var, "sound-prefix") && !zstr(val)) { - sound_prefix = val; - } else if (!strcasecmp(var, "max-members") && !zstr(val)) { - errno = 0; /* sanity first */ - max_members = strtol(val, NULL, 0); /* base 0 lets 0x... for hex 0... for octal and base 10 otherwise through */ - if (errno == ERANGE || errno == EINVAL || max_members < 0 || max_members == 1) { - /* a negative wont work well, and its foolish to have a conference limited to 1 person unless the outbound - * stuff is added, see comments above - */ - max_members = 0; /* set to 0 to disable max counts */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "max-members %s is invalid, not setting a limit\n", val); - } - } else if (!strcasecmp(var, "max-members-sound") && !zstr(val)) { - maxmember_sound = val; - } else if (!strcasecmp(var, "announce-count") && !zstr(val)) { - errno = 0; /* safety first */ - announce_count = strtol(val, NULL, 0); - if (errno == ERANGE || errno == EINVAL) { - announce_count = 0; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "announce-count is invalid, not anouncing member counts\n"); - } - } else if (!strcasecmp(var, "suppress-events") && !zstr(val)) { - suppress_events = val; - } else if (!strcasecmp(var, "verbose-events") && !zstr(val)) { - verbose_events = val; - } else if (!strcasecmp(var, "auto-record") && !zstr(val)) { - auto_record = val; } - } /* Set defaults and various paramaters */ @@ -5971,7 +5963,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m } conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR; - + if (!zstr(moh_sound) && switch_is_moh(moh_sound)) { conference->moh_sound = switch_core_strdup(conference->pool, moh_sound); } @@ -6085,7 +6077,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m if (!zstr(verbose_events) && switch_true(verbose_events)) { conference->verbose_events = 1; } - + /* caller control configuration chores */ if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) { @@ -6116,7 +6108,7 @@ static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_m switch_core_hash_insert(globals.conference_hash, conference->name, conference); switch_mutex_unlock(globals.hash_mutex); - end: + end: switch_mutex_unlock(globals.hash_mutex); @@ -6277,7 +6269,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load) switch_mutex_init(&globals.setup_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool); /* Subscribe to presence request events */ - if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) { + if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) != + SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n"); return SWITCH_STATUS_GENERR; } diff --git a/src/mod/applications/mod_curl/mod_curl.c b/src/mod/applications/mod_curl/mod_curl.c index 30dff12b43..2991350526 100755 --- a/src/mod/applications/mod_curl/mod_curl.c +++ b/src/mod/applications/mod_curl/mod_curl.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -28,7 +28,7 @@ * mod_curl.c -- API for performing http queries * */ - + #include #include #include @@ -75,13 +75,12 @@ static size_t file_callback(void *ptr, size_t size, size_t nmemb, void *data) http_data->bytes += realsize; if (http_data->bytes > http_data->max_bytes) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)http_data->bytes); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) http_data->bytes); http_data->err = 1; return 0; } - http_data->stream.write_function( - &http_data->stream, "%.*s", realsize, ptr); + http_data->stream.write_function(&http_data->stream, "%.*s", realsize, ptr); return realsize; } @@ -90,18 +89,19 @@ static size_t header_callback(void *ptr, size_t size, size_t nmemb, void *data) register unsigned int realsize = (unsigned int) (size * nmemb); http_data_t *http_data = data; char *header = NULL; - - header = switch_core_alloc(http_data->pool, realsize+1); + + header = switch_core_alloc(http_data->pool, realsize + 1); switch_copy_string(header, ptr, realsize); header[realsize] = '\0'; http_data->headers = curl_slist_append(http_data->headers, header); - + return realsize; } -static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, const char *method, const char *data) { - +static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, const char *method, const char *data) +{ + CURL *curl_handle = NULL; long httpRes = 0; char hostname[256] = ""; @@ -111,19 +111,19 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c http_data = switch_core_alloc(pool, sizeof(http_data_t)); memset(http_data, 0, sizeof(http_data_t)); http_data->pool = pool; - + http_data->max_bytes = 64000; SWITCH_STANDARD_STREAM(http_data->stream); gethostname(hostname, sizeof(hostname)); - + if (!method) { method = "get"; } - + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "method: %s, url: %s\n", method, url); curl_handle = curl_easy_init(); - + if (!strncasecmp(url, "https", 5)) { curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0); curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0); @@ -150,54 +150,53 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c curl_easy_perform(curl_handle); curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes); curl_easy_cleanup(curl_handle); - - if ( http_data->stream.data && - !zstr((char *)http_data->stream.data) && - strcmp(" ", http_data->stream.data) ) { - + + if (http_data->stream.data && !zstr((char *) http_data->stream.data) && strcmp(" ", http_data->stream.data)) { + http_data->http_response = switch_core_strdup(pool, http_data->stream.data); } - + http_data->http_response_code = httpRes; - + switch_safe_free(http_data->stream.data); return http_data; } -static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data) { +static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data) +{ struct json_object *top = NULL; struct json_object *headers = NULL; char *data = NULL; struct curl_slist *header = http_data->headers; - + top = json_object_new_object(); headers = json_object_new_array(); json_object_object_add(top, "status_code", json_object_new_int(http_data->http_response_code)); if (http_data->http_response) { json_object_object_add(top, "body", json_object_new_string(http_data->http_response)); } - + /* parse header data */ - while(header) { + while (header) { struct json_object *obj = NULL; /* remove trailing \r */ - if ((data=rindex(header->data, '\r'))) { + if ((data = rindex(header->data, '\r'))) { *data = '\0'; } - + if (zstr(header->data)) { header = header->next; continue; } - + if ((data = index(header->data, ':'))) { *data = '\0'; data++; - while(*data == ' ' && *data != '\0') { + while (*data == ' ' && *data != '\0') { data++; } - obj = json_object_new_object(); + obj = json_object_new_object(); json_object_object_add(obj, "key", json_object_new_string(header->data)); json_object_object_add(obj, "value", json_object_new_string(data)); json_object_array_add(headers, obj); @@ -223,15 +222,15 @@ static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data) { } json_object_object_add(top, "headers", headers); data = switch_core_strdup(pool, json_object_to_json_string(top)); - json_object_put(top); /* should free up all children */ - + json_object_put(top); /* should free up all children */ + return data; } SWITCH_STANDARD_APP(curl_app_function) { switch_status_t status = SWITCH_STATUS_SUCCESS; - + char *argv[10] = { 0 }; int argc; char *mydata = NULL; @@ -247,8 +246,8 @@ SWITCH_STANDARD_APP(curl_app_function) struct curl_slist *slist = NULL; switch_stream_handle_t stream = { 0 }; int i = 0; - - + + if (session) { pool = switch_core_session_get_pool(session); } else { @@ -257,24 +256,23 @@ SWITCH_STANDARD_APP(curl_app_function) if (!(mydata = switch_core_session_strdup(session, data))) { return; } - + if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) { if (argc == 0) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } - + url = switch_core_strdup(pool, argv[0]); - for (i =1; i < argc; i++) { + for (i = 1; i < argc; i++) { if (!strcasecmp("headers", argv[i])) { do_headers = SWITCH_TRUE; } else if (!strcasecmp("json", argv[i])) { do_json = SWITCH_TRUE; - } else if ( !strcasecmp("get", argv[i]) || - !strcasecmp("head", argv[i])) { + } else if (!strcasecmp("get", argv[i]) || !strcasecmp("head", argv[i])) { method = switch_core_strdup(pool, argv[i]); } else if (!strcasecmp("post", argv[i])) { - if ( ++i < argc) { + if (++i < argc) { postdata = switch_core_strdup(pool, argv[i]); switch_url_decode(postdata); } else { @@ -283,7 +281,7 @@ SWITCH_STANDARD_APP(curl_app_function) } } } - + http_data = do_lookup_url(pool, url, method, postdata); if (do_json) { switch_channel_set_variable(channel, "curl_response_data", print_json(pool, http_data)); @@ -291,7 +289,7 @@ SWITCH_STANDARD_APP(curl_app_function) SWITCH_STANDARD_STREAM(stream); if (do_headers) { slist = http_data->headers; - while(slist) { + while (slist) { stream.write_function(&stream, "%s\n", slist->data); slist = slist->next; } @@ -300,17 +298,16 @@ SWITCH_STANDARD_APP(curl_app_function) stream.write_function(&stream, "%s", http_data->http_response ? http_data->http_response : ""); switch_channel_set_variable(channel, "curl_response_data", stream.data); } - switch_channel_set_variable(channel, "curl_response_code", - switch_core_sprintf(pool, "%ld", http_data->http_response_code)); + switch_channel_set_variable(channel, "curl_response_code", switch_core_sprintf(pool, "%ld", http_data->http_response_code)); switch_channel_set_variable(channel, "curl_method", method); switch_goto_status(SWITCH_STATUS_SUCCESS, done); - -usage: + + usage: switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SYNTAX); switch_goto_status(status, done); - -done: + + done: switch_safe_free(stream.data); if (http_data && http_data->headers) { curl_slist_free_all(http_data->headers); @@ -319,6 +316,7 @@ done: switch_core_destroy_memory_pool(&pool); } } + SWITCH_STANDARD_API(curl_function) { switch_status_t status; @@ -335,7 +333,7 @@ SWITCH_STANDARD_API(curl_function) int i = 0; switch_memory_pool_t *pool = NULL; - + if (zstr(cmd)) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } @@ -351,20 +349,19 @@ SWITCH_STANDARD_API(curl_function) if (argc < 1) { switch_goto_status(SWITCH_STATUS_SUCCESS, usage); } - + url = switch_core_strdup(pool, argv[0]); - - for (i =1; i < argc; i++) { + + for (i = 1; i < argc; i++) { if (!strcasecmp("headers", argv[i])) { do_headers = SWITCH_TRUE; } else if (!strcasecmp("json", argv[i])) { do_json = SWITCH_TRUE; - } else if ( !strcasecmp("get", argv[i]) || - !strcasecmp("head", argv[i])) { + } else if (!strcasecmp("get", argv[i]) || !strcasecmp("head", argv[i])) { method = switch_core_strdup(pool, argv[i]); } else if (!strcasecmp("post", argv[i])) { method = "post"; - if ( ++i < argc) { + if (++i < argc) { postdata = switch_core_strdup(pool, argv[i]); switch_url_decode(postdata); } else { @@ -372,14 +369,14 @@ SWITCH_STANDARD_API(curl_function) } } } - + http_data = do_lookup_url(pool, url, method, postdata); if (do_json) { stream->write_function(stream, "%s", print_json(pool, http_data)); } else { if (do_headers) { slist = http_data->headers; - while(slist) { + while (slist) { stream->write_function(stream, "%s\n", slist->data); slist = slist->next; } @@ -390,11 +387,11 @@ SWITCH_STANDARD_API(curl_function) } switch_goto_status(SWITCH_STATUS_SUCCESS, done); -usage: + usage: stream->write_function(stream, "-ERR\n%s\n", SYNTAX); switch_goto_status(status, done); - -done: + + done: if (http_data && http_data->headers) { curl_slist_free_all(http_data->headers); } @@ -414,7 +411,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_curl_load) *module_interface = switch_loadable_module_create_module_interface(pool, modname); memset(&globals, 0, sizeof(globals)); - + globals.pool = pool; SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX); diff --git a/src/mod/applications/mod_directory/mod_directory.c b/src/mod/applications/mod_directory/mod_directory.c index 7db9548c5c..f4335d51df 100644 --- a/src/mod/applications/mod_directory/mod_directory.c +++ b/src/mod/applications/mod_directory/mod_directory.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -40,19 +40,16 @@ SWITCH_MODULE_DEFINITION(mod_directory, mod_directory_load, mod_directory_shutdo static const char *global_cf = "directory.conf"; static char dir_sql[] = -"CREATE TABLE directory_search (\n" -" hostname VARCHAR(255),\n" -" uuid VARCHAR(255),\n" -" extension VARCHAR(255),\n" -" full_name VARCHAR(255),\n" -" full_name_digit VARCHAR(255),\n" -" first_name VARCHAR(255),\n" -" first_name_digit VARCHAR(255),\n" -" last_name VARCHAR(255),\n" -" last_name_digit VARCHAR(255),\n" -" name_visible INTEGER,\n" -" exten_visible INTEGER\n" -");\n"; + "CREATE TABLE directory_search (\n" + " hostname VARCHAR(255),\n" + " uuid VARCHAR(255),\n" + " extension VARCHAR(255),\n" + " full_name VARCHAR(255),\n" + " full_name_digit VARCHAR(255),\n" + " first_name VARCHAR(255),\n" + " first_name_digit VARCHAR(255),\n" + " last_name VARCHAR(255),\n" + " last_name_digit VARCHAR(255),\n" " name_visible INTEGER,\n" " exten_visible INTEGER\n" ");\n"; #define DIR_RESULT_ITEM "directory_result_item" #define DIR_RESULT_SAY_NAME "directory_result_say_name" @@ -113,51 +110,52 @@ typedef enum { PFLAG_DESTROY = 1 << 0 } dir_flags_t; -static int digit_matching_keypad(char letter) { +static int digit_matching_keypad(char letter) +{ int result = -1; - switch(toupper(letter)) { - case 'A': - case 'B': - case 'C': - result = 2; - break; - case 'D': - case 'E': - case 'F': - result = 3; - break; - case 'G': - case 'H': - case 'I': - result = 4; - break; - case 'J': - case 'K': - case 'L': - result = 5; - break; - case 'M': - case 'N': - case 'O': - result = 6; - break; - case 'P': - case 'Q': - case 'R': - case 'S': - result = 7; - break; - case 'T': - case 'U': - case 'V': - result = 8; - break; - case 'W': - case 'X': - case 'Y': - case 'Z': - result = 9; - break; + switch (toupper(letter)) { + case 'A': + case 'B': + case 'C': + result = 2; + break; + case 'D': + case 'E': + case 'F': + result = 3; + break; + case 'G': + case 'H': + case 'I': + result = 4; + break; + case 'J': + case 'K': + case 'L': + result = 5; + break; + case 'M': + case 'N': + case 'O': + result = 6; + break; + case 'P': + case 'Q': + case 'R': + case 'S': + result = 7; + break; + case 'T': + case 'U': + case 'V': + result = 8; + break; + case 'W': + case 'X': + case 'Y': + case 'Z': + result = 9; + break; } @@ -185,7 +183,7 @@ char *string_to_keypad_digit(const char *in) if (*d) { *d = '\0'; } - } + } return dst; } @@ -206,7 +204,7 @@ static switch_status_t directory_execute_sql(char *sql, switch_mutex_t *mutex) status = switch_core_db_persistant_execute(db, sql, 1); switch_core_db_close(db); -end: + end: if (mutex) { switch_mutex_unlock(mutex); } @@ -304,7 +302,7 @@ static switch_bool_t directory_execute_sql_callback(switch_mutex_t *mutex, char switch_core_db_close(db); } -end: + end: if (mutex) { switch_mutex_unlock(mutex); } @@ -337,34 +335,32 @@ dir_profile_t *profile_set_config(dir_profile_t *profile) profile->config_str_pool.pool = profile->pool; - SWITCH_CONFIG_SET_ITEM(profile->config[i++], "next-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->next_key, "6", &config_dtmf, NULL, NULL); - SWITCH_CONFIG_SET_ITEM(profile->config[i++], "prev-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->prev_key, "4", &config_dtmf, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(profile->config[i++], "next-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->next_key, "6", &config_dtmf, NULL, NULL); + SWITCH_CONFIG_SET_ITEM(profile->config[i++], "prev-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->prev_key, "4", &config_dtmf, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "terminator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->terminator_key, "#", &config_dtmf, NULL, NULL); + &profile->terminator_key, "#", &config_dtmf, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "switch-order-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->switch_order_key, "*", &config_dtmf, NULL, NULL); + &profile->switch_order_key, "*", &config_dtmf, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "select-name-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->select_name_key, "1", &config_dtmf, NULL, NULL); + &profile->select_name_key, "1", &config_dtmf, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "new-search-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->new_search_key, "3", &config_dtmf, NULL, NULL); + &profile->new_search_key, "3", &config_dtmf, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "search-order", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, - &profile->search_order, "last_name", &profile->config_str_pool, NULL, NULL); + &profile->search_order, "last_name", &profile->config_str_pool, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "digit-timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, - &profile->digit_timeout, 3000, &config_int_digit_timeout, NULL, NULL); + &profile->digit_timeout, 3000, &config_int_digit_timeout, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "min-search-digits", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, - &profile->min_search_digits, 3, &config_int_ht_0, NULL, NULL); + &profile->min_search_digits, 3, &config_int_ht_0, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-menu-attempts", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, - &profile->max_menu_attempt, 3, &config_int_ht_0, NULL, NULL); + &profile->max_menu_attempt, 3, &config_int_ht_0, NULL, NULL); SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-result", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, - &profile->max_result, 5, &config_int_ht_0, NULL, NULL); + &profile->max_result, 5, &config_int_ht_0, NULL, NULL); return profile; } -static dir_profile_t * load_profile(const char *profile_name) +static dir_profile_t *load_profile(const char *profile_name) { dir_profile_t *profile = NULL; switch_xml_t x_profiles, x_profile, cfg, xml = NULL; @@ -413,7 +409,7 @@ static dir_profile_t * load_profile(const char *profile_name) switch_core_hash_insert(globals.profile_hash, profile->name, profile); } -end: + end: switch_xml_free(xml); return profile; @@ -451,7 +447,7 @@ static switch_status_t load_config(switch_bool_t reload) return SWITCH_STATUS_SUCCESS; } -static dir_profile_t * get_profile(const char *profile_name) +static dir_profile_t *get_profile(const char *profile_name) { dir_profile_t *profile = NULL; @@ -469,7 +465,8 @@ static dir_profile_t * get_profile(const char *profile_name) return profile; } -static switch_status_t populate_database(switch_core_session_t *session, dir_profile_t * profile, const char *domain_name) { +static switch_status_t populate_database(switch_core_session_t *session, dir_profile_t *profile, const char *domain_name) +{ switch_status_t status = SWITCH_STATUS_SUCCESS; char *sql = NULL; @@ -561,8 +558,9 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro firstNameDigit = string_to_keypad_digit(firstName); /* add user into DB */ - sql = switch_mprintf("insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')", - globals.hostname, switch_core_session_get_uuid(session), id, fullName, fullNameDigit, firstName, firstNameDigit, lastName, lastNameDigit, name_visible, exten_visible); + sql = switch_mprintf("insert into directory_search values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%d','%d')", + globals.hostname, switch_core_session_get_uuid(session), id, fullName, fullNameDigit, firstName, firstNameDigit, + lastName, lastNameDigit, name_visible, exten_visible); if (sqlvalues) { sqltmp = sqlvalues; @@ -580,10 +578,10 @@ static switch_status_t populate_database(switch_core_session_t *session, dir_pro } } } - sql = switch_mprintf("BEGIN;%s;COMMIT;",sqlvalues); + sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues); directory_execute_sql(sql, profile->mutex); -end: + end: switch_safe_free(sql); switch_safe_free(sqlvalues); switch_event_destroy(&xml_params); @@ -603,27 +601,27 @@ typedef struct cb_result cbr_t; static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen) { switch (itype) { - case SWITCH_INPUT_TYPE_DTMF: - { - switch_dtmf_t *dtmf = (switch_dtmf_t *) input; - cbr_t *cbr = (cbr_t *) buf; - cbr->digit = dtmf->digit; - if (dtmf->digit == *cbr->profile->terminator_key || dtmf->digit == *cbr->profile->switch_order_key) { - return SWITCH_STATUS_BREAK; - } - - if (strlen(cbr->digits) < sizeof(cbr->digits) - 2) { - int at = strlen(cbr->digits); - cbr->digits[at++] = dtmf->digit; - cbr->digits[at] = '\0'; - } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "DTMF buffer is full\n"); - return SWITCH_STATUS_BREAK; - } + case SWITCH_INPUT_TYPE_DTMF: + { + switch_dtmf_t *dtmf = (switch_dtmf_t *) input; + cbr_t *cbr = (cbr_t *) buf; + cbr->digit = dtmf->digit; + if (dtmf->digit == *cbr->profile->terminator_key || dtmf->digit == *cbr->profile->switch_order_key) { + return SWITCH_STATUS_BREAK; } - break; - default: - break; + + if (strlen(cbr->digits) < sizeof(cbr->digits) - 2) { + int at = strlen(cbr->digits); + cbr->digits[at++] = dtmf->digit; + cbr->digits[at] = '\0'; + } else { + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "DTMF buffer is full\n"); + return SWITCH_STATUS_BREAK; + } + } + break; + default: + break; } return SWITCH_STATUS_BREAK; @@ -650,12 +648,12 @@ static switch_status_t listen_entry(switch_core_session_t *session, dir_profile_ } if (zstr_buf(buf)) { - switch_snprintf(macro, sizeof(macro), "phrase:%s:%d", DIR_RESULT_ITEM, cbt->want+1); + switch_snprintf(macro, sizeof(macro), "phrase:%s:%d", DIR_RESULT_ITEM, cbt->want + 1); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key); } if (!zstr_buf(recorded_name) && zstr_buf(buf)) { - switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile->terminator_key); + switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile->terminator_key); } if (zstr_buf(recorded_name) && zstr_buf(buf)) { @@ -667,7 +665,8 @@ static switch_status_t listen_entry(switch_core_session_t *session, dir_profile_ switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key); } if (zstr_buf(buf)) { - switch_snprintf(macro, sizeof(macro), "phrase:%s:%c,%c,%c,%c", DIR_RESULT_MENU, *profile->select_name_key, *profile->next_key, *profile->prev_key, *profile->new_search_key); + switch_snprintf(macro, sizeof(macro), "phrase:%s:%c,%c,%c,%c", DIR_RESULT_MENU, *profile->select_name_key, *profile->next_key, *profile->prev_key, + *profile->new_search_key); switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), profile->digit_timeout, profile->terminator_key); } @@ -688,7 +687,8 @@ static switch_status_t listen_entry(switch_core_session_t *session, dir_profile_ return SWITCH_STATUS_SUCCESS; } -switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) { +switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) +{ switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status = SWITCH_STATUS_SUCCESS; cbr_t cbr; @@ -707,7 +707,7 @@ switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t /* Gather the user Name */ - switch_snprintf(macro, sizeof(macro), "%s:%c", (params->search_by_last_name?"last_name":"first_name"), *profile->switch_order_key); + switch_snprintf(macro, sizeof(macro), "%s:%c", (params->search_by_last_name ? "last_name" : "first_name"), *profile->switch_order_key); switch_ivr_phrase_macro(session, DIR_INTRO, macro, NULL, &args); while (switch_channel_ready(channel)) { @@ -737,7 +737,8 @@ switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t return status; } -switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) { +switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) +{ switch_status_t status = SWITCH_STATUS_SUCCESS; char *sql = NULL; char entry_count[80] = ""; @@ -749,7 +750,10 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p cbt.buf = entry_count; cbt.len = sizeof(entry_count); - sql = switch_mprintf("select count(*) from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%'", globals.hostname, switch_core_session_get_uuid(session), (params->search_by_last_name?"last_name_digit":"first_name_digit"), params->digits); + sql = + switch_mprintf("select count(*) from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%'", + globals.hostname, switch_core_session_get_uuid(session), (params->search_by_last_name ? "last_name_digit" : "first_name_digit"), + params->digits); directory_execute_sql_callback(profile->mutex, sql, sql2str_callback, &cbt); switch_safe_free(sql); @@ -773,7 +777,10 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p memset(&listing_cbt, 0, sizeof(listing_cbt)); listing_cbt.params = params; - sql = switch_mprintf("select extension, full_name, last_name, first_name, name_visible, exten_visible from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%' order by last_name, first_name", globals.hostname, switch_core_session_get_uuid(session), (params->search_by_last_name?"last_name_digit":"first_name_digit"), params->digits); + sql = + switch_mprintf + ("select extension, full_name, last_name, first_name, name_visible, exten_visible from directory_search where hostname = '%q' and uuid = '%q' and name_visible = 1 and %s like '%q%%' order by last_name, first_name", + globals.hostname, switch_core_session_get_uuid(session), (params->search_by_last_name ? "last_name_digit" : "first_name_digit"), params->digits); for (cur_entry = 0; cur_entry < result_count; cur_entry++) { listing_cbt.index = 0; @@ -812,7 +819,7 @@ switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *p } } -end: + end: switch_safe_free(sql); return status; @@ -825,8 +832,8 @@ SWITCH_STANDARD_APP(directory_function) char *argv[6] = { 0 }; char *mydata = NULL; const char *profile_name = NULL; - const char *domain_name = NULL; - dir_profile_t * profile = NULL; + const char *domain_name = NULL; + dir_profile_t *profile = NULL; int x = 0; char *sql = NULL; search_params_t s_param; @@ -866,7 +873,7 @@ SWITCH_STANDARD_APP(directory_function) s_param.search_by_last_name = 0; } attempts = profile->max_menu_attempt; - s_param.try_again = 1; + s_param.try_again = 1; while (switch_channel_ready(channel) && (s_param.try_again && attempts-- > 0)) { s_param.try_again = 0; gather_name_digit(session, profile, &s_param); @@ -895,7 +902,7 @@ SWITCH_STANDARD_APP(directory_function) sql = switch_mprintf("delete from directory_search where hostname = '%q' and uuid = '%q'", globals.hostname, switch_core_session_get_uuid(session)); directory_execute_sql(sql, profile->mutex); switch_safe_free(sql); - profile_rwunlock(profile); + profile_rwunlock(profile); } SWITCH_MODULE_LOAD_FUNCTION(mod_directory_load) @@ -954,7 +961,7 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_directory_shutdown) switch_mutex_lock(globals.mutex); - while((hi = switch_hash_first(NULL, globals.profile_hash))) { + while ((hi = switch_hash_first(NULL, globals.profile_hash))) { switch_hash_this(hi, &key, &keylen, &val); profile = (dir_profile_t *) val; diff --git a/src/mod/applications/mod_distributor/mod_distributor.c b/src/mod/applications/mod_distributor/mod_distributor.c index a1f79384b5..24ab9c682e 100644 --- a/src/mod/applications/mod_distributor/mod_distributor.c +++ b/src/mod/applications/mod_distributor/mod_distributor.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -64,7 +64,7 @@ struct dist_list { static void destroy_node(struct dist_node *node) { struct dist_node *old; - while(node) { + while (node) { old = node; node = node->next; if (old->name) { @@ -78,7 +78,7 @@ static void destroy_list(struct dist_list *list) { struct dist_list *old; - while(list) { + while (list) { old = list; list = list->next; destroy_node(old->nodes); @@ -97,14 +97,14 @@ static struct { -static int load_config(int reloading) +static int load_config(int reloading) { - struct dist_list *main_list=NULL, *new_list, *old_list=NULL, *lp=NULL; + struct dist_list *main_list = NULL, *new_list, *old_list = NULL, *lp = NULL; switch_status_t status = SWITCH_STATUS_FALSE; char *cf = "distributor.conf"; switch_xml_t cfg, xml, lists, list, param; - - + + if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); return SWITCH_STATUS_TERM; @@ -120,7 +120,7 @@ static int load_config(int reloading) for (list = switch_xml_child(lists, "list"); list; list = list->next) { const char *name = switch_xml_attr(list, "name"); const char *tweight = switch_xml_attr(list, "total-weight"); - struct dist_node *node, *np=NULL; + struct dist_node *node, *np = NULL; int target_weight = 10; int accum = 0; @@ -128,30 +128,30 @@ static int load_config(int reloading) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing NAME!\n"); continue; } - + if (!zstr(tweight)) { target_weight = atoi(tweight); } switch_zmalloc(new_list, sizeof(*new_list)); - + new_list->name = strdup(name); new_list->last = -1; new_list->target_weight = target_weight; - + if (lp) { lp->next = new_list; } else { main_list = new_list; } - + lp = new_list; - + for (param = switch_xml_child(list, "node"); param; param = param->next) { char *name = (char *) switch_xml_attr_soft(param, "name"); char *weight_val = (char *) switch_xml_attr_soft(param, "weight"); int weight = 0, tmp; - + if ((tmp = atoi(weight_val)) < 1) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be > 0\n", tmp); continue; @@ -163,23 +163,25 @@ static int load_config(int reloading) } if (accum + tmp > lp->target_weight) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Target Weight %d already met, ignoring subsequent entries.\n", lp->target_weight); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Target Weight %d already met, ignoring subsequent entries.\n", + lp->target_weight); continue; } accum += tmp; weight = lp->target_weight - tmp; - + if (weight < 0 || weight > lp->target_weight) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be between 1 and %d\n", weight, lp->target_weight); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be between 1 and %d\n", weight, + lp->target_weight); continue; } - + switch_zmalloc(node, sizeof(*node)); node->name = strdup(name); node->weight = node->cur_weight = weight; - + if (np) { np->next = node; @@ -198,7 +200,7 @@ static int load_config(int reloading) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Total weight does not add up to total weight %d\n", lp->target_weight); - for(np1 = lp->nodes; np1; np1 = np1->next) { + for (np1 = lp->nodes; np1; np1 = np1->next) { np1->weight += lp->target_weight - ea; } @@ -230,7 +232,7 @@ static int reset_list(struct dist_list *list) { struct dist_node *np; - for(np = list->nodes; np; np = np->next) { + for (np = list->nodes; np; np = np->next) { np->cur_weight = np->weight; } list->last = -1; @@ -243,8 +245,8 @@ static struct dist_node *find_next(struct dist_list *list) struct dist_node *np, *match = NULL; int x = 0, mx = 0; int matches = 0, loops = 0; - - for(;;) { + + for (;;) { if (++loops > 1000) { break; @@ -255,7 +257,7 @@ static struct dist_node *find_next(struct dist_list *list) list->last = -1; } match = NULL; - for(np = list->nodes; np; np = np->next) { + for (np = list->nodes; np; np = np->next) { if (np->cur_weight < list->target_weight) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s %d/%d\n", np->name, np->cur_weight, list->target_weight); matches++; @@ -274,7 +276,7 @@ static struct dist_node *find_next(struct dist_list *list) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choose %s\n", match->name); return match; } - + if (matches) { list->last = -1; } else { @@ -294,7 +296,7 @@ static char *dist_engine(const char *name) char *str = NULL; switch_mutex_lock(globals.mod_lock); - for(lp = globals.list; lp; lp = lp->next) { + for (lp = globals.list; lp; lp = lp->next) { if (!strcasecmp(name, lp->name)) { np = find_next(lp); break; @@ -307,14 +309,14 @@ static char *dist_engine(const char *name) switch_mutex_unlock(globals.mod_lock); return str; - + } SWITCH_STANDARD_APP(distributor_exec) { switch_channel_t *channel = switch_core_session_get_channel(session); char *ret = NULL; - + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "distributor requires an argument\n"); return; @@ -370,11 +372,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_distributor_load) globals.pool = pool; load_config(SWITCH_FALSE); - + SWITCH_ADD_API(api_interface, "distributor", "Distributor API", distributor_function, ""); SWITCH_ADD_API(api_interface, "distributor_ctl", "Distributor API", distributor_ctl_function, "[reload]"); - SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "", SAF_SUPPORT_NOMEDIA|SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); /* indicate that the module should continue to be loaded */ diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index f148f672a4..fd5b21d22b 100644 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1,6 +1,6 @@ /* * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2009, Anthony Minessale II + * Copyright (C) 2005-2010, Anthony Minessale II * * Version: MPL 1.1 * @@ -89,7 +89,7 @@ SWITCH_STANDARD_DIALPLAN(inline_dialplan_hunt) switch_caller_extension_add_application(session, extension, app, data); } - caller_profile->destination_number = (char *)caller_profile->rdnis; + caller_profile->destination_number = (char *) caller_profile->rdnis; caller_profile->rdnis = SWITCH_BLANK_STRING; return extension; @@ -177,7 +177,8 @@ SWITCH_STANDARD_APP(exe_function) SWITCH_STANDARD_APP(mkdir_function) { switch_dir_make_recursive(data, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s MKDIR: %s\n", switch_channel_get_name(switch_core_session_get_channel(session)), data); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s MKDIR: %s\n", + switch_channel_get_name(switch_core_session_get_channel(session)), data); } #define SOFT_HOLD_SYNTAX " [] []" @@ -276,7 +277,7 @@ SWITCH_STANDARD_APP(dtmf_bind_function) if (strchr(argv[2], '1')) { bind_flags |= SBF_ONCE; } - + if (switch_ivr_bind_dtmf_meta_session(session, kval, bind_flags, argv[3]) != SWITCH_STATUS_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Bind Error!\n"); } @@ -375,7 +376,7 @@ SWITCH_STANDARD_APP(eavesdrop_function) if (e_data.total) { for (x = 0; x < e_data.total && switch_channel_ready(channel); x++) { /* If we have a group and 1000 concurrent calls, we will flood the logs. This check avoids this */ - if ( !require_group ) + if (!require_group) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Spy: %s\n", e_data.uuid_list[x]); if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_new"))) { switch_ivr_play_file(session, NULL, file, NULL); @@ -437,9 +438,9 @@ SWITCH_STANDARD_APP(set_audio_level_function) mydata = switch_core_session_strdup(session, data); argc = switch_split(mydata, ' ', argv); - + if (argc != 2) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", switch_core_session_get_name(session), SET_AUDIO_LEVEL_SYNTAX); return; } @@ -447,8 +448,8 @@ SWITCH_STANDARD_APP(set_audio_level_function) level = atoi(argv[1]); switch_ivr_session_audio(session, "level", argv[0], level); - - + + } #define SET_MUTE_SYNTAX "[read|write] [[true|cn level]|false]" @@ -461,19 +462,19 @@ SWITCH_STANDARD_APP(set_mute_function) mydata = switch_core_session_strdup(session, data); argc = switch_split(mydata, ' ', argv); - + if (argc != 2) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n", switch_core_session_get_name(session), SET_MUTE_SYNTAX); return; } - + if ((level = atoi(argv[1])) <= 0) { level = switch_true(argv[1]); } - + switch_ivr_session_audio(session, "mute", argv[0], level); - + } @@ -731,7 +732,7 @@ SWITCH_STANDARD_APP(presence_function) return; } - switch_channel_presence(channel, argv[0], argv[1], argv[2]); + switch_channel_presence(channel, argv[0], argv[1], argv[2]); } SWITCH_STANDARD_APP(pre_answer_function) @@ -787,7 +788,7 @@ SWITCH_STANDARD_APP(deflect_function) SWITCH_STANDARD_APP(set_function) { char *var, *val = NULL; - + if (zstr(data)) { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { @@ -808,7 +809,8 @@ SWITCH_STANDARD_APP(set_function) expanded = switch_channel_expand_variables(channel, val); } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SET [%s]=[%s]\n", switch_channel_get_name(channel), var, expanded ? expanded : "UNDEF"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SET [%s]=[%s]\n", switch_channel_get_name(channel), var, + expanded ? expanded : "UNDEF"); switch_channel_set_variable_var_check(channel, var, expanded, SWITCH_FALSE); if (expanded && expanded != val) { @@ -857,7 +859,7 @@ SWITCH_STANDARD_APP(set_profile_var_function) val = NULL; } } - + switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val); } } @@ -891,8 +893,8 @@ SWITCH_STANDARD_APP(export_function) } } - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", var_name ? var_name : "", - val ? val : "UNDEF"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "EXPORT %s[%s]=[%s]\n", local ? "" : "(REMOTE ONLY) ", + var_name ? var_name : "", val ? val : "UNDEF"); switch_channel_set_variable(channel, var, val); if (var && val) { @@ -999,11 +1001,11 @@ SWITCH_STANDARD_APP(event_function) while (*p == ' ') *p++ = '\0'; val = p; - if (!strcasecmp(var,"Event-Name")) { + if (!strcasecmp(var, "Event-Name")) { switch_name_event(val, &event->event_id); switch_event_del_header(event, var); switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val); - } else if (!strcasecmp(var,"Event-Subclass")) { + } else if (!strcasecmp(var, "Event-Subclass")) { size_t len = strlen(val) + 1; void *new = malloc(len); switch_assert(new); @@ -1043,7 +1045,8 @@ SWITCH_STANDARD_APP(privacy_function) switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME); switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER); } else { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n"); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, + "INVALID privacy mode specified. Use a valid mode [no|yes|name|full|number].\n"); } switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", data, caller_profile->flags); } @@ -1112,7 +1115,7 @@ SWITCH_STANDARD_API(strftime_api_function) SWITCH_STANDARD_API(presence_api_function) { switch_event_t *event; - char *lbuf = NULL , *argv[4]; + char *lbuf = NULL, *argv[4]; int argc = 0; switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN; int need = 4; @@ -1158,7 +1161,7 @@ SWITCH_STANDARD_API(presence_api_function) switch_safe_free(lbuf); return SWITCH_STATUS_SUCCESS; - error: + error: switch_safe_free(lbuf); stream->write_function(stream, "Invalid: presence %s", PRESENCE_USAGE); @@ -1173,8 +1176,7 @@ SWITCH_STANDARD_API(chat_api_function) if (!zstr(cmd) && (lbuf = strdup(cmd)) && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) { - if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], - !zstr(argv[4]) ? argv[4] : NULL , "") == SWITCH_STATUS_SUCCESS) { + if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) { stream->write_function(stream, "Sent"); } else { stream->write_function(stream, "Error! Message Not Sent"); @@ -1206,7 +1208,7 @@ SWITCH_STANDARD_APP(ivr_application_function) { switch_channel_t *channel = switch_core_session_get_channel(session); switch_event_t *params; - const char *name = (const char*)data; + const char *name = (const char *) data; if (channel) { switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL; @@ -1234,7 +1236,7 @@ SWITCH_STANDARD_APP(ivr_application_function) && switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) { switch_xml_free(cxml); cxml = NULL; - switch_ivr_menu_execute(session, menu_stack, (char*)name, NULL); + switch_ivr_menu_execute(session, menu_stack, (char *) name, NULL); switch_ivr_menu_stack_free(menu_stack); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unable to create menu\n"); @@ -1404,7 +1406,7 @@ static switch_status_t on_dtmf(switch_core_session_t *session, void *input, swit for (p = terminators; p && *p; p++) { if (*p == dtmf->digit) { switch_snprintf(sbuf, sizeof(sbuf), "%c", *p); - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, sbuf ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, sbuf); return SWITCH_STATUS_BREAK; } } @@ -1432,7 +1434,7 @@ SWITCH_STANDARD_APP(sleep_function) args.input_callback = on_dtmf; args.buf = buf; args.buflen = sizeof(buf); - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); } switch_ivr_sleep(session, ms, SWITCH_TRUE, &args); @@ -1503,7 +1505,7 @@ SWITCH_STANDARD_APP(speak_function) args.buf = buf; args.buflen = sizeof(buf); - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); switch_ivr_speak_text(session, engine, voice, text, &args); } @@ -1582,7 +1584,8 @@ static switch_status_t hanguphook(switch_core_session_t *session) switch_stream_handle_t stream = { 0 }; SWITCH_STANDARD_STREAM(stream); switch_api_execute("uuid_bridge", id, NULL, &stream); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "\nHangup Command uuid_bridge(%s):\n%s\n", id, switch_str_nil((char *) stream.data)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "\nHangup Command uuid_bridge(%s):\n%s\n", id, + switch_str_nil((char *) stream.data)); switch_safe_free(stream.data); } @@ -1607,7 +1610,7 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond); - if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) + if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS || !peer_session) { goto end; } @@ -1640,13 +1643,13 @@ SWITCH_STANDARD_APP(att_xfer_function) switch_channel_t *b_channel = switch_core_session_get_channel(b_session); switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session)); switch_channel_set_variable(b_channel, "xfer_uuids", buf); - + switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), bond); switch_channel_set_variable(channel, "xfer_uuids", buf); - + switch_core_event_hook_add_state_change(session, hanguphook); switch_core_event_hook_add_state_change(b_session, hanguphook); - + switch_core_session_rwunlock(b_session); } } @@ -1654,7 +1657,7 @@ SWITCH_STANDARD_APP(att_xfer_function) if (!br) { switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond); } - + } switch_core_session_rwunlock(peer_session); @@ -1813,11 +1816,11 @@ SWITCH_STANDARD_APP(say_function) if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) { - + args.input_callback = on_dtmf; - - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); - + + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); + switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], &args); } else { switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX); @@ -1841,14 +1844,15 @@ SWITCH_STANDARD_APP(phrase_function) if ((mdata = strchr(macro, ','))) { *mdata++ = '\0'; } - + lang = switch_channel_get_variable(channel, "language"); - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata), switch_str_nil(lang)); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Execute %s(%s) lang %s\n", macro, switch_str_nil(mdata), + switch_str_nil(lang)); args.input_callback = on_dtmf; - - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); status = switch_ivr_phrase_macro(session, macro, mdata, lang, &args); } else { @@ -1878,10 +1882,10 @@ SWITCH_STANDARD_APP(playback_function) switch_file_handle_t fh = { 0 }; char *p; const char *file = NULL; - + if (data) { file = switch_core_session_strdup(session, data); - if ((p = strchr(file, '@')) && *(p+1) == '@') { + if ((p = strchr(file, '@')) && *(p + 1) == '@') { *p = '\0'; p += 2; if (p && *p) { @@ -1894,7 +1898,7 @@ SWITCH_STANDARD_APP(playback_function) args.input_callback = on_dtmf; - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); status = switch_ivr_play_file(session, &fh, file, &args); @@ -1920,8 +1924,8 @@ SWITCH_STANDARD_APP(endless_playback_function) switch_channel_t *channel = switch_core_session_get_channel(session); switch_status_t status = SWITCH_STATUS_SUCCESS; const char *file = data; - - while(switch_channel_ready(channel)) { + + while (switch_channel_ready(channel)) { status = switch_ivr_play_file(session, NULL, file, NULL); if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) { @@ -1968,7 +1972,7 @@ SWITCH_STANDARD_APP(gentones_function) args.input_callback = on_dtmf; - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); switch_ivr_gentones(session, tone_script, loops, &args); } @@ -2060,7 +2064,7 @@ SWITCH_STANDARD_APP(record_function) args.input_callback = on_dtmf; - switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" ); + switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, ""); status = switch_ivr_record_file(session, &fh, path, &args, limit); @@ -2071,7 +2075,7 @@ SWITCH_STANDARD_APP(record_function) SWITCH_STANDARD_APP(preprocess_session_function) { - switch_ivr_preprocess_session(session, (char *)data); + switch_ivr_preprocess_session(session, (char *) data); } SWITCH_STANDARD_APP(record_session_function) @@ -2089,7 +2093,7 @@ SWITCH_STANDARD_APP(record_session_function) /* Search for a space then a plus followed by only numbers at the end of the path, if found trim any spaces to the left/right of the plus use the left side as the path and right side as a time limit on the recording - */ + */ /* if we find a + and the character before it is a space */ if ((path_end = strrchr(path, '+')) && path_end > path && *(path_end - 1) == ' ') { @@ -2102,7 +2106,7 @@ SWITCH_STANDARD_APP(record_session_function) path_end--; /* trim spaces to the left of the plus */ - while(path_end > path && *path_end == ' ') { + while (path_end > path && *path_end == ' ') { path_end--; } @@ -2165,15 +2169,15 @@ static void *SWITCH_THREAD_FUNC camp_music_thread(switch_thread_t *thread, void args.input_callback = camp_fire; args.buf = dbuf; args.buflen = sizeof(dbuf); - + switch_core_session_read_lock(session); /* don't set this to a local_stream:// or you will not be happy */ if ((greet = switch_channel_get_variable(channel, "campon_announce_sound"))) { status = switch_ivr_play_file(session, NULL, greet, &args); } - - while(stake->running && switch_channel_ready(channel)) { + + while (stake->running && switch_channel_ready(channel)) { if (status != SWITCH_STATUS_BREAK) { if (!strcasecmp(moh, "silence")) { status = switch_ivr_collect_digits_callback(session, &args, 0, 0); @@ -2207,7 +2211,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) switch_threadattr_t *thd_attr = NULL; char *camp_data = NULL; switch_status_t status; - + if (zstr(data)) { return; } @@ -2218,7 +2222,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) if ((v_campon = switch_channel_get_variable(caller_channel, "campon")) && switch_true(v_campon)) { const char *cid_name = NULL; const char *cid_number = NULL; - + if (!(cid_name = switch_channel_get_variable(caller_channel, "effective_caller_id_name"))) { cid_name = switch_channel_get_variable(caller_channel, "caller_id_name"); } @@ -2239,7 +2243,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) v_campon_timeout = switch_channel_get_variable(caller_channel, "campon_timeout"); v_campon_sleep = switch_channel_get_variable(caller_channel, "campon_sleep"); v_campon_fallback_exten = switch_channel_get_variable(caller_channel, "campon_fallback_exten"); - + if (v_campon_retries) { if ((tmp = atoi(v_campon_retries)) > 0) { campon_retries = tmp; @@ -2262,10 +2266,10 @@ SWITCH_STANDARD_APP(audio_bridge_function) camping = 1; if (cid_name && cid_number) { - camp_data = switch_core_session_sprintf(session, "{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s", + camp_data = switch_core_session_sprintf(session, "{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s", cid_name, cid_number, data); } else { - camp_data = (char *)data; + camp_data = (char *) data; } if (!(moh = switch_channel_get_variable(caller_channel, "hold_music"))) { @@ -2275,22 +2279,22 @@ SWITCH_STANDARD_APP(audio_bridge_function) do { fail = 0; status = switch_ivr_originate(NULL, &peer_session, &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL); - + if (!switch_channel_ready(caller_channel)) { fail = 1; break; } - + if (status == SWITCH_STATUS_SUCCESS) { camping = 0; break; } else { fail = 1; } - + if (camping) { - - if (!thread_started && fail && moh && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && + + if (!thread_started && fail && moh && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && !switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) && !switch_true(switch_channel_get_variable(caller_channel, "bypass_media"))) { switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session)); @@ -2311,15 +2315,15 @@ SWITCH_STANDARD_APP(audio_bridge_function) if (fail) { int64_t wait = campon_sleep * 1000000; - - while(stake.running && wait > 0 && switch_channel_ready(caller_channel)) { + + while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) { switch_yield(100000); wait -= 100000; } } } } while (camping && switch_channel_ready(caller_channel)); - + if (thread) { stake.running = 0; switch_channel_set_flag(caller_channel, CF_NOT_READY); @@ -2327,17 +2331,18 @@ SWITCH_STANDARD_APP(audio_bridge_function) } switch_channel_clear_flag(caller_channel, CF_NOT_READY); - + if (stake.do_xfer && !zstr(v_campon_fallback_exten)) { - switch_ivr_session_transfer(session, - v_campon_fallback_exten, + switch_ivr_session_transfer(session, + v_campon_fallback_exten, switch_channel_get_variable(caller_channel, "campon_fallback_dialplan"), switch_channel_get_variable(caller_channel, "campon_fallback_context")); return; } } else { - if ((status = switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) { + if ((status = + switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) { fail = 1; } } @@ -2350,23 +2355,23 @@ SWITCH_STANDARD_APP(audio_bridge_function) 'true' to continue on all failures. 'false' to not continue. A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603" - failure_causes acts as the opposite version + failure_causes acts as the opposite version EXCEPTION... ATTENDED_TRANSFER never is a reason to continue....... */ if (cause != SWITCH_CAUSE_ATTENDED_TRANSFER) { if (continue_on_fail || failure_causes) { const char *cause_str; char cause_num[35] = ""; - + cause_str = switch_channel_cause2str(cause); switch_snprintf(cause_num, sizeof(cause_num), "%u", cause); - + if (failure_causes) { char *lbuf = switch_core_session_strdup(session, failure_causes); char *argv[256] = { 0 }; int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))); int i, x = 0; - + for (i = 0; i < argc; i++) { if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) { x++; @@ -2374,7 +2379,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) } } if (!x) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str); return; } @@ -2388,10 +2393,10 @@ SWITCH_STANDARD_APP(audio_bridge_function) char *argv[256] = { 0 }; int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0]))); int i; - + for (i = 0; i < argc; i++) { if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str); return; } @@ -2410,7 +2415,7 @@ SWITCH_STANDARD_APP(audio_bridge_function) } return; } else { - + if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) { switch_ivr_signal_bridge(session, peer_session); } else { @@ -2439,10 +2444,10 @@ SWITCH_STANDARD_APP(audio_bridge_function) if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) { switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE); } - + switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key); } - + if (peer_session) { switch_core_session_rwunlock(peer_session); } @@ -2452,17 +2457,19 @@ SWITCH_STANDARD_APP(audio_bridge_function) /* fake chan_error */ switch_endpoint_interface_t *error_endpoint_interface; static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session, - switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); switch_io_routines_t error_io_routines = { /*.outgoing_channel */ error_outgoing_channel }; static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session, - switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) { switch_call_cause_t cause = switch_channel_str2cause(outbound_profile->destination_number); if (cause == SWITCH_CAUSE_NONE) { @@ -2476,17 +2483,19 @@ static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session /* fake chan_group */ switch_endpoint_interface_t *group_endpoint_interface; static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session, - switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); switch_io_routines_t group_io_routines = { /*.outgoing_channel */ group_outgoing_channel }; static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session, - switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) + switch_event_t *var_event, + switch_caller_profile_t *outbound_profile, + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) { char *group = NULL; switch_call_cause_t cause = SWITCH_CAUSE_NONE; @@ -2501,33 +2510,32 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session group = strdup(outbound_profile->destination_number); - if (!group) goto done; - + if (!group) + goto done; + if ((domain = strchr(group, '@'))) { *domain++ = '\0'; } else { domain = switch_core_get_variable("domain"); } - + if (!domain) { goto done; } - if (var_event && (skip=switch_event_get_header(var_event, "group_recurse_variables")) && switch_false(skip)) { - if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || - (var = switch_event_get_header(var_event, "leg_timeout"))) { + if (var_event && (skip = switch_event_get_header(var_event, "group_recurse_variables")) && switch_false(skip)) { + if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(var); } var_event = NULL; } template = switch_mprintf("${group_call(%s@%s)}", group, domain); - + if (session) { switch_channel_t *channel = switch_core_session_get_channel(session); dest = switch_channel_expand_variables(channel, template); - if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)) || - (var = switch_event_get_header(var_event, "leg_timeout"))) { + if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(var); } } else if (var_event) { @@ -2542,28 +2550,27 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session if (!dest) { goto done; } - + if (var_event) { cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name"); cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number"); - if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || - (var = switch_event_get_header(var_event, "leg_timeout"))) { + if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(var); } } - + if ((flags & SOF_FORKED_DIAL)) { myflags |= SOF_NOBLOCK; } - - - if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL, + + + if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL, cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) { const char *context; switch_caller_profile_t *cp; - + new_channel = switch_core_session_get_channel(*new_session); - + if ((context = switch_channel_get_variable(new_channel, "group_context"))) { if ((cp = switch_channel_get_caller_profile(new_channel))) { cp->context = switch_core_strdup(cp->pool, context); @@ -2578,9 +2585,9 @@ static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session if (dest && dest != template) { switch_safe_free(dest); } - - switch_safe_free(template); - switch_safe_free(group); + + switch_safe_free(template); + switch_safe_free(group); if (cause == SWITCH_CAUSE_NONE) { cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; @@ -2596,7 +2603,8 @@ switch_endpoint_interface_t *user_endpoint_interface; static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause); + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause); switch_io_routines_t user_io_routines = { /*.outgoing_channel */ user_outgoing_channel }; @@ -2604,7 +2612,8 @@ switch_io_routines_t user_io_routines = { static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause) + switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, + switch_call_cause_t *cancel_cause) { switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params; char *user = NULL, *domain = NULL; @@ -2622,22 +2631,22 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, user = strdup(outbound_profile->destination_number); - if (!user) goto done; + if (!user) + goto done; if ((domain = strchr(user, '@'))) { *domain++ = '\0'; } else { domain = switch_core_get_variable("domain"); } - + if (!domain) { goto done; } - - if (var_event && (skip=switch_event_get_header(var_event, "user_recurse_variables")) && switch_false(skip)) { - if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || - (var = switch_event_get_header(var_event, "leg_timeout"))) { + + if (var_event && (skip = switch_event_get_header(var_event, "user_recurse_variables")) && switch_false(skip)) { + if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(var); } var_event = NULL; @@ -2744,7 +2753,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_event_dup(&event, var_event); switch_event_del_header(event, "dialed_user"); switch_event_del_header(event, "dialed_domain"); - if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || + if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (varval = switch_event_get_header(var_event, "leg_timeout"))) { timelimit = atoi(varval); } @@ -2765,10 +2774,12 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, switch_snprintf(stupid, sizeof(stupid), "user/%s", user); if (switch_stristr(stupid, d_dest)) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid); + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", + stupid); cause = SWITCH_CAUSE_INVALID_IE_CONTENTS; - } else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, - cid_name_override, cid_num_override, outbound_profile, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) { + } else if (switch_ivr_originate(session, new_session, &cause, d_dest, timelimit, NULL, + cid_name_override, cid_num_override, outbound_profile, var_event, myflags, + cancel_cause) == SWITCH_STATUS_SUCCESS) { const char *context; switch_caller_profile_t *cp; @@ -2812,7 +2823,7 @@ static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session, if (params) { switch_event_destroy(¶ms); } - + if (var_event && var_event_orig != var_event) { switch_event_destroy(&var_event); } @@ -2851,7 +2862,7 @@ SWITCH_STANDARD_APP(wait_for_silence_function) uint32_t thresh, silence_hits, listen_hits, timeout_ms = 0; int argc; char *lbuf = NULL; - + if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data)) && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 3) { thresh = atoi(argv[0]); @@ -2869,8 +2880,8 @@ SWITCH_STANDARD_APP(wait_for_silence_function) return; } - } - + } + switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", WAIT_FOR_SILENCE_SYNTAX); } @@ -2880,12 +2891,17 @@ static switch_status_t event_chat_send(const char *proto, const char *from, cons switch_event_t *event; if (switch_event_create(&event, SWITCH_EVENT_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) { - if (proto) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Proto", proto); - if (from) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "From", from); - if (subject) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Subject", subject); - if (hint) switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hint", hint); - if (body) switch_event_add_body(event, "%s", body); - if (to) { + if (proto) + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Proto", proto); + if (from) + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "From", from); + if (subject) + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Subject", subject); + if (hint) + switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Hint", hint); + if (body) + switch_event_add_body(event, "%s", body); + if (to) { const char *v; switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "To", to); if ((v = switch_core_get_variable(to))) { @@ -2899,18 +2915,18 @@ static switch_status_t event_chat_send(const char *proto, const char *from, cons switch_event_destroy(&event); } - + return SWITCH_STATUS_MEMERR; } static switch_status_t api_chat_send(const char *proto, const char *from, const char *to, const char *subject, const char *body, const char *type, const char *hint) { - if (to) { + if (to) { const char *v; switch_stream_handle_t stream = { 0 }; char *cmd = NULL, *arg; - + if (!(v = switch_core_get_variable(to))) { v = to; } @@ -2928,16 +2944,15 @@ static switch_status_t api_chat_send(const char *proto, const char *from, const switch_api_execute(cmd, arg, NULL, &stream); if (proto) { - switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, - !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL); + switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL); } switch_safe_free(stream.data); - + free(cmd); } - + return SWITCH_STATUS_SUCCESS; } @@ -2998,7 +3013,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_CHAT(chat_interface, "event", event_chat_send); SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send); - + SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, ""); SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "||||[]"); SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, ""); @@ -3016,7 +3031,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function, " []", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); - SWITCH_ADD_APP(app_interface, "verbose_events", "Make ALL Events verbose.", "Make ALL Events verbose.", verbose_events_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "verbose_events", "Make ALL Events verbose.", "Make ALL Events verbose.", verbose_events_function, "", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "early_hangup", "Enable early hangup", "", early_hangup_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "sleep", "Pause a channel", SLEEP_LONG_DESC, sleep_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "delay_echo", "echo audio at a specified delay", "Delay n ms", delay_function, "", SAF_NONE); @@ -3027,19 +3043,23 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[]", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "", SAF_SUPPORT_NOMEDIA); - SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, " []", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); - SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, " ", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, " []", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, " ", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); - SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "=", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); - SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); + SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC); SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA); SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "", SAF_NONE); SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA); @@ -3063,21 +3083,22 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function, "[+]